From 3d1c880570aa97ee629ac9e474a1ccf3ddef69a3 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Mon, 13 Apr 2026 02:35:54 +0000 Subject: [PATCH] Release v0.9.319 Automated sync from private repository. Built with obfuscation enabled. --- frontend/dist/VERSION | 2 +- ...D46.js => AnalyzerFilterPanel-Cq7b3I2L.js} | 4 +- ...Lmv.js => AutoConfigureDialog-CDgcxIyE.js} | 2 +- ...r-DQCsZLc0.js => BasemapLayer-DhvtWc_h.js} | 2 +- ...ble-DsIWWOdr.js => ChatBubble-BqRoJxSW.js} | 2 +- ....js => CollisionExplorerModal-P8ZOhB65.js} | 2 +- ...nion-DeUMmHbn.js => Companion-CMsDpx5g.js} | 6 +- ...02AMdw.js => CompanionEchoMap-ui9UBOvI.js} | 2 +- ...vrWwCv.js => CompanionPathMap-CPxxakse.js} | 2 +- ...-BmeDX9th.js => Configuration-BMVfY1Wg.js} | 4 +- ...l-eC-cl0ep.js => ConfirmModal-J2_Sxirm.js} | 2 +- ...tacts-CTRl8l-x.js => Contacts-2M50JufT.js} | 8 +-- ...SF9.js => ContactsMapMapLibre-DlBh136H.js} | 2 +- frontend/dist/assets/Dashboard-Bn3hcO_4.js | 69 +++++++++++++++++++ frontend/dist/assets/Dashboard-TId1VvOA.js | 65 ----------------- ...alue-9iNfucjq.js => DataValue-B0xdrk88.js} | 2 +- .../{Grid-kVOI-wJp.js => Grid-DQYUnZsY.js} | 2 +- ...n-BVIaMPId.js => KeycapButton-xWUX1i8p.js} | 2 +- ...Dtyxi9BD.js => LightSparkline-r3FtGEtW.js} | 2 +- .../{Login-BbzCGlZ1.js => Login-roDFdIby.js} | 2 +- .../{Logs-DyZ7duPG.js => Logs-Dy7jDjKn.js} | 2 +- ...raph-D_cqlL51.js => MeshGraph-DJIb7g1_.js} | 6 +- .../{Mqtt-DF6wnkuy.js => Mqtt-C8Anxpfs.js} | 6 +- ...-DOXwpg3i.js => MqttModeBadge-BtcQeS2v.js} | 4 +- ...ist-BlTe2eo4.js => PacketList-CbRsdi2q.js} | 8 +-- ...UbS9G.js => PacketObservatory-Dkvi-AKO.js} | 4 +- ...ackets-DkmiTj3L.js => Packets-DmI71CFc.js} | 4 +- ...out-Cg7r5tdt.js => PageLayout-CRN-E5xi.js} | 2 +- .../dist/assets/PathMapMapLibre-CmQJ8_VP.js | 1 - .../dist/assets/PathMapMapLibre-DYyUo4Xc.js | 1 + ...ver-BLm1y_Ek.js => RoomServer-D7QRe_4I.js} | 10 +-- ...sions-CB2LEa_r.js => Sessions-ChDjzsGf.js} | 4 +- ...O8Lkax5.js => SignalIndicator-DmWlnzMv.js} | 6 +- ...ics-B5Y-pM3d.js => Statistics-C8dae4fy.js} | 6 +- ...{System-C3tiCIme.js => System-DDVQJuHy.js} | 4 +- ...minal-CrgP7ye2.js => Terminal-DLdeTxtN.js} | 38 +++++----- .../{Test-BEpj0lEQ.js => Test-DjOBviXb.js} | 4 +- ...ivity-BFfde9uG.js => activity-D6ySIfuC.js} | 2 +- ...ntenna-Dr-Egqv0.js => antenna-rn7EByqR.js} | 2 +- ...own-4OY_dsXk.js => arrow-down-BI9NpupK.js} | 2 +- ...ht-DySc3ssS.js => arrow-right-aT_K-Mjc.js} | 2 +- ...ow-up-C0VG8Et4.js => arrow-up-C4DdHKHn.js} | 2 +- .../{car-D35Wwv-5.js => car-CeuvJE3C.js} | 2 +- ...ils-DnJ-lYj3.js => chat-utils-DIy1-SG1.js} | 2 +- ...ck-UEaQfqci.js => check-check-C-QgFmon.js} | 2 +- ...-C9GG0xWI.js => chevron-right-D4kUPDBw.js} | 2 +- ...-up-CTCjpmk_.js => chevron-up-DyOgmQ5-.js} | 2 +- ...t-kdR_gb55.js => circle-alert-BgZmhbSe.js} | 2 +- ...hH.js => circle-question-mark-CO80vHQp.js} | 2 +- ...op-DHdw14LD.js => circle-stop-Dh0g22OE.js} | 2 +- .../{clock-DU0z3qMB.js => clock-D_m2QiHa.js} | 2 +- ...ompass-D_q1TimF.js => compass-CncUthiD.js} | 2 +- ...YnY6J.js => consumer-registry-DXaeZxMm.js} | 2 +- .../{cpu-CUBKtjSm.js => cpu--k4RdYyx.js} | 2 +- ...abase-cyku2KnA.js => database-Bm4-qoOy.js} | 2 +- ...{easing-2tSIucrJ.js => easing-D0twVjny.js} | 2 +- ...QuYFsD.js => element-movement-BL6huHzq.js} | 2 +- ...ldset-DQmrmWyj.js => fieldset-DsbEWHIy.js} | 2 +- frontend/dist/assets/frozen-C10EXZ59.js | 1 + frontend/dist/assets/frozen-Cx4cJH6f.js | 1 - ...{funnel-DGVJFdsh.js => funnel-BBIwSMOb.js} | 2 +- ...nch-BhoB5t-Q.js => git-branch-Ryinnbc1.js} | 2 +- .../{hash-DjqT3oXN.js => hash-Ba9bZo8v.js} | 2 +- .../{index-QCPybZMd.js => index-5slIee7x.js} | 2 +- .../{index-C2xvS0Jd.js => index-D33fcA3L.js} | 6 +- .../{index-wtt5rE5a.js => index-DuiHY5wq.js} | 2 +- ...ound-DBZOsqH6.js => key-round-n5zCigFv.js} | 2 +- ...{layers-BICmdhXR.js => layers-DguV5fdN.js} | 2 +- ...g-BjtZpDDb.js => link-scoring-Chr3N5ba.js} | 2 +- ...istbox-DnHpTyQt.js => listbox-DkfYDEqr.js} | 2 +- ...ap-pin-CQk00ph2.js => map-pin-B_Rx-xpd.js} | 4 +- ...ff-D8fZRJ6M.js => map-pin-off-V0MBukP5.js} | 2 +- ...gl-C9QYi5T6.js => maplibre-gl-B42P8ehE.js} | 4 +- ...gl-CfJOR1BZ.js => maplibre-gl-DOIRzRto.js} | 2 +- .../{max-BBb5g8bL.js => max-CkBnBUwN.js} | 2 +- ...BE66c4_-.js => message-square-DFs8_yFI.js} | 2 +- ...jgn.js => message-square-text-DlzXvsDV.js} | 2 +- ...etwork-D80fXCJJ.js => network-Btok3jeo.js} | 2 +- ...pes-BD70swWz.js => node-types-BoqnL0Eg.js} | 2 +- ...BAEvS7Pl.js => payload-detail-DbnSd5NL.js} | 2 +- ...{pencil-55Hza1I4.js => pencil-Cg0kSr82.js} | 2 +- .../{plus-CH14Vv92.js => plus-C0dCjBh9.js} | 2 +- ...ves-Ctn6pdEU.js => primitives-C8YoaXqf.js} | 2 +- ...{repeat-CprMAEnr.js => repeat-DUo9RRDi.js} | 2 +- ...ccw-Sqgw9a-1.js => rotate-ccw-B3SnN1wY.js} | 2 +- .../{route-Awj5QSAO.js => route-5o9tQENO.js} | 2 +- ...{search-DPGHPI2q.js => search-DN8guzpX.js} | 2 +- ...s-2-OYYe3udS.js => settings-2-C5Lvk9-M.js} | 2 +- ...hare-2-DLfTr0kI.js => share-2-BAsDxZE2.js} | 2 +- ...{shield-DvZvtyKV.js => shield-Ceq641wy.js} | 2 +- ...k-BB1TbeiZ.js => shield-check-DOoXovft.js} | 2 +- ...{system-Cf6Lcq9I.js => system-4FyMIaL1.js} | 2 +- ...{target-BpFOYbOg.js => target-B3CHoIpd.js} | 2 +- ...er-CG3c-cKn.js => thermometer-A8kLkazp.js} | 2 +- ...rash-2-Def3YmfN.js => trash-2-CUY4NG5t.js} | 2 +- ...CU5Ho7TY.js => use-text-value-iYUkduzo.js} | 2 +- ...pJfMrbM.js => use-tree-walker-DjLWwhV9.js} | 2 +- ...nPjO7Qt.js => useMapViewStore-Ey8vE9rr.js} | 4 +- ...-g28wv.js => usePipelineStore-DDHEHTlZ.js} | 4 +- ...-DbeD1_Sw.js => useReplayTick-BbXJoz75.js} | 2 +- ...iants-cyDnzhWy.js => variants-ByRhxIcL.js} | 2 +- ...-D9rSrVnU.js => wand-sparkles-CEbXzjVw.js} | 2 +- ...o.js => webgl-device-QoBMYpnS-CdQYT9sr.js} | 2 +- .../{wifi-Bc9OxL0c.js => wifi-D716s0ef.js} | 2 +- ...i-off-omfJv-eS.js => wifi-off-BQtV63nI.js} | 2 +- .../{zap-v3FkQoQ-.js => zap-C-Mue2DZ.js} | 2 +- frontend/dist/index.html | 2 +- frontend/package.json | 2 +- 108 files changed, 225 insertions(+), 221 deletions(-) rename frontend/dist/assets/{AnalyzerFilterPanel-CckWnD46.js => AnalyzerFilterPanel-Cq7b3I2L.js} (93%) rename frontend/dist/assets/{AutoConfigureDialog-C6zj_Lmv.js => AutoConfigureDialog-CDgcxIyE.js} (94%) rename frontend/dist/assets/{BasemapLayer-DQCsZLc0.js => BasemapLayer-DhvtWc_h.js} (95%) rename frontend/dist/assets/{ChatBubble-DsIWWOdr.js => ChatBubble-BqRoJxSW.js} (97%) rename frontend/dist/assets/{CollisionExplorerModal-Du9NEbAu.js => CollisionExplorerModal-P8ZOhB65.js} (87%) rename frontend/dist/assets/{Companion-DeUMmHbn.js => Companion-CMsDpx5g.js} (98%) rename frontend/dist/assets/{CompanionEchoMap-Hp02AMdw.js => CompanionEchoMap-ui9UBOvI.js} (75%) rename frontend/dist/assets/{CompanionPathMap-DEvrWwCv.js => CompanionPathMap-CPxxakse.js} (73%) rename frontend/dist/assets/{Configuration-BmeDX9th.js => Configuration-BMVfY1Wg.js} (95%) rename frontend/dist/assets/{ConfirmModal-eC-cl0ep.js => ConfirmModal-J2_Sxirm.js} (83%) rename frontend/dist/assets/{Contacts-CTRl8l-x.js => Contacts-2M50JufT.js} (79%) rename frontend/dist/assets/{ContactsMapMapLibre-CnXabSF9.js => ContactsMapMapLibre-DlBh136H.js} (99%) create mode 100644 frontend/dist/assets/Dashboard-Bn3hcO_4.js delete mode 100644 frontend/dist/assets/Dashboard-TId1VvOA.js rename frontend/dist/assets/{DataValue-9iNfucjq.js => DataValue-B0xdrk88.js} (87%) rename frontend/dist/assets/{Grid-kVOI-wJp.js => Grid-DQYUnZsY.js} (95%) rename frontend/dist/assets/{KeycapButton-BVIaMPId.js => KeycapButton-xWUX1i8p.js} (98%) rename frontend/dist/assets/{LightSparkline-Dtyxi9BD.js => LightSparkline-r3FtGEtW.js} (96%) rename frontend/dist/assets/{Login-BbzCGlZ1.js => Login-roDFdIby.js} (99%) rename frontend/dist/assets/{Logs-DyZ7duPG.js => Logs-Dy7jDjKn.js} (92%) rename frontend/dist/assets/{MeshGraph-D_cqlL51.js => MeshGraph-DJIb7g1_.js} (99%) rename frontend/dist/assets/{Mqtt-DF6wnkuy.js => Mqtt-C8Anxpfs.js} (95%) rename frontend/dist/assets/{MqttModeBadge-DOXwpg3i.js => MqttModeBadge-BtcQeS2v.js} (60%) rename frontend/dist/assets/{PacketList-BlTe2eo4.js => PacketList-CbRsdi2q.js} (95%) rename frontend/dist/assets/{PacketObservatory-CBpUbS9G.js => PacketObservatory-Dkvi-AKO.js} (99%) rename frontend/dist/assets/{Packets-DkmiTj3L.js => Packets-DmI71CFc.js} (62%) rename frontend/dist/assets/{PageLayout-Cg7r5tdt.js => PageLayout-CRN-E5xi.js} (90%) delete mode 100644 frontend/dist/assets/PathMapMapLibre-CmQJ8_VP.js create mode 100644 frontend/dist/assets/PathMapMapLibre-DYyUo4Xc.js rename frontend/dist/assets/{RoomServer-BLm1y_Ek.js => RoomServer-D7QRe_4I.js} (92%) rename frontend/dist/assets/{Sessions-CB2LEa_r.js => Sessions-ChDjzsGf.js} (91%) rename frontend/dist/assets/{SignalIndicator-DO8Lkax5.js => SignalIndicator-DmWlnzMv.js} (94%) rename frontend/dist/assets/{Statistics-B5Y-pM3d.js => Statistics-C8dae4fy.js} (93%) rename frontend/dist/assets/{System-C3tiCIme.js => System-DDVQJuHy.js} (95%) rename frontend/dist/assets/{Terminal-CrgP7ye2.js => Terminal-DLdeTxtN.js} (97%) rename frontend/dist/assets/{Test-BEpj0lEQ.js => Test-DjOBviXb.js} (95%) rename frontend/dist/assets/{activity-BFfde9uG.js => activity-D6ySIfuC.js} (89%) rename frontend/dist/assets/{antenna-Dr-Egqv0.js => antenna-rn7EByqR.js} (91%) rename frontend/dist/assets/{arrow-down-4OY_dsXk.js => arrow-down-BI9NpupK.js} (86%) rename frontend/dist/assets/{arrow-right-DySc3ssS.js => arrow-right-aT_K-Mjc.js} (86%) rename frontend/dist/assets/{arrow-up-C0VG8Et4.js => arrow-up-C4DdHKHn.js} (86%) rename frontend/dist/assets/{car-D35Wwv-5.js => car-CeuvJE3C.js} (92%) rename frontend/dist/assets/{chat-utils-DnJ-lYj3.js => chat-utils-DIy1-SG1.js} (97%) rename frontend/dist/assets/{check-check-UEaQfqci.js => check-check-C-QgFmon.js} (88%) rename frontend/dist/assets/{chevron-right-C9GG0xWI.js => chevron-right-D4kUPDBw.js} (85%) rename frontend/dist/assets/{chevron-up-CTCjpmk_.js => chevron-up-DyOgmQ5-.js} (99%) rename frontend/dist/assets/{circle-alert-kdR_gb55.js => circle-alert-BgZmhbSe.js} (90%) rename frontend/dist/assets/{circle-question-mark-CF3fGjhH.js => circle-question-mark-CO80vHQp.js} (89%) rename frontend/dist/assets/{circle-stop-DHdw14LD.js => circle-stop-Dh0g22OE.js} (94%) rename frontend/dist/assets/{clock-DU0z3qMB.js => clock-D_m2QiHa.js} (87%) rename frontend/dist/assets/{compass-D_q1TimF.js => compass-CncUthiD.js} (89%) rename frontend/dist/assets/{consumer-registry-DJyYnY6J.js => consumer-registry-DXaeZxMm.js} (92%) rename frontend/dist/assets/{cpu-CUBKtjSm.js => cpu--k4RdYyx.js} (94%) rename frontend/dist/assets/{database-cyku2KnA.js => database-Bm4-qoOy.js} (90%) rename frontend/dist/assets/{easing-2tSIucrJ.js => easing-D0twVjny.js} (57%) rename frontend/dist/assets/{element-movement-CSQuYFsD.js => element-movement-BL6huHzq.js} (73%) rename frontend/dist/assets/{fieldset-DQmrmWyj.js => fieldset-DsbEWHIy.js} (80%) create mode 100644 frontend/dist/assets/frozen-C10EXZ59.js delete mode 100644 frontend/dist/assets/frozen-Cx4cJH6f.js rename frontend/dist/assets/{funnel-DGVJFdsh.js => funnel-BBIwSMOb.js} (90%) rename frontend/dist/assets/{git-branch-BhoB5t-Q.js => git-branch-Ryinnbc1.js} (90%) rename frontend/dist/assets/{hash-DjqT3oXN.js => hash-Ba9bZo8v.js} (91%) rename frontend/dist/assets/{index-QCPybZMd.js => index-5slIee7x.js} (98%) rename frontend/dist/assets/{index-C2xvS0Jd.js => index-D33fcA3L.js} (99%) rename frontend/dist/assets/{index-wtt5rE5a.js => index-DuiHY5wq.js} (98%) rename frontend/dist/assets/{key-round-DBZOsqH6.js => key-round-n5zCigFv.js} (92%) rename frontend/dist/assets/{layers-BICmdhXR.js => layers-DguV5fdN.js} (92%) rename frontend/dist/assets/{link-scoring-BjtZpDDb.js => link-scoring-Chr3N5ba.js} (78%) rename frontend/dist/assets/{listbox-DnHpTyQt.js => listbox-DkfYDEqr.js} (83%) rename frontend/dist/assets/{map-pin-CQk00ph2.js => map-pin-B_Rx-xpd.js} (88%) rename frontend/dist/assets/{map-pin-off-D8fZRJ6M.js => map-pin-off-V0MBukP5.js} (93%) rename frontend/dist/assets/{maplibre-gl-C9QYi5T6.js => maplibre-gl-B42P8ehE.js} (98%) rename frontend/dist/assets/{maplibre-gl-CfJOR1BZ.js => maplibre-gl-DOIRzRto.js} (99%) rename frontend/dist/assets/{max-BBb5g8bL.js => max-CkBnBUwN.js} (99%) rename frontend/dist/assets/{message-square-BE66c4_-.js => message-square-DFs8_yFI.js} (90%) rename frontend/dist/assets/{message-square-text-B47-Hjgn.js => message-square-text-DlzXvsDV.js} (92%) rename frontend/dist/assets/{network-D80fXCJJ.js => network-Btok3jeo.js} (92%) rename frontend/dist/assets/{node-types-BD70swWz.js => node-types-BoqnL0Eg.js} (85%) rename frontend/dist/assets/{payload-detail-BAEvS7Pl.js => payload-detail-DbnSd5NL.js} (94%) rename frontend/dist/assets/{pencil-55Hza1I4.js => pencil-Cg0kSr82.js} (95%) rename frontend/dist/assets/{plus-CH14Vv92.js => plus-C0dCjBh9.js} (87%) rename frontend/dist/assets/{primitives-Ctn6pdEU.js => primitives-C8YoaXqf.js} (93%) rename frontend/dist/assets/{repeat-CprMAEnr.js => repeat-DUo9RRDi.js} (91%) rename frontend/dist/assets/{rotate-ccw-Sqgw9a-1.js => rotate-ccw-B3SnN1wY.js} (89%) rename frontend/dist/assets/{route-Awj5QSAO.js => route-5o9tQENO.js} (94%) rename frontend/dist/assets/{search-DPGHPI2q.js => search-DN8guzpX.js} (87%) rename frontend/dist/assets/{settings-2-OYYe3udS.js => settings-2-C5Lvk9-M.js} (89%) rename frontend/dist/assets/{share-2-DLfTr0kI.js => share-2-BAsDxZE2.js} (91%) rename frontend/dist/assets/{shield-DvZvtyKV.js => shield-Ceq641wy.js} (91%) rename frontend/dist/assets/{shield-check-BB1TbeiZ.js => shield-check-DOoXovft.js} (92%) rename frontend/dist/assets/{system-Cf6Lcq9I.js => system-4FyMIaL1.js} (91%) rename frontend/dist/assets/{target-BpFOYbOg.js => target-B3CHoIpd.js} (94%) rename frontend/dist/assets/{thermometer-CG3c-cKn.js => thermometer-A8kLkazp.js} (88%) rename frontend/dist/assets/{trash-2-Def3YmfN.js => trash-2-CUY4NG5t.js} (91%) rename frontend/dist/assets/{use-text-value-CU5Ho7TY.js => use-text-value-iYUkduzo.js} (93%) rename frontend/dist/assets/{use-tree-walker-BpJfMrbM.js => use-tree-walker-DjLWwhV9.js} (84%) rename frontend/dist/assets/{useMapViewStore-DnPjO7Qt.js => useMapViewStore-Ey8vE9rr.js} (85%) rename frontend/dist/assets/{usePipelineStore-Do-g28wv.js => usePipelineStore-DDHEHTlZ.js} (97%) rename frontend/dist/assets/{useReplayTick-DbeD1_Sw.js => useReplayTick-BbXJoz75.js} (97%) rename frontend/dist/assets/{variants-cyDnzhWy.js => variants-ByRhxIcL.js} (95%) rename frontend/dist/assets/{wand-sparkles-D9rSrVnU.js => wand-sparkles-CEbXzjVw.js} (93%) rename frontend/dist/assets/{webgl-device-QoBMYpnS-Crxmw1Do.js => webgl-device-QoBMYpnS-CdQYT9sr.js} (99%) rename frontend/dist/assets/{wifi-Bc9OxL0c.js => wifi-D716s0ef.js} (91%) rename frontend/dist/assets/{wifi-off-omfJv-eS.js => wifi-off-BQtV63nI.js} (93%) rename frontend/dist/assets/{zap-v3FkQoQ-.js => zap-C-Mue2DZ.js} (89%) diff --git a/frontend/dist/VERSION b/frontend/dist/VERSION index 4d838d20..36ac29e5 100644 --- a/frontend/dist/VERSION +++ b/frontend/dist/VERSION @@ -1 +1 @@ -0.9.318 +0.9.319 diff --git a/frontend/dist/assets/AnalyzerFilterPanel-CckWnD46.js b/frontend/dist/assets/AnalyzerFilterPanel-Cq7b3I2L.js similarity index 93% rename from frontend/dist/assets/AnalyzerFilterPanel-CckWnD46.js rename to frontend/dist/assets/AnalyzerFilterPanel-Cq7b3I2L.js index d74e401e..8b8f2d10 100644 --- a/frontend/dist/assets/AnalyzerFilterPanel-CckWnD46.js +++ b/frontend/dist/assets/AnalyzerFilterPanel-Cq7b3I2L.js @@ -1,4 +1,4 @@ -import{e as U,c_ as J,ao as q,aa as G,cE as Q,cs as V,r as d,j as n,bM as K,B as Y}from"./index-C2xvS0Jd.js";import{c as Z}from"./node-types-BD70swWz.js";import{C as W}from"./circle-question-mark-CF3fGjhH.js";import{F as ee}from"./funnel-DGVJFdsh.js";import{S as te}from"./search-DPGHPI2q.js";/** +import{e as U,c$ as J,ao as q,aa as G,cF as Q,ct as V,r as d,j as n,bN as K,B as Y}from"./index-D33fcA3L.js";import{c as Z}from"./node-types-BoqnL0Eg.js";import{C as W}from"./circle-question-mark-CO80vHQp.js";import{F as ee}from"./funnel-BBIwSMOb.js";import{S as te}from"./search-DN8guzpX.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -8,7 +8,7 @@ import{e as U,c_ as J,ao as q,aa as G,cE as Q,cs as V,r as d,j as n,bM as K,B as * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const oe=[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]],re=U("droplets",oe);function xe(){return{timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}}function ae(c,l){const{timeStart:u,timeEnd:t,deviceTypes:o,nodeIds:m,disabledNodeIds:v,nodeFilterMode:w}=c,p=!0,N=o.size>0;let h;if(v.size>0){h=new Set;for(const S of m)v.has(S)||h.add(S)}else h=m;const k=h.size>0;let M=null;return k&&(M=J(h)),{hasTime:p,hasDevice:N,hasNode:k,tStart:u??l.start,tEnd:t??l.end,deviceTypes:o,effectiveNodeIds:h,nodeIdPrefixes:M,nodeFilterMode:w,needsDisambiguation:N||k}}function le(c,l,u){if(c.timestampl.tEnd)return!1;if(l.needsDisambiguation){const t=u(c);if(l.hasDevice&&!l.deviceTypes.has(t.type))return!1;if(l.hasNode){if(l.nodeFilterMode==="observed"){let o=!1;if(t.hash&&l.effectiveNodeIds.has(t.hash)&&(o=!0),!o&&c.dst_hash)if(l.effectiveNodeIds.has(c.dst_hash))o=!0;else{const m=q(c.dst_hash);l.nodeIdPrefixes.has(m)&&(o=!0)}if(!o){const m=c.forwarded_path??c.original_path;if(m&&Array.isArray(m))for(const v of m){const w=String(v).toUpperCase();if(l.nodeIdPrefixes.has(w)){o=!0;break}}}if(!o)return!1}else if(!t.hash||!l.effectiveNodeIds.has(t.hash))return!1}}return!0}function he(c,l,u,t){const o=ae(l,t);return c.filter(m=>le(m,o,u))}function X(c,l){const u=new Date(c*1e3),t=v=>v.toString().padStart(2,"0"),o=`${t(u.getHours())}:${t(u.getMinutes())}`;return l<24?o:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][u.getMonth()]} ${u.getDate()} ${o}`}const ie=[{type:"repeater",label:"Repeater",icon:G,buttonColor:"primary",iconColor:"text-sys-blue",hoverClass:"hover:border-sys-blue hover:text-sys-blue hover:!bg-transparent"},{type:"companion",label:"Companion",icon:Q,buttonColor:"indigo",iconColor:"text-sys-indigo",hoverClass:"hover:border-sys-indigo hover:text-sys-indigo hover:!bg-transparent"},{type:"room_server",label:"Room",icon:V,buttonColor:"purple",iconColor:"text-sys-purple",hoverClass:"hover:border-sys-purple hover:text-sys-purple hover:!bg-transparent"},{type:"unknown",label:"Unknown",icon:W,buttonColor:"zinc",iconColor:"text-zinc-400",hoverClass:"hover:border-zinc-400 hover:text-zinc-400 hover:!bg-transparent"}],D=60,E=.005;function de({min:c,max:l,valueStart:u,valueEnd:t,onChange:o}){const m=d.useRef(null),[v,w]=d.useState(null),p=d.useRef({valueStart:u,valueEnd:t,min:c,max:l});p.current={valueStart:u,valueEnd:t,min:c,max:l};const N=d.useRef({offset:0,width:0}),h=l-c||1,k=h/3600,M=u??c,S=t??l,C=(M-c)/h*100,_=(S-c)/h*100,F=u!==null||t!==null,I=d.useCallback(i=>{const a=m.current.getBoundingClientRect(),e=Math.max(0,Math.min(1,(i-a.left)/a.width)),{min:s,max:r}=p.current;return Math.round(s+e*(r-s||1))},[]),P=d.useCallback((i,a)=>{a.preventDefault(),a.stopPropagation();const e=a.currentTarget;e.setPointerCapture(a.pointerId),w(i);const s=f=>{const g=I(f.clientX),{valueStart:y,valueEnd:x,min:b,max:L}=p.current,z=L-b||1;if(i==="start"){const j=Math.min(g,(x??L)-D);o(j<=b+z*E?null:j,x)}else{const j=Math.max(g,(y??b)+D);o(y,j>=L-z*E?null:j)}},r=()=>{w(null),e.removeEventListener("pointermove",s),e.removeEventListener("pointerup",r),e.removeEventListener("pointercancel",r)};e.addEventListener("pointermove",s),e.addEventListener("pointerup",r),e.addEventListener("pointercancel",r)},[I,o]),$=d.useCallback(i=>{i.preventDefault(),i.stopPropagation();const a=i.currentTarget;a.setPointerCapture(i.pointerId),w("range");const e=p.current.valueStart??p.current.min,s=p.current.valueEnd??p.current.max;N.current={offset:I(i.clientX)-e,width:s-e};const r=g=>{const y=I(g.clientX),{min:x,max:b}=p.current,{offset:L,width:z}=N.current;let j=y-L;j=Math.max(x,Math.min(b-z,j));const O=j+z;o(Math.round(j)<=x?null:Math.round(j),Math.round(O)>=b?null:Math.round(O))},f=()=>{w(null),a.removeEventListener("pointermove",r),a.removeEventListener("pointerup",f),a.removeEventListener("pointercancel",f)};a.addEventListener("pointermove",r),a.addEventListener("pointerup",f),a.addEventListener("pointercancel",f)},[I,o]),H=d.useCallback(i=>{const a=I(i.clientX),{valueStart:e,valueEnd:s,min:r,max:f}=p.current,g=f-r||1,y=e??r,x=s??f;if(Math.abs(a-y)<=Math.abs(a-x)){const b=Math.min(a,x-D);o(b<=r+g*E?null:b,s)}else{const b=Math.max(a,y+D);o(e,b>=f-g*E?null:b)}},[I,o]),A=d.useCallback(()=>o(null,null),[o]),R=d.useCallback((i,a)=>{const e=a.key==="ArrowRight"||a.key==="ArrowUp"?1:a.key==="ArrowLeft"||a.key==="ArrowDown"?-1:0;if(!e)return;a.preventDefault();const s=(a.shiftKey?.1:.01)*h,{valueStart:r,valueEnd:f,min:g,max:y}=p.current,x=y-g||1;if(i==="start"){const b=Math.max(g,Math.min((r??g)+e*s,(f??y)-D));o(b<=g+x*E?null:b,f)}else{const b=Math.min(y,Math.max((f??y)+e*s,(r??g)+D));o(r,b>=y-x*E?null:b)}},[h,o]),T=i=>{const a=i==="start"?u!==null:t!==null,e=v===i;return["absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-1 h-4 rounded-full","before:content-[''] before:absolute before:-inset-x-3 before:-inset-y-1","touch-none outline-none",e?"cursor-grabbing":"cursor-ew-resize",e?"bg-sys-blue shadow-[0_0_8px_var(--sys-blue)] scale-x-150 z-20":a?"bg-sys-blue shadow-[0_0_4px_var(--sys-blue)] hover:shadow-[0_0_8px_var(--sys-blue)] hover:scale-x-150 z-10":"bg-edge-subtle hover:bg-fg-muted hover:scale-x-150 z-10",e?"":"transition-[transform,box-shadow,background-color] duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-sys-blue/50"].filter(Boolean).join(" ")};return n.jsxs("div",{className:"flex flex-col gap-0.5 min-w-[160px] sm:min-w-[220px]",children:[n.jsxs("div",{className:"flex items-center justify-between type-data-xs text-fg-muted tabular-nums select-none",children:[n.jsx("span",{className:F&&u!==null?"text-sys-blue":"",children:X(M,k)}),n.jsx("span",{className:F&&t!==null?"text-sys-blue":"",children:X(S,k)})]}),n.jsxs("div",{ref:m,className:"relative h-5 select-none",onPointerDown:H,onDoubleClick:A,children:[n.jsx("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full bg-white/[0.06] pointer-events-none"}),F?n.jsx("div",{className:["group/band absolute inset-y-0 touch-none",v==="range"?"cursor-grabbing":"cursor-grab"].join(" "),style:{left:`${C}%`,right:`${100-_}%`},onPointerDown:$,children:n.jsx("div",{className:["absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full pointer-events-none transition-colors",v==="range"?"bg-sys-blue/40":"bg-sys-blue/25 group-hover/band:bg-sys-blue/35"].join(" ")})}):n.jsx("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full bg-white/[0.04] pointer-events-none"}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range start","aria-valuenow":M,className:T("start"),style:{left:`${C}%`},onPointerDown:i=>P("start",i),onKeyDown:i=>R("start",i)}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range end","aria-valuenow":S,className:T("end"),style:{left:`${_}%`},onPointerDown:i=>P("end",i),onKeyDown:i=>R("end",i)})]})]})}function fe({parentStartTs:c,parentEndTs:l,neighbors:u,filter:t,onChange:o,scatterDotSize:m,onScatterDotSizeChange:v,scatterOpacity:w,onScatterOpacityChange:p}){const[N,h]=d.useState(""),[k,M]=d.useState(!1),S=d.useRef(null);d.useEffect(()=>{function e(s){S.current&&!S.current.contains(s.target)&&M(!1)}if(k)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[k]);const C=d.useMemo(()=>Object.entries(u).map(([e,s])=>{const r=Z(s);return{hash:e,name:s.name??s.node_name??e.slice(0,8),type:r.type,label:r.label}}).sort((e,s)=>e.name.localeCompare(s.name)),[u]),_=d.useMemo(()=>{if(!N)return C;const e=N.toLowerCase();return C.filter(s=>s.name.toLowerCase().includes(e)||s.hash.toLowerCase().includes(e))},[C,N]),F=t.timeStart!==null||t.timeEnd!==null||t.deviceTypes.size>0||t.nodeIds.size>0,I=d.useCallback((e,s)=>{o({...t,timeStart:e,timeEnd:s})},[t,o]),P=d.useCallback(e=>{const s=new Set(t.deviceTypes);s.has(e)?s.delete(e):s.add(e),o({...t,deviceTypes:s})},[t,o]),$=d.useCallback(e=>{const s=new Set(t.nodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,nodeIds:s}),h("")},[t,o]),H=d.useCallback(e=>{const s=new Set(t.nodeIds);s.delete(e);const r=new Set(t.disabledNodeIds);r.delete(e),o({...t,nodeIds:s,disabledNodeIds:r})},[t,o]),A=d.useCallback(e=>{const s=new Set(t.disabledNodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,disabledNodeIds:s})},[t,o]),R=d.useCallback(()=>{o({...t,nodeFilterMode:t.nodeFilterMode==="source"?"observed":"source"})},[t,o]),T=d.useCallback(()=>{o({timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}),h("")},[o]),i=d.useMemo(()=>{const e=new Map;for(const s of t.nodeIds){const r=u[s];e.set(s,(r==null?void 0:r.name)??(r==null?void 0:r.node_name)??s.slice(0,8))}return e},[t.nodeIds,u]),a=!!(v&&p);return n.jsxs("div",{className:"flex flex-col gap-2 card-padding",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[a&&n.jsxs(n.Fragment,{children:[n.jsx(B,{icon:n.jsx(ne,{className:"w-3 h-3"}),label:"Size",value:m??.8,onChange:v,min:.3,max:3,step:.1,format:e=>e.toFixed(1)}),n.jsx(B,{icon:n.jsx(re,{className:"w-3 h-3"}),label:"Opacity",value:w??50,onChange:p,min:5,max:100,step:5,format:e=>`${Math.round(e)}%`}),n.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden sm:block"})]}),n.jsx("div",{className:"flex items-center gap-1.5 text-fg-muted shrink-0",children:n.jsx(ee,{className:"w-3.5 h-3.5"})}),n.jsx("div",{className:"flex-1 min-w-[120px]",children:n.jsx(de,{min:c,max:l,valueStart:t.timeStart,valueEnd:t.timeEnd,onChange:I})}),F&&n.jsxs("button",{type:"button",onClick:T,className:"flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs text-fg-muted hover:text-fg-primary border border-edge-subtle hover:border-fg-muted/40 transition-colors shrink-0",title:"Clear all filters",children:[n.jsx(K,{className:"w-3 h-3"}),n.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-0.5 -mb-0.5 shrink-0",children:ie.map(({type:e,label:s,icon:r,buttonColor:f,iconColor:g,hoverClass:y})=>{const x=t.deviceTypes.has(e);return n.jsxs(Y,{color:x?f:"zinc",outline:!x,className:`!h-8 !py-0 ${x?"":y}`,onClick:()=>P(e),title:`Filter by ${s}`,children:[n.jsx(r,{"data-slot":"icon",className:x?"":g}),n.jsx("span",{className:`hidden sm:inline ${x?"":"text-fg-muted"}`,children:s})]},e)})}),n.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden md:block"}),n.jsxs("div",{className:"relative flex items-center gap-1.5 flex-1 min-w-[120px] sm:min-w-[180px] h-8 px-2 rounded-md border border-edge-subtle bg-white/[0.03] transition-colors focus-within:border-sys-blue",ref:S,children:[n.jsx(te,{className:"w-3 h-3 text-fg-muted/50 shrink-0"}),n.jsx("input",{type:"text",className:"flex-1 min-w-[60px] type-data-xs py-0.5 bg-transparent text-fg-secondary placeholder:text-fg-muted/40 border-none focus:outline-none",placeholder:"Search nodes...",value:N,onChange:e=>{h(e.target.value),M(!0)},onFocus:()=>M(!0)}),k&&_.length>0&&n.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 z-[200] surface-popover border border-edge-subtle radius-inner max-h-48 overflow-y-auto",children:_.slice(0,20).map(e=>{const s=t.nodeIds.has(e.hash);return n.jsxs("button",{type:"button",onClick:()=>$(e.hash),className:` + */const oe=[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]],re=U("droplets",oe);function xe(){return{timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}}function ae(c,l){const{timeStart:u,timeEnd:t,deviceTypes:o,nodeIds:m,disabledNodeIds:v,nodeFilterMode:w}=c,p=!0,N=o.size>0;let h;if(v.size>0){h=new Set;for(const S of m)v.has(S)||h.add(S)}else h=m;const k=h.size>0;let M=null;return k&&(M=J(h)),{hasTime:p,hasDevice:N,hasNode:k,tStart:u??l.start,tEnd:t??l.end,deviceTypes:o,effectiveNodeIds:h,nodeIdPrefixes:M,nodeFilterMode:w,needsDisambiguation:N||k}}function le(c,l,u){if(c.timestampl.tEnd)return!1;if(l.needsDisambiguation){const t=u(c);if(l.hasDevice&&!l.deviceTypes.has(t.type))return!1;if(l.hasNode){if(l.nodeFilterMode==="observed"){let o=!1;if(t.hash&&l.effectiveNodeIds.has(t.hash)&&(o=!0),!o&&c.dst_hash)if(l.effectiveNodeIds.has(c.dst_hash))o=!0;else{const m=q(c.dst_hash);l.nodeIdPrefixes.has(m)&&(o=!0)}if(!o){const m=c.forwarded_path??c.original_path;if(m&&Array.isArray(m))for(const v of m){const w=String(v).toUpperCase();if(l.nodeIdPrefixes.has(w)){o=!0;break}}}if(!o)return!1}else if(!t.hash||!l.effectiveNodeIds.has(t.hash))return!1}}return!0}function he(c,l,u,t){const o=ae(l,t);return c.filter(m=>le(m,o,u))}function X(c,l){const u=new Date(c*1e3),t=v=>v.toString().padStart(2,"0"),o=`${t(u.getHours())}:${t(u.getMinutes())}`;return l<24?o:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][u.getMonth()]} ${u.getDate()} ${o}`}const ie=[{type:"repeater",label:"Repeater",icon:G,buttonColor:"primary",iconColor:"text-sys-blue",hoverClass:"hover:border-sys-blue hover:text-sys-blue hover:!bg-transparent"},{type:"companion",label:"Companion",icon:Q,buttonColor:"indigo",iconColor:"text-sys-indigo",hoverClass:"hover:border-sys-indigo hover:text-sys-indigo hover:!bg-transparent"},{type:"room_server",label:"Room",icon:V,buttonColor:"purple",iconColor:"text-sys-purple",hoverClass:"hover:border-sys-purple hover:text-sys-purple hover:!bg-transparent"},{type:"unknown",label:"Unknown",icon:W,buttonColor:"zinc",iconColor:"text-zinc-400",hoverClass:"hover:border-zinc-400 hover:text-zinc-400 hover:!bg-transparent"}],D=60,E=.005;function de({min:c,max:l,valueStart:u,valueEnd:t,onChange:o}){const m=d.useRef(null),[v,w]=d.useState(null),p=d.useRef({valueStart:u,valueEnd:t,min:c,max:l});p.current={valueStart:u,valueEnd:t,min:c,max:l};const N=d.useRef({offset:0,width:0}),h=l-c||1,k=h/3600,M=u??c,S=t??l,C=(M-c)/h*100,F=(S-c)/h*100,_=u!==null||t!==null,I=d.useCallback(i=>{const a=m.current.getBoundingClientRect(),e=Math.max(0,Math.min(1,(i-a.left)/a.width)),{min:s,max:r}=p.current;return Math.round(s+e*(r-s||1))},[]),P=d.useCallback((i,a)=>{a.preventDefault(),a.stopPropagation();const e=a.currentTarget;e.setPointerCapture(a.pointerId),w(i);const s=f=>{const g=I(f.clientX),{valueStart:y,valueEnd:x,min:b,max:L}=p.current,z=L-b||1;if(i==="start"){const j=Math.min(g,(x??L)-D);o(j<=b+z*E?null:j,x)}else{const j=Math.max(g,(y??b)+D);o(y,j>=L-z*E?null:j)}},r=()=>{w(null),e.removeEventListener("pointermove",s),e.removeEventListener("pointerup",r),e.removeEventListener("pointercancel",r)};e.addEventListener("pointermove",s),e.addEventListener("pointerup",r),e.addEventListener("pointercancel",r)},[I,o]),$=d.useCallback(i=>{i.preventDefault(),i.stopPropagation();const a=i.currentTarget;a.setPointerCapture(i.pointerId),w("range");const e=p.current.valueStart??p.current.min,s=p.current.valueEnd??p.current.max;N.current={offset:I(i.clientX)-e,width:s-e};const r=g=>{const y=I(g.clientX),{min:x,max:b}=p.current,{offset:L,width:z}=N.current;let j=y-L;j=Math.max(x,Math.min(b-z,j));const O=j+z;o(Math.round(j)<=x?null:Math.round(j),Math.round(O)>=b?null:Math.round(O))},f=()=>{w(null),a.removeEventListener("pointermove",r),a.removeEventListener("pointerup",f),a.removeEventListener("pointercancel",f)};a.addEventListener("pointermove",r),a.addEventListener("pointerup",f),a.addEventListener("pointercancel",f)},[I,o]),H=d.useCallback(i=>{const a=I(i.clientX),{valueStart:e,valueEnd:s,min:r,max:f}=p.current,g=f-r||1,y=e??r,x=s??f;if(Math.abs(a-y)<=Math.abs(a-x)){const b=Math.min(a,x-D);o(b<=r+g*E?null:b,s)}else{const b=Math.max(a,y+D);o(e,b>=f-g*E?null:b)}},[I,o]),A=d.useCallback(()=>o(null,null),[o]),R=d.useCallback((i,a)=>{const e=a.key==="ArrowRight"||a.key==="ArrowUp"?1:a.key==="ArrowLeft"||a.key==="ArrowDown"?-1:0;if(!e)return;a.preventDefault();const s=(a.shiftKey?.1:.01)*h,{valueStart:r,valueEnd:f,min:g,max:y}=p.current,x=y-g||1;if(i==="start"){const b=Math.max(g,Math.min((r??g)+e*s,(f??y)-D));o(b<=g+x*E?null:b,f)}else{const b=Math.min(y,Math.max((f??y)+e*s,(r??g)+D));o(r,b>=y-x*E?null:b)}},[h,o]),T=i=>{const a=i==="start"?u!==null:t!==null,e=v===i;return["absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-1 h-4 rounded-full","before:content-[''] before:absolute before:-inset-x-3 before:-inset-y-1","touch-none outline-none",e?"cursor-grabbing":"cursor-ew-resize",e?"bg-sys-blue shadow-[0_0_8px_var(--sys-blue)] scale-x-150 z-20":a?"bg-sys-blue shadow-[0_0_4px_var(--sys-blue)] hover:shadow-[0_0_8px_var(--sys-blue)] hover:scale-x-150 z-10":"bg-edge-subtle hover:bg-fg-muted hover:scale-x-150 z-10",e?"":"transition-[transform,box-shadow,background-color] duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-sys-blue/50"].filter(Boolean).join(" ")};return n.jsxs("div",{className:"flex flex-col gap-0.5 min-w-[160px] sm:min-w-[220px]",children:[n.jsxs("div",{className:"flex items-center justify-between type-data-xs text-fg-muted tabular-nums select-none",children:[n.jsx("span",{className:_&&u!==null?"text-sys-blue":"",children:X(M,k)}),n.jsx("span",{className:_&&t!==null?"text-sys-blue":"",children:X(S,k)})]}),n.jsxs("div",{ref:m,className:"relative h-5 select-none",onPointerDown:H,onDoubleClick:A,children:[n.jsx("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full bg-white/[0.06] pointer-events-none"}),_?n.jsx("div",{className:["group/band absolute inset-y-0 touch-none",v==="range"?"cursor-grabbing":"cursor-grab"].join(" "),style:{left:`${C}%`,right:`${100-F}%`},onPointerDown:$,children:n.jsx("div",{className:["absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full pointer-events-none transition-colors",v==="range"?"bg-sys-blue/40":"bg-sys-blue/25 group-hover/band:bg-sys-blue/35"].join(" ")})}):n.jsx("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full bg-white/[0.04] pointer-events-none"}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range start","aria-valuenow":M,className:T("start"),style:{left:`${C}%`},onPointerDown:i=>P("start",i),onKeyDown:i=>R("start",i)}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range end","aria-valuenow":S,className:T("end"),style:{left:`${F}%`},onPointerDown:i=>P("end",i),onKeyDown:i=>R("end",i)})]})]})}function fe({parentStartTs:c,parentEndTs:l,neighbors:u,filter:t,onChange:o,scatterDotSize:m,onScatterDotSizeChange:v,scatterOpacity:w,onScatterOpacityChange:p}){const[N,h]=d.useState(""),[k,M]=d.useState(!1),S=d.useRef(null);d.useEffect(()=>{function e(s){S.current&&!S.current.contains(s.target)&&M(!1)}if(k)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[k]);const C=d.useMemo(()=>Object.entries(u).map(([e,s])=>{const r=Z(s);return{hash:e,name:s.name??s.node_name??e.slice(0,8),type:r.type,label:r.label}}).sort((e,s)=>e.name.localeCompare(s.name)),[u]),F=d.useMemo(()=>{if(!N)return C;const e=N.toLowerCase();return C.filter(s=>s.name.toLowerCase().includes(e)||s.hash.toLowerCase().includes(e))},[C,N]),_=t.timeStart!==null||t.timeEnd!==null||t.deviceTypes.size>0||t.nodeIds.size>0,I=d.useCallback((e,s)=>{o({...t,timeStart:e,timeEnd:s})},[t,o]),P=d.useCallback(e=>{const s=new Set(t.deviceTypes);s.has(e)?s.delete(e):s.add(e),o({...t,deviceTypes:s})},[t,o]),$=d.useCallback(e=>{const s=new Set(t.nodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,nodeIds:s}),h("")},[t,o]),H=d.useCallback(e=>{const s=new Set(t.nodeIds);s.delete(e);const r=new Set(t.disabledNodeIds);r.delete(e),o({...t,nodeIds:s,disabledNodeIds:r})},[t,o]),A=d.useCallback(e=>{const s=new Set(t.disabledNodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,disabledNodeIds:s})},[t,o]),R=d.useCallback(()=>{o({...t,nodeFilterMode:t.nodeFilterMode==="source"?"observed":"source"})},[t,o]),T=d.useCallback(()=>{o({timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}),h("")},[o]),i=d.useMemo(()=>{const e=new Map;for(const s of t.nodeIds){const r=u[s];e.set(s,(r==null?void 0:r.name)??(r==null?void 0:r.node_name)??s.slice(0,8))}return e},[t.nodeIds,u]),a=!!(v&&p);return n.jsxs("div",{className:"flex flex-col gap-2 card-padding",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[a&&n.jsxs(n.Fragment,{children:[n.jsx(B,{icon:n.jsx(ne,{className:"w-3 h-3"}),label:"Size",value:m??.8,onChange:v,min:.3,max:3,step:.1,format:e=>e.toFixed(1)}),n.jsx(B,{icon:n.jsx(re,{className:"w-3 h-3"}),label:"Opacity",value:w??50,onChange:p,min:5,max:100,step:5,format:e=>`${Math.round(e)}%`}),n.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden sm:block"})]}),n.jsx("div",{className:"flex items-center gap-1.5 text-fg-muted shrink-0",children:n.jsx(ee,{className:"w-3.5 h-3.5"})}),n.jsx("div",{className:"flex-1 min-w-[120px]",children:n.jsx(de,{min:c,max:l,valueStart:t.timeStart,valueEnd:t.timeEnd,onChange:I})}),_&&n.jsxs("button",{type:"button",onClick:T,className:"flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs text-fg-muted hover:text-fg-primary border border-edge-subtle hover:border-fg-muted/40 transition-colors shrink-0",title:"Clear all filters",children:[n.jsx(K,{className:"w-3 h-3"}),n.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-0.5 -mb-0.5 shrink-0",children:ie.map(({type:e,label:s,icon:r,buttonColor:f,iconColor:g,hoverClass:y})=>{const x=t.deviceTypes.has(e);return n.jsxs(Y,{color:x?f:"zinc",outline:!x,className:`!h-8 !py-0 ${x?"":y}`,onClick:()=>P(e),title:`Filter by ${s}`,children:[n.jsx(r,{"data-slot":"icon",className:x?"":g}),n.jsx("span",{className:`hidden sm:inline ${x?"":"text-fg-muted"}`,children:s})]},e)})}),n.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden md:block"}),n.jsxs("div",{className:"relative flex items-center gap-1.5 flex-1 min-w-[120px] sm:min-w-[180px] h-8 px-2 rounded-md border border-edge-subtle bg-white/[0.03] transition-colors focus-within:border-sys-blue",ref:S,children:[n.jsx(te,{className:"w-3 h-3 text-fg-muted/50 shrink-0"}),n.jsx("input",{type:"text",className:"flex-1 min-w-[60px] type-data-xs py-0.5 bg-transparent text-fg-secondary placeholder:text-fg-muted/40 border-none focus:outline-none",placeholder:"Search nodes...",value:N,onChange:e=>{h(e.target.value),M(!0)},onFocus:()=>M(!0)}),k&&F.length>0&&n.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 z-[200] surface-popover border border-edge-subtle radius-inner max-h-48 overflow-y-auto",children:F.slice(0,20).map(e=>{const s=t.nodeIds.has(e.hash);return n.jsxs("button",{type:"button",onClick:()=>$(e.hash),className:` w-full flex items-center gap-2 px-2.5 py-1.5 type-data-xs text-left transition-colors ${s?"bg-sys-indigo/15 text-sys-indigo":"text-fg-secondary hover:bg-subtle-fill"} `,children:[n.jsx("span",{className:"flex-1 truncate",children:e.name}),n.jsx("span",{className:"text-fg-muted type-data-xs shrink-0",children:e.label})]},e.hash)})})]})]}),t.nodeIds.size>0&&n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Array.from(t.nodeIds).map(e=>{const s=t.disabledNodeIds.has(e);return n.jsxs("span",{role:"button",tabIndex:0,onClick:()=>A(e),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),A(e))},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors select-none ${s?"bg-zinc-500/10 text-fg-muted border-edge-subtle cursor-pointer hover:bg-zinc-500/15":"bg-sys-indigo/15 text-sys-indigo border-sys-indigo/25 cursor-pointer hover:bg-sys-indigo/25"}`,title:e,children:[i.get(e)??e.slice(0,8),n.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),H(e)},className:"hover:text-fg-primary transition-colors -mr-0.5",title:"Remove from filter",children:n.jsx(K,{className:"w-3 h-3"})})]},e)}),n.jsx("button",{type:"button",onClick:R,className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors ${t.nodeFilterMode==="observed"?"bg-sys-blue/15 text-sys-blue border-sys-blue/25 hover:bg-sys-blue/25":"bg-white/[0.04] text-fg-muted border-edge-subtle hover:text-fg-secondary hover:border-fg-muted/40"}`,title:t.nodeFilterMode==="source"?"Source Only — showing packets sent by selected node(s)":"Total Observed — showing all packets where selected node(s) appear (source, path, or destination)",children:t.nodeFilterMode==="source"?"Source Only":"Total Observed"})]})]})}const B=d.memo(function({icon:l,label:u,value:t,onChange:o,min:m,max:v,step:w,format:p}){return n.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-fg-muted shrink-0",children:[l,n.jsx("span",{className:"type-data-xs font-medium hidden sm:inline",children:u})]}),n.jsx("input",{type:"range",min:m,max:v,step:w,value:t,onChange:N=>o(parseFloat(N.target.value)),className:"flex-1 h-1 min-w-[60px] bg-subtle-fill rounded appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-2.5 [&::-webkit-slider-thumb]:h-2.5 [&::-webkit-slider-thumb]:bg-sys-blue [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:cursor-pointer"}),n.jsx("span",{className:"type-data-xs text-fg-secondary tabular-nums shrink-0 w-8 text-right",children:p?p(t):t})]})});export{fe as A,ie as D,he as a,de as b,xe as c}; diff --git a/frontend/dist/assets/AutoConfigureDialog-C6zj_Lmv.js b/frontend/dist/assets/AutoConfigureDialog-CDgcxIyE.js similarity index 94% rename from frontend/dist/assets/AutoConfigureDialog-C6zj_Lmv.js rename to frontend/dist/assets/AutoConfigureDialog-CDgcxIyE.js index 979d4f7f..ac84de4d 100644 --- a/frontend/dist/assets/AutoConfigureDialog-C6zj_Lmv.js +++ b/frontend/dist/assets/AutoConfigureDialog-CDgcxIyE.js @@ -1 +1 @@ -import{r as f,ef as Q,j as e,a7 as X,aa as Z,c3 as M,cs as U,cE as V,ew as G,eB as ee,aC as ae,aK as se,aD as te,a2 as J,bY as ne,B as w,c as g,aE as le}from"./index-C2xvS0Jd.js";import{C as ie}from"./PageLayout-Cg7r5tdt.js";import{W as re}from"./wand-sparkles-D9rSrVnU.js";import{A as oe}from"./arrow-right-DySc3ssS.js";const ce={0:"1-byte",1:"2-byte",2:"3-byte"};function de(s){return ce[s]??`${s+1}-byte`}function ke({nodeName:s,publicKey:a,pathHashMode:r}){const[c,n]=f.useState(null),[o,m]=f.useState(null);f.useEffect(()=>{let l=!1;return(async()=>{try{const p=await Q();if(l)return;if(p.success&&p.data){const h=p.data;n(Array.isArray(h.configured)?h.configured:[]),m(Array.isArray(h.configured_companions)?h.configured_companions:[])}}catch{}})(),()=>{l=!0}},[]);const y=l=>{var p;return((p=l.settings)==null?void 0:p.node_name)||l.name};return e.jsxs(ie,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(Z,{}),title:"Node Information"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 sm:gap-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Repeater Name"}),e.jsx("div",{className:"mt-0.5 sm:mt-1 space-y-2",children:e.jsxs("div",{children:[e.jsx("p",{className:"type-data text-fg-primary truncate font-mono",title:s,children:s}),a&&e.jsx("div",{className:"mt-1 min-w-0",children:e.jsx(M,{copy:!0,truncate:"css",className:"w-full",size:"responsive",children:a})})]})}),r!=null&&e.jsxs("div",{className:"mt-4",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Path Hash Size"}),e.jsx("p",{className:"type-data text-fg-primary mt-0.5 font-mono",children:de(r)})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Room Servers"}),e.jsx("div",{className:"mt-0.5 sm:mt-1 space-y-2",children:c===null?e.jsx("span",{className:"type-data text-fg-muted",children:"—"}):c.length===0?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(U,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:"None"})]}):c.map(l=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(U,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary truncate",title:y(l),children:y(l)})]}),(l.public_key||l.identity_key)&&e.jsx("div",{className:"mt-1 pl-5 min-w-0",children:e.jsx(M,{copy:!0,truncate:"css",className:"w-full",size:"responsive",children:l.public_key||l.identity_key})})]},l.name))})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Companions"}),e.jsx("div",{className:"mt-0.5 sm:mt-1 space-y-2",children:o===null?e.jsx("span",{className:"type-data text-fg-muted",children:"—"}):o.length===0?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(V,{className:"w-3.5 h-3.5 text-sys-cyan flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:"None"})]}):o.map(l=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(V,{className:"w-3.5 h-3.5 text-sys-cyan flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary truncate",title:y(l),children:y(l)})]}),(l.public_key||l.identity_key)&&e.jsx("div",{className:"mt-1 pl-5 min-w-0",children:e.jsx(M,{copy:!0,truncate:"css",className:"w-full",size:"responsive",children:l.public_key||l.identity_key})})]},l.name))})]})]})]})}const j=168,S={sparse:50,light:200,moderate:500,dense:1e3},me={sparse:{bucketCapacity:3,refillTokens:1,refillIntervalHours:1,minIntervalSeconds:15,violationThreshold:2,basePenaltyMinutes:30,penaltyMultiplier:2,maxPenaltyHours:12,violationDecayHours:2,ewmaAlpha:.15,hysteresisMinutes:8},light:{bucketCapacity:2,refillTokens:1,refillIntervalHours:1,minIntervalSeconds:20,violationThreshold:2,basePenaltyMinutes:60,penaltyMultiplier:3,maxPenaltyHours:24,violationDecayHours:2,ewmaAlpha:.12,hysteresisMinutes:6},moderate:{bucketCapacity:2,refillTokens:1,refillIntervalHours:2,minIntervalSeconds:30,violationThreshold:1,basePenaltyMinutes:120,penaltyMultiplier:4,maxPenaltyHours:48,violationDecayHours:4,ewmaAlpha:.1,hysteresisMinutes:5},dense:{bucketCapacity:1,refillTokens:1,refillIntervalHours:4,minIntervalSeconds:60,violationThreshold:1,basePenaltyMinutes:180,penaltyMultiplier:4,maxPenaltyHours:72,violationDecayHours:6,ewmaAlpha:.08,hysteresisMinutes:3},congested:{bucketCapacity:1,refillTokens:1,refillIntervalHours:8,minIntervalSeconds:120,violationThreshold:1,basePenaltyMinutes:360,penaltyMultiplier:4,maxPenaltyHours:168,violationDecayHours:12,ewmaAlpha:.03,hysteresisMinutes:2}};function pe(s){return si.type===4))==null?void 0:h.count)??0,c=a.drop_reasons??[],n=((N=c.find(i=>i.reason==="advert rate limit exceeded"))==null?void 0:N.count)??0,o=c.filter(i=>i.reason.startsWith("advert penalty box")).reduce((i,d)=>i+d.count,0),m=((_=c.find(i=>i.reason==="Duplicate"))==null?void 0:_.count)??0;let y=0;try{const i=await G("/api/advert_rate_limit_stats");i.success&&i.data&&(y=i.data.tracked_pubkeys??Object.keys(i.data.bucket_states??{}).length)}catch{y=Math.max(1,Math.round(r/j/12))}const l=a.total_packets/j,p=r/j;return{hours:j,totalPackets:a.total_packets,transmittedPackets:a.transmitted_packets,droppedPackets:a.dropped_packets,packetsPerHour:l,advertsPerHour:p,advertPercent:a.total_packets>0?r/a.total_packets*100:0,advertCount:r,trackedSources:Math.max(1,y),advertsPerSourcePerHour:p/Math.max(1,y),rateLimitDrops:n,penaltyBoxDrops:o,duplicateDrops:m,meshDensity:pe(l)}}function ue(s){const a=me[s.meshDensity],r=s.packetsPerHour/60,c=Math.max(.01,B(r*.2)),n=Math.max(c+.01,B(r*.5)),o=Math.max(n+.01,B(r*.9));return{tokenBucket:{enabled:!0,bucket_capacity:a.bucketCapacity,refill_tokens:a.refillTokens,refill_interval_seconds:a.refillIntervalHours*3600,min_interval_seconds:a.minIntervalSeconds},penaltyBox:{enabled:!0,violation_threshold:a.violationThreshold,base_penalty_seconds:a.basePenaltyMinutes*60,penalty_multiplier:a.penaltyMultiplier,max_penalty_seconds:a.maxPenaltyHours*3600,violation_decay_seconds:a.violationDecayHours*3600},adaptive:{enabled:!0,ewma_alpha:a.ewmaAlpha,hysteresis_seconds:a.hysteresisMinutes*60,thresholds:{quiet_max:c,normal_max:n,busy_max:o}}}}async function ye(s){const a=await xe(),r=ue(a);return{analysis:a,recommended:r,current:{tokenBucket:s.tokenBucket??null,penaltyBox:s.penaltyBox??null,adaptive:s.adaptive??null}}}function B(s){return Math.round(s*100)/100}function k(s){if(s<60)return`${s}s`;if(s<3600)return`${Math.floor(s/60)}m`;const a=s/3600;return a===Math.floor(a)?`${a}h`:`${a.toFixed(1)}h`}function A(s){return s.toLocaleString(void 0,{maximumFractionDigits:1})}const he={sparse:"Sparse",light:"Light",moderate:"Moderate",dense:"Dense",congested:"Congested"},fe={sparse:"text-sys-green",light:"text-sys-cyan",moderate:"text-sys-blue",dense:"text-sys-amber",congested:"text-sys-red"},ge={rate_limit_enabled:!1,bucket_capacity:10,refill_tokens:5,refill_interval_seconds:3600,min_interval_seconds:0,penalty_enabled:!1,violation_threshold:5,base_penalty_seconds:1800,penalty_multiplier:2,max_penalty_seconds:86400,violation_decay_seconds:21600,adaptive_enabled:!1,ewma_alpha:.1,hysteresis_seconds:300,quiet_max:2,normal_max:6,busy_max:10},Ne=["rate_limit_enabled","bucket_capacity","refill_tokens","refill_interval_seconds","min_interval_seconds","penalty_enabled","violation_threshold","base_penalty_seconds","penalty_multiplier","max_penalty_seconds","violation_decay_seconds","adaptive_enabled","ewma_alpha","hysteresis_seconds","quiet_max","normal_max","busy_max"];function D({title:s,enabled:a,defaultOpen:r=!1,children:c}){const[n,o]=f.useState(r);return e.jsxs("div",{className:"bg-subtle-fill radius-inner overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>o(!n),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-subtle-fill-hover transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-label text-fg-muted",children:s}),e.jsx("span",{className:g("type-data-xs px-1.5 py-0.5 rounded-full font-medium uppercase tracking-wide",a?"bg-sys-green/15 text-sys-green":"bg-sys-red/15 text-sys-red"),children:a?"On":"Off"})]}),e.jsx(le,{className:g("w-4 h-4 text-fg-muted transition-transform",n&&"rotate-180")})]}),n&&e.jsx("div",{className:"px-4 pb-4 pt-1 space-y-1",children:c})]})}function u({label:s,current:a,recommended:r,format:c=n=>String(n)}){const n=a!=null?c(a):"—",o=c(r),m=a!=null&&n!==o;return e.jsxs("div",{className:"flex items-center justify-between gap-2 py-1",children:[e.jsx("span",{className:"type-body-sm text-fg-muted flex-1 min-w-0 truncate",children:s}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:g("data-box data-box-compact",m?"text-fg-muted line-through opacity-60":"text-fg-secondary"),children:n}),m&&e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"w-3 h-3 text-fg-muted"}),e.jsx("span",{className:"data-box data-box-compact text-sys-blue font-medium",children:o})]})]})]})}function we({open:s,onClose:a,currentConfig:r,onApplied:c}){var C,H,P,T,I,R,E,L,$,z,F,O,q,Y;const[n,o]=f.useState("idle"),[m,y]=f.useState(null),[l,p]=f.useState(null),h=f.useCallback(async()=>{o("analyzing"),p(null);try{const t=await ye(r);y(t),o("ready")}catch(t){p(t instanceof Error?t.message:"Analysis failed"),o("error")}},[r]),N=f.useCallback(async()=>{if(!m)return;o("applying"),p(null);const{tokenBucket:t,penaltyBox:b,adaptive:v}=m.recommended,K={rate_limit_enabled:t.enabled,bucket_capacity:t.bucket_capacity,refill_tokens:t.refill_tokens,refill_interval_seconds:t.refill_interval_seconds,min_interval_seconds:t.min_interval_seconds,penalty_enabled:b.enabled,violation_threshold:b.violation_threshold,base_penalty_seconds:b.base_penalty_seconds,penalty_multiplier:b.penalty_multiplier,max_penalty_seconds:b.max_penalty_seconds,violation_decay_seconds:b.violation_decay_seconds,adaptive_enabled:v.enabled,ewma_alpha:v.ewma_alpha,hysteresis_seconds:v.hysteresis_seconds,quiet_max:v.thresholds.quiet_max,normal_max:v.thresholds.normal_max,busy_max:v.thresholds.busy_max};try{const W=await ee(K);W.success?(o("applied"),c==null||c()):(p(W.error||"Failed to apply settings"),o("error"))}catch{p("Failed to apply settings"),o("error")}},[m,c]),_=f.useCallback(()=>{a(),setTimeout(()=>{o("idle"),y(null),p(null)},300)},[a]);s&&n==="idle"&&h();const i=m==null?void 0:m.analysis,d=m==null?void 0:m.recommended,x=m==null?void 0:m.current;return e.jsxs(ae,{open:s,onClose:_,size:"lg",children:[e.jsx(se,{icon:e.jsx(re,{size:20}),title:"Auto-Configure",onClose:_}),e.jsxs(te,{className:"flex flex-col gap-5 max-h-[70vh] overflow-y-auto",children:[n==="analyzing"&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12",children:[e.jsx(J,{className:"w-6 h-6 text-sys-blue animate-spin"}),e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Analyzing 7 days of mesh traffic…"})]}),n==="error"&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-8",children:[e.jsx(ne,{className:"w-6 h-6 text-sys-amber"}),e.jsx("p",{className:"type-body-sm text-fg-secondary",children:l}),e.jsx(w,{plain:!0,onClick:h,className:"text-sys-blue",children:"Retry"})]}),(n==="ready"||n==="applying"||n==="applied")&&i&&d&&x&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"type-micro mb-3",children:"7-DAY ANALYSIS"}),e.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Pkts/hr"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:A(i.packetsPerHour)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Adverts/hr"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:A(i.advertsPerHour)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Sources"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:i.trackedSources})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Density"}),e.jsx("div",{className:g("data-box data-box-fill data-box-left",fe[i.meshDensity]),children:he[i.meshDensity]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{title:"Token Bucket of Shame",enabled:d.tokenBucket.enabled,defaultOpen:!0,children:[e.jsx(u,{label:"Bucket Capacity",current:(C=x.tokenBucket)==null?void 0:C.bucket_capacity,recommended:d.tokenBucket.bucket_capacity,format:t=>`${t} tokens`}),e.jsx(u,{label:"Refill Tokens",current:(H=x.tokenBucket)==null?void 0:H.refill_tokens,recommended:d.tokenBucket.refill_tokens,format:t=>`${t} tokens`}),e.jsx(u,{label:"Refill Interval",current:(P=x.tokenBucket)==null?void 0:P.refill_interval_seconds,recommended:d.tokenBucket.refill_interval_seconds,format:t=>k(t)}),e.jsx(u,{label:"Min Interval",current:(T=x.tokenBucket)==null?void 0:T.min_interval_seconds,recommended:d.tokenBucket.min_interval_seconds,format:t=>`${t}s`})]}),e.jsxs(D,{title:"Jail",enabled:d.penaltyBox.enabled,children:[e.jsx(u,{label:"Violation Threshold",current:(I=x.penaltyBox)==null?void 0:I.violation_threshold,recommended:d.penaltyBox.violation_threshold,format:t=>`${t} violations`}),e.jsx(u,{label:"Base Penalty",current:(R=x.penaltyBox)==null?void 0:R.base_penalty_seconds,recommended:d.penaltyBox.base_penalty_seconds,format:t=>k(t)}),e.jsx(u,{label:"Multiplier",current:(E=x.penaltyBox)==null?void 0:E.penalty_multiplier,recommended:d.penaltyBox.penalty_multiplier,format:t=>`${t}×`}),e.jsx(u,{label:"Max Penalty",current:(L=x.penaltyBox)==null?void 0:L.max_penalty_seconds,recommended:d.penaltyBox.max_penalty_seconds,format:t=>k(t)}),e.jsx(u,{label:"Violation Decay",current:($=x.penaltyBox)==null?void 0:$.violation_decay_seconds,recommended:d.penaltyBox.violation_decay_seconds,format:t=>k(t)})]}),e.jsxs(D,{title:"Adaptive Tiers",enabled:d.adaptive.enabled,children:[e.jsx(u,{label:"EWMA α",current:(z=x.adaptive)==null?void 0:z.ewma_alpha,recommended:d.adaptive.ewma_alpha}),e.jsx(u,{label:"Hysteresis",current:(F=x.adaptive)==null?void 0:F.hysteresis_seconds,recommended:d.adaptive.hysteresis_seconds,format:t=>k(t)}),e.jsx(u,{label:"Quiet Max",current:(O=x.adaptive)==null?void 0:O.thresholds.quiet_max,recommended:d.adaptive.thresholds.quiet_max,format:t=>`${t} pkts/min`}),e.jsx(u,{label:"Normal Max",current:(q=x.adaptive)==null?void 0:q.thresholds.normal_max,recommended:d.adaptive.thresholds.normal_max,format:t=>`${t} pkts/min`}),e.jsx(u,{label:"Busy Max",current:(Y=x.adaptive)==null?void 0:Y.thresholds.busy_max,recommended:d.adaptive.thresholds.busy_max,format:t=>`${t} pkts/min`})]})]}),e.jsxs("div",{className:g("flex justify-between gap-4 pt-1",n==="applied"?"items-center":"items-end"),children:[n==="applied"?e.jsx("span",{className:"type-body-sm text-zinc-500",children:"Settings applied"}):e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Analyzed"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[A(i.totalPackets)," packets"]})]}),e.jsx("div",{className:"flex items-center gap-2",children:n==="applied"?e.jsx(w,{color:"primary",onClick:_,children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx(w,{plain:!0,onClick:_,children:"Cancel"}),e.jsx(w,{color:"primary",onClick:N,disabled:n==="applying",children:n==="applying"?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4 animate-spin"}),"Applying…"]}):"Apply All"})]})})]})]})]})]})}export{we as A,ke as N,ge as S,Ne as a}; +import{r as f,ef as Z,j as e,a7 as K,aa as X,c4 as M,ct as U,cF as V,ew as G,eB as ee,aC as ae,aL as se,aD as te,a2 as J,bZ as ne,B as w,c as g,aF as le}from"./index-D33fcA3L.js";import{C as ie}from"./PageLayout-CRN-E5xi.js";import{W as re}from"./wand-sparkles-CEbXzjVw.js";import{A as oe}from"./arrow-right-aT_K-Mjc.js";const ce={0:"1-byte",1:"2-byte",2:"3-byte"};function de(s){return ce[s]??`${s+1}-byte`}function ke({nodeName:s,publicKey:a,pathHashMode:r}){const[c,n]=f.useState(null),[o,m]=f.useState(null);f.useEffect(()=>{let l=!1;return(async()=>{try{const p=await Z();if(l)return;if(p.success&&p.data){const h=p.data;n(Array.isArray(h.configured)?h.configured:[]),m(Array.isArray(h.configured_companions)?h.configured_companions:[])}}catch{}})(),()=>{l=!0}},[]);const y=l=>{var p;return((p=l.settings)==null?void 0:p.node_name)||l.name};return e.jsxs(ie,{neomorphic:!0,children:[e.jsx(K,{icon:e.jsx(X,{}),title:"Node Information"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 sm:gap-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Repeater Name"}),e.jsx("div",{className:"mt-0.5 sm:mt-1 space-y-2",children:e.jsxs("div",{children:[e.jsx("p",{className:"type-data text-fg-primary truncate font-mono",title:s,children:s}),a&&e.jsx("div",{className:"mt-1 min-w-0",children:e.jsx(M,{copy:!0,truncate:"css",className:"w-full",size:"responsive",children:a})})]})}),r!=null&&e.jsxs("div",{className:"mt-4",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Path Hash Size"}),e.jsx("p",{className:"type-data text-fg-primary mt-0.5 font-mono",children:de(r)})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Room Servers"}),e.jsx("div",{className:"mt-0.5 sm:mt-1 space-y-2",children:c===null?e.jsx("span",{className:"type-data text-fg-muted",children:"—"}):c.length===0?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(U,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:"None"})]}):c.map(l=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(U,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary truncate",title:y(l),children:y(l)})]}),(l.public_key||l.identity_key)&&e.jsx("div",{className:"mt-1 pl-5 min-w-0",children:e.jsx(M,{copy:!0,truncate:"css",className:"w-full",size:"responsive",children:l.public_key||l.identity_key})})]},l.name))})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Companions"}),e.jsx("div",{className:"mt-0.5 sm:mt-1 space-y-2",children:o===null?e.jsx("span",{className:"type-data text-fg-muted",children:"—"}):o.length===0?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(V,{className:"w-3.5 h-3.5 text-sys-cyan flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:"None"})]}):o.map(l=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(V,{className:"w-3.5 h-3.5 text-sys-cyan flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary truncate",title:y(l),children:y(l)})]}),(l.public_key||l.identity_key)&&e.jsx("div",{className:"mt-1 pl-5 min-w-0",children:e.jsx(M,{copy:!0,truncate:"css",className:"w-full",size:"responsive",children:l.public_key||l.identity_key})})]},l.name))})]})]})]})}const j=168,S={sparse:50,light:200,moderate:500,dense:1e3},me={sparse:{bucketCapacity:3,refillTokens:1,refillIntervalHours:1,minIntervalSeconds:15,violationThreshold:2,basePenaltyMinutes:30,penaltyMultiplier:2,maxPenaltyHours:12,violationDecayHours:2,ewmaAlpha:.15,hysteresisMinutes:8},light:{bucketCapacity:2,refillTokens:1,refillIntervalHours:1,minIntervalSeconds:20,violationThreshold:2,basePenaltyMinutes:60,penaltyMultiplier:3,maxPenaltyHours:24,violationDecayHours:2,ewmaAlpha:.12,hysteresisMinutes:6},moderate:{bucketCapacity:2,refillTokens:1,refillIntervalHours:2,minIntervalSeconds:30,violationThreshold:1,basePenaltyMinutes:120,penaltyMultiplier:4,maxPenaltyHours:48,violationDecayHours:4,ewmaAlpha:.1,hysteresisMinutes:5},dense:{bucketCapacity:1,refillTokens:1,refillIntervalHours:4,minIntervalSeconds:60,violationThreshold:1,basePenaltyMinutes:180,penaltyMultiplier:4,maxPenaltyHours:72,violationDecayHours:6,ewmaAlpha:.08,hysteresisMinutes:3},congested:{bucketCapacity:1,refillTokens:1,refillIntervalHours:8,minIntervalSeconds:120,violationThreshold:1,basePenaltyMinutes:360,penaltyMultiplier:4,maxPenaltyHours:168,violationDecayHours:12,ewmaAlpha:.03,hysteresisMinutes:2}};function pe(s){return si.type===4))==null?void 0:h.count)??0,c=a.drop_reasons??[],n=((N=c.find(i=>i.reason==="advert rate limit exceeded"))==null?void 0:N.count)??0,o=c.filter(i=>i.reason.startsWith("advert penalty box")).reduce((i,d)=>i+d.count,0),m=((_=c.find(i=>i.reason==="Duplicate"))==null?void 0:_.count)??0;let y=0;try{const i=await G("/api/advert_rate_limit_stats");i.success&&i.data&&(y=i.data.tracked_pubkeys??Object.keys(i.data.bucket_states??{}).length)}catch{y=Math.max(1,Math.round(r/j/12))}const l=a.total_packets/j,p=r/j;return{hours:j,totalPackets:a.total_packets,transmittedPackets:a.transmitted_packets,droppedPackets:a.dropped_packets,packetsPerHour:l,advertsPerHour:p,advertPercent:a.total_packets>0?r/a.total_packets*100:0,advertCount:r,trackedSources:Math.max(1,y),advertsPerSourcePerHour:p/Math.max(1,y),rateLimitDrops:n,penaltyBoxDrops:o,duplicateDrops:m,meshDensity:pe(l)}}function ue(s){const a=me[s.meshDensity],r=s.packetsPerHour/60,c=Math.max(.01,B(r*.2)),n=Math.max(c+.01,B(r*.5)),o=Math.max(n+.01,B(r*.9));return{tokenBucket:{enabled:!0,bucket_capacity:a.bucketCapacity,refill_tokens:a.refillTokens,refill_interval_seconds:a.refillIntervalHours*3600,min_interval_seconds:a.minIntervalSeconds},penaltyBox:{enabled:!0,violation_threshold:a.violationThreshold,base_penalty_seconds:a.basePenaltyMinutes*60,penalty_multiplier:a.penaltyMultiplier,max_penalty_seconds:a.maxPenaltyHours*3600,violation_decay_seconds:a.violationDecayHours*3600},adaptive:{enabled:!0,ewma_alpha:a.ewmaAlpha,hysteresis_seconds:a.hysteresisMinutes*60,thresholds:{quiet_max:c,normal_max:n,busy_max:o}}}}async function ye(s){const a=await xe(),r=ue(a);return{analysis:a,recommended:r,current:{tokenBucket:s.tokenBucket??null,penaltyBox:s.penaltyBox??null,adaptive:s.adaptive??null}}}function B(s){return Math.round(s*100)/100}function k(s){if(s<60)return`${s}s`;if(s<3600)return`${Math.floor(s/60)}m`;const a=s/3600;return a===Math.floor(a)?`${a}h`:`${a.toFixed(1)}h`}function A(s){return s.toLocaleString(void 0,{maximumFractionDigits:1})}const he={sparse:"Sparse",light:"Light",moderate:"Moderate",dense:"Dense",congested:"Congested"},fe={sparse:"text-sys-green",light:"text-sys-cyan",moderate:"text-sys-blue",dense:"text-sys-amber",congested:"text-sys-red"},ge={rate_limit_enabled:!1,bucket_capacity:10,refill_tokens:5,refill_interval_seconds:3600,min_interval_seconds:0,penalty_enabled:!1,violation_threshold:5,base_penalty_seconds:1800,penalty_multiplier:2,max_penalty_seconds:86400,violation_decay_seconds:21600,adaptive_enabled:!1,ewma_alpha:.1,hysteresis_seconds:300,quiet_max:2,normal_max:6,busy_max:10},Ne=["rate_limit_enabled","bucket_capacity","refill_tokens","refill_interval_seconds","min_interval_seconds","penalty_enabled","violation_threshold","base_penalty_seconds","penalty_multiplier","max_penalty_seconds","violation_decay_seconds","adaptive_enabled","ewma_alpha","hysteresis_seconds","quiet_max","normal_max","busy_max"];function D({title:s,enabled:a,defaultOpen:r=!1,children:c}){const[n,o]=f.useState(r);return e.jsxs("div",{className:"bg-subtle-fill radius-inner overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>o(!n),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-subtle-fill-hover transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-label text-fg-muted",children:s}),e.jsx("span",{className:g("type-data-xs px-1.5 py-0.5 rounded-full font-medium uppercase tracking-wide",a?"bg-sys-green/15 text-sys-green":"bg-sys-red/15 text-sys-red"),children:a?"On":"Off"})]}),e.jsx(le,{className:g("w-4 h-4 text-fg-muted transition-transform",n&&"rotate-180")})]}),n&&e.jsx("div",{className:"px-4 pb-4 pt-1 space-y-1",children:c})]})}function u({label:s,current:a,recommended:r,format:c=n=>String(n)}){const n=a!=null?c(a):"—",o=c(r),m=a!=null&&n!==o;return e.jsxs("div",{className:"flex items-center justify-between gap-2 py-1",children:[e.jsx("span",{className:"type-body-sm text-fg-muted flex-1 min-w-0 truncate",children:s}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:g("data-box data-box-compact",m?"text-fg-muted line-through opacity-60":"text-fg-secondary"),children:n}),m&&e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"w-3 h-3 text-fg-muted"}),e.jsx("span",{className:"data-box data-box-compact text-sys-blue font-medium",children:o})]})]})]})}function we({open:s,onClose:a,currentConfig:r,onApplied:c}){var C,H,P,T,I,R,L,E,$,z,F,O,q,Y;const[n,o]=f.useState("idle"),[m,y]=f.useState(null),[l,p]=f.useState(null),h=f.useCallback(async()=>{o("analyzing"),p(null);try{const t=await ye(r);y(t),o("ready")}catch(t){p(t instanceof Error?t.message:"Analysis failed"),o("error")}},[r]),N=f.useCallback(async()=>{if(!m)return;o("applying"),p(null);const{tokenBucket:t,penaltyBox:b,adaptive:v}=m.recommended,Q={rate_limit_enabled:t.enabled,bucket_capacity:t.bucket_capacity,refill_tokens:t.refill_tokens,refill_interval_seconds:t.refill_interval_seconds,min_interval_seconds:t.min_interval_seconds,penalty_enabled:b.enabled,violation_threshold:b.violation_threshold,base_penalty_seconds:b.base_penalty_seconds,penalty_multiplier:b.penalty_multiplier,max_penalty_seconds:b.max_penalty_seconds,violation_decay_seconds:b.violation_decay_seconds,adaptive_enabled:v.enabled,ewma_alpha:v.ewma_alpha,hysteresis_seconds:v.hysteresis_seconds,quiet_max:v.thresholds.quiet_max,normal_max:v.thresholds.normal_max,busy_max:v.thresholds.busy_max};try{const W=await ee(Q);W.success?(o("applied"),c==null||c()):(p(W.error||"Failed to apply settings"),o("error"))}catch{p("Failed to apply settings"),o("error")}},[m,c]),_=f.useCallback(()=>{a(),setTimeout(()=>{o("idle"),y(null),p(null)},300)},[a]);s&&n==="idle"&&h();const i=m==null?void 0:m.analysis,d=m==null?void 0:m.recommended,x=m==null?void 0:m.current;return e.jsxs(ae,{open:s,onClose:_,size:"lg",children:[e.jsx(se,{icon:e.jsx(re,{size:20}),title:"Auto-Configure",onClose:_}),e.jsxs(te,{className:"flex flex-col gap-5 max-h-[70vh] overflow-y-auto",children:[n==="analyzing"&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12",children:[e.jsx(J,{className:"w-6 h-6 text-sys-blue animate-spin"}),e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Analyzing 7 days of mesh traffic…"})]}),n==="error"&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-8",children:[e.jsx(ne,{className:"w-6 h-6 text-sys-amber"}),e.jsx("p",{className:"type-body-sm text-fg-secondary",children:l}),e.jsx(w,{plain:!0,onClick:h,className:"text-sys-blue",children:"Retry"})]}),(n==="ready"||n==="applying"||n==="applied")&&i&&d&&x&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"type-micro mb-3",children:"7-DAY ANALYSIS"}),e.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Pkts/hr"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:A(i.packetsPerHour)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Adverts/hr"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:A(i.advertsPerHour)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Sources"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:i.trackedSources})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Density"}),e.jsx("div",{className:g("data-box data-box-fill data-box-left",fe[i.meshDensity]),children:he[i.meshDensity]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{title:"Token Bucket of Shame",enabled:d.tokenBucket.enabled,defaultOpen:!0,children:[e.jsx(u,{label:"Bucket Capacity",current:(C=x.tokenBucket)==null?void 0:C.bucket_capacity,recommended:d.tokenBucket.bucket_capacity,format:t=>`${t} tokens`}),e.jsx(u,{label:"Refill Tokens",current:(H=x.tokenBucket)==null?void 0:H.refill_tokens,recommended:d.tokenBucket.refill_tokens,format:t=>`${t} tokens`}),e.jsx(u,{label:"Refill Interval",current:(P=x.tokenBucket)==null?void 0:P.refill_interval_seconds,recommended:d.tokenBucket.refill_interval_seconds,format:t=>k(t)}),e.jsx(u,{label:"Min Interval",current:(T=x.tokenBucket)==null?void 0:T.min_interval_seconds,recommended:d.tokenBucket.min_interval_seconds,format:t=>`${t}s`})]}),e.jsxs(D,{title:"Jail",enabled:d.penaltyBox.enabled,children:[e.jsx(u,{label:"Violation Threshold",current:(I=x.penaltyBox)==null?void 0:I.violation_threshold,recommended:d.penaltyBox.violation_threshold,format:t=>`${t} violations`}),e.jsx(u,{label:"Base Penalty",current:(R=x.penaltyBox)==null?void 0:R.base_penalty_seconds,recommended:d.penaltyBox.base_penalty_seconds,format:t=>k(t)}),e.jsx(u,{label:"Multiplier",current:(L=x.penaltyBox)==null?void 0:L.penalty_multiplier,recommended:d.penaltyBox.penalty_multiplier,format:t=>`${t}×`}),e.jsx(u,{label:"Max Penalty",current:(E=x.penaltyBox)==null?void 0:E.max_penalty_seconds,recommended:d.penaltyBox.max_penalty_seconds,format:t=>k(t)}),e.jsx(u,{label:"Violation Decay",current:($=x.penaltyBox)==null?void 0:$.violation_decay_seconds,recommended:d.penaltyBox.violation_decay_seconds,format:t=>k(t)})]}),e.jsxs(D,{title:"Adaptive Tiers",enabled:d.adaptive.enabled,children:[e.jsx(u,{label:"EWMA α",current:(z=x.adaptive)==null?void 0:z.ewma_alpha,recommended:d.adaptive.ewma_alpha}),e.jsx(u,{label:"Hysteresis",current:(F=x.adaptive)==null?void 0:F.hysteresis_seconds,recommended:d.adaptive.hysteresis_seconds,format:t=>k(t)}),e.jsx(u,{label:"Quiet Max",current:(O=x.adaptive)==null?void 0:O.thresholds.quiet_max,recommended:d.adaptive.thresholds.quiet_max,format:t=>`${t} pkts/min`}),e.jsx(u,{label:"Normal Max",current:(q=x.adaptive)==null?void 0:q.thresholds.normal_max,recommended:d.adaptive.thresholds.normal_max,format:t=>`${t} pkts/min`}),e.jsx(u,{label:"Busy Max",current:(Y=x.adaptive)==null?void 0:Y.thresholds.busy_max,recommended:d.adaptive.thresholds.busy_max,format:t=>`${t} pkts/min`})]})]}),e.jsxs("div",{className:g("flex justify-between gap-4 pt-1",n==="applied"?"items-center":"items-end"),children:[n==="applied"?e.jsx("span",{className:"type-body-sm text-zinc-500",children:"Settings applied"}):e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Analyzed"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[A(i.totalPackets)," packets"]})]}),e.jsx("div",{className:"flex items-center gap-2",children:n==="applied"?e.jsx(w,{color:"primary",onClick:_,children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx(w,{plain:!0,onClick:_,children:"Cancel"}),e.jsx(w,{color:"primary",onClick:N,disabled:n==="applying",children:n==="applying"?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4 animate-spin"}),"Applying…"]}):"Apply All"})]})})]})]})]})]})}export{we as A,ke as N,ge as S,Ne as a}; diff --git a/frontend/dist/assets/BasemapLayer-DQCsZLc0.js b/frontend/dist/assets/BasemapLayer-DhvtWc_h.js similarity index 95% rename from frontend/dist/assets/BasemapLayer-DQCsZLc0.js rename to frontend/dist/assets/BasemapLayer-DhvtWc_h.js index ee23f255..7151975c 100644 --- a/frontend/dist/assets/BasemapLayer-DQCsZLc0.js +++ b/frontend/dist/assets/BasemapLayer-DhvtWc_h.js @@ -1 +1 @@ -import{r as o}from"./index-C2xvS0Jd.js";import{u as w}from"./maplibre-gl-C9QYi5T6.js";const C={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},x={light:"basemap-light-",dark:"basemap-dark-"},k={};async function E(i){if(k[i])return k[i];const t=await(await fetch(C[i])).json();return k[i]=t,t}function R({mode:i}){const{current:l}=w(),[t,b]=o.useState(null),u=o.useRef({light:!1,dark:!1}),m=o.useRef({light:[],dark:[]});o.useEffect(()=>{const e=()=>{var a;const s=(a=l==null?void 0:l.getMap)==null?void 0:a.call(l);s&&!t&&b(s)};e();const r=setInterval(e,50),c=setTimeout(()=>clearInterval(r),5e3);return()=>{clearInterval(r),clearTimeout(c)}},[l,t]);const g=o.useCallback(async(e,r,c)=>{var L,I;if(u.current[r])return;const s=x[r],a=await E(r),d=[];for(const[y,f]of Object.entries(a.sources||{})){const n=s+y;e.getSource(n)||e.addSource(n,f)}const v=(I=(((L=e.getStyle())==null?void 0:L.layers)||[]).find(y=>!y.id.startsWith("basemap-light-")&&!y.id.startsWith("basemap-dark-")))==null?void 0:I.id;for(const y of a.layers||[]){const f=s+y.id;if(d.push(f),e.getLayer(f))continue;const n={...y,id:f};"source"in n&&typeof n.source=="string"&&(n.source=s+n.source),n.layout||(n.layout={}),n.layout.visibility=c?"visible":"none";try{e.addLayer(n,v)}catch(S){console.warn(`[BasemapLayer] Failed to add layer ${f}:`,S)}}m.current[r]=d,u.current[r]=!0},[]),h=o.useCallback((e,r,c)=>{const s=m.current[r],a=c?"visible":"none";for(const d of s)if(e.getLayer(d))try{e.setLayoutProperty(d,"visibility",a)}catch{}},[]),p=o.useCallback(e=>{var s;const c=(((s=e.getStyle())==null?void 0:s.layers)||[]).filter(a=>!a.id.startsWith("basemap-light-")&&!a.id.startsWith("basemap-dark-"));for(const a of c)try{e.moveLayer(a.id)}catch{}},[]);return o.useEffect(()=>{if(!t)return;const e=r=>{t.hasImage(r.id)||t.addImage(r.id,{width:1,height:1,data:new Uint8Array([0,0,0,0])})};return t.on("styleimagemissing",e),()=>{t.off("styleimagemissing",e)}},[t]),o.useEffect(()=>{if(!t)return;let e=!1;const r=async()=>{if(!e)try{await Promise.all([g(t,"light",i==="light"),g(t,"dark",i==="dark")]),e||p(t)}catch(s){console.error("[BasemapLayer] Setup error:",s)}};t.isStyleLoaded()?r():(t.once("style.load",r),t.once("load",()=>{!e&&!u.current.light&&r()}));const c=()=>{e||setTimeout(()=>{!e&&u.current.light&&u.current.dark&&p(t)},100)};return t.on("styledata",c),()=>{e=!0,t.off("styledata",c)}},[t,g,p,i]),o.useEffect(()=>{t&&(!u.current.light||!u.current.dark||(h(t,"light",i==="light"),h(t,"dark",i==="dark")))},[t,i,h]),null}export{R as B}; +import{r as o}from"./index-D33fcA3L.js";import{u as w}from"./maplibre-gl-B42P8ehE.js";const C={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},x={light:"basemap-light-",dark:"basemap-dark-"},k={};async function E(i){if(k[i])return k[i];const t=await(await fetch(C[i])).json();return k[i]=t,t}function R({mode:i}){const{current:l}=w(),[t,b]=o.useState(null),u=o.useRef({light:!1,dark:!1}),m=o.useRef({light:[],dark:[]});o.useEffect(()=>{const e=()=>{var a;const s=(a=l==null?void 0:l.getMap)==null?void 0:a.call(l);s&&!t&&b(s)};e();const r=setInterval(e,50),c=setTimeout(()=>clearInterval(r),5e3);return()=>{clearInterval(r),clearTimeout(c)}},[l,t]);const g=o.useCallback(async(e,r,c)=>{var L,I;if(u.current[r])return;const s=x[r],a=await E(r),d=[];for(const[y,f]of Object.entries(a.sources||{})){const n=s+y;e.getSource(n)||e.addSource(n,f)}const v=(I=(((L=e.getStyle())==null?void 0:L.layers)||[]).find(y=>!y.id.startsWith("basemap-light-")&&!y.id.startsWith("basemap-dark-")))==null?void 0:I.id;for(const y of a.layers||[]){const f=s+y.id;if(d.push(f),e.getLayer(f))continue;const n={...y,id:f};"source"in n&&typeof n.source=="string"&&(n.source=s+n.source),n.layout||(n.layout={}),n.layout.visibility=c?"visible":"none";try{e.addLayer(n,v)}catch(S){console.warn(`[BasemapLayer] Failed to add layer ${f}:`,S)}}m.current[r]=d,u.current[r]=!0},[]),h=o.useCallback((e,r,c)=>{const s=m.current[r],a=c?"visible":"none";for(const d of s)if(e.getLayer(d))try{e.setLayoutProperty(d,"visibility",a)}catch{}},[]),p=o.useCallback(e=>{var s;const c=(((s=e.getStyle())==null?void 0:s.layers)||[]).filter(a=>!a.id.startsWith("basemap-light-")&&!a.id.startsWith("basemap-dark-"));for(const a of c)try{e.moveLayer(a.id)}catch{}},[]);return o.useEffect(()=>{if(!t)return;const e=r=>{t.hasImage(r.id)||t.addImage(r.id,{width:1,height:1,data:new Uint8Array([0,0,0,0])})};return t.on("styleimagemissing",e),()=>{t.off("styleimagemissing",e)}},[t]),o.useEffect(()=>{if(!t)return;let e=!1;const r=async()=>{if(!e)try{await Promise.all([g(t,"light",i==="light"),g(t,"dark",i==="dark")]),e||p(t)}catch(s){console.error("[BasemapLayer] Setup error:",s)}};t.isStyleLoaded()?r():(t.once("style.load",r),t.once("load",()=>{!e&&!u.current.light&&r()}));const c=()=>{e||setTimeout(()=>{!e&&u.current.light&&u.current.dark&&p(t)},100)};return t.on("styledata",c),()=>{e=!0,t.off("styledata",c)}},[t,g,p,i]),o.useEffect(()=>{t&&(!u.current.light||!u.current.dark||(h(t,"light",i==="light"),h(t,"dark",i==="dark")))},[t,i,h]),null}export{R as B}; diff --git a/frontend/dist/assets/ChatBubble-DsIWWOdr.js b/frontend/dist/assets/ChatBubble-BqRoJxSW.js similarity index 97% rename from frontend/dist/assets/ChatBubble-DsIWWOdr.js rename to frontend/dist/assets/ChatBubble-BqRoJxSW.js index 1bfab651..e17db78c 100644 --- a/frontend/dist/assets/ChatBubble-DsIWWOdr.js +++ b/frontend/dist/assets/ChatBubble-BqRoJxSW.js @@ -1 +1 @@ -import{r as B,j as e,c as s}from"./index-C2xvS0Jd.js";import{e as M,g as W,a as E,c as S,f as g,b}from"./chat-utils-DnJ-lYj3.js";const v=["","text-[42px]","text-[36px]","text-[30px]"],O=B.memo(function({senderName:x,text:n,timestamp:d,nameAccessory:y,bubbleAccessory:c,className:o,isOutgoing:N,status:t,onRetry:m,onRetryAsFlood:h,retryAttempt:p,maxRetries:l,signed:w,echoCount:r,bubbleVariant:V="accent",onMentionClick:f}){const{emoji:u,cleanName:j}=M(x),k=W(j),C=E(x),a=S(n);return N?e.jsxs("div",{className:s("group flex flex-col items-end w-full p-2",o),children:[e.jsxs("div",{className:"flex items-end gap-1.5 max-w-[80%]",children:[c,a>0?e.jsx("p",{className:s("leading-none",v[a]),children:n.trim()}):e.jsx("div",{className:s("inline-block px-3.5 py-2.5","rounded-2xl rounded-br-md",t==="failed"?"bg-sys-red depth-raised-soft":"bg-sys-blue depth-raised-soft"),children:e.jsx("p",{className:"text-sm text-white leading-relaxed tracking-wide whitespace-pre-wrap break-words",children:g(n,{isOutgoing:!0,onMentionClick:f})})})]}),e.jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-0.5 mr-1",children:[r!=null&&r>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-sys-green tabular-nums font-medium",children:[e.jsxs("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M17 1l4 4-4 4"}),e.jsx("path",{d:"M3 11V9a4 4 0 0 1 4-4h14"}),e.jsx("path",{d:"M7 23l-4-4 4-4"}),e.jsx("path",{d:"M21 13v2a4 4 0 0 1-4 4H3"})]}),r]}),t==="confirmed"&&e.jsxs("svg",{className:"w-3 h-3 text-sys-green",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("polyline",{points:"3 12 8 17 14 6"}),e.jsx("polyline",{points:"10 12 15 17 21 6"})]}),t==="sent"&&e.jsx("svg",{className:"w-3 h-3 text-fg-muted",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),t==="pending"&&e.jsx("svg",{className:"w-3 h-3 text-chat-timestamp animate-spin",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),t==="retrying"&&e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-3 h-3 text-sys-amber animate-spin",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),p!=null&&l!=null&&e.jsxs("span",{className:"text-[10px] text-sys-amber font-medium tabular-nums",children:["Retry ",p,"/",l]})]}),t==="unconfirmed"&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-sys-amber flex-shrink-0"}),t==="failed"&&e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"w-3 h-3 text-sys-red",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),l!=null&&l>0&&e.jsxs("span",{className:"text-[10px] text-sys-red/70",children:["after ",l," ",l===1?"retry":"retries"]}),m&&e.jsx("button",{onClick:m,className:"text-[10px] font-medium text-sys-red hover:text-sys-red/80 underline underline-offset-2 transition-colors",children:"Retry"}),h&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] text-fg-muted/50",children:"·"}),e.jsx("button",{onClick:h,className:"text-[10px] font-medium text-sys-amber hover:text-sys-amber/80 underline underline-offset-2 transition-colors",children:"Flood"})]})]}),e.jsx("span",{className:"text-[10px] text-chat-timestamp tabular-nums",children:b(d)})]})]}):e.jsxs("div",{className:s("group flex items-start gap-4 w-full p-2",o),children:[e.jsxs("div",{className:"flex-shrink-0 w-9 flex flex-col items-center gap-1",children:[e.jsx("div",{className:s("clay-avatar w-9 h-9",u?"text-lg":"text-white text-[13px] font-bold tracking-tight"),style:{"--avatar-color":k},children:u||C}),e.jsx("span",{className:"text-xs text-chat-timestamp tabular-nums h-4 leading-4",children:b(d)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 -mt-[3px] mb-1",children:[e.jsx("span",{className:"text-[13px] font-normal text-chat-incoming-name truncate leading-tight tabular-nums",children:j}),w&&e.jsxs("svg",{className:"w-3.5 h-3.5 text-sys-green flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("title",{children:"Ed25519 signed message"}),e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"}),e.jsx("polyline",{points:"9 12 11 14 15 10"})]}),y]}),e.jsxs("div",{className:"flex items-end gap-1.5",children:[a>0?e.jsx("p",{className:s("leading-none",v[a]),children:n.trim()}):e.jsx("div",{className:s("inline-block px-3.5 py-2.5 max-w-full","rounded-2xl rounded-tl-md","bg-chat-incoming depth-raised-soft"),children:e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed tracking-wide whitespace-pre-wrap break-words",children:g(n,{onMentionClick:f})})}),c]})]})]})});function T({text:i}){return e.jsx("div",{className:"flex justify-center my-1",children:e.jsx("span",{className:s("px-3 py-1 rounded-full","bg-subtle-fill text-[11px] text-fg-muted/80 font-medium","ring-1 ring-edge-subtle"),children:i})})}export{O as C,T as S}; +import{r as B,j as e,c as s}from"./index-D33fcA3L.js";import{e as M,g as W,a as E,c as S,f as g,b}from"./chat-utils-DIy1-SG1.js";const v=["","text-[42px]","text-[36px]","text-[30px]"],O=B.memo(function({senderName:x,text:n,timestamp:d,nameAccessory:y,bubbleAccessory:c,className:o,isOutgoing:N,status:t,onRetry:m,onRetryAsFlood:h,retryAttempt:p,maxRetries:l,signed:w,echoCount:r,bubbleVariant:V="accent",onMentionClick:f}){const{emoji:u,cleanName:j}=M(x),k=W(j),C=E(x),a=S(n);return N?e.jsxs("div",{className:s("group flex flex-col items-end w-full p-2",o),children:[e.jsxs("div",{className:"flex items-end gap-1.5 max-w-[80%]",children:[c,a>0?e.jsx("p",{className:s("leading-none",v[a]),children:n.trim()}):e.jsx("div",{className:s("inline-block px-3.5 py-2.5","rounded-2xl rounded-br-md",t==="failed"?"bg-sys-red depth-raised-soft":"bg-sys-blue depth-raised-soft"),children:e.jsx("p",{className:"text-sm text-white leading-relaxed tracking-wide whitespace-pre-wrap break-words",children:g(n,{isOutgoing:!0,onMentionClick:f})})})]}),e.jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-0.5 mr-1",children:[r!=null&&r>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-sys-green tabular-nums font-medium",children:[e.jsxs("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M17 1l4 4-4 4"}),e.jsx("path",{d:"M3 11V9a4 4 0 0 1 4-4h14"}),e.jsx("path",{d:"M7 23l-4-4 4-4"}),e.jsx("path",{d:"M21 13v2a4 4 0 0 1-4 4H3"})]}),r]}),t==="confirmed"&&e.jsxs("svg",{className:"w-3 h-3 text-sys-green",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("polyline",{points:"3 12 8 17 14 6"}),e.jsx("polyline",{points:"10 12 15 17 21 6"})]}),t==="sent"&&e.jsx("svg",{className:"w-3 h-3 text-fg-muted",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),t==="pending"&&e.jsx("svg",{className:"w-3 h-3 text-chat-timestamp animate-spin",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),t==="retrying"&&e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-3 h-3 text-sys-amber animate-spin",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),p!=null&&l!=null&&e.jsxs("span",{className:"text-[10px] text-sys-amber font-medium tabular-nums",children:["Retry ",p,"/",l]})]}),t==="unconfirmed"&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-sys-amber flex-shrink-0"}),t==="failed"&&e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"w-3 h-3 text-sys-red",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),l!=null&&l>0&&e.jsxs("span",{className:"text-[10px] text-sys-red/70",children:["after ",l," ",l===1?"retry":"retries"]}),m&&e.jsx("button",{onClick:m,className:"text-[10px] font-medium text-sys-red hover:text-sys-red/80 underline underline-offset-2 transition-colors",children:"Retry"}),h&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] text-fg-muted/50",children:"·"}),e.jsx("button",{onClick:h,className:"text-[10px] font-medium text-sys-amber hover:text-sys-amber/80 underline underline-offset-2 transition-colors",children:"Flood"})]})]}),e.jsx("span",{className:"text-[10px] text-chat-timestamp tabular-nums",children:b(d)})]})]}):e.jsxs("div",{className:s("group flex items-start gap-4 w-full p-2",o),children:[e.jsxs("div",{className:"flex-shrink-0 w-9 flex flex-col items-center gap-1",children:[e.jsx("div",{className:s("clay-avatar w-9 h-9",u?"text-lg":"text-white text-[13px] font-bold tracking-tight"),style:{"--avatar-color":k},children:u||C}),e.jsx("span",{className:"text-xs text-chat-timestamp tabular-nums h-4 leading-4",children:b(d)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 -mt-[3px] mb-1",children:[e.jsx("span",{className:"text-[13px] font-normal text-chat-incoming-name truncate leading-tight tabular-nums",children:j}),w&&e.jsxs("svg",{className:"w-3.5 h-3.5 text-sys-green flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("title",{children:"Ed25519 signed message"}),e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"}),e.jsx("polyline",{points:"9 12 11 14 15 10"})]}),y]}),e.jsxs("div",{className:"flex items-end gap-1.5",children:[a>0?e.jsx("p",{className:s("leading-none",v[a]),children:n.trim()}):e.jsx("div",{className:s("inline-block px-3.5 py-2.5 max-w-full","rounded-2xl rounded-tl-md","bg-chat-incoming depth-raised-soft"),children:e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed tracking-wide whitespace-pre-wrap break-words",children:g(n,{onMentionClick:f})})}),c]})]})]})});function T({text:i}){return e.jsx("div",{className:"flex justify-center my-1",children:e.jsx("span",{className:s("px-3 py-1 rounded-full","bg-subtle-fill text-[11px] text-fg-muted/80 font-medium","ring-1 ring-edge-subtle"),children:i})})}export{O as C,T as S}; diff --git a/frontend/dist/assets/CollisionExplorerModal-Du9NEbAu.js b/frontend/dist/assets/CollisionExplorerModal-P8ZOhB65.js similarity index 87% rename from frontend/dist/assets/CollisionExplorerModal-Du9NEbAu.js rename to frontend/dist/assets/CollisionExplorerModal-P8ZOhB65.js index 11eb7913..1cec38e7 100644 --- a/frontend/dist/assets/CollisionExplorerModal-Du9NEbAu.js +++ b/frontend/dist/assets/CollisionExplorerModal-P8ZOhB65.js @@ -1 +1 @@ -import{r as c,a6 as L,ch as S,ab as H,j as e,aC as k,bY as R,aD as B,c$ as E,b$ as T,c as N,ao as D,V as M,a3 as P,a0 as _,a1 as z,cs as I,cE as W}from"./index-C2xvS0Jd.js";import{M as $,S as F,L as Y,a as q}from"./maplibre-gl-C9QYi5T6.js";import{B as A}from"./BasemapLayer-DQCsZLc0.js";import{M as U}from"./map-pin-CQk00ph2.js";import{S as V}from"./share-2-DLfTr0kI.js";const G={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"};function w({node:o,isHovered:v,onHover:f}){const[g,p]=c.useState(!1),y=c.useCallback(async d=>{d.stopPropagation(),await P(o.hash),p(!0),setTimeout(()=>p(!1),2e3)},[o.hash]),h=o.contactType.toLowerCase(),m=h.includes("room")||h.includes("server"),l=h==="companion"||h==="client";let n=V,r="text-sys-blue";return m?(n=I,r="text-signal-fair"):l?(n=W,r="text-fg-muted"):o.isNeighbor&&(r="text-sys-green"),e.jsxs("div",{className:N("flex items-center gap-3 px-3 py-2.5 radius-inner transition-base cursor-pointer",v?"bg-sys-blue/10":"hover:bg-subtle-fill"),onMouseEnter:()=>f(o.hash),onMouseLeave:()=>f(null),children:[e.jsx(n,{className:N("w-4 h-4 flex-shrink-0",r)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"type-label text-fg-primary truncate",children:o.name}),o.isNeighbor&&e.jsx(M,{color:"green",compact:!0,children:"NBR"}),o.isRepeater&&e.jsx(M,{color:"zinc",compact:!0,children:"RPT"}),o.isHub&&e.jsx(M,{color:"indigo",compact:!0,children:"HUB"})]}),e.jsxs("button",{onClick:y,className:N("mt-1 inline-flex items-center gap-1 type-data-xs px-1.5 py-0.5 rounded","border transition-all cursor-pointer",g?"border-sys-green/50 bg-sys-green/10 text-sys-green":"border-edge-subtle bg-subtle/50 text-fg-muted hover:border-edge-strong"),title:`Copy: ${o.hash}`,children:[o.hash.slice(0,12),"…",g?e.jsx(_,{className:"w-2.5 h-2.5"}):e.jsx(z,{className:"w-2.5 h-2.5 opacity-50"})]})]})]})}function C({nodes:o,hoveredHash:v,onHover:f}){const g=E(),p=c.useRef(null),y=T(),[h,m]=c.useState(!1),l=c.useMemo(()=>o.filter(a=>a.latitude!=null&&a.longitude!=null&&(a.latitude!==0||a.longitude!==0)),[o]),n=c.useMemo(()=>{if(l.length===0)return null;let a=1/0,s=-1/0,t=1/0,i=-1/0;for(const x of l)a=Math.min(a,x.longitude),s=Math.max(s,x.longitude),t=Math.min(t,x.latitude),i=Math.max(i,x.latitude);const u=.01;if(i-tn?{longitude:(n[0][0]+n[1][0])/2,latitude:(n[0][1]+n[1][1])/2}:{longitude:0,latitude:0},[n]),d=c.useMemo(()=>{if(l.length<2)return null;const a=[];for(let s=0;s{var s;const a=(s=p.current)==null?void 0:s.getMap();if(!a||!n){m(!0);return}a.fitBounds(n,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:13,duration:0}),setTimeout(()=>m(!0),50)},[n]),b=y&&h;return l.length===0?e.jsx("div",{className:"h-full flex items-center justify-center bg-subtle/30 radius-inner",children:e.jsxs("div",{className:"text-center text-fg-secondary p-4",children:[e.jsx(U,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No location data available"})]})}):e.jsxs("div",{className:"h-full w-full relative radius-inner overflow-hidden bg-elevated",children:[e.jsx("div",{className:N("absolute inset-0 flex items-center justify-center z-10","transition-opacity duration-200 pointer-events-none",b?"opacity-0":"opacity-100 bg-elevated"),children:e.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),e.jsx("div",{className:N("h-full w-full transition-opacity duration-200",b?"opacity-100":"opacity-0"),children:e.jsxs($,{ref:p,initialViewState:{longitude:r.longitude,latitude:r.latitude,zoom:10},style:{height:"100%",width:"100%"},mapStyle:G,attributionControl:!1,onLoad:j,children:[e.jsx(A,{mode:g}),d&&e.jsx(F,{id:"collision-edges",type:"geojson",data:d,children:e.jsx(Y,{id:"collision-edges-line",type:"line",paint:{"line-color":"#3B3F4A","line-width":2,"line-opacity":.8},layout:{"line-cap":"round","line-join":"round"}})}),l.map(a=>{const s=a.hash===v,t=D(a.hash);return e.jsx(q,{longitude:a.longitude,latitude:a.latitude,anchor:"center",children:e.jsx("div",{className:"cursor-pointer transition-all duration-150",onMouseEnter:()=>f(a.hash),onMouseLeave:()=>f(null),style:{pointerEvents:"auto"},children:e.jsxs(M,{color:"amber",filled:!0,className:"type-data-xs shadow-lg",children:[t,s&&e.jsx("span",{className:"ml-1 opacity-75 font-sans",children:a.name})]})})},a.hash)})]})})]})}function J({isOpen:o,prefix:v,candidateHashes:f,onClose:g}){const p=L(),y=S(),h=H(),[m,l]=c.useState(null),n=c.useMemo(()=>new Set(h.map(s=>s.hash)),[h]),r=(p==null?void 0:p.neighbors)??{},d=c.useMemo(()=>{const s=t=>{if(r[t])return r[t];if(!t.startsWith("0x")&&r["0x"+t])return r["0x"+t];if(t.startsWith("0x")&&r[t.slice(2)])return r[t.slice(2)]};return f.map(t=>{var u;const i=s(t);return{hash:t,name:(i==null?void 0:i.node_name)||(i==null?void 0:i.name)||`Unknown (${t.slice(0,8)}…)`,contactType:(i==null?void 0:i.contact_type)||"",isRepeater:(i==null?void 0:i.is_repeater)||((u=i==null?void 0:i.contact_type)==null?void 0:u.toLowerCase())==="repeater"||!1,isNeighbor:n.has(t)||n.has("0x"+t)||n.has(t.replace(/^0x/,"")),isHub:y.has(t),latitude:i==null?void 0:i.latitude,longitude:i==null?void 0:i.longitude}}).sort((t,i)=>t.isNeighbor!==i.isNeighbor?t.isNeighbor?-1:1:t.isHub!==i.isHub?t.isHub?-1:1:t.name.localeCompare(i.name))},[f,r,n,y]),j=c.useMemo(()=>d.some(s=>s.latitude!=null&&s.longitude!=null&&(s.latitude!==0||s.longitude!==0)),[d]),b=c.useCallback(s=>{l(s)},[]),a=j?"4xl":"lg";return o?e.jsxs(k,{open:o,onClose:g,size:a,motionPlus:!0,className:j?"sm:h-[500px] sm:max-h-[600px]":"",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-edge-subtle",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 radius-inner bg-signal-fair/10",children:e.jsx(R,{className:"w-5 h-5 text-signal-fair"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"type-micro",children:["Prefix Collision: ",e.jsx("span",{className:"font-mono text-sys-blue",children:v})]}),e.jsxs("p",{className:"text-xs text-fg-secondary",children:[d.length," nodes share this prefix"]})]})]}),e.jsx("button",{onClick:g,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),e.jsx("button",{onClick:g,className:"hidden sm:flex items-center justify-center p-2 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-subtle","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs(B,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"sm:hidden flex-1 overflow-y-auto",children:[j&&e.jsx("div",{className:"h-64 p-2 border-b border-edge-subtle",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:b})}),e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(w,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})]}),j?e.jsxs("div",{className:"hidden sm:grid sm:grid-cols-[280px_minmax(400px,1fr)] flex-1 overflow-hidden sm:min-w-[700px]",children:[e.jsx("div",{className:"overflow-y-auto border-r border-edge-subtle",children:e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(w,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})}),e.jsx("div",{className:"overflow-hidden p-2",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:b})})]}):e.jsx("div",{className:"hidden sm:block flex-1 overflow-y-auto",children:e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(w,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})})]})]}):null}const ee=c.memo(J);export{ee as C}; +import{r as c,a6 as L,ci as S,ab as H,j as e,aC as k,bZ as R,aD as B,d0 as E,c0 as T,c as N,ao as D,V as M,a3 as P,a0 as _,a1 as z,ct as I,cF as F}from"./index-D33fcA3L.js";import{M as W,S as q,L as A,a as U}from"./maplibre-gl-B42P8ehE.js";import{B as V}from"./BasemapLayer-DhvtWc_h.js";import{M as Y}from"./map-pin-B_Rx-xpd.js";import{S as Z}from"./share-2-BAsDxZE2.js";const $={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"};function w({node:o,isHovered:v,onHover:f}){const[g,p]=c.useState(!1),y=c.useCallback(async d=>{d.stopPropagation(),await P(o.hash),p(!0),setTimeout(()=>p(!1),2e3)},[o.hash]),h=o.contactType.toLowerCase(),m=h.includes("room")||h.includes("server"),l=h==="companion"||h==="client";let n=Z,r="text-sys-blue";return m?(n=I,r="text-signal-fair"):l?(n=F,r="text-fg-muted"):o.isNeighbor&&(r="text-sys-green"),e.jsxs("div",{className:N("flex items-center gap-3 px-3 py-2.5 radius-inner transition-base cursor-pointer",v?"bg-sys-blue/10":"hover:bg-subtle-fill"),onMouseEnter:()=>f(o.hash),onMouseLeave:()=>f(null),children:[e.jsx(n,{className:N("w-4 h-4 flex-shrink-0",r)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"type-label text-fg-primary truncate",children:o.name}),o.isNeighbor&&e.jsx(M,{color:"green",compact:!0,children:"NBR"}),o.isRepeater&&e.jsx(M,{color:"zinc",compact:!0,children:"RPT"}),o.isHub&&e.jsx(M,{color:"indigo",compact:!0,children:"HUB"})]}),e.jsxs("button",{onClick:y,className:N("mt-1 inline-flex items-center gap-1 type-data-xs px-1.5 py-0.5 rounded","border transition-all cursor-pointer",g?"border-sys-green/50 bg-sys-green/10 text-sys-green":"border-edge-subtle bg-subtle/50 text-fg-muted hover:border-edge-strong"),title:`Copy: ${o.hash}`,children:[o.hash.slice(0,12),"…",g?e.jsx(_,{className:"w-2.5 h-2.5"}):e.jsx(z,{className:"w-2.5 h-2.5 opacity-50"})]})]})]})}function C({nodes:o,hoveredHash:v,onHover:f}){const g=E(),p=c.useRef(null),y=T(),[h,m]=c.useState(!1),l=c.useMemo(()=>o.filter(a=>a.latitude!=null&&a.longitude!=null&&(a.latitude!==0||a.longitude!==0)),[o]),n=c.useMemo(()=>{if(l.length===0)return null;let a=1/0,s=-1/0,t=1/0,i=-1/0;for(const x of l)a=Math.min(a,x.longitude),s=Math.max(s,x.longitude),t=Math.min(t,x.latitude),i=Math.max(i,x.latitude);const u=.01;if(i-tn?{longitude:(n[0][0]+n[1][0])/2,latitude:(n[0][1]+n[1][1])/2}:{longitude:0,latitude:0},[n]),d=c.useMemo(()=>{if(l.length<2)return null;const a=[];for(let s=0;s{var s;const a=(s=p.current)==null?void 0:s.getMap();if(!a||!n){m(!0);return}a.fitBounds(n,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:13,duration:0}),setTimeout(()=>m(!0),50)},[n]),b=y&&h;return l.length===0?e.jsx("div",{className:"h-full flex items-center justify-center bg-subtle/30 radius-inner",children:e.jsxs("div",{className:"text-center text-fg-secondary p-4",children:[e.jsx(Y,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No location data available"})]})}):e.jsxs("div",{className:"h-full w-full relative radius-inner overflow-hidden bg-elevated",children:[e.jsx("div",{className:N("absolute inset-0 flex items-center justify-center z-10","transition-opacity duration-200 pointer-events-none",b?"opacity-0":"opacity-100 bg-elevated"),children:e.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),e.jsx("div",{className:N("h-full w-full transition-opacity duration-200",b?"opacity-100":"opacity-0"),children:e.jsxs(W,{ref:p,initialViewState:{longitude:r.longitude,latitude:r.latitude,zoom:10},style:{height:"100%",width:"100%"},mapStyle:$,attributionControl:!1,onLoad:j,children:[e.jsx(V,{mode:g}),d&&e.jsx(q,{id:"collision-edges",type:"geojson",data:d,children:e.jsx(A,{id:"collision-edges-line",type:"line",paint:{"line-color":"#3B3F4A","line-width":2,"line-opacity":.8},layout:{"line-cap":"round","line-join":"round"}})}),l.map(a=>{const s=a.hash===v,t=D(a.hash);return e.jsx(U,{longitude:a.longitude,latitude:a.latitude,anchor:"center",children:e.jsx("div",{className:"cursor-pointer transition-all duration-150",onMouseEnter:()=>f(a.hash),onMouseLeave:()=>f(null),style:{pointerEvents:"auto"},children:e.jsxs(M,{color:"amber",filled:!0,className:"type-data-xs shadow-lg",children:[t,s&&e.jsx("span",{className:"ml-1 opacity-75 font-sans",children:a.name})]})})},a.hash)})]})})]})}function G({isOpen:o,prefix:v,candidateHashes:f,onClose:g}){const p=L(),y=S(),h=H(),[m,l]=c.useState(null),n=c.useMemo(()=>new Set(h.map(s=>s.hash)),[h]),r=(p==null?void 0:p.neighbors)??{},d=c.useMemo(()=>{const s=t=>{if(r[t])return r[t];if(!t.startsWith("0x")&&r["0x"+t])return r["0x"+t];if(t.startsWith("0x")&&r[t.slice(2)])return r[t.slice(2)]};return f.map(t=>{var u;const i=s(t);return{hash:t,name:(i==null?void 0:i.node_name)||(i==null?void 0:i.name)||`Unknown (${t.slice(0,8)}…)`,contactType:(i==null?void 0:i.contact_type)||"",isRepeater:(i==null?void 0:i.is_repeater)||((u=i==null?void 0:i.contact_type)==null?void 0:u.toLowerCase())==="repeater"||!1,isNeighbor:n.has(t)||n.has("0x"+t)||n.has(t.replace(/^0x/,"")),isHub:y.has(t),latitude:i==null?void 0:i.latitude,longitude:i==null?void 0:i.longitude}}).sort((t,i)=>t.isNeighbor!==i.isNeighbor?t.isNeighbor?-1:1:t.isHub!==i.isHub?t.isHub?-1:1:t.name.localeCompare(i.name))},[f,r,n,y]),j=c.useMemo(()=>d.some(s=>s.latitude!=null&&s.longitude!=null&&(s.latitude!==0||s.longitude!==0)),[d]),b=c.useCallback(s=>{l(s)},[]),a=j?"4xl":"lg";return o?e.jsxs(k,{open:o,onClose:g,size:a,motionPlus:!0,className:j?"sm:h-[500px] sm:max-h-[600px]":"",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-edge-subtle",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 radius-inner bg-signal-fair/10",children:e.jsx(R,{className:"w-5 h-5 text-signal-fair"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"type-micro",children:["Prefix Collision: ",e.jsx("span",{className:"font-mono text-sys-blue",children:v})]}),e.jsxs("p",{className:"text-xs text-fg-secondary",children:[d.length," nodes share this prefix"]})]})]}),e.jsx("button",{onClick:g,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),e.jsx("button",{onClick:g,className:"hidden sm:flex items-center justify-center p-2 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-subtle","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs(B,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"sm:hidden flex-1 overflow-y-auto",children:[j&&e.jsx("div",{className:"h-64 p-2 border-b border-edge-subtle",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:b})}),e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(w,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})]}),j?e.jsxs("div",{className:"hidden sm:grid sm:grid-cols-[280px_minmax(400px,1fr)] flex-1 overflow-hidden sm:min-w-[700px]",children:[e.jsx("div",{className:"overflow-y-auto border-r border-edge-subtle",children:e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(w,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})}),e.jsx("div",{className:"overflow-hidden p-2",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:b})})]}):e.jsx("div",{className:"hidden sm:block flex-1 overflow-y-auto",children:e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(w,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})})]})]}):null}const ee=c.memo(G);export{ee as C}; diff --git a/frontend/dist/assets/Companion-DeUMmHbn.js b/frontend/dist/assets/Companion-CMsDpx5g.js similarity index 98% rename from frontend/dist/assets/Companion-DeUMmHbn.js rename to frontend/dist/assets/Companion-CMsDpx5g.js index d45d1c44..9cb3414e 100644 --- a/frontend/dist/assets/Companion-DeUMmHbn.js +++ b/frontend/dist/assets/Companion-CMsDpx5g.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CompanionPathMap-DEvrWwCv.js","assets/index-C2xvS0Jd.js","assets/usePipelineStore-Do-g28wv.js","assets/node-types-BD70swWz.js","assets/useReplayTick-DbeD1_Sw.js","assets/payload-detail-BAEvS7Pl.js","assets/car-D35Wwv-5.js","assets/map-pin-off-D8fZRJ6M.js","assets/index-7uzBcJ1E.css","assets/maplibre-gl-B1CfjdFi.css","assets/CompanionEchoMap-Hp02AMdw.js"])))=>i.map(i=>d[i]); -import{aX as Ba,fB as js,aZ as dn,a_ as Wa,aY as Tt,a$ as un,r as l,b0 as Ua,b1 as ye,b4 as _e,aT as ee,b8 as Q,b5 as ge,bi as Ga,b9 as Mt,bd as $t,be as At,bj as Ka,bf as Me,bg as mt,bk as qa,bh as be,bl as Ns,bm as Va,bn as Ja,bo as ot,bp as Qa,bq as Xa,br as Ya,aW as at,b6 as Za,fD as er,d7 as De,fE as mn,bt as tr,bu as le,bv as sr,bC as nr,dk as ar,dl as rr,bE as lr,fF as ir,bs as Le,bD as pt,bx as or,fG as Ft,bG as ws,fH as xt,b2 as Ye,bz as pn,bA as cr,bB as dr,d5 as ks,d8 as Cs,fC as ur,bF as mr,b3 as pr,bb as xr,bc as hr,bw as xn,d3 as hn,e as ae,j as e,c as E,a0 as Ne,fI as fr,t as gr,cZ as ue,fJ as re,cE as je,cs as ht,aa as Ke,bM as ft,f2 as Re,f3 as Ee,f4 as Pe,d as ve,fK as yr,fL as br,m as me,fM as vr,cT as ct,aC as Ce,aK as Te,dK as qe,aD as Se,a2 as ce,bY as Ve,eJ as $e,B as U,fN as jr,fO as gt,au as Nr,Q as wr,fP as Ss,_ as fn,ca as kr,V as ze,fQ as Cr,dy as Sr,fR as Ot,fS as Ir,fT as _r,bI as Rt,fU as Mr,fV as Rr,fW as Er,dJ as Pr,a1 as Dt,ef as Tr,fX as $r,fY as Ar,fZ as gn,f_ as Fr,a8 as Or,f$ as Dr,g0 as yn,fq as Lr,g1 as zr,g2 as Hr,I as fe,C as Is,g3 as bn,g4 as Br,g5 as Wr,g6 as Ur,g7 as Gr,g8 as Kr,g9 as qr,ga as Vr,gb as Jr,gc as Qr,gd as Xr,a6 as Yr,ge as Zr,gf as el,gg as tl,gh as sl,gi as nl,gj as al,gk as rl,gl as ll,gm as il,gn as ol,eE as cl}from"./index-C2xvS0Jd.js";import{P as _s,a as Ms,B as Rs,C as Es}from"./PageLayout-Cg7r5tdt.js";import{e as yt,g as bt,a as vt,f as dl,b as ul}from"./chat-utils-DnJ-lYj3.js";import{c as Ps,S as ml,a as pl}from"./SignalIndicator-DO8Lkax5.js";import{b as xl,F as hl,y as fl,R as gl,T as yl,w as bl,A as vl,M as vn}from"./map-pin-CQk00ph2.js";import{p as jl,a as rt,c as Y,f as st,b as Nl,L as wl,S as nt,s as kl,u as Cl,d as Sl}from"./element-movement-CSQuYFsD.js";import{s as Il}from"./use-text-value-CU5Ho7TY.js";import{F as _l}from"./use-tree-walker-BpJfMrbM.js";import{a as lt}from"./index-wtt5rE5a.js";import{S as Ts}from"./search-DPGHPI2q.js";import{S as Ml}from"./share-2-DLfTr0kI.js";import{R as Je,L as Rl}from"./route-Awj5QSAO.js";import{R as jn}from"./rotate-ccw-Sqgw9a-1.js";import{T as Qe}from"./trash-2-Def3YmfN.js";import{H as He}from"./hash-DjqT3oXN.js";import{C as El}from"./check-check-UEaQfqci.js";import{P as Xe}from"./plus-CH14Vv92.js";import{S as Pl,C as Tl}from"./ChatBubble-DsIWWOdr.js";import{p as $l}from"./payload-detail-BAEvS7Pl.js";import{A as Al}from"./arrow-down-4OY_dsXk.js";import{C as Fl}from"./chevron-right-C9GG0xWI.js";import{C as Nn}from"./circle-alert-kdR_gb55.js";import{f as Ol,c as Dl,a as Ll,M as zl}from"./variants-cyDnzhWy.js";import{C as wn}from"./clock-DU0z3qMB.js";import{A as kn}from"./activity-BFfde9uG.js";import{T as Cn}from"./thermometer-CG3c-cKn.js";import{S as Hl}from"./shield-check-BB1TbeiZ.js";import{W as $s}from"./wand-sparkles-D9rSrVnU.js";import{C as Bl}from"./compass-D_q1TimF.js";import{G as As}from"./git-branch-BhoB5t-Q.js";import{F as ie,L as oe,D as Ie}from"./fieldset-DQmrmWyj.js";import{C as Sn}from"./ConfirmModal-eC-cl0ep.js";import{K as In}from"./key-round-DBZOsqH6.js";import{F as _n,P as Wl}from"./pencil-55Hza1I4.js";var Ul=Object.defineProperty,Gl=(s,t,n)=>t in s?Ul(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n,Fs=(s,t,n)=>(Gl(s,typeof t!="symbol"?t+"":t,n),n),ne=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(ne||{}),dt=(s=>(s[s.Pointer=0]="Pointer",s[s.Other=1]="Other",s))(dt||{}),V=(s=>(s[s.OpenMenu=0]="OpenMenu",s[s.CloseMenu=1]="CloseMenu",s[s.GoToItem=2]="GoToItem",s[s.Search=3]="Search",s[s.ClearSearch=4]="ClearSearch",s[s.RegisterItems=5]="RegisterItems",s[s.UnregisterItems=6]="UnregisterItems",s[s.SetButtonElement=7]="SetButtonElement",s[s.SetItemsElement=8]="SetItemsElement",s[s.SortItems=9]="SortItems",s[s.MarkButtonAsMoved=10]="MarkButtonAsMoved",s))(V||{});function Os(s,t=n=>n){let n=s.activeItemIndex!==null?s.items[s.activeItemIndex]:null,a=un(t(s.items.slice()),i=>i.dataRef.current.domRef.current),r=n?a.indexOf(n):null;return r===-1&&(r=null),{items:a,activeItemIndex:r}}let Kl={1(s){if(s.menuState===1)return s;let t=s.buttonElement?rt.Tracked(Nl(s.buttonElement)):s.buttonPositionState;return{...s,activeItemIndex:null,pendingFocus:{focus:Y.Nothing},menuState:1,buttonPositionState:t}},0(s,t){return s.menuState===0?s:{...s,__demoMode:!1,pendingFocus:t.focus,menuState:0,buttonPositionState:rt.Idle}},2:(s,t)=>{var n,a,r,i,o;if(s.menuState===1)return s;let u={...s,searchQuery:"",activationTrigger:(n=t.trigger)!=null?n:1,__demoMode:!1};if(t.focus===Y.Nothing)return{...u,activeItemIndex:null};if(t.focus===Y.Specific)return{...u,activeItemIndex:s.items.findIndex(c=>c.id===t.id)};if(t.focus===Y.Previous){let c=s.activeItemIndex;if(c!==null){let x=s.items[c].dataRef.current.domRef,y=st(t,{resolveItems:()=>s.items,resolveActiveIndex:()=>s.activeItemIndex,resolveId:g=>g.id,resolveDisabled:g=>g.dataRef.current.disabled});if(y!==null){let g=s.items[y].dataRef.current.domRef;if(((a=x.current)==null?void 0:a.previousElementSibling)===g.current||((r=g.current)==null?void 0:r.previousElementSibling)===null)return{...u,activeItemIndex:y}}}}else if(t.focus===Y.Next){let c=s.activeItemIndex;if(c!==null){let x=s.items[c].dataRef.current.domRef,y=st(t,{resolveItems:()=>s.items,resolveActiveIndex:()=>s.activeItemIndex,resolveId:g=>g.id,resolveDisabled:g=>g.dataRef.current.disabled});if(y!==null){let g=s.items[y].dataRef.current.domRef;if(((i=x.current)==null?void 0:i.nextElementSibling)===g.current||((o=g.current)==null?void 0:o.nextElementSibling)===null)return{...u,activeItemIndex:y}}}}let d=Os(s),f=st(t,{resolveItems:()=>d.items,resolveActiveIndex:()=>d.activeItemIndex,resolveId:c=>c.id,resolveDisabled:c=>c.dataRef.current.disabled});return{...u,...d,activeItemIndex:f}},3:(s,t)=>{let n=s.searchQuery!==""?0:1,a=s.searchQuery+t.value.toLowerCase(),r=(s.activeItemIndex!==null?s.items.slice(s.activeItemIndex+n).concat(s.items.slice(0,s.activeItemIndex+n)):s.items).find(o=>{var u;return((u=o.dataRef.current.textValue)==null?void 0:u.startsWith(a))&&!o.dataRef.current.disabled}),i=r?s.items.indexOf(r):-1;return i===-1||i===s.activeItemIndex?{...s,searchQuery:a}:{...s,searchQuery:a,activeItemIndex:i,activationTrigger:1}},4(s){return s.searchQuery===""?s:{...s,searchQuery:"",searchActiveItemIndex:null}},5:(s,t)=>{let n=s.items.concat(t.items.map(r=>r)),a=s.activeItemIndex;return s.pendingFocus.focus!==Y.Nothing&&(a=st(s.pendingFocus,{resolveItems:()=>n,resolveActiveIndex:()=>s.activeItemIndex,resolveId:r=>r.id,resolveDisabled:r=>r.dataRef.current.disabled})),{...s,items:n,activeItemIndex:a,pendingFocus:{focus:Y.Nothing},pendingShouldSort:!0}},6:(s,t)=>{let n=s.items,a=[],r=new Set(t.items);for(let[i,o]of n.entries())if(r.has(o.id)&&(a.push(i),r.delete(o.id),r.size===0))break;if(a.length>0){n=n.slice();for(let i of a.reverse())n.splice(i,1)}return{...s,items:n,activationTrigger:1}},7:(s,t)=>s.buttonElement===t.element?s:{...s,buttonElement:t.element},8:(s,t)=>s.itemsElement===t.element?s:{...s,itemsElement:t.element},9:s=>s.pendingShouldSort?{...s,...Os(s),pendingShouldSort:!1}:s,10(s){return s.buttonPositionState.kind!=="Tracked"?s:{...s,buttonPositionState:rt.Moved}}};class Lt extends Ba{constructor(t){super(t),Fs(this,"actions",{registerItem:js(()=>{let n=[],a=new Set;return[(r,i)=>{a.has(i)||(a.add(i),n.push({id:r,dataRef:i}))},()=>(a.clear(),this.send({type:5,items:n.splice(0)}))]}),unregisterItem:js(()=>{let n=[];return[a=>n.push(a),()=>this.send({type:6,items:n.splice(0)})]})}),Fs(this,"selectors",{activeDescendantId(n){var a;let r=n.activeItemIndex,i=n.items;return r===null||(a=i[r])==null?void 0:a.id},isActive(n,a){var r;let i=n.activeItemIndex,o=n.items;return i!==null?((r=o[i])==null?void 0:r.id)===a:!1},shouldScrollIntoView(n,a){return n.__demoMode||n.menuState!==0||n.activationTrigger===0?!1:this.isActive(n,a)},didButtonMove(n){return n.buttonPositionState.kind==="Moved"}}),this.on(5,()=>{this.disposables.requestAnimationFrame(()=>{this.send({type:9})})});{let n=this.state.id,a=dn.get(null);this.disposables.add(a.on(Wa.Push,r=>{!a.selectors.isTop(r,n)&&this.state.menuState===0&&this.send({type:1})})),this.on(0,()=>a.actions.push(n)),this.on(1,()=>a.actions.pop(n))}this.disposables.group(n=>{this.on(1,a=>{a.buttonElement&&(n.dispose(),n.add(jl(a.buttonElement,a.buttonPositionState,()=>{this.send({type:10})})))})})}static new({id:t,__demoMode:n=!1}){return new Lt({id:t,__demoMode:n,menuState:n?0:1,buttonElement:null,itemsElement:null,items:[],searchQuery:"",activeItemIndex:null,activationTrigger:1,pendingShouldSort:!1,pendingFocus:{focus:Y.Nothing},buttonPositionState:rt.Idle})}reduce(t,n){return Tt(n.type,Kl,t,n)}}const Mn=l.createContext(null);function zt(s){let t=l.useContext(Mn);if(t===null){let n=new Error(`<${s} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Rn),n}return t}function Rn({id:s,__demoMode:t=!1}){let n=l.useMemo(()=>Lt.new({id:s,__demoMode:t}),[]);return Ua(()=>n.dispose()),n}let ql=l.Fragment;function Vl(s,t){let n=l.useId(),{__demoMode:a=!1,...r}=s,i=Rn({id:n,__demoMode:a}),[o,u,d]=ge(i,k=>[k.menuState,k.itemsElement,k.buttonElement]),f=_e(t),c=dn.get(null),x=ge(c,l.useCallback(k=>c.selectors.isTop(k,n),[c,n]));nr(x,[d,u],(k,h)=>{var w;i.send({type:V.CloseMenu}),ar(h,rr.Loose)||(k.preventDefault(),(w=i.state.buttonElement)==null||w.focus())});let y=ee(()=>{i.send({type:V.CloseMenu})}),g=Me({open:o===ne.Open,close:y}),m={ref:f},j=be();return le.createElement(vl,null,le.createElement(Mn.Provider,{value:i},le.createElement(lr,{value:Tt(o,{[ne.Open]:ot.Open,[ne.Closed]:ot.Closed})},j({ourProps:m,theirProps:r,slot:g,defaultTag:ql,name:"Menu"}))))}let Jl="button";function Ql(s,t){let n=zt("Menu.Button"),a=l.useId(),{id:r=`headlessui-menu-button-${a}`,disabled:i=!1,autoFocus:o=!1,...u}=s,d=l.useRef(null),f=xl(),c=_e(t,d,hl(),ee(N=>n.send({type:V.SetButtonElement,element:N}))),x=ee(N=>{switch(N.key){case Q.Space:case Q.Enter:case Q.ArrowDown:N.preventDefault(),N.stopPropagation(),n.send({type:V.OpenMenu,focus:{focus:Y.First}});break;case Q.ArrowUp:N.preventDefault(),N.stopPropagation(),n.send({type:V.OpenMenu,focus:{focus:Y.Last}});break}}),y=ee(N=>{switch(N.key){case Q.Space:N.preventDefault();break}}),[g,m,j]=ge(n,N=>[N.menuState,N.buttonElement,N.itemsElement]),k=g===ne.Open;wl(k,{trigger:m,action:l.useCallback(N=>{if(m!=null&&m.contains(N.target))return nt.Ignore;let _=N.target.closest('[role="menuitem"]:not([data-disabled])');return Ga(_)?nt.Select(_):j!=null&&j.contains(N.target)?nt.Ignore:nt.Close},[m,j]),close:l.useCallback(()=>n.send({type:V.CloseMenu}),[]),select:l.useCallback(N=>N.click(),[])});let h=kl(N=>{var _;i||(g===ne.Open?(Mt.flushSync(()=>n.send({type:V.CloseMenu})),(_=d.current)==null||_.focus({preventScroll:!0})):(N.preventDefault(),n.send({type:V.OpenMenu,focus:{focus:Y.Nothing},trigger:dt.Pointer})))}),{isFocusVisible:w,focusProps:I}=$t({autoFocus:o}),{isHovered:R,hoverProps:v}=At({isDisabled:i}),{pressed:S,pressProps:T}=Ka({disabled:i}),M=Me({open:g===ne.Open,active:S||g===ne.Open,disabled:i,hover:R,focus:w,autofocus:o}),p=mt(f(),{ref:c,id:r,type:qa(s,d.current),"aria-haspopup":"menu","aria-controls":j==null?void 0:j.id,"aria-expanded":g===ne.Open,disabled:i||void 0,autoFocus:o,onKeyDown:x,onKeyUp:y},h,I,v,T);return be()({ourProps:p,theirProps:u,slot:M,defaultTag:Jl,name:"Menu.Button"})}let Xl="div",Yl=ws.RenderStrategy|ws.Static;function Zl(s,t){let n=l.useId(),{id:a=`headlessui-menu-items-${n}`,anchor:r,portal:i=!1,modal:o=!0,transition:u=!1,...d}=s,f=fl(r),c=zt("Menu.Items"),[x,y]=gl(f),g=yl(),[m,j]=l.useState(null),k=_e(t,f?x:null,ee(F=>c.send({type:V.SetItemsElement,element:F})),j),[h,w]=ge(c,F=>[F.menuState,F.buttonElement]),I=Ns(w),R=Ns(m);f&&(i=!0);let v=Va(),[S,T]=Ja(u,m,v!==null?(v&ot.Open)===ot.Open:h===ne.Open);Qa(S,w,()=>{c.send({type:V.CloseMenu})});let M=ge(c,F=>F.__demoMode),p=M?!1:o&&h===ne.Open;Xa(p,R);let N=M?!1:o&&h===ne.Open;Ya(N,{allowed:l.useCallback(()=>[w,m],[w,m])});let _=ge(c,c.selectors.didButtonMove)?!1:S;l.useEffect(()=>{let F=m;F&&h===ne.Open&&(at(F)||F.focus({preventScroll:!0}))},[h,m]),_l(h===ne.Open,{container:m,accept(F){return F.getAttribute("role")==="menuitem"?NodeFilter.FILTER_REJECT:F.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(F){F.setAttribute("role","none")}});let b=Za(),L=ee(F=>{var q,X,H;switch(b.dispose(),F.key){case Q.Space:if(c.state.searchQuery!=="")return F.preventDefault(),F.stopPropagation(),c.send({type:V.Search,value:F.key});case Q.Enter:if(F.preventDefault(),F.stopPropagation(),c.state.activeItemIndex!==null){let{dataRef:A}=c.state.items[c.state.activeItemIndex];(X=(q=A.current)==null?void 0:q.domRef.current)==null||X.click()}c.send({type:V.CloseMenu}),mn(c.state.buttonElement);break;case Q.ArrowDown:return F.preventDefault(),F.stopPropagation(),c.send({type:V.GoToItem,focus:Y.Next});case Q.ArrowUp:return F.preventDefault(),F.stopPropagation(),c.send({type:V.GoToItem,focus:Y.Previous});case Q.Home:case Q.PageUp:return F.preventDefault(),F.stopPropagation(),c.send({type:V.GoToItem,focus:Y.First});case Q.End:case Q.PageDown:return F.preventDefault(),F.stopPropagation(),c.send({type:V.GoToItem,focus:Y.Last});case Q.Escape:F.preventDefault(),F.stopPropagation(),Mt.flushSync(()=>c.send({type:V.CloseMenu})),(H=c.state.buttonElement)==null||H.focus({preventScroll:!0});break;case Q.Tab:F.preventDefault(),F.stopPropagation(),Mt.flushSync(()=>c.send({type:V.CloseMenu})),er(c.state.buttonElement,F.shiftKey?De.Previous:De.Next);break;default:F.key.length===1&&(c.send({type:V.Search,value:F.key}),b.setTimeout(()=>c.send({type:V.ClearSearch}),350));break}}),C=ee(F=>{switch(F.key){case Q.Space:F.preventDefault();break}}),D=Me({open:h===ne.Open}),$=mt(f?g():{},{"aria-activedescendant":ge(c,c.selectors.activeDescendantId),"aria-labelledby":ge(c,F=>{var q;return(q=F.buttonElement)==null?void 0:q.id}),id:a,onKeyDown:L,onKeyUp:C,role:"menu",tabIndex:h===ne.Open?0:void 0,ref:k,style:{...d.style,...y,"--button-width":bl(S,w,!0).width},...tr(T)}),G=be();return le.createElement(sr,{enabled:i?s.static||S:!1,ownerDocument:I},G({ourProps:$,theirProps:d,slot:D,defaultTag:Xl,features:Yl,visible:_,name:"Menu.Items"}))}let ei=l.Fragment;function ti(s,t){let n=l.useId(),{id:a=`headlessui-menu-item-${n}`,disabled:r=!1,...i}=s,o=zt("Menu.Item"),u=ge(o,_=>o.selectors.isActive(_,a)),d=l.useRef(null),f=_e(t,d),c=ge(o,_=>o.selectors.shouldScrollIntoView(_,a));Le(()=>{if(c)return or().requestAnimationFrame(()=>{var _,b;(b=(_=d.current)==null?void 0:_.scrollIntoView)==null||b.call(_,{block:"nearest"})})},[c,d]);let x=Il(d),y=l.useRef({disabled:r,domRef:d,get textValue(){return x()}});Le(()=>{y.current.disabled=r},[y,r]),Le(()=>(o.actions.registerItem(a,y),()=>o.actions.unregisterItem(a)),[y,a]);let g=ee(()=>{o.send({type:V.CloseMenu})}),m=ee(_=>{if(r)return _.preventDefault();o.send({type:V.CloseMenu}),mn(o.state.buttonElement)}),j=ee(()=>{if(r)return o.send({type:V.GoToItem,focus:Y.Nothing});o.send({type:V.GoToItem,focus:Y.Specific,id:a})}),k=Cl(),h=ee(_=>k.update(_)),w=ee(_=>{k.wasMoved(_)&&(r||u||o.send({type:V.GoToItem,focus:Y.Specific,id:a,trigger:dt.Pointer}))}),I=ee(_=>{k.wasMoved(_)&&(r||u&&o.state.activationTrigger===dt.Pointer&&o.send({type:V.GoToItem,focus:Y.Nothing}))}),[R,v]=pt(),[S,T]=Ft(),M=Me({active:u,focus:u,disabled:r,close:g}),p={id:a,ref:f,role:"menuitem",tabIndex:r===!0?void 0:-1,"aria-disabled":r===!0?!0:void 0,"aria-labelledby":R,"aria-describedby":S,disabled:void 0,onClick:m,onFocus:j,onPointerEnter:h,onMouseEnter:h,onPointerMove:w,onMouseMove:w,onPointerLeave:I,onMouseLeave:I},N=be();return le.createElement(v,null,le.createElement(T,null,N({ourProps:p,theirProps:i,slot:M,defaultTag:ei,name:"Menu.Item"})))}let si="div";function ni(s,t){let[n,a]=pt(),r=s,i={ref:t,"aria-labelledby":n,role:"group"},o=be();return le.createElement(a,null,o({ourProps:i,theirProps:r,slot:{},defaultTag:si,name:"Menu.Section"}))}let ai="header";function ri(s,t){let n=l.useId(),{id:a=`headlessui-menu-heading-${n}`,...r}=s,i=ir();Le(()=>i.register(a),[a,i.register]);let o={id:a,ref:t,role:"presentation",...i.props};return be()({ourProps:o,theirProps:r,slot:{},defaultTag:ai,name:"Menu.Heading"})}let li="div";function ii(s,t){let n=s,a={ref:t,role:"separator"};return be()({ourProps:a,theirProps:n,slot:{},defaultTag:li,name:"Menu.Separator"})}let oi=ye(Vl),En=ye(Ql),Pn=ye(Zl),Et=ye(ti),ci=ye(ni),di=ye(ri),Tn=ye(ii),ui=Object.assign(oi,{Button:En,Items:Pn,Item:Et,Section:ci,Heading:di,Separator:Tn});var mi=(s=>(s[s.RegisterOption=0]="RegisterOption",s[s.UnregisterOption=1]="UnregisterOption",s))(mi||{});let pi={0(s,t){let n=[...s.options,{id:t.id,element:t.element,propsRef:t.propsRef}];return{...s,options:un(n,a=>a.element.current)}},1(s,t){let n=s.options.slice(),a=s.options.findIndex(r=>r.id===t.id);return a===-1?s:(n.splice(a,1),{...s,options:n})}},Ht=l.createContext(null);Ht.displayName="RadioGroupDataContext";function Bt(s){let t=l.useContext(Ht);if(t===null){let n=new Error(`<${s} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Bt),n}return t}let Wt=l.createContext(null);Wt.displayName="RadioGroupActionsContext";function Ut(s){let t=l.useContext(Wt);if(t===null){let n=new Error(`<${s} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Ut),n}return t}function xi(s,t){return Tt(t.type,pi,s,t)}let hi="div";function fi(s,t){let n=l.useId(),a=pn(),{id:r=`headlessui-radiogroup-${n}`,value:i,form:o,name:u,onChange:d,by:f,disabled:c=a||!1,defaultValue:x,tabIndex:y=0,...g}=s,m=Sl(f),[j,k]=l.useReducer(xi,{options:[]}),h=j.options,[w,I]=pt(),[R,v]=Ft(),S=l.useRef(null),T=_e(S,t),M=cr(x),[p,N]=dr(i,d,M),_=l.useMemo(()=>h.find(A=>!A.propsRef.current.disabled),[h]),b=l.useMemo(()=>h.some(A=>m(A.propsRef.current.value,p)),[h,p]),L=ee(A=>{var z;if(c||m(A,p))return!1;let O=(z=h.find(W=>m(W.propsRef.current.value,A)))==null?void 0:z.propsRef.current;return O!=null&&O.disabled?!1:(N==null||N(A),!0)}),C=ee(A=>{if(!S.current)return;let z=h.filter(O=>O.propsRef.current.disabled===!1).map(O=>O.element.current);switch(A.key){case Q.Enter:ur(A.currentTarget);break;case Q.ArrowLeft:case Q.ArrowUp:if(A.preventDefault(),A.stopPropagation(),ks(z,De.Previous|De.WrapAround)===Cs.Success){let O=h.find(W=>at(W.element.current));O&&L(O.propsRef.current.value)}break;case Q.ArrowRight:case Q.ArrowDown:if(A.preventDefault(),A.stopPropagation(),ks(z,De.Next|De.WrapAround)===Cs.Success){let O=h.find(W=>at(W.element.current));O&&L(O.propsRef.current.value)}break;case Q.Space:{A.preventDefault(),A.stopPropagation();let O=h.find(W=>at(W.element.current));O&&L(O.propsRef.current.value)}break}}),D=ee(A=>(k({type:0,...A}),()=>k({type:1,id:A.id}))),$=l.useMemo(()=>({value:p,firstOption:_,containsCheckedOption:b,disabled:c,compare:m,tabIndex:y,...j}),[p,_,b,c,m,y,j]),G=l.useMemo(()=>({registerOption:D,change:L}),[D,L]),F={ref:T,id:r,role:"radiogroup","aria-labelledby":w,"aria-describedby":R,onKeyDown:C},q=Me({value:p}),X=l.useCallback(()=>{if(M!==void 0)return L(M)},[L,M]),H=be();return le.createElement(v,{name:"RadioGroup.Description"},le.createElement(I,{name:"RadioGroup.Label"},le.createElement(Wt.Provider,{value:G},le.createElement(Ht.Provider,{value:$},u!=null&&le.createElement(mr,{disabled:c,data:{[u]:p||"on"},overrides:{type:"radio",checked:p!=null},form:o,onReset:X}),H({ourProps:F,theirProps:g,slot:q,defaultTag:hi,name:"RadioGroup"})))))}let gi="div";function yi(s,t){var n;let a=Bt("RadioGroup.Option"),r=Ut("RadioGroup.Option"),i=l.useId(),{id:o=`headlessui-radiogroup-option-${i}`,value:u,disabled:d=a.disabled||!1,autoFocus:f=!1,...c}=s,x=l.useRef(null),y=_e(x,t),[g,m]=pt(),[j,k]=Ft(),h=xn({value:u,disabled:d});Le(()=>r.registerOption({id:o,element:x,propsRef:h}),[o,r,x,h]);let w=ee(b=>{var L;if(hn(b.currentTarget))return b.preventDefault();r.change(u)&&((L=x.current)==null||L.focus())}),I=((n=a.firstOption)==null?void 0:n.id)===o,{isFocusVisible:R,focusProps:v}=$t({autoFocus:f}),{isHovered:S,hoverProps:T}=At({isDisabled:d}),M=a.compare(a.value,u),p=mt({ref:y,id:o,role:"radio","aria-checked":M?"true":"false","aria-labelledby":g,"aria-describedby":j,"aria-disabled":d?!0:void 0,tabIndex:d?-1:M||!a.containsCheckedOption&&I?a.tabIndex:-1,onClick:d?void 0:w,autoFocus:f},v,T),N=Me({checked:M,disabled:d,active:R,hover:S,focus:R,autofocus:f}),_=be();return le.createElement(k,{name:"RadioGroup.Description"},le.createElement(m,{name:"RadioGroup.Label"},_({ourProps:p,theirProps:c,slot:N,defaultTag:gi,name:"RadioGroup.Option"})))}let bi="span";function vi(s,t){var n;let a=Bt("Radio"),r=Ut("Radio"),i=l.useId(),o=pr(),u=pn(),{id:d=o||`headlessui-radio-${i}`,value:f,disabled:c=a.disabled||u||!1,autoFocus:x=!1,...y}=s,g=l.useRef(null),m=_e(g,t),j=xr(),k=hr(),h=xn({value:f,disabled:c});Le(()=>r.registerOption({id:d,element:g,propsRef:h}),[d,r,g,h]);let w=ee(_=>{var b;if(hn(_.currentTarget))return _.preventDefault();r.change(f)&&((b=g.current)==null||b.focus())}),{isFocusVisible:I,focusProps:R}=$t({autoFocus:x}),{isHovered:v,hoverProps:S}=At({isDisabled:c}),T=((n=a.firstOption)==null?void 0:n.id)===d,M=a.compare(a.value,f),p=mt({ref:m,id:d,role:"radio","aria-checked":M?"true":"false","aria-labelledby":j,"aria-describedby":k,"aria-disabled":c?!0:void 0,tabIndex:c?-1:M||!a.containsCheckedOption&&T?a.tabIndex:-1,autoFocus:x,onClick:c?void 0:w},R,S),N=Me({checked:M,disabled:c,hover:v,focus:I,autofocus:x});return be()({ourProps:p,theirProps:y,slot:N,defaultTag:bi,name:"Radio"})}let ji=ye(fi),Ni=ye(yi),jt=ye(vi),wi=Ye,ki=xt,Ci=Object.assign(ji,{Option:Ni,Radio:jt,Label:wi,Description:ki});/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CompanionPathMap-CPxxakse.js","assets/index-D33fcA3L.js","assets/usePipelineStore-DDHEHTlZ.js","assets/node-types-BoqnL0Eg.js","assets/useReplayTick-BbXJoz75.js","assets/payload-detail-DbnSd5NL.js","assets/car-CeuvJE3C.js","assets/map-pin-off-V0MBukP5.js","assets/index-7uzBcJ1E.css","assets/maplibre-gl-B1CfjdFi.css","assets/CompanionEchoMap-ui9UBOvI.js"])))=>i.map(i=>d[i]); +import{aY as Ba,fB as js,a_ as dn,a$ as Wa,aZ as Tt,b0 as un,r as l,b1 as Ua,b2 as ye,b5 as _e,aU as ee,b9 as Q,b6 as ge,bj as Ga,ba as Mt,be as $t,bf as At,bk as Ka,bg as Me,bh as mt,bl as qa,bi as be,bm as Ns,bn as Va,bo as Ja,bp as ot,bq as Qa,br as Xa,bs as Ya,aX as at,b7 as Za,fD as er,d8 as De,fE as mn,bu as tr,bv as le,bw as sr,bD as nr,dl as ar,dm as rr,bF as lr,fF as ir,bt as Le,bE as pt,by as or,fG as Ft,bH as ws,fH as xt,b3 as Ye,bA as pn,bB as cr,bC as dr,d6 as ks,d9 as Cs,fC as ur,bG as mr,b4 as pr,bc as xr,bd as hr,bx as xn,d4 as hn,e as ae,j as e,c as E,a0 as Ne,fI as fr,t as gr,c_ as ue,fJ as re,cF as je,ct as ht,aa as Ke,bN as ft,f2 as Re,f3 as Ee,f4 as Pe,d as ve,fK as yr,fL as br,m as me,fM as vr,cU as ct,aC as Ce,aL as Te,aE as qe,aD as Se,a2 as ce,bZ as Ve,eJ as $e,B as U,fN as jr,fO as gt,au as Nr,Q as wr,fP as Ss,_ as fn,cb as kr,V as ze,fQ as Cr,dz as Sr,fR as Ot,fS as Ir,fT as _r,bJ as Rt,fU as Mr,fV as Rr,fW as Er,dK as Pr,a1 as Dt,ef as Tr,fX as $r,fY as Ar,fZ as gn,f_ as Fr,a8 as Or,f$ as Dr,g0 as yn,fq as Lr,g1 as zr,g2 as Hr,I as fe,C as Is,g3 as bn,g4 as Br,g5 as Wr,g6 as Ur,g7 as Gr,g8 as Kr,g9 as qr,ga as Vr,gb as Jr,gc as Qr,gd as Xr,a6 as Yr,ge as Zr,gf as el,gg as tl,gh as sl,gi as nl,gj as al,gk as rl,gl as ll,gm as il,gn as ol,eE as cl}from"./index-D33fcA3L.js";import{P as _s,a as Ms,B as Rs,C as Es}from"./PageLayout-CRN-E5xi.js";import{e as yt,g as bt,a as vt,f as dl,b as ul}from"./chat-utils-DIy1-SG1.js";import{c as Ps,S as ml,a as pl}from"./SignalIndicator-DmWlnzMv.js";import{b as xl,F as hl,y as fl,R as gl,T as yl,w as bl,A as vl,M as vn}from"./map-pin-B_Rx-xpd.js";import{p as jl,a as rt,c as Y,f as st,b as Nl,L as wl,S as nt,s as kl,u as Cl,d as Sl}from"./element-movement-BL6huHzq.js";import{s as Il}from"./use-text-value-iYUkduzo.js";import{F as _l}from"./use-tree-walker-DjLWwhV9.js";import{a as lt}from"./index-DuiHY5wq.js";import{S as Ts}from"./search-DN8guzpX.js";import{S as Ml}from"./share-2-BAsDxZE2.js";import{R as Je,L as Rl}from"./route-5o9tQENO.js";import{R as jn}from"./rotate-ccw-B3SnN1wY.js";import{T as Qe}from"./trash-2-CUY4NG5t.js";import{H as He}from"./hash-Ba9bZo8v.js";import{C as El}from"./check-check-C-QgFmon.js";import{P as Xe}from"./plus-C0dCjBh9.js";import{S as Pl,C as Tl}from"./ChatBubble-BqRoJxSW.js";import{p as $l}from"./payload-detail-DbnSd5NL.js";import{A as Al}from"./arrow-down-BI9NpupK.js";import{C as Fl}from"./chevron-right-D4kUPDBw.js";import{C as Nn}from"./circle-alert-BgZmhbSe.js";import{f as Ol,c as Dl,a as Ll,M as zl}from"./variants-ByRhxIcL.js";import{C as wn}from"./clock-D_m2QiHa.js";import{A as kn}from"./activity-D6ySIfuC.js";import{T as Cn}from"./thermometer-A8kLkazp.js";import{S as Hl}from"./shield-check-DOoXovft.js";import{W as $s}from"./wand-sparkles-CEbXzjVw.js";import{C as Bl}from"./compass-CncUthiD.js";import{G as As}from"./git-branch-Ryinnbc1.js";import{F as ie,L as oe,D as Ie}from"./fieldset-DsbEWHIy.js";import{C as Sn}from"./ConfirmModal-J2_Sxirm.js";import{K as In}from"./key-round-n5zCigFv.js";import{F as _n,P as Wl}from"./pencil-Cg0kSr82.js";var Ul=Object.defineProperty,Gl=(s,t,n)=>t in s?Ul(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n,Fs=(s,t,n)=>(Gl(s,typeof t!="symbol"?t+"":t,n),n),ne=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(ne||{}),dt=(s=>(s[s.Pointer=0]="Pointer",s[s.Other=1]="Other",s))(dt||{}),V=(s=>(s[s.OpenMenu=0]="OpenMenu",s[s.CloseMenu=1]="CloseMenu",s[s.GoToItem=2]="GoToItem",s[s.Search=3]="Search",s[s.ClearSearch=4]="ClearSearch",s[s.RegisterItems=5]="RegisterItems",s[s.UnregisterItems=6]="UnregisterItems",s[s.SetButtonElement=7]="SetButtonElement",s[s.SetItemsElement=8]="SetItemsElement",s[s.SortItems=9]="SortItems",s[s.MarkButtonAsMoved=10]="MarkButtonAsMoved",s))(V||{});function Os(s,t=n=>n){let n=s.activeItemIndex!==null?s.items[s.activeItemIndex]:null,a=un(t(s.items.slice()),i=>i.dataRef.current.domRef.current),r=n?a.indexOf(n):null;return r===-1&&(r=null),{items:a,activeItemIndex:r}}let Kl={1(s){if(s.menuState===1)return s;let t=s.buttonElement?rt.Tracked(Nl(s.buttonElement)):s.buttonPositionState;return{...s,activeItemIndex:null,pendingFocus:{focus:Y.Nothing},menuState:1,buttonPositionState:t}},0(s,t){return s.menuState===0?s:{...s,__demoMode:!1,pendingFocus:t.focus,menuState:0,buttonPositionState:rt.Idle}},2:(s,t)=>{var n,a,r,i,o;if(s.menuState===1)return s;let u={...s,searchQuery:"",activationTrigger:(n=t.trigger)!=null?n:1,__demoMode:!1};if(t.focus===Y.Nothing)return{...u,activeItemIndex:null};if(t.focus===Y.Specific)return{...u,activeItemIndex:s.items.findIndex(c=>c.id===t.id)};if(t.focus===Y.Previous){let c=s.activeItemIndex;if(c!==null){let x=s.items[c].dataRef.current.domRef,y=st(t,{resolveItems:()=>s.items,resolveActiveIndex:()=>s.activeItemIndex,resolveId:g=>g.id,resolveDisabled:g=>g.dataRef.current.disabled});if(y!==null){let g=s.items[y].dataRef.current.domRef;if(((a=x.current)==null?void 0:a.previousElementSibling)===g.current||((r=g.current)==null?void 0:r.previousElementSibling)===null)return{...u,activeItemIndex:y}}}}else if(t.focus===Y.Next){let c=s.activeItemIndex;if(c!==null){let x=s.items[c].dataRef.current.domRef,y=st(t,{resolveItems:()=>s.items,resolveActiveIndex:()=>s.activeItemIndex,resolveId:g=>g.id,resolveDisabled:g=>g.dataRef.current.disabled});if(y!==null){let g=s.items[y].dataRef.current.domRef;if(((i=x.current)==null?void 0:i.nextElementSibling)===g.current||((o=g.current)==null?void 0:o.nextElementSibling)===null)return{...u,activeItemIndex:y}}}}let d=Os(s),f=st(t,{resolveItems:()=>d.items,resolveActiveIndex:()=>d.activeItemIndex,resolveId:c=>c.id,resolveDisabled:c=>c.dataRef.current.disabled});return{...u,...d,activeItemIndex:f}},3:(s,t)=>{let n=s.searchQuery!==""?0:1,a=s.searchQuery+t.value.toLowerCase(),r=(s.activeItemIndex!==null?s.items.slice(s.activeItemIndex+n).concat(s.items.slice(0,s.activeItemIndex+n)):s.items).find(o=>{var u;return((u=o.dataRef.current.textValue)==null?void 0:u.startsWith(a))&&!o.dataRef.current.disabled}),i=r?s.items.indexOf(r):-1;return i===-1||i===s.activeItemIndex?{...s,searchQuery:a}:{...s,searchQuery:a,activeItemIndex:i,activationTrigger:1}},4(s){return s.searchQuery===""?s:{...s,searchQuery:"",searchActiveItemIndex:null}},5:(s,t)=>{let n=s.items.concat(t.items.map(r=>r)),a=s.activeItemIndex;return s.pendingFocus.focus!==Y.Nothing&&(a=st(s.pendingFocus,{resolveItems:()=>n,resolveActiveIndex:()=>s.activeItemIndex,resolveId:r=>r.id,resolveDisabled:r=>r.dataRef.current.disabled})),{...s,items:n,activeItemIndex:a,pendingFocus:{focus:Y.Nothing},pendingShouldSort:!0}},6:(s,t)=>{let n=s.items,a=[],r=new Set(t.items);for(let[i,o]of n.entries())if(r.has(o.id)&&(a.push(i),r.delete(o.id),r.size===0))break;if(a.length>0){n=n.slice();for(let i of a.reverse())n.splice(i,1)}return{...s,items:n,activationTrigger:1}},7:(s,t)=>s.buttonElement===t.element?s:{...s,buttonElement:t.element},8:(s,t)=>s.itemsElement===t.element?s:{...s,itemsElement:t.element},9:s=>s.pendingShouldSort?{...s,...Os(s),pendingShouldSort:!1}:s,10(s){return s.buttonPositionState.kind!=="Tracked"?s:{...s,buttonPositionState:rt.Moved}}};class Lt extends Ba{constructor(t){super(t),Fs(this,"actions",{registerItem:js(()=>{let n=[],a=new Set;return[(r,i)=>{a.has(i)||(a.add(i),n.push({id:r,dataRef:i}))},()=>(a.clear(),this.send({type:5,items:n.splice(0)}))]}),unregisterItem:js(()=>{let n=[];return[a=>n.push(a),()=>this.send({type:6,items:n.splice(0)})]})}),Fs(this,"selectors",{activeDescendantId(n){var a;let r=n.activeItemIndex,i=n.items;return r===null||(a=i[r])==null?void 0:a.id},isActive(n,a){var r;let i=n.activeItemIndex,o=n.items;return i!==null?((r=o[i])==null?void 0:r.id)===a:!1},shouldScrollIntoView(n,a){return n.__demoMode||n.menuState!==0||n.activationTrigger===0?!1:this.isActive(n,a)},didButtonMove(n){return n.buttonPositionState.kind==="Moved"}}),this.on(5,()=>{this.disposables.requestAnimationFrame(()=>{this.send({type:9})})});{let n=this.state.id,a=dn.get(null);this.disposables.add(a.on(Wa.Push,r=>{!a.selectors.isTop(r,n)&&this.state.menuState===0&&this.send({type:1})})),this.on(0,()=>a.actions.push(n)),this.on(1,()=>a.actions.pop(n))}this.disposables.group(n=>{this.on(1,a=>{a.buttonElement&&(n.dispose(),n.add(jl(a.buttonElement,a.buttonPositionState,()=>{this.send({type:10})})))})})}static new({id:t,__demoMode:n=!1}){return new Lt({id:t,__demoMode:n,menuState:n?0:1,buttonElement:null,itemsElement:null,items:[],searchQuery:"",activeItemIndex:null,activationTrigger:1,pendingShouldSort:!1,pendingFocus:{focus:Y.Nothing},buttonPositionState:rt.Idle})}reduce(t,n){return Tt(n.type,Kl,t,n)}}const Mn=l.createContext(null);function zt(s){let t=l.useContext(Mn);if(t===null){let n=new Error(`<${s} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Rn),n}return t}function Rn({id:s,__demoMode:t=!1}){let n=l.useMemo(()=>Lt.new({id:s,__demoMode:t}),[]);return Ua(()=>n.dispose()),n}let ql=l.Fragment;function Vl(s,t){let n=l.useId(),{__demoMode:a=!1,...r}=s,i=Rn({id:n,__demoMode:a}),[o,u,d]=ge(i,k=>[k.menuState,k.itemsElement,k.buttonElement]),f=_e(t),c=dn.get(null),x=ge(c,l.useCallback(k=>c.selectors.isTop(k,n),[c,n]));nr(x,[d,u],(k,h)=>{var w;i.send({type:V.CloseMenu}),ar(h,rr.Loose)||(k.preventDefault(),(w=i.state.buttonElement)==null||w.focus())});let y=ee(()=>{i.send({type:V.CloseMenu})}),g=Me({open:o===ne.Open,close:y}),m={ref:f},j=be();return le.createElement(vl,null,le.createElement(Mn.Provider,{value:i},le.createElement(lr,{value:Tt(o,{[ne.Open]:ot.Open,[ne.Closed]:ot.Closed})},j({ourProps:m,theirProps:r,slot:g,defaultTag:ql,name:"Menu"}))))}let Jl="button";function Ql(s,t){let n=zt("Menu.Button"),a=l.useId(),{id:r=`headlessui-menu-button-${a}`,disabled:i=!1,autoFocus:o=!1,...u}=s,d=l.useRef(null),f=xl(),c=_e(t,d,hl(),ee(N=>n.send({type:V.SetButtonElement,element:N}))),x=ee(N=>{switch(N.key){case Q.Space:case Q.Enter:case Q.ArrowDown:N.preventDefault(),N.stopPropagation(),n.send({type:V.OpenMenu,focus:{focus:Y.First}});break;case Q.ArrowUp:N.preventDefault(),N.stopPropagation(),n.send({type:V.OpenMenu,focus:{focus:Y.Last}});break}}),y=ee(N=>{switch(N.key){case Q.Space:N.preventDefault();break}}),[g,m,j]=ge(n,N=>[N.menuState,N.buttonElement,N.itemsElement]),k=g===ne.Open;wl(k,{trigger:m,action:l.useCallback(N=>{if(m!=null&&m.contains(N.target))return nt.Ignore;let _=N.target.closest('[role="menuitem"]:not([data-disabled])');return Ga(_)?nt.Select(_):j!=null&&j.contains(N.target)?nt.Ignore:nt.Close},[m,j]),close:l.useCallback(()=>n.send({type:V.CloseMenu}),[]),select:l.useCallback(N=>N.click(),[])});let h=kl(N=>{var _;i||(g===ne.Open?(Mt.flushSync(()=>n.send({type:V.CloseMenu})),(_=d.current)==null||_.focus({preventScroll:!0})):(N.preventDefault(),n.send({type:V.OpenMenu,focus:{focus:Y.Nothing},trigger:dt.Pointer})))}),{isFocusVisible:w,focusProps:I}=$t({autoFocus:o}),{isHovered:R,hoverProps:v}=At({isDisabled:i}),{pressed:S,pressProps:T}=Ka({disabled:i}),M=Me({open:g===ne.Open,active:S||g===ne.Open,disabled:i,hover:R,focus:w,autofocus:o}),p=mt(f(),{ref:c,id:r,type:qa(s,d.current),"aria-haspopup":"menu","aria-controls":j==null?void 0:j.id,"aria-expanded":g===ne.Open,disabled:i||void 0,autoFocus:o,onKeyDown:x,onKeyUp:y},h,I,v,T);return be()({ourProps:p,theirProps:u,slot:M,defaultTag:Jl,name:"Menu.Button"})}let Xl="div",Yl=ws.RenderStrategy|ws.Static;function Zl(s,t){let n=l.useId(),{id:a=`headlessui-menu-items-${n}`,anchor:r,portal:i=!1,modal:o=!0,transition:u=!1,...d}=s,f=fl(r),c=zt("Menu.Items"),[x,y]=gl(f),g=yl(),[m,j]=l.useState(null),k=_e(t,f?x:null,ee(F=>c.send({type:V.SetItemsElement,element:F})),j),[h,w]=ge(c,F=>[F.menuState,F.buttonElement]),I=Ns(w),R=Ns(m);f&&(i=!0);let v=Va(),[S,T]=Ja(u,m,v!==null?(v&ot.Open)===ot.Open:h===ne.Open);Qa(S,w,()=>{c.send({type:V.CloseMenu})});let M=ge(c,F=>F.__demoMode),p=M?!1:o&&h===ne.Open;Xa(p,R);let N=M?!1:o&&h===ne.Open;Ya(N,{allowed:l.useCallback(()=>[w,m],[w,m])});let _=ge(c,c.selectors.didButtonMove)?!1:S;l.useEffect(()=>{let F=m;F&&h===ne.Open&&(at(F)||F.focus({preventScroll:!0}))},[h,m]),_l(h===ne.Open,{container:m,accept(F){return F.getAttribute("role")==="menuitem"?NodeFilter.FILTER_REJECT:F.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(F){F.setAttribute("role","none")}});let b=Za(),L=ee(F=>{var q,X,H;switch(b.dispose(),F.key){case Q.Space:if(c.state.searchQuery!=="")return F.preventDefault(),F.stopPropagation(),c.send({type:V.Search,value:F.key});case Q.Enter:if(F.preventDefault(),F.stopPropagation(),c.state.activeItemIndex!==null){let{dataRef:A}=c.state.items[c.state.activeItemIndex];(X=(q=A.current)==null?void 0:q.domRef.current)==null||X.click()}c.send({type:V.CloseMenu}),mn(c.state.buttonElement);break;case Q.ArrowDown:return F.preventDefault(),F.stopPropagation(),c.send({type:V.GoToItem,focus:Y.Next});case Q.ArrowUp:return F.preventDefault(),F.stopPropagation(),c.send({type:V.GoToItem,focus:Y.Previous});case Q.Home:case Q.PageUp:return F.preventDefault(),F.stopPropagation(),c.send({type:V.GoToItem,focus:Y.First});case Q.End:case Q.PageDown:return F.preventDefault(),F.stopPropagation(),c.send({type:V.GoToItem,focus:Y.Last});case Q.Escape:F.preventDefault(),F.stopPropagation(),Mt.flushSync(()=>c.send({type:V.CloseMenu})),(H=c.state.buttonElement)==null||H.focus({preventScroll:!0});break;case Q.Tab:F.preventDefault(),F.stopPropagation(),Mt.flushSync(()=>c.send({type:V.CloseMenu})),er(c.state.buttonElement,F.shiftKey?De.Previous:De.Next);break;default:F.key.length===1&&(c.send({type:V.Search,value:F.key}),b.setTimeout(()=>c.send({type:V.ClearSearch}),350));break}}),C=ee(F=>{switch(F.key){case Q.Space:F.preventDefault();break}}),D=Me({open:h===ne.Open}),$=mt(f?g():{},{"aria-activedescendant":ge(c,c.selectors.activeDescendantId),"aria-labelledby":ge(c,F=>{var q;return(q=F.buttonElement)==null?void 0:q.id}),id:a,onKeyDown:L,onKeyUp:C,role:"menu",tabIndex:h===ne.Open?0:void 0,ref:k,style:{...d.style,...y,"--button-width":bl(S,w,!0).width},...tr(T)}),G=be();return le.createElement(sr,{enabled:i?s.static||S:!1,ownerDocument:I},G({ourProps:$,theirProps:d,slot:D,defaultTag:Xl,features:Yl,visible:_,name:"Menu.Items"}))}let ei=l.Fragment;function ti(s,t){let n=l.useId(),{id:a=`headlessui-menu-item-${n}`,disabled:r=!1,...i}=s,o=zt("Menu.Item"),u=ge(o,_=>o.selectors.isActive(_,a)),d=l.useRef(null),f=_e(t,d),c=ge(o,_=>o.selectors.shouldScrollIntoView(_,a));Le(()=>{if(c)return or().requestAnimationFrame(()=>{var _,b;(b=(_=d.current)==null?void 0:_.scrollIntoView)==null||b.call(_,{block:"nearest"})})},[c,d]);let x=Il(d),y=l.useRef({disabled:r,domRef:d,get textValue(){return x()}});Le(()=>{y.current.disabled=r},[y,r]),Le(()=>(o.actions.registerItem(a,y),()=>o.actions.unregisterItem(a)),[y,a]);let g=ee(()=>{o.send({type:V.CloseMenu})}),m=ee(_=>{if(r)return _.preventDefault();o.send({type:V.CloseMenu}),mn(o.state.buttonElement)}),j=ee(()=>{if(r)return o.send({type:V.GoToItem,focus:Y.Nothing});o.send({type:V.GoToItem,focus:Y.Specific,id:a})}),k=Cl(),h=ee(_=>k.update(_)),w=ee(_=>{k.wasMoved(_)&&(r||u||o.send({type:V.GoToItem,focus:Y.Specific,id:a,trigger:dt.Pointer}))}),I=ee(_=>{k.wasMoved(_)&&(r||u&&o.state.activationTrigger===dt.Pointer&&o.send({type:V.GoToItem,focus:Y.Nothing}))}),[R,v]=pt(),[S,T]=Ft(),M=Me({active:u,focus:u,disabled:r,close:g}),p={id:a,ref:f,role:"menuitem",tabIndex:r===!0?void 0:-1,"aria-disabled":r===!0?!0:void 0,"aria-labelledby":R,"aria-describedby":S,disabled:void 0,onClick:m,onFocus:j,onPointerEnter:h,onMouseEnter:h,onPointerMove:w,onMouseMove:w,onPointerLeave:I,onMouseLeave:I},N=be();return le.createElement(v,null,le.createElement(T,null,N({ourProps:p,theirProps:i,slot:M,defaultTag:ei,name:"Menu.Item"})))}let si="div";function ni(s,t){let[n,a]=pt(),r=s,i={ref:t,"aria-labelledby":n,role:"group"},o=be();return le.createElement(a,null,o({ourProps:i,theirProps:r,slot:{},defaultTag:si,name:"Menu.Section"}))}let ai="header";function ri(s,t){let n=l.useId(),{id:a=`headlessui-menu-heading-${n}`,...r}=s,i=ir();Le(()=>i.register(a),[a,i.register]);let o={id:a,ref:t,role:"presentation",...i.props};return be()({ourProps:o,theirProps:r,slot:{},defaultTag:ai,name:"Menu.Heading"})}let li="div";function ii(s,t){let n=s,a={ref:t,role:"separator"};return be()({ourProps:a,theirProps:n,slot:{},defaultTag:li,name:"Menu.Separator"})}let oi=ye(Vl),En=ye(Ql),Pn=ye(Zl),Et=ye(ti),ci=ye(ni),di=ye(ri),Tn=ye(ii),ui=Object.assign(oi,{Button:En,Items:Pn,Item:Et,Section:ci,Heading:di,Separator:Tn});var mi=(s=>(s[s.RegisterOption=0]="RegisterOption",s[s.UnregisterOption=1]="UnregisterOption",s))(mi||{});let pi={0(s,t){let n=[...s.options,{id:t.id,element:t.element,propsRef:t.propsRef}];return{...s,options:un(n,a=>a.element.current)}},1(s,t){let n=s.options.slice(),a=s.options.findIndex(r=>r.id===t.id);return a===-1?s:(n.splice(a,1),{...s,options:n})}},Ht=l.createContext(null);Ht.displayName="RadioGroupDataContext";function Bt(s){let t=l.useContext(Ht);if(t===null){let n=new Error(`<${s} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Bt),n}return t}let Wt=l.createContext(null);Wt.displayName="RadioGroupActionsContext";function Ut(s){let t=l.useContext(Wt);if(t===null){let n=new Error(`<${s} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Ut),n}return t}function xi(s,t){return Tt(t.type,pi,s,t)}let hi="div";function fi(s,t){let n=l.useId(),a=pn(),{id:r=`headlessui-radiogroup-${n}`,value:i,form:o,name:u,onChange:d,by:f,disabled:c=a||!1,defaultValue:x,tabIndex:y=0,...g}=s,m=Sl(f),[j,k]=l.useReducer(xi,{options:[]}),h=j.options,[w,I]=pt(),[R,v]=Ft(),S=l.useRef(null),T=_e(S,t),M=cr(x),[p,N]=dr(i,d,M),_=l.useMemo(()=>h.find(A=>!A.propsRef.current.disabled),[h]),b=l.useMemo(()=>h.some(A=>m(A.propsRef.current.value,p)),[h,p]),L=ee(A=>{var z;if(c||m(A,p))return!1;let O=(z=h.find(W=>m(W.propsRef.current.value,A)))==null?void 0:z.propsRef.current;return O!=null&&O.disabled?!1:(N==null||N(A),!0)}),C=ee(A=>{if(!S.current)return;let z=h.filter(O=>O.propsRef.current.disabled===!1).map(O=>O.element.current);switch(A.key){case Q.Enter:ur(A.currentTarget);break;case Q.ArrowLeft:case Q.ArrowUp:if(A.preventDefault(),A.stopPropagation(),ks(z,De.Previous|De.WrapAround)===Cs.Success){let O=h.find(W=>at(W.element.current));O&&L(O.propsRef.current.value)}break;case Q.ArrowRight:case Q.ArrowDown:if(A.preventDefault(),A.stopPropagation(),ks(z,De.Next|De.WrapAround)===Cs.Success){let O=h.find(W=>at(W.element.current));O&&L(O.propsRef.current.value)}break;case Q.Space:{A.preventDefault(),A.stopPropagation();let O=h.find(W=>at(W.element.current));O&&L(O.propsRef.current.value)}break}}),D=ee(A=>(k({type:0,...A}),()=>k({type:1,id:A.id}))),$=l.useMemo(()=>({value:p,firstOption:_,containsCheckedOption:b,disabled:c,compare:m,tabIndex:y,...j}),[p,_,b,c,m,y,j]),G=l.useMemo(()=>({registerOption:D,change:L}),[D,L]),F={ref:T,id:r,role:"radiogroup","aria-labelledby":w,"aria-describedby":R,onKeyDown:C},q=Me({value:p}),X=l.useCallback(()=>{if(M!==void 0)return L(M)},[L,M]),H=be();return le.createElement(v,{name:"RadioGroup.Description"},le.createElement(I,{name:"RadioGroup.Label"},le.createElement(Wt.Provider,{value:G},le.createElement(Ht.Provider,{value:$},u!=null&&le.createElement(mr,{disabled:c,data:{[u]:p||"on"},overrides:{type:"radio",checked:p!=null},form:o,onReset:X}),H({ourProps:F,theirProps:g,slot:q,defaultTag:hi,name:"RadioGroup"})))))}let gi="div";function yi(s,t){var n;let a=Bt("RadioGroup.Option"),r=Ut("RadioGroup.Option"),i=l.useId(),{id:o=`headlessui-radiogroup-option-${i}`,value:u,disabled:d=a.disabled||!1,autoFocus:f=!1,...c}=s,x=l.useRef(null),y=_e(x,t),[g,m]=pt(),[j,k]=Ft(),h=xn({value:u,disabled:d});Le(()=>r.registerOption({id:o,element:x,propsRef:h}),[o,r,x,h]);let w=ee(b=>{var L;if(hn(b.currentTarget))return b.preventDefault();r.change(u)&&((L=x.current)==null||L.focus())}),I=((n=a.firstOption)==null?void 0:n.id)===o,{isFocusVisible:R,focusProps:v}=$t({autoFocus:f}),{isHovered:S,hoverProps:T}=At({isDisabled:d}),M=a.compare(a.value,u),p=mt({ref:y,id:o,role:"radio","aria-checked":M?"true":"false","aria-labelledby":g,"aria-describedby":j,"aria-disabled":d?!0:void 0,tabIndex:d?-1:M||!a.containsCheckedOption&&I?a.tabIndex:-1,onClick:d?void 0:w,autoFocus:f},v,T),N=Me({checked:M,disabled:d,active:R,hover:S,focus:R,autofocus:f}),_=be();return le.createElement(k,{name:"RadioGroup.Description"},le.createElement(m,{name:"RadioGroup.Label"},_({ourProps:p,theirProps:c,slot:N,defaultTag:gi,name:"RadioGroup.Option"})))}let bi="span";function vi(s,t){var n;let a=Bt("Radio"),r=Ut("Radio"),i=l.useId(),o=pr(),u=pn(),{id:d=o||`headlessui-radio-${i}`,value:f,disabled:c=a.disabled||u||!1,autoFocus:x=!1,...y}=s,g=l.useRef(null),m=_e(g,t),j=xr(),k=hr(),h=xn({value:f,disabled:c});Le(()=>r.registerOption({id:d,element:g,propsRef:h}),[d,r,g,h]);let w=ee(_=>{var b;if(hn(_.currentTarget))return _.preventDefault();r.change(f)&&((b=g.current)==null||b.focus())}),{isFocusVisible:I,focusProps:R}=$t({autoFocus:x}),{isHovered:v,hoverProps:S}=At({isDisabled:c}),T=((n=a.firstOption)==null?void 0:n.id)===d,M=a.compare(a.value,f),p=mt({ref:m,id:d,role:"radio","aria-checked":M?"true":"false","aria-labelledby":j,"aria-describedby":k,"aria-disabled":c?!0:void 0,tabIndex:c?-1:M||!a.containsCheckedOption&&T?a.tabIndex:-1,autoFocus:x,onClick:c?void 0:w},R,S),N=Me({checked:M,disabled:c,hover:v,focus:I,autofocus:x});return be()({ourProps:p,theirProps:y,slot:N,defaultTag:bi,name:"Radio"})}let ji=ye(fi),Ni=ye(yi),jt=ye(vi),wi=Ye,ki=xt,Ci=Object.assign(ji,{Option:Ni,Radio:jt,Label:wi,Description:ki});/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -86,6 +86,6 @@ import{aX as Ba,fB as js,aZ as dn,a_ as Wa,aY as Tt,a$ as un,r as l,b0 as Ua,b1 `).map(a=>a.trim()).filter(Boolean);if(t.length<2)return null;const n=[];for(const a of t){const r=a.match(/^(\d{1,2}[AP]M):\s*/i);if(!r)continue;let i=a.slice(r[0].length),o="";for(const g of Nt)if(i.includes(g)){o=g,i=i.replace(g,"").trim();break}if(!o)continue;let u;const d=i.match(/(\d+)%/);d&&(u=parseInt(d[1],10),i=i.replace(d[0],"").trim());const f=i.match(/(-?\d+)°/);if(!f)continue;const c=parseInt(f[1],10),x=i.indexOf(f[0]),y=x>0?i.slice(0,x).trim():"";n.push({hour:r[1].toUpperCase(),conditionEmoji:o,condition:y||"Unknown",temp:c,precipChance:u})}return n.length>=2?n:null}function Gn(s){const t=s.split(` `).map(a=>a.trim()).filter(Boolean);if(t.length===0)return null;const n=[];for(const a of t){const r=a.match(/^([0-9A-Fa-f]{2})\s*→\s*(.+)/);if(!r)continue;const i=r[1].toUpperCase(),o=r[2].trim();if(o==="?")n.push({hex:i,unknown:!0});else if(/^\d+\s*matches?$/i.test(o))n.push({hex:i,matchCount:parseInt(o,10)});else{let u,d=o;d.includes("🎯")?(u="high",d=d.replace("🎯","").trim()):d.includes("📍")?(u="medium",d=d.replace("📍","").trim()):d.includes("❓")&&(u="low",d=d.replace("❓","").trim()),n.push({hex:i,name:d,confidence:u})}}return n.length>=2?{hops:n}:null}const vo=new Set(["🟢","🟡","🟠","🔴","🟣","🟤"]);function Kn(s){let t="";for(const x of vo)if(s.includes(x)){t=x;break}if(!t)return null;const n=s.match(/(?:AQI:?\s*)?\b(\d{1,3})\b\s*\(?(Good|Moderate|USG|Unhealthy|Very Unhealthy|Hazardous)\)?/i)??s.match(new RegExp(`${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*(\\d{1,3})\\s*\\(?(\\w[\\w ]*?)\\)?(?:\\s|$)`));if(!n)return null;const a=parseInt(n[1],10),r=n[2].trim(),i=s.split(` `)[0],o=i.indexOf(t),u=o>2?i.slice(0,o).replace(/:$/,"").trim():void 0,d=[],f=/(PM2\.5|PM10|O3|NO2|CO|SO2):\s*([\d.]+)/gi;let c;for(;(c=f.exec(s))!==null;)d.push({name:c[1].toUpperCase(),value:parseFloat(c[2])});return{location:u,aqi:a,category:r,colorEmoji:t,pollutants:d}}function qn(s){const t=/A[- ]?Index:?\s*\d/i.test(s)||/\bA:\s*\d/i.test(s),n=/K[- ]?Index:?\s*\d/i.test(s)||/\bK:\s*\d/i.test(s);if(!t&&!n)return null;const a=s.match(/A[- ]?Index:?\s*(\d+)/i)??s.match(/\bA:(\d+)/),r=s.match(/K[- ]?Index:?\s*(\d+)/i)??s.match(/\bK:(\d+)/),i=s.match(/Sun(?:spots)?:?\s*(\d+)/i),o=s.match(/(?:Solar\s*)?Flux:?\s*(\d+)/i),u=s.match(/X[- ]?[Rr]ay(?:\s*Flux)?:?\s*([A-Z]\d+\.?\d*)/i)??s.match(/Xray:([A-Z]\d+\.?\d*)/i),d=s.match(/(?:Signal\s*)?Noise:?\s*([A-Z]\d+)/i);return{aIndex:a?parseInt(a[1],10):void 0,kIndex:r?parseInt(r[1],10):void 0,sunspots:i?parseInt(i[1],10):void 0,solarFlux:o?parseInt(o[1],10):void 0,xrayFlux:u==null?void 0:u[1],signalNoise:d==null?void 0:d[1]}}function Vn(s){const t=[],n=/([dn])(\d+m(?:-\d+m)?)=(Good|Fair|Poor|Excellent)/gi;let a;for(;(a=n.exec(s))!==null;)t.push({time:a[1].toLowerCase()==="d"?"day":"night",name:a[2],condition:a[3]});if(t.length>=2)return{bands:t};const r=/([DN]):\s*((?:\d+m(?:-\d+m)?(?:Good|Fair|Poor|Excellent)\s*)+)/gi;let i;for(;(i=r.exec(s))!==null;){const o=i[1].toUpperCase()==="D"?"day":"night",u=/(\d+m(?:-\d+m)?)(Good|Fair|Poor|Excellent)/gi;let d;for(;(d=u.exec(i[2]))!==null;)t.push({time:o,name:d[1],condition:d[2]})}return t.length>=2?{bands:t}:null}function Jn(s){var g,m;const t=/Sun\s*Rise:?/i.test(s),n=/Sun\s*Set:?|\bSet:/i.test(s);if(!/Daylight:/i.test(s)&&!(t&&n))return null;const r=s.match(/(?:Sun\s*)?Rise:?\s*(.+?)(?:\n|$)/i),i=s.match(/(?:Sun\s*)?Set:?\s*(.+?)(?:\n|$)/i),o=s.match(/Daylight:?\s*(\d+)h\s*(\d+)m/i),u=s.match(/Remaining:?\s*(\d+)h\s*(\d+)m/i),d=s.match(/Azimuth:?\s*([\d.]+)/i),f=s.match(/Altitude:?\s*(-?[\d.]+)/i),c=s.search(/Sun\s*Rise/i),x=s.search(/Sun\s*Set/i),y=x>=0&&(c<0||xa.trim()).filter(Boolean),n=[];for(const a of t){let r="";for(const d of No)if(a.startsWith(d)){r=d;break}if(!r)continue;const i=a.slice(r.length).trim(),o=i.match(/^(.+?)\s+(\d+)\s*[-–]\s*(.+?)\s+(\d+)\s*\((.+)\)$/);if(o){const d=o[5].trim(),f=/final/i.test(d),c=!f&&/\d/.test(d);n.push({sportEmoji:r,away:o[1].trim(),home:o[3].trim(),awayScore:parseInt(o[2],10),homeScore:parseInt(o[4],10),status:d,isLive:c,isFinal:f});continue}const u=i.match(/^(.+?)\s*[-–]\s*(.+?)\s*\((.+)\)$/);u&&n.push({sportEmoji:r,away:u[1].trim(),home:u[2].trim(),status:u[3].trim(),isLive:!1,isFinal:!1})}return n.length>=1?{games:n}:null}function ea(s){var f,c,x,y;const t=[],n=/^(\d+)\.\s+(.+?):\s*(\d+)/gm;let a;for(;(a=n.exec(s))!==null;)t.push({rank:parseInt(a[1],10),name:a[2].trim(),value:parseInt(a[3],10)});if(t.length>=2){const g=s.match(/^(.+?)\n/i);return{type:"leaderboard",entries:t,title:(f=g==null?void 0:g[1])==null?void 0:f.replace(/📊\s*/,"").trim()}}const r=s.match(/Cmds?:\s*(\d+)/i),i=s.match(/Replies?:\s*(\d+)/i);if(!r&&!i)return null;const o=s.match(/Top\s*Cmd:\s*(.+?)\s*\(/i),u=s.match(/Top\s*User:\s*(.+?)\s*\(/i),d=s.match(/^(.+?)\n/i);return{type:"basic",commands:r?parseInt(r[1],10):void 0,replies:i?parseInt(i[1],10):void 0,topCommand:(c=o==null?void 0:o[1])==null?void 0:c.trim(),topUser:(x=u==null?void 0:u[1])==null?void 0:x.trim(),title:(y=d==null?void 0:d[1])==null?void 0:y.replace(/📊\s*/,"").trim()}}const wo=new Set(["🐱","🐈","😺","😸","😹","😻","😼","😽","🙀","😿","😾","🐾","👂","🐟","🧶","🥛"]);function ta(s){if(!/\bcats?\b/i.test(s))return null;const t=s.slice(-4);for(const n of wo)if(t.includes(n))return s;return null}const ko=[{type:"dice",test:Dn},{type:"joke",test:Ln},{type:"dadjoke",test:zn},{type:"magic8",test:Hn},{type:"weather-alert",test:Bn},{type:"satpass",test:Xn},{type:"aurora",test:Yn},{type:"moon",test:Qn},{type:"sun",test:Jn},{type:"hfcond",test:Vn},{type:"solar",test:qn},{type:"aqi",test:Kn},{type:"sports",test:Zn},{type:"stats",test:ea},{type:"path",test:Gn},{type:"weather-multiday",test:Wn},{type:"weather-hourly",test:Un},{type:"test",test:On},{type:"weather",test:Fn},{type:"catfact",test:ta}];function sa(s){for(const{type:t,test:n}of ko)if(n(s)!=null)return t;return null}function Co(s,t){switch(t){case"weather":return Fn(s);case"weather-multiday":return Wn(s);case"weather-hourly":return Un(s);case"weather-alert":return Bn(s);case"test":return On(s);case"path":return Gn(s);case"aqi":return Kn(s);case"solar":return qn(s);case"hfcond":return Vn(s);case"sun":return Jn(s);case"moon":return Qn(s);case"satpass":return Xn(s);case"aurora":return Yn(s);case"dice":return Dn(s);case"joke":return Ln(s);case"dadjoke":return zn(s);case"magic8":return Hn(s);case"sports":return Zn(s);case"stats":return ea(s);case"catfact":return ta(s);default:return null}}const na=/[\u{1F916}\u{1F9BE}\u{1F9BF}]/u;function So(s,t,n){if(t==="bot")return!0;if(t==="not-bot")return!1;if(na.test(s)||/bot\b/i.test(s))return!0;if(n&&n.length>0){let a=0;const r=n.slice(-5);for(const i of r)sa(i)!=null&&a++;if(a>=Math.ceil(r.length*.6))return!0}return!1}function aa(s){return na.test(s)||/bot\b/i.test(s)}const ra="pymc_howl_bot_overrides";function Io(){try{const s=localStorage.getItem(ra);if(!s)return new Map;const t=JSON.parse(s);return new Map(t)}catch{return new Map}}function zs(s){try{localStorage.setItem(ra,JSON.stringify([...s]))}catch{}}const la=gr(s=>({overrides:Io(),setOverride:(t,n)=>s(a=>{const r=new Map(a.overrides);return r.set(t,n),zs(r),{overrides:r}}),clearOverride:t=>s(n=>{const a=new Map(n.overrides);return a.delete(t),zs(a),{overrides:a}})}));function ia(s){return la(t=>t.overrides.get(s))}function _o(){return la(s=>s.setOverride)}const oa="pymc_companion_contacts_micro",ca="pymc_companion_favorites",St=56;function Hs(){try{return localStorage.getItem(oa)==="1"}catch{return!1}}function Mo(s){try{localStorage.setItem(oa,s?"1":"0")}catch{}}function Ro(){try{const s=localStorage.getItem(ca);return s?new Set(JSON.parse(s)):new Set}catch{return new Set}}function Eo(s){try{localStorage.setItem(ca,JSON.stringify([...s]))}catch{}}function Po({name:s,pubkey:t,advType:n,size:a="md",signal:r}){const i=(n??0)&15,o=a==="sm"?"w-5 h-5":"w-6 h-6",u=a==="sm"?"size-3":"size-3.5";if(i===2){const x=r&&r.rssi!==0,y=x?`RSSI: ${r.rssi} dBm · SNR: ${r.snr.toFixed(1)} dB${r.rtt_ms!=null?` · RTT: ${r.rtt_ms} ms`:""}`:void 0;return e.jsx("div",{className:E(o,"relative rounded-full flex items-center justify-center flex-shrink-0 ring-[1.5px]",x?"ring-transparent":"ring-sys-blue"),title:y,children:x?e.jsx(ml,{rssi:r.rssi,snr:r.snr,compact:!0,showValues:!1}):e.jsx(Ke,{className:E(u,"text-sys-blue")})})}if(i===3)return e.jsx("div",{className:E(o,"relative rounded-full flex items-center justify-center flex-shrink-0 ring-[1.5px] ring-sys-pink"),children:e.jsx(ht,{className:E(u,"text-sys-pink")})});if(!s)return e.jsx("div",{className:E(o,"relative rounded-full bg-sys-blue/12 flex items-center justify-center flex-shrink-0"),children:e.jsx("span",{className:"text-sys-blue font-mono text-[10px] font-bold",children:t.slice(0,4)})});const{emoji:d}=yt(s),f=bt(s),c=vt(s);return e.jsx("div",{className:E(o,"relative clay-avatar",d?"text-base":"text-white text-[11px] font-bold"),style:{"--avatar-color":f},children:d||c})}const Bs=[{key:"companion",label:"Companions",icon:je,color:"text-sys-blue"},{key:"room",label:"Room Servers",icon:ht,color:"text-sys-pink"},{key:"repeater",label:"Repeaters",icon:Ke,color:"text-sys-blue"}];function To(s){const t=(s.adv_type??0)&15;return t===3?"room":t===2?"repeater":"companion"}const $o=4e3,Ao=5e3,Fo=2e3,Oo=8,Do=l.forwardRef(function({contact:t,isActive:n,unread:a,lastMsg:r,isFav:i,microContent:o,onSelect:u,onShowDetails:d,onShareContact:f,onResetPath:c,onRemoveContact:x,onPingContact:y,repeaterNeighborHashes:g,repeaterSignal:m,toggleFavorite:j},k){const h=yr(t.public_key),w=br(t.public_key),I=ia(t.public_key),R=_o(),v=I==="bot"||I==null&&aa(t.name||""),[S,T]=l.useState(!1),[M,p]=l.useState(!1),N=l.useRef(null),[_,b]=l.useState("idle"),L=l.useRef(!1),C=l.useRef(null),[D,$]=l.useState({w:0,h:0});l.useEffect(()=>{if(h)L.current=!0,b("idle");else if(L.current){L.current=!1;const O=re.getState().pingResults.get(t.public_key),W=O!=null&&O.rssi!==0;b(W?"success":"failed")}},[h,t.public_key]),l.useEffect(()=>{if(_==="idle")return;const W=setTimeout(()=>b("idle"),_==="success"?Ao:Fo);return()=>clearTimeout(W)},[_]);const G=(h||_!=="idle")&&!S;l.useEffect(()=>{if(!G)return;const O=C.current;if(!O)return;const W=()=>{const pe=O.offsetWidth,xe=O.offsetHeight;$(Ae=>Ae.w===pe&&Ae.h===xe?Ae:{w:pe,h:xe})};W();const J=new ResizeObserver(W);return J.observe(O),()=>J.disconnect()},[G]);const F=l.useCallback(()=>{T(!0),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>T(!1),$o)},[]),q=l.useCallback(()=>{T(!1),N.current&&clearTimeout(N.current)},[]),X=l.useCallback(async()=>{x&&(N.current&&clearTimeout(N.current),p(!0),await x(t.public_key),p(!1),T(!1))},[x,t.public_key]),H=l.useMemo(()=>{const O=w&&w.rssi!==0,W=m&&m.rssi!==0;if(!O&&!W)return null;if(O&&!W)return{rssi:w.rssi,snr:w.snr_db,rtt_ms:w.rtt_ms};if(!O&&W)return{rssi:m.rssi,snr:m.snr};const J=m.advertCount,pe=3,xe=J+pe;return{rssi:Math.round((m.rssi*J+w.rssi*pe)/xe),snr:(m.snr*J+w.snr_db*pe)/xe,rtt_ms:w.rtt_ms}},[w,m]),A=l.useCallback(O=>{C.current=O,typeof k=="function"?k(O):k&&(k.current=O)},[k]),z=S?"":_==="success"?"bg-sys-green/5":_==="failed"?"bg-sys-red/5":h?"bg-sys-blue/5":n?"bg-sys-blue":"hover:bg-elevated";return e.jsxs(me.div,{ref:A,layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:ue.fade,className:E("group relative w-full flex items-center gap-2.5 px-2.5 py-[3px] radius-inner overflow-hidden","transition-[background-color,box-shadow] duration-150",z),children:[e.jsx(ve,{children:G&&D.w>0&&(_!=="idle"?e.jsx(me.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{opacity:{duration:.15}},className:E("absolute inset-0 radius-inner ring-2 ring-inset pointer-events-none z-[2]",_==="success"?"ring-sys-green":"ring-sys-red")},`ping-${_}`):e.jsx(vr,{borderRadius:Oo,width:D.w,height:D.h,color:"blue"},"ping-crawl"))}),e.jsxs("div",{className:"grid flex-1 min-w-0 [&>*]:col-start-1 [&>*]:row-start-1",children:[e.jsxs("div",{className:E("flex items-center gap-2.5",S&&!o&&"invisible pointer-events-none"),children:[e.jsxs("button",{onClick:()=>u({type:"contact",id:t.public_key}),className:"flex items-center gap-2.5 flex-1 min-w-0 text-left",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Po,{name:t.name,pubkey:t.public_key,advType:t.adv_type,signal:H}),a>0&&e.jsx("span",{className:"absolute -top-0.5 -right-0.5 h-2.5 w-2.5 rounded-full bg-sys-red ring-2 ring-body"}),v&&!a&&e.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 flex items-center justify-center w-3 h-3 rounded-full bg-sys-violet ring-[1.5px] ring-body",title:"HOWL Bot",children:e.jsx(Ds,{className:"w-2 h-2 text-white"})})]}),!o&&e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("span",{className:E("text-sm truncate flex-1",n?"text-white font-medium":i?"text-sys-amber font-bold":"text-fg-primary font-medium"),children:t.name||t.public_key.slice(0,12)+"…"})}),_==="success"&&w?e.jsxs("div",{className:"text-[11px] text-sys-green font-medium truncate tabular-nums",children:[w.rssi," dBm · ",w.snr_db.toFixed(1)," dB",w.rtt_ms!=null&&` · ${w.rtt_ms} ms`]}):_==="failed"?e.jsx("div",{className:"text-[11px] text-sys-red font-medium truncate",children:"No response"}):r?e.jsx("div",{className:E("text-[11px] truncate",n?"text-white/70":"text-fg-muted"),children:r.text}):null]})]}),!o&&e.jsx("div",{className:"relative flex-shrink-0 w-[18px] h-[18px] flex items-center justify-center",children:e.jsx(ui,{as:"div",className:"absolute inset-0",children:({open:O})=>e.jsxs(e.Fragment,{children:[e.jsx(En,{className:E("absolute inset-0 flex items-center justify-center rounded transition-[opacity,background-color] duration-100","focus:outline-none",n?"hover:bg-white/15":"hover:bg-subtle-fill",O?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":"Contact options",children:e.jsx(Ai,{className:E("h-3.5 w-3.5 transition-colors",n?"text-white/60 hover:text-white":"text-fg-muted hover:text-sys-blue")})}),e.jsxs(Pn,{anchor:"right start",transition:!0,className:E("min-w-[10rem] max-w-[20rem]","radius-inset p-1 ml-1","surface-elevated","focus:outline-none z-50","transition-[opacity,transform]","data-[closed]:opacity-0 data-[closed]:scale-[0.98] data-[closed]:translate-x-[-4px]","data-[enter]:duration-150 data-[leave]:duration-100","data-[enter]:ease-out data-[leave]:ease-in"),children:[e.jsx(ke,{icon:e.jsx(ct,{className:"w-4 h-4"}),onClick:()=>{d==null||d({type:"contact",id:t.public_key})},children:"Details"}),f&&e.jsx(ke,{icon:e.jsx(Ml,{className:"w-4 h-4"}),onClick:()=>f(t.public_key),children:"Share"}),e.jsx(ke,{icon:e.jsx(Je,{className:"w-4 h-4"}),onClick:()=>u({type:"contact",id:t.public_key}),children:"Set Path"}),c&&e.jsx(ke,{icon:e.jsx(jn,{className:"w-4 h-4"}),onClick:()=>c(t.public_key),children:"Reset Path"}),y&&e.jsx(ke,{icon:e.jsx(Ti,{className:"w-4 h-4"}),onClick:()=>y(t.public_key),disabled:!(g!=null&&g.has(t.public_key)),children:"Ping"}),x&&e.jsx(ke,{icon:e.jsx(Qe,{className:"w-4 h-4"}),destructive:!0,onClick:F,children:"Remove Contact"}),e.jsx(no,{}),e.jsx(ke,{icon:v?e.jsx(Mi,{className:"w-4 h-4 text-fg-muted"}):e.jsx(Ds,{className:"w-4 h-4 text-sys-violet"}),onClick:()=>R(t.public_key,v?"not-bot":"bot"),children:v?"Not a Bot":"Mark as HOWL Bot"}),e.jsx(ke,{icon:e.jsx(Ji,{className:E("w-4 h-4 group-data-[focus]:text-white group-data-[focus]:fill-white",i?"text-sys-amber fill-sys-amber":"text-fg-muted")}),onClick:()=>j(t.public_key),children:i?"Unfavorite":"Favorite"})]})]})})})]}),!o&&e.jsx("div",{className:E("flex items-center gap-1.5 self-center",!S&&"invisible pointer-events-none"),children:M?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"w-3.5 h-3.5 animate-spin rounded-full border-2 border-white border-t-transparent"})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:q,className:"flex-1 flex items-center justify-center py-1 radius-inner bg-zinc-500/80 hover:bg-zinc-500 depth-stroke-raised transition-colors",children:e.jsx("span",{className:"text-[11px] font-semibold text-white",children:"Cancel"})}),e.jsx("button",{onClick:X,className:"flex-1 flex items-center justify-center py-1 radius-inner bg-sys-red/80 hover:bg-sys-red depth-stroke-raised transition-colors",children:e.jsx(Qe,{className:"w-4 h-4 text-white"})})]})})]})]},t.public_key)}),Ws={excellent:4,good:3,fair:2,weak:1,poor:0};function Us(s,t,n){const a=t==null?void 0:t.get(s),r=a&&a.rssi!==0,i=n==null?void 0:n.get(s),o=i&&typeof i.rssi=="number"&&i.rssi!==0;if(!r&&!o)return null;if(o&&!r)return i.rssi;if(!o&&r)return a.rssi;const u=a.advertCount,d=3;return Math.round((a.rssi*u+i.rssi*d)/(u+d))}function Lo(s,t,n,a,r){return[...s].sort((i,o)=>{const u=t.has(i.public_key)?0:1,d=t.has(o.public_key)?0:1;if(u!==d)return u-d;if(n){const f=n.get(i.public_key),c=f&&f.length>0?f[f.length-1].timestamp:0,x=n.get(o.public_key),y=x&&x.length>0?x[x.length-1].timestamp:0;if(c!==y)return y-c}if(a){const f=Us(i.public_key,a,r),c=Us(o.public_key,a,r);if(f!=null&&c==null)return-1;if(f==null&&c!=null)return 1;if(f!=null&&c!=null){const x=Ws[Ps(f)]??0,y=Ws[Ps(c)]??0;if(x!==y)return y-x}}return(i.name||"").localeCompare(o.name||"")})}const zo=l.memo(l.forwardRef(function({contacts:t,selectedConversation:n,unreadMap:a,messages:r,onSelect:i,onShowDetails:o,onShareContact:u,onResetPath:d,onRemoveContact:f,onPingContact:c,repeaterNeighborHashes:x,repeaterSignalMap:y,isLoading:g,splitPercent:m=50,onMicroChange:j,className:k},h){const[w,I]=l.useState(Hs),[R,v]=l.useState(Hs),[S,T]=l.useState(""),[M,p]=l.useState(!1),[N,_]=l.useState(Ro),b=l.useRef(null),L=l.useRef(null),C=l.useCallback(A=>{L.current=A,typeof h=="function"?h(A):h&&(h.current=A)},[h]),D=l.useCallback(()=>{I(A=>{const z=!A;Mo(z);const O=L.current;if(z&&v(!0),O){let W=0;const J=O.parentElement;if(z)W=(J==null?void 0:J.offsetWidth)??O.offsetWidth;else if(J){const xe=J.style.width;J.style.width="var(--companion-side)",W=J.offsetWidth,J.style.width=xe}const pe=z?St:Math.round(m/100*W);lt(O,{width:`${pe}px`},{...ue.layoutResize,onComplete(){O.style.width=z?`${St}px`:`${m}%`,z||v(!1)}})}return j==null||j(z),z})},[m,j]),$=l.useCallback(A=>{_(z=>{const O=new Set(z);return O.has(A)?O.delete(A):O.add(A),Eo(O),O})},[]),G=M||S.length>0,F=l.useMemo(()=>{const A=new Set,z=t.filter(W=>A.has(W.public_key)?!1:(A.add(W.public_key),!0));if(!S.trim())return z;const O=S.toLowerCase();return z.filter(W=>{var J;return((J=W.name)==null?void 0:J.toLowerCase().includes(O))||W.public_key.toLowerCase().includes(O)})},[t,S]),q=re(A=>A.pingResults),X=l.useMemo(()=>{const A=new Map;for(const z of Bs)A.set(z.key,[]);for(const z of F)A.get(To(z)).push(z);return Bs.map(z=>({...z,items:Lo(A.get(z.key),N,r,z.key==="repeater"?y:void 0,z.key==="repeater"?q:void 0)})).filter(z=>z.items.length>0)},[F,N,r,y,q]),H=(n==null?void 0:n.type)==="contact"?n.id:null;return e.jsxs("div",{ref:C,className:E("flex-shrink-0 overflow-hidden flex flex-col h-full",k),style:{width:w?St:`${m}%`},children:[e.jsx("div",{className:E("flex items-center border-b border-edge-subtle flex-shrink-0",R?"justify-center p-2":"gap-2 px-3 py-2"),children:R?e.jsx("button",{onClick:D,className:"p-1 hover:bg-subtle-fill rounded transition-colors",title:"Expand contacts",children:e.jsx(Bi,{className:"w-3.5 h-3.5 text-fg-muted"})}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide flex-shrink-0",children:"Contacts"}),e.jsxs("div",{className:"flex items-center gap-1 ml-auto flex-shrink-0",children:[e.jsx("button",{onClick:()=>{G?(T(""),p(!1)):(p(!0),setTimeout(()=>{var A;return(A=b.current)==null?void 0:A.focus()},50))},className:E("p-1 rounded transition-colors flex-shrink-0",G?"bg-sys-blue/10 text-sys-blue":"hover:bg-subtle-fill text-fg-muted"),title:G?"Close search":"Search contacts",children:e.jsx(Ts,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:D,className:"p-1 hover:bg-subtle-fill rounded transition-colors flex-shrink-0",title:"Collapse contacts",children:e.jsx(zi,{className:"w-3.5 h-3.5 text-fg-muted"})})]})]})}),!R&&G&&e.jsxs("div",{className:"relative px-2.5 py-2 border-b border-edge-subtle/50 flex-shrink-0",children:[e.jsx(Ts,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-muted pointer-events-none"}),e.jsx("input",{ref:b,type:"text",value:S,onChange:A=>T(A.target.value),onFocus:()=>p(!0),onBlur:()=>p(!1),placeholder:"Search contacts…",className:"w-full pl-8 pr-8 py-1.5 text-sm radius-inner bg-input-bg border border-input-border text-fg-primary placeholder:text-fg-muted/50 ring-focus-inset hover:border-edge-strong transition-colors",autoFocus:!0}),e.jsx("button",{onClick:()=>{T(""),p(!1)},className:"absolute right-5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-subtle-fill rounded",children:e.jsx(ft,{className:"w-3.5 h-3.5 text-fg-muted"})})]}),g&&e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsx("div",{className:"w-5 h-5 animate-spin rounded-full border-2 border-sys-blue border-t-transparent"})}),!g&&e.jsxs("div",{className:E("flex-1 overflow-y-auto min-h-0",R?"px-0":"px-1.5"),style:{contain:"layout style paint"},children:[X.map(A=>{const z=A.icon;return e.jsxs(Re,{defaultOpen:!0,className:"mb-1",children:[e.jsxs(Ee,{className:E("px-2 py-1 flex items-center gap-1.5 w-full","text-left radius-inner hover:bg-subtle-fill-strong transition-colors"),children:[e.jsx(z,{className:E("w-3.5 h-3.5",A.color)}),!R&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:A.label}),e.jsx("span",{className:"type-data-xs text-fg-muted/50 ml-auto",children:A.items.length})]})]}),e.jsx(Pe,{children:e.jsx(ve,{initial:!1,mode:"popLayout",children:A.items.map(O=>e.jsx(Do,{contact:O,isActive:H===O.public_key,unread:a.get(O.public_key)??0,lastMsg:(()=>{const W=r.get(O.public_key);return W&&W.length>0?W[W.length-1]:void 0})(),isFav:N.has(O.public_key),microContent:R,onSelect:i,onShowDetails:o,onShareContact:u,onResetPath:d,onRemoveContact:f,onPingContact:c,repeaterNeighborHashes:x,repeaterSignal:y==null?void 0:y.get(O.public_key),toggleFavorite:$},O.public_key))})})]},A.key)}),F.length===0&&e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-sm text-fg-muted",children:S?"No matches":"No contacts yet"})})]})]})}));function Ho({open:s,onClose:t}){const n=re(p=>p.discoverImportableChannels),a=re(p=>p.getEmptyChannelSlots),r=re(p=>p.importChannel),i=re(p=>p.refreshChannels),[o,u]=l.useState("discover"),[d,f]=l.useState([]),[c,x]=l.useState([]),[y,g]=l.useState(null),m=l.useRef(!1);l.useEffect(()=>{if(!s)return;u("discover"),f([]),x([]),g(null),m.current=!1;let p=!1;return(async()=>{try{const[N,_]=await Promise.all([n(),a()]);if(p)return;if(x(_),N.length===0){g("No channels found in repeater history. Decoded messages may still be loading."),u("select");return}_.length===0&&g("No empty channel slots on device. Delete a channel first to make room."),f(N.map(b=>({name:b.name,alreadyOnDevice:b.alreadyOnDevice,selected:!b.alreadyOnDevice,status:"pending"}))),u("select")}catch(N){p||(g(N instanceof Error?N.message:"Discovery failed"),u("select"))}})(),()=>{p=!0}},[s,n,a]);const j=l.useCallback(p=>{f(N=>N.map(_=>_.name===p&&!_.alreadyOnDevice?{..._,selected:!_.selected}:_))},[]),k=l.useCallback(()=>{f(p=>p.map(N=>N.alreadyOnDevice?N:{...N,selected:!0}))},[]),h=l.useCallback(()=>{f(p=>p.map(N=>N.alreadyOnDevice?N:{...N,selected:!1}))},[]),w=l.useMemo(()=>d.filter(p=>!p.alreadyOnDevice).length,[d]),I=l.useMemo(()=>d.filter(p=>p.selected&&!p.alreadyOnDevice).length,[d]),R=l.useMemo(()=>d.filter(p=>p.status==="done").length,[d]),v=l.useMemo(()=>d.filter(p=>p.status==="failed").length,[d]),S=l.useCallback(async()=>{u("import"),m.current=!1;const p=d.filter(_=>_.selected&&!_.alreadyOnDevice),N=[...c];for(const _ of p){if(m.current)break;const b=N.shift();if(b===void 0){f(C=>C.map(D=>D.name===_.name&&D.status==="pending"?{...D,status:"failed"}:D));continue}f(C=>C.map(D=>D.name===_.name?{...D,status:"sending"}:D)),await new Promise(C=>setTimeout(C,150));const L=await r(_.name,b);f(C=>C.map(D=>D.name===_.name?{...D,status:L?"done":"failed"}:D)),L||N.unshift(b),m.current||await new Promise(C=>setTimeout(C,300))}await i(),u("complete")},[d,c,r,i]),T=l.useCallback(()=>{m.current=!0},[]),M=p=>{switch(p){case"pending":return e.jsx($n,{className:"w-3.5 h-3.5 text-fg-muted"});case"sending":return e.jsx(ce,{className:"w-3.5 h-3.5 text-sys-blue animate-spin"});case"done":return e.jsx(Ne,{className:"w-3.5 h-3.5 text-sys-green"});case"failed":return e.jsx(ft,{className:"w-3.5 h-3.5 text-sys-red"})}};return e.jsxs(Ce,{open:s,onClose:o==="import"?()=>{}:t,size:"sm",children:[e.jsx(Te,{icon:e.jsx(qe,{className:"w-5 h-5"}),title:"Import Channels",onClose:o==="import"?void 0:t}),e.jsxs(Se,{className:"!py-3 !px-0",children:[o==="discover"&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-8 px-6",children:[e.jsx(ce,{className:"w-6 h-6 text-sys-blue animate-spin"}),e.jsx("p",{className:"text-sm text-fg-secondary",children:"Scanning repeater history…"}),e.jsx("p",{className:"text-[11px] text-fg-muted",children:"Waiting for decoded messages"})]}),o==="select"&&e.jsxs(e.Fragment,{children:[y&&e.jsxs("div",{className:"flex items-start gap-2 mx-4 mb-3 p-2.5 radius-inner bg-sys-amber/8 border border-sys-amber/20",children:[e.jsx(Ve,{className:"w-3.5 h-3.5 text-sys-amber flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-fg-secondary",children:y})]}),d.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-4 pb-2 border-b border-edge-subtle",children:[e.jsxs("span",{className:"text-[11px] text-fg-muted",children:[w," discoverable · ",c.length," slot",c.length!==1?"s":""," free"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:k,className:"text-[11px] text-sys-blue hover:underline",children:"All"}),e.jsx("span",{className:"text-fg-muted/40",children:"·"}),e.jsx("button",{onClick:h,className:"text-[11px] text-sys-blue hover:underline",children:"None"})]})]}),e.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:d.map(p=>e.jsxs("button",{onClick:()=>j(p.name),disabled:p.alreadyOnDevice,className:E("w-full flex items-center gap-3 px-4 py-2 transition-colors",p.alreadyOnDevice?"opacity-40 cursor-default":"hover:bg-subtle-fill"),children:[e.jsx("div",{className:E("w-4 h-4 rounded border flex items-center justify-center flex-shrink-0 transition-colors",p.alreadyOnDevice?"border-fg-muted/30 bg-fg-muted/10":p.selected?"border-sys-blue bg-sys-blue":"border-edge-subtle"),children:(p.selected||p.alreadyOnDevice)&&e.jsx(Ne,{className:"w-3 h-3 text-white"})}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(He,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-primary truncate",children:p.name})]}),p.alreadyOnDevice&&e.jsx("span",{className:"text-[10px] text-fg-muted bg-subtle-fill px-1.5 py-0.5 rounded flex-shrink-0",children:"on device"})]},p.name))})]})]}),(o==="import"||o==="complete")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-4 pb-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"text-[11px] text-fg-muted",children:o==="import"?"Importing channels…":"Import complete"}),e.jsxs("span",{className:"text-[11px] tabular-nums text-fg-secondary",children:[R+v," / ",d.filter(p=>p.selected&&!p.alreadyOnDevice).length]})]}),e.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:d.filter(p=>p.selected&&!p.alreadyOnDevice).map(p=>e.jsxs("div",{className:E("flex items-center gap-3 px-4 py-2",p.status==="sending"&&"bg-sys-blue/5",p.status==="done"&&"bg-sys-green/5",p.status==="failed"&&"bg-sys-red/5"),children:[e.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:M(p.status)}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(He,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:E("text-sm truncate",p.status==="done"?"text-fg-primary":"text-fg-secondary"),children:p.name})]}),e.jsx("span",{className:E("text-[10px] flex-shrink-0",p.status==="sending"&&"text-sys-blue",p.status==="done"&&"text-sys-green",p.status==="failed"&&"text-sys-red",p.status==="pending"&&"text-fg-muted"),children:p.status==="sending"?"sending…":p.status==="done"?"added":p.status==="failed"?"failed":"waiting"})]},p.name))})]})]}),e.jsxs($e,{children:[o==="select"&&e.jsxs(e.Fragment,{children:[e.jsx(U,{plain:!0,onClick:t,children:"Cancel"}),e.jsxs(U,{color:"primary",onClick:S,disabled:I===0||c.length===0,children:[e.jsx(qe,{className:"w-4 h-4"}),"Import ",I," ",I===1?"Channel":"Channels"]})]}),o==="import"&&e.jsx(U,{plain:!0,onClick:T,children:"Stop"}),o==="complete"&&e.jsxs(e.Fragment,{children:[v>0&&e.jsxs("span",{className:"text-xs text-sys-red flex items-center gap-1 mr-auto",children:[e.jsx(Ve,{className:"w-3.5 h-3.5"}),v," failed"]}),e.jsxs(U,{color:"primary",onClick:t,children:[e.jsx(El,{className:"w-4 h-4"}),"Done — ",R," imported"]})]})]})]})}const Bo=4e3;function Wo(s){const t=s.frequency_hz/1e3,n=s.bandwidth_hz/1e3;return`${t} · SF${s.spreading_factor} · ${n}k`}const Uo=l.forwardRef(function({channel:t,isActive:n,unread:a,lastMsg:r,isLoadingMessages:i,selfInfo:o,onSelect:u,onDeleteChannel:d},f){const[c,x]=l.useState(!1),[y,g]=l.useState(!1),m=l.useRef(null),j=l.useCallback(()=>{x(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>x(!1),Bo)},[]),k=l.useCallback(()=>{x(!1),m.current&&clearTimeout(m.current)},[]),h=l.useCallback(async()=>{d&&(m.current&&clearTimeout(m.current),g(!0),await d(t.index),g(!1),x(!1))},[d,t.index]),w=t.name.toLowerCase()==="public",I=d&&!w;return e.jsx(me.div,{ref:f,layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:ue.fade,className:E("group w-full flex items-center gap-2.5 px-2.5 py-1 radius-inner","transition-[background-color] duration-150",c?"":n?"bg-sys-blue":"hover:bg-subtle-fill-strong"),children:e.jsxs("div",{className:"grid flex-1 min-w-0 [&>*]:col-start-1 [&>*]:row-start-1",children:[e.jsxs("div",{className:E("flex items-center gap-2.5 min-w-0",c&&"invisible pointer-events-none"),children:[e.jsx("button",{onClick:()=>u({type:"channel",id:String(t.index)}),className:"flex items-center gap-2.5 flex-1 min-w-0 text-left",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:E("text-sm flex-shrink-0",n?"text-white font-semibold":r?"text-fg-primary font-semibold":"text-fg-secondary font-normal"),children:t.name}),w&&o&&e.jsx("span",{className:E("text-[9px] font-medium px-1.5 py-px rounded-full whitespace-nowrap truncate",n?"text-white/80 bg-white/15":"text-fg-muted/70 bg-subtle-fill"),children:Wo(o)})]}),r&&e.jsx("div",{className:E("text-[11px] truncate pl-2",n?"text-white/70":"text-fg-muted"),children:r.text})]})}),e.jsx("div",{className:"flex items-center flex-shrink-0",children:i?e.jsx("span",{className:"h-1.5 w-6 rounded-full bg-fg-muted/20 animate-pulse"}):I?e.jsxs("div",{className:"relative w-[18px] h-[18px] flex items-center justify-center",children:[a>0&&e.jsx("span",{className:"absolute inset-0 flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded-full bg-sys-red text-white text-[10px] font-bold leading-none group-hover:invisible transition-[visibility] duration-100",children:a>99?"99+":a}),e.jsx("button",{onClick:j,className:E("absolute inset-0 flex items-center justify-center rounded opacity-0 group-hover:opacity-100 transition-[opacity,background-color] duration-100",n?"hover:bg-white/15":"hover:bg-subtle-fill"),title:"Remove channel",children:e.jsx(Qe,{className:E("w-3 h-3 transition-colors",n?"text-white/60 hover:text-white":"text-fg-muted hover:text-sys-red")})})]}):a>0?e.jsx("span",{className:"min-w-[18px] h-[18px] px-1 rounded-full bg-sys-red text-white text-[10px] font-bold flex items-center justify-center leading-none",children:a>99?"99+":a}):null})]}),e.jsx("div",{className:E("flex items-center gap-1.5 self-center",!c&&"invisible pointer-events-none"),children:y?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"w-3.5 h-3.5 animate-spin rounded-full border-2 border-white border-t-transparent"})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:k,className:"flex-1 flex items-center justify-center py-1 radius-inner bg-zinc-500/80 hover:bg-zinc-500 depth-stroke-raised transition-colors",children:e.jsx("span",{className:"text-[11px] font-semibold text-white",children:"Cancel"})}),e.jsx("button",{onClick:h,className:"flex-1 flex items-center justify-center py-1 radius-inner bg-sys-red/80 hover:bg-sys-red depth-stroke-raised transition-colors",children:e.jsx(Qe,{className:"w-4 h-4 text-white"})})]})})]})})}),Go=l.memo(l.forwardRef(function({channels:t,selectedConversation:n,unreadMap:a,messages:r,onSelect:i,onAddChannel:o,onDeleteChannel:u,className:d},f){const c=jr(),x=gt(),[y,g]=l.useState(!1),m=l.useMemo(()=>{const k=new Set,h=t.filter(w=>k.has(w.index)?!1:(k.add(w.index),!0));return h.sort((w,I)=>{const R=w.name.toLowerCase()==="public",v=I.name.toLowerCase()==="public";if(R&&!v)return-1;if(!R&&v)return 1;const S=r.get(`ch:${w.index}`),T=S&&S.length>0?S[S.length-1].timestamp:0,M=r.get(`ch:${I.index}`),p=M&&M.length>0?M[M.length-1].timestamp:0;return T!==p?p-T:w.name.localeCompare(I.name)}),h},[t,r]),j=(n==null?void 0:n.type)==="channel"?n.id:null;return e.jsxs("div",{ref:f,className:E("flex-1 min-w-0 overflow-hidden flex flex-col h-full",d),children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-edge-subtle flex-shrink-0 overflow-hidden whitespace-nowrap",children:[e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide flex-shrink-0",children:"Channels"}),e.jsxs("div",{className:"flex items-center gap-1 ml-auto flex-shrink-0",children:[e.jsx("button",{onClick:()=>g(!0),className:"p-1 rounded hover:bg-subtle-fill transition-colors flex-shrink-0",title:"Import channels from repeater history",children:e.jsx(qe,{className:"w-3.5 h-3.5 text-fg-muted"})}),o&&e.jsx("button",{onClick:o,className:"p-1 rounded hover:bg-subtle-fill transition-colors flex-shrink-0",title:"Add channel",children:e.jsx(Xe,{className:"w-3.5 h-3.5 text-fg-muted"})})]})]}),e.jsx(Ho,{open:y,onClose:()=>g(!1)}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 px-1.5 py-1",style:{contain:"layout style paint"},children:m.length===0?e.jsxs("div",{className:"px-1.5 py-4 space-y-2",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"No channels"}),o&&e.jsxs("button",{onClick:o,className:"inline-flex items-center gap-1.5 px-2 py-1.5 text-xs font-medium text-sys-blue hover:bg-sys-blue/8 rounded transition-colors",children:[e.jsx(Xe,{className:"w-3.5 h-3.5"}),"Add Channel"]})]}):e.jsx(ve,{initial:!1,mode:"popLayout",children:m.map(k=>e.jsx(Uo,{channel:k,isActive:j===String(k.index),unread:a.get(`ch:${k.index}`)??0,lastMsg:(()=>{const h=r.get(`ch:${k.index}`);return h&&h.length>0?h[h.length-1]:void 0})(),isLoadingMessages:c,selfInfo:x,onSelect:i,onDeleteChannel:u},k.index))})})]})}));function Ko(s,t){const n=new Map;for(const[a,r]of s){const i=r.decoded;if(!(i!=null&&i.decrypted)||i.senderName!==t)continue;const o=i.timestamp??r.timestamp,u=Math.floor(o/30),d=`${i.text}:${u}`;n.has(d)||n.set(d,a)}return n}function qo(s){const t=gt(),n=Nr(),a=wr(),r=t==null?void 0:t.node_name,i=l.useMemo(()=>r?Ko(n,r):new Map,[n,r]);return l.useMemo(()=>{const o=new Map;if(!r||i.size===0)return o;const u=new Map;for(const c of s){if(!c.is_outgoing||!c.is_channel)continue;const x=Math.floor(c.timestamp/30);let y=!1;for(const g of[x-1,x,x+1]){const m=i.get(`${c.text}:${g}`);if(m){const j=u.get(m)??[];j.push(c.id),u.set(m,j),y=!0;break}}}if(u.size===0)return o;const d=new Set(u.keys()),f=new Map;for(const c of a)d.has(c.packet_hash)&&f.set(c.packet_hash,(f.get(c.packet_hash)??0)+1);for(const[c,x]of u){const y=f.get(c)??0,g=Math.max(0,y-1);for(const m of x)o.set(m,g)}return o},[s,r,i,a])}const Z=l.memo(function({children:t,className:n,bgClassName:a,hideBadge:r,compact:i}){return e.jsxs("div",{className:E("relative max-w-full animate-bot-widget-in","rounded-2xl rounded-tl-md overflow-hidden","ring-1 ring-inset ring-edge-subtle",a||"bg-chat-incoming",i?"px-3 py-2":"px-3.5 py-3",n),children:[!r&&e.jsx("span",{className:"absolute top-1.5 right-2 text-[9px] text-sys-indigo/50 select-none pointer-events-none",children:"🤖"}),t]})}),Vo=new Set(["☀️","🌤","🌤️"]),Jo=new Set(["⛅","⛅️"]),Qo=new Set(["☁️","🌫","🌫️"]),Xo=new Set(["🌧","🌧️","🌦","🌦️","⛈","⛈️","🌩","🌩️"]),Yo=new Set(["❄️","🌨","🌨️"]);function Zo(s){return Vo.has(s)?"bg-gradient-to-br from-[var(--sys-blue)]/20 to-[var(--sys-indigo)]/10":Jo.has(s)?"bg-gradient-to-br from-[var(--zinc-800)]/80 to-[var(--sys-blue)]/15":Qo.has(s)?"bg-gradient-to-br from-[var(--zinc-800)]/80 to-[var(--zinc-700)]/60":Xo.has(s)?"bg-gradient-to-br from-[var(--zinc-900)]/80 to-[var(--zinc-700)]/60":Yo.has(s)?"bg-gradient-to-br from-[var(--zinc-800)]/80 to-[var(--sys-cyan)]/10":"bg-gradient-to-br from-[var(--zinc-800)]/80 to-[var(--zinc-700)]/60"}function Ue({label:s}){return e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md bg-fg-primary/10 text-[10px] text-fg-primary/80 tabular-nums",children:s})}function ec({period:s}){return e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"text-fg-muted min-w-[56px]",children:s.label}),e.jsx("span",{className:"text-sm",children:s.conditionEmoji}),e.jsx("span",{className:"text-fg-primary/70",children:s.condition}),e.jsxs("span",{className:"text-fg-primary font-medium tabular-nums",children:[s.temp,s.unit]}),s.wind&&e.jsx("span",{className:"text-fg-muted tabular-nums",children:s.wind})]})}const tc=l.memo(function({data:t}){const n=t.periods[0],a=t.periods.slice(1),r=Zo(n.conditionEmoji);return e.jsxs(Z,{bgClassName:r,children:[e.jsx("div",{className:"text-[11px] text-fg-muted font-medium mb-1 pr-6",children:n.label}),e.jsxs("div",{className:"flex items-start gap-1.5 mb-2",children:[e.jsx("span",{className:"text-2xl leading-none",children:n.conditionEmoji}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsxs("span",{className:"text-3xl font-light text-fg-primary tabular-nums leading-none",children:[n.temp,"°"]}),e.jsx("span",{className:"text-xs text-fg-muted",children:n.unit.replace("°","")})]}),e.jsx("div",{className:"text-xs text-fg-primary/70 mt-0.5",children:n.condition})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-2",children:[n.wind&&e.jsx(Ue,{label:`💨 ${n.wind}`}),n.humidity&&e.jsx(Ue,{label:`💧 ${n.humidity}`}),n.dewPoint&&e.jsx(Ue,{label:`💧 ${n.dewPoint}`}),n.visibility&&e.jsx(Ue,{label:`👁️ ${n.visibility}`}),n.pressure&&e.jsx(Ue,{label:`📊 ${n.pressure}`})]}),n.high!=null&&n.low!=null&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] mb-2",children:[e.jsxs("span",{className:"text-fg-muted tabular-nums",children:["L ",n.low,"°"]}),e.jsx("div",{className:"flex-1 h-1 rounded-full bg-fg-primary/15 relative",children:e.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full bg-fg-primary/35",style:{width:n.high!==n.low?`${Math.max(0,Math.min(100,(n.temp-n.low)/(n.high-n.low)*100))}%`:"50%"}})}),e.jsxs("span",{className:"text-fg-primary/70 tabular-nums font-medium",children:["H ",n.high,"°"]})]}),a.length>0&&e.jsx("div",{className:"border-t border-edge-subtle pt-1.5 mt-1 space-y-0.5",children:a.map((i,o)=>e.jsx(ec,{period:i},o))})]})}),sc=l.memo(function({data:t}){return e.jsx(Z,{compact:!0,children:e.jsx("div",{className:"flex gap-3 overflow-x-auto pb-0.5 -mx-1 px-1 scrollbar-none",children:t.map((n,a)=>e.jsxs("div",{className:"flex flex-col items-center gap-1 flex-shrink-0 min-w-[52px]",children:[e.jsx("span",{className:"text-[11px] text-fg-muted font-medium",children:n.dayAbbrev}),e.jsx("span",{className:"text-lg leading-none",children:n.conditionEmoji}),e.jsx("span",{className:"text-[10px] text-fg-primary/70 text-center leading-tight",children:n.condition}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] tabular-nums",children:[n.high!=null&&e.jsxs("span",{className:"text-fg-primary font-medium",children:[n.high,"°"]}),n.low!=null&&e.jsxs("span",{className:"text-fg-muted",children:[n.low,"°"]})]})]},a))})})}),nc=l.memo(function({data:t}){return e.jsx(Z,{compact:!0,children:e.jsx("div",{className:"flex gap-2.5 overflow-x-auto pb-0.5 -mx-1 px-1 scrollbar-none",children:t.map((n,a)=>e.jsxs("div",{className:"flex flex-col items-center gap-0.5 flex-shrink-0 min-w-[44px]",children:[e.jsx("span",{className:"text-[10px] text-fg-muted font-medium tabular-nums",children:n.hour}),e.jsx("span",{className:"text-base leading-none",children:n.conditionEmoji}),e.jsxs("span",{className:"text-xs text-fg-primary font-medium tabular-nums",children:[n.temp,"°"]}),n.precipChance!=null&&n.precipChance>0&&e.jsxs("span",{className:E("text-[9px] tabular-nums font-medium",n.precipChance>=50?"text-sys-blue":"text-sys-blue/60"),children:[n.precipChance,"%"]})]},a))})})});function ac(s){if(!s)return"amber";const t=s.toUpperCase();return t.includes("EXTREME")||t.includes("TORNADO")||t.includes("HURRICANE")||t.includes("SEVERE")||t.includes("WARNING")?"red":"amber"}const rc={red:"border-l-sys-red",amber:"border-l-sys-amber"},lc={red:"text-sys-red",amber:"text-sys-amber"},ic=l.memo(function({data:t}){const n=ac(t.severity);return e.jsx(Z,{compact:!0,hideBadge:!0,children:e.jsxs("div",{className:E("border-l-[3px] pl-2.5 -ml-0.5",rc[n]),children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:"text-sm leading-none",children:"⚠️"}),t.severity&&e.jsx("span",{className:E("text-[10px] font-bold uppercase tracking-wider",lc[n]),children:t.severity})]}),e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed whitespace-pre-wrap break-words",children:t.headline}),t.body&&e.jsx("p",{className:"text-xs text-fg-muted mt-1 leading-relaxed whitespace-pre-wrap break-words",children:t.body})]})})}),oc={high:"🎯",medium:"📍",low:"❓"};function cc({hop:s}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-mono text-[11px] text-sys-blue font-bold tabular-nums min-w-[20px]",children:s.hex}),e.jsx("span",{className:"text-fg-muted/40 text-xs",children:"→"}),s.unknown?e.jsx("span",{className:"text-xs text-fg-muted/50 italic",children:"unknown"}):s.matchCount!=null?e.jsxs("span",{className:"text-xs text-sys-amber",children:[s.matchCount," matches"]}):e.jsxs("span",{className:E("text-xs font-medium truncate max-w-[140px]",s.confidence==="low"?"text-fg-muted":"text-fg-primary"),children:[s.name,s.confidence&&e.jsx("span",{className:"ml-0.5 text-[10px]",children:oc[s.confidence]})]})]})}const dc=l.memo(function({data:t}){return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1.5 pr-6",children:[e.jsx("span",{className:"text-[11px] font-medium text-fg-muted",children:"🛤️ Path"}),e.jsxs("span",{className:"text-[10px] text-fg-muted/60 tabular-nums",children:[t.hops.length," hop",t.hops.length!==1?"s":""]})]}),e.jsx("div",{className:"space-y-1",children:t.hops.map((n,a)=>e.jsx(cc,{hop:n},a))})]})});function uc(s){return s>=10?5:s>=6?4:s>=3?3:s>=0?2:s>=-5?1:0}function mc(s){return s>=4?"bg-sys-green":s>=3?"bg-sys-amber":s>=2?"bg-sys-orange":"bg-sys-red"}function pc({bars:s}){const t=mc(s);return e.jsx("div",{className:"flex items-end gap-[2px] h-[20px]",children:[6,10,14,18,20].map((n,a)=>e.jsx("div",{className:E("w-[4px] rounded-sm transition-colors",a0?"+":"",t.snr.toFixed(1),e.jsx("span",{className:"text-[10px] text-fg-muted font-normal ml-0.5",children:"dB"})]}),t.rssi!=null&&e.jsxs("span",{className:"text-[11px] text-fg-muted tabular-nums",children:[t.rssi," dBm"]})]})]}),(t.hops!=null||t.pathHops)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap mb-1.5",children:[t.hops!=null&&e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded bg-sys-blue/10 text-[10px] text-sys-blue font-semibold tabular-nums",children:[t.hops," hop",t.hops!==1?"s":""]}),t.pathHops&&t.pathHops.length>0&&e.jsx("div",{className:"flex items-center gap-0.5 text-[10px]",children:t.pathHops.map((a,r)=>e.jsxs("span",{className:"contents",children:[r>0&&e.jsx("span",{className:"text-fg-muted/40",children:"›"}),e.jsx("span",{className:"font-mono text-fg-muted",children:a})]},r))})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-[10px] text-fg-muted",children:[t.distance&&e.jsx("span",{className:"tabular-nums",children:t.distance}),t.receivedAt&&e.jsxs("span",{className:"tabular-nums",children:["@ ",t.receivedAt]}),t.elapsed&&e.jsx("span",{className:"tabular-nums",children:t.elapsed}),t.phrase&&e.jsxs("span",{className:"text-fg-muted/60 italic truncate max-w-[120px]",children:['"',t.phrase,'"']})]})]})});function hc(s){return s<=50?{text:"text-sys-green",bg:"bg-sys-green/10"}:s<=100?{text:"text-sys-amber",bg:"bg-sys-amber/10"}:s<=150?{text:"text-sys-orange",bg:"bg-sys-orange/10"}:s<=200?{text:"text-sys-red",bg:"bg-sys-red/10"}:s<=300?{text:"text-sys-violet",bg:"bg-sys-violet/10"}:{text:"text-sys-red",bg:"bg-sys-red/10"}}const fc=l.memo(function({data:t}){const{text:n,bg:a}=hc(t.aqi);return e.jsxs(Z,{compact:!0,children:[t.location&&e.jsx("div",{className:"text-[11px] text-fg-muted font-medium mb-1 pr-6",children:t.location}),e.jsxs("div",{className:"flex items-center gap-2.5 mb-2",children:[e.jsx("div",{className:E("flex items-center justify-center w-12 h-12 rounded-xl",a),children:e.jsx("span",{className:E("text-xl font-bold tabular-nums",n),children:t.aqi})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-base leading-none",children:t.colorEmoji}),e.jsx("span",{className:E("text-sm font-semibold",n),children:t.category})]}),e.jsx("span",{className:"text-[10px] text-fg-muted",children:"Air Quality Index"})]})]}),t.pollutants.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:t.pollutants.map(r=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-fg-primary/5 text-[10px] tabular-nums",children:[e.jsx("span",{className:"text-fg-muted font-medium",children:r.name}),e.jsx("span",{className:"text-fg-primary",children:r.value})]},r.name))})]})});function gc(s){return s<=3?"text-sys-green":s<=4?"text-sys-amber":s<=6?"text-sys-orange":"text-sys-red"}function Oe({label:s,value:t,className:n}){return e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[9px] text-fg-muted uppercase tracking-wider",children:s}),e.jsx("span",{className:E("text-sm font-semibold tabular-nums text-fg-primary",n),children:t})]})}const yc=l.memo(function({data:t}){return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 pr-6",children:[e.jsx("span",{className:"text-sm leading-none",children:"☀️"}),e.jsx("span",{className:"text-[11px] font-medium text-fg-muted",children:"Solar Conditions"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2",children:[t.aIndex!=null&&e.jsx(Oe,{label:"A-Index",value:t.aIndex}),t.kIndex!=null&&e.jsx(Oe,{label:"K-Index",value:t.kIndex,className:gc(t.kIndex)}),t.sunspots!=null&&e.jsx(Oe,{label:"Sunspots",value:t.sunspots}),t.xrayFlux!=null&&e.jsx(Oe,{label:"X-Ray",value:t.xrayFlux}),t.solarFlux!=null&&e.jsx(Oe,{label:"Flux",value:t.solarFlux}),t.signalNoise!=null&&e.jsx(Oe,{label:"Noise",value:t.signalNoise})]})]})});function bc(s){const t=s.toLowerCase();return t==="excellent"||t==="good"?"text-sys-green bg-sys-green/10":t==="fair"?"text-sys-amber bg-sys-amber/10":"text-sys-red bg-sys-red/10"}function Gs({band:s}){return e.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[e.jsx("span",{className:"text-[11px] text-fg-primary font-mono tabular-nums",children:s.name}),e.jsx("span",{className:E("text-[10px] font-semibold px-1.5 py-0.5 rounded",bc(s.condition)),children:s.condition})]})}const vc=l.memo(function({data:t}){const n=t.bands.filter(r=>r.time==="day"),a=t.bands.filter(r=>r.time==="night");return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 pr-6",children:[e.jsx("span",{className:"text-sm leading-none",children:"📻"}),e.jsx("span",{className:"text-[11px] font-medium text-fg-muted",children:"HF Band Conditions"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] text-fg-muted uppercase tracking-wider",children:"Day"}),n.map((r,i)=>e.jsx(Gs,{band:r},i))]}),a.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] text-fg-muted uppercase tracking-wider",children:"Night"}),a.map((r,i)=>e.jsx(Gs,{band:r},i))]})]})]})});function jc({progress:s}){if(s==null)return null;const t=Math.max(0,Math.min(1,s)),n=Math.PI*(1-t),a=50-40*Math.cos(n),r=45-40*Math.sin(n);return e.jsxs("svg",{viewBox:"0 0 100 50",className:"w-full h-8 mb-1","aria-hidden":"true",children:[e.jsx("line",{x1:"8",y1:"45",x2:"92",y2:"45",stroke:"var(--fg-muted)",strokeWidth:"0.5",opacity:"0.3"}),e.jsx("path",{d:"M 10 45 A 40 40 0 0 1 90 45",fill:"none",stroke:"var(--sys-amber)",strokeWidth:"1",opacity:"0.3",strokeDasharray:"3 2"}),e.jsx("circle",{cx:a,cy:r,r:"3.5",fill:"var(--sys-amber)"}),e.jsx("text",{x:"10",y:"49",fontSize:"4.5",fill:"var(--fg-muted)",textAnchor:"middle",children:"↑"}),e.jsx("text",{x:"90",y:"49",fontSize:"4.5",fill:"var(--fg-muted)",textAnchor:"middle",children:"↓"})]})}const Nc=l.memo(function({data:t}){let n=null;if(t.daylightHours!=null&&t.daylightMinutes!=null&&t.remainingHours!=null&&t.remainingMinutes!=null){const u=t.daylightHours*60+t.daylightMinutes,d=t.remainingHours*60+t.remainingMinutes;u>0&&(n=1-d/u)}const a=t.isEvening?t.setTime:t.riseTime,r=t.isEvening?t.riseTime:t.setTime,i=t.isEvening?"Sunset":"Sunrise",o=t.isEvening?"Sunrise":"Sunset";return e.jsxs(Z,{compact:!0,children:[e.jsx(jc,{progress:n}),e.jsxs("div",{className:"flex justify-between items-center mb-1.5",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[9px] text-fg-muted uppercase",children:i}),e.jsx("span",{className:"text-xs text-fg-primary font-medium tabular-nums",children:a??"—"})]}),e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("span",{className:"text-[9px] text-fg-muted uppercase",children:o}),e.jsx("span",{className:"text-xs text-fg-primary font-medium tabular-nums",children:r??"—"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px]",children:[t.daylightHours!=null&&e.jsxs("span",{className:"text-fg-muted",children:["Daylight: ",e.jsxs("span",{className:"text-fg-primary font-medium tabular-nums",children:[t.daylightHours,"h ",t.daylightMinutes,"m"]})]}),t.remainingHours!=null&&e.jsxs("span",{className:"text-sys-amber",children:["Remaining: ",e.jsxs("span",{className:"font-medium tabular-nums",children:[t.remainingHours,"h ",t.remainingMinutes,"m"]})]})]}),(t.azimuth!=null||t.altitude!=null)&&e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[10px] text-fg-muted tabular-nums",children:[t.azimuth!=null&&e.jsxs("span",{children:["Az: ",t.azimuth.toFixed(1),"°"]}),t.altitude!=null&&e.jsxs("span",{children:["Alt: ",t.altitude.toFixed(1),"°"]})]})]})}),wc=l.memo(function({data:t}){return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-2",children:[e.jsx("span",{className:"text-3xl leading-none",children:t.phaseEmoji}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-fg-primary font-medium",children:t.phaseName}),t.illumination!=null&&e.jsxs("div",{className:"text-[11px] text-fg-muted tabular-nums",children:[t.illumination.toFixed(1),"% illuminated"]})]})]}),e.jsxs("div",{className:"flex gap-4 mb-1.5 text-[10px]",children:[t.riseTime&&e.jsxs("span",{className:"text-fg-muted",children:["Rise: ",e.jsx("span",{className:"text-fg-primary font-medium tabular-nums",children:t.riseTime})]}),t.setTime&&e.jsxs("span",{className:"text-fg-muted",children:["Set: ",e.jsx("span",{className:"text-fg-primary font-medium tabular-nums",children:t.setTime})]})]}),(t.nextFullMoon||t.nextNewMoon)&&e.jsxs("div",{className:"flex gap-3 text-[10px] text-fg-muted",children:[t.nextFullMoon&&e.jsxs("span",{children:["🌕 ",t.nextFullMoon]}),t.nextNewMoon&&e.jsxs("span",{children:["🌑 ",t.nextNewMoon]})]}),(t.azimuth!=null||t.altitude!=null)&&e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[10px] text-fg-muted tabular-nums",children:[t.azimuth!=null&&e.jsxs("span",{children:["Az: ",t.azimuth.toFixed(1),"°"]}),t.altitude!=null&&e.jsxs("span",{children:["Alt: ",t.altitude.toFixed(1),"°"]})]})]})}),kc=l.memo(function({data:t}){return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"text-sm font-semibold text-fg-primary mb-2 flex items-center gap-1.5",children:[e.jsx("span",{className:"text-base leading-none",children:"🛰"}),t.satName]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2 text-[11px]",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-fg-muted",children:"Rise"}),e.jsx("div",{className:"text-fg-primary font-medium tabular-nums",children:t.riseTime}),e.jsx("div",{className:"text-fg-muted",children:t.startAz})]}),e.jsxs("div",{className:"flex flex-col items-center flex-1",children:[e.jsxs("div",{className:"text-[10px] font-semibold tabular-nums",style:{color:t.maxEl>=60?"var(--sys-green)":t.maxEl>=30?"var(--sys-amber)":"var(--sys-red)"},children:[t.maxEl,"° max"]}),e.jsx("div",{className:"w-full h-px my-0.5",style:{background:"var(--edge-subtle)"}})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-fg-muted",children:"Set"}),e.jsx("div",{className:"text-fg-primary font-medium tabular-nums",children:t.setTime}),e.jsx("div",{className:"text-fg-muted",children:t.endAz})]})]}),e.jsxs("div",{className:"text-[10px] text-fg-muted tabular-nums",children:["Duration: ",e.jsx("span",{className:"text-fg-primary font-medium",children:t.duration})]})]})});function Cc(s){return s<=1?"var(--sys-green)":s<=3?"var(--sys-lime)":s<=4?"var(--sys-amber)":s<=6?"var(--sys-orange)":"var(--sys-red)"}const Sc=l.memo(function({data:t}){const n=Cc(t.kpIndex);return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center text-lg font-bold",style:{background:n,color:"var(--zinc-950)"},children:t.kpIndex}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary",children:t.status}),e.jsx("div",{className:"text-[10px] text-fg-muted",children:"Kp Index"})]})]}),t.probability!=null&&e.jsxs("div",{className:"mb-1.5",children:[e.jsxs("div",{className:"flex justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"text-fg-muted",children:"Probability"}),e.jsxs("span",{className:"text-fg-primary font-medium tabular-nums",children:[t.probability,"%"]})]}),e.jsx("div",{className:"w-full h-1.5 rounded-full",style:{background:"var(--edge-subtle)"},children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.min(t.probability,100)}%`,background:n}})})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-fg-muted",children:[t.location&&e.jsx("span",{children:t.location}),t.timestamp&&e.jsx("span",{className:"tabular-nums",children:t.timestamp})]})]})}),Ic=l.memo(function({data:t}){return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("span",{className:"text-base leading-none",children:"🎲"}),e.jsx("span",{className:"text-[11px] font-medium text-fg-muted",children:"Dice Roll"})]}),e.jsx("div",{className:"space-y-1.5",children:t.rolls.map((n,a)=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"text-fg-muted font-mono w-8 shrink-0",children:n.count>1?`${n.count}${n.dieType}`:n.dieType}),n.results.length>1?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-fg-primary tabular-nums",children:["[",n.results.join(", "),"]"]}),e.jsx("span",{className:"text-fg-muted",children:"="}),e.jsx("span",{className:"text-fg-primary font-semibold tabular-nums",children:n.total})]}):e.jsx("span",{className:"text-fg-primary font-semibold tabular-nums",children:n.total})]},a))}),t.grandTotal!=null&&t.rolls.length>1&&e.jsxs("div",{className:"mt-2 pt-1.5 flex items-center justify-between text-xs",style:{borderTop:"1px solid var(--edge-subtle)"},children:[e.jsx("span",{className:"text-fg-muted",children:"Total"}),e.jsx("span",{className:"text-fg-primary font-bold tabular-nums",children:t.grandTotal})]})]})}),Ks=l.memo(function({data:t,isDadJoke:n}){const a=n?"🥸":"🎭";return e.jsx(Z,{compact:!0,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-lg leading-none shrink-0 mt-0.5",children:a}),e.jsx("div",{className:"min-w-0",children:t.isTwoPart?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed whitespace-pre-wrap break-words",children:t.setup}),e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed whitespace-pre-wrap break-words mt-2 pt-2 italic",style:{borderTop:"1px solid var(--edge-subtle)"},children:t.delivery})]}):e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed whitespace-pre-wrap break-words",children:t.text})})]})})}),_c=l.memo(function({data:t}){return e.jsx(Z,{compact:!0,children:e.jsx("div",{className:"space-y-1.5",children:t.games.map((n,a)=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",style:a>0?{borderTop:"1px solid var(--edge-subtle)",paddingTop:"6px"}:void 0,children:[e.jsx("span",{className:"text-sm leading-none shrink-0",children:n.sportEmoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-1",children:[e.jsx("span",{className:"text-fg-primary font-medium truncate",children:n.away}),n.awayScore!=null&&e.jsx("span",{className:"text-fg-primary font-bold tabular-nums",children:n.awayScore})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-1",children:[e.jsx("span",{className:"text-fg-primary font-medium truncate",children:n.home}),n.homeScore!=null&&e.jsx("span",{className:"text-fg-primary font-bold tabular-nums",children:n.homeScore})]})]}),e.jsxs("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded shrink-0 tabular-nums",style:{color:n.isLive?"var(--sys-green)":n.isFinal?"var(--fg-muted)":"var(--sys-blue)",background:n.isLive?"color-mix(in srgb, var(--sys-green) 12%, transparent)":n.isFinal?"color-mix(in srgb, var(--fg-muted) 10%, transparent)":"color-mix(in srgb, var(--sys-blue) 12%, transparent)"},children:[n.isLive&&e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full mr-1 align-middle",style:{background:"var(--sys-green)",animation:"pulse 2s ease-in-out infinite"}}),n.status]})]},a))})})}),Mc=l.memo(function({data:t}){var n;return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("span",{className:"text-sm leading-none",children:"📊"}),e.jsx("span",{className:"text-[11px] font-medium text-fg-muted",children:t.title??"Bot Stats"})]}),t.type==="basic"?e.jsxs("div",{className:"space-y-1 text-[11px]",children:[t.commands!=null&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-fg-muted",children:"Commands"}),e.jsx("span",{className:"text-fg-primary font-semibold tabular-nums",children:t.commands})]}),t.replies!=null&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-fg-muted",children:"Replies"}),e.jsx("span",{className:"text-fg-primary font-semibold tabular-nums",children:t.replies})]}),t.topCommand&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-fg-muted",children:"Top Cmd"}),e.jsx("span",{className:"text-fg-primary font-medium",children:t.topCommand})]}),t.topUser&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-fg-muted",children:"Top User"}),e.jsx("span",{className:"text-fg-primary font-medium",children:t.topUser})]})]}):e.jsx("div",{className:"space-y-1",children:(n=t.entries)==null?void 0:n.map(a=>{const r=t.entries[0].value,i=r>0?a.value/r*100:0;return e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsxs("span",{className:"text-fg-muted w-4 text-right tabular-nums shrink-0",children:[a.rank,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex justify-between mb-0.5",children:[e.jsx("span",{className:"text-fg-primary font-medium truncate",children:a.name}),e.jsx("span",{className:"text-fg-primary font-semibold tabular-nums shrink-0 ml-2",children:a.value})]}),e.jsx("div",{className:"w-full h-1 rounded-full",style:{background:"var(--edge-subtle)"},children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${i}%`,background:"var(--sys-blue)"}})})]})]},a.rank)})})]})}),Rc=l.memo(function({data:t}){return e.jsx(Z,{compact:!0,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-lg leading-none shrink-0 mt-0.5",children:"🐱"}),e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed whitespace-pre-wrap break-words",children:t})]})})});function Ec({text:s}){return e.jsx(Z,{compact:!0,children:e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed tracking-wide whitespace-pre-wrap break-words",children:dl(s)})})}const Pc=l.memo(function({text:t,messageType:n}){const a=l.useMemo(()=>n?Co(t,n):null,[t,n]);if(a)switch(n){case"weather":return e.jsx(tc,{data:a});case"weather-multiday":return e.jsx(sc,{data:a});case"weather-hourly":return e.jsx(nc,{data:a});case"weather-alert":return e.jsx(ic,{data:a});case"path":return e.jsx(dc,{data:a});case"test":return e.jsx(xc,{data:a});case"aqi":return e.jsx(fc,{data:a});case"solar":return e.jsx(yc,{data:a});case"hfcond":return e.jsx(vc,{data:a});case"sun":return e.jsx(Nc,{data:a});case"moon":return e.jsx(wc,{data:a});case"satpass":return e.jsx(kc,{data:a});case"aurora":return e.jsx(Sc,{data:a});case"dice":return e.jsx(Ic,{data:a});case"joke":return e.jsx(Ks,{data:a});case"dadjoke":return e.jsx(Ks,{data:a,isDadJoke:!0});case"sports":return e.jsx(_c,{data:a});case"stats":return e.jsx(Mc,{data:a});case"catfact":return e.jsx(Rc,{data:a})}return e.jsx(Ec,{text:t})}),Tc=l.lazy(()=>fn(()=>import("./CompanionPathMap-DEvrWwCv.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(s=>({default:s.CompanionPathMap}))),$c=l.lazy(()=>fn(()=>import("./CompanionEchoMap-Hp02AMdw.js"),__vite__mapDeps([10,1,2,3,7,8,9])).then(s=>({default:s.CompanionEchoMap}))),qs=e.jsx("div",{className:"rounded-lg bg-elevated flex items-center justify-center",style:{aspectRatio:"16 / 10"},children:e.jsx("div",{className:"w-4 h-4 border-2 border-fg-muted/30 border-t-fg-muted rounded-full animate-spin"})});function Ac(s){const t=new Date(s*1e3),a=Math.floor((new Date().getTime()-t.getTime())/864e5);return a===0?"Today":a===1?"Yesterday":t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Fc(s){const t=new Date(s*1e3);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function Oc(s){const t=new Map;for(const n of s)n.name&&t.set(n.public_key,n.name);return t}function Dc(s){const t=new Map;for(const n of s)t.set(n.public_key,n);return t}function Lc(s){if(!s)return[];const t=[];for(let n=0;na.public_key.startsWith(s));return(n==null?void 0:n.name)||null}function Vs(s,t){return s.is_outgoing?"You":s.sender_name?s.sender_name:t.get(s.sender_key)??s.sender_key.slice(0,8)}const Hc=new Set(["🎭","🥸"]);function Bc({senderName:s,timestamp:t,signed:n,children:a}){const{emoji:r,cleanName:i}=yt(s),o=bt(i),u=vt(s);return e.jsxs("div",{className:"group flex items-start gap-4 w-full p-2",children:[e.jsxs("div",{className:"flex-shrink-0 w-9 flex flex-col items-center gap-1",children:[e.jsx("div",{className:E("clay-avatar w-9 h-9",r?"text-lg":"text-white text-[13px] font-bold tracking-tight"),style:{"--avatar-color":o},children:r||u}),e.jsx("span",{className:"text-xs text-chat-timestamp tabular-nums h-4 leading-4",children:ul(t)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 -mt-[3px] mb-1",children:[e.jsx("span",{className:"text-[13px] font-normal text-chat-incoming-name truncate leading-tight tabular-nums",children:i}),n&&e.jsxs("svg",{className:"w-3.5 h-3.5 text-sys-green flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("title",{children:"Ed25519 signed message"}),e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"}),e.jsx("polyline",{points:"9 12 11 14 15 10"})]})]}),e.jsx("div",{className:"flex items-end gap-1.5 min-w-0",children:a})]})]})}const Wc=l.memo(function({msg:t,contact:n,contacts:a,selfInfo:r,echoCount:i,channelName:o,allMessages:u,children:d}){const[f,c]=l.useState(!1),[x,y]=l.useState(!1),[g,m]=l.useState(0),j=l.useRef(null),k=t.path_len,h=!t.is_outgoing,w=h&&k!=null,I=t.is_outgoing&&t.is_channel&&(i??0)>0,R=(o==null?void 0:o.toLowerCase().includes("wardrive"))??!1,v=l.useMemo(()=>R&&h?$l(t.text):null,[R,h,t.text]),S=w||I,T=l.useMemo(()=>{const C=[];if(t.path_hops&&t.path_hops.length>0)C.push({hops:t.path_hops,snr:t.path_snr,rssi:t.path_rssi});else if(h&&(n!=null&&n.out_path)){const D=Lc(n.out_path);D.length>0&&C.push({hops:D})}if(t.alternate_paths)for(const D of t.alternate_paths)C.push(D);return C},[t.path_hops,t.path_snr,t.path_rssi,t.alternate_paths,h,n==null?void 0:n.out_path]),M=g1,_=(p==null?void 0:p.snr)??t.msg_snr,b=()=>{y(!0),c(C=>!C)},L=l.useCallback(C=>{var D;C.propertyName==="grid-template-rows"&&(f?(D=j.current)==null||D.scrollIntoView({block:"nearest",behavior:"smooth"}):y(!1))},[f]);return e.jsxs("div",{ref:j,className:E("rounded-xl px-2 py-1 -mx-2 transition-colors duration-150",S&&"hover:bg-subtle-fill cursor-pointer"),onClick:()=>S&&b(),children:[d,S&&e.jsx("div",{className:"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.83,0,0.17,1)]",style:{gridTemplateRows:f?"1fr":"0fr"},onTransitionEnd:L,children:e.jsxs("div",{className:"overflow-hidden",children:[x&&w&&e.jsxs("div",{className:"mt-1.5 ml-13 space-y-1",children:[N&&e.jsx("div",{className:"flex items-center gap-1 flex-wrap",onClick:C=>C.stopPropagation(),children:T.map((C,D)=>e.jsxs("button",{onClick:()=>m(D),className:E("flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] transition-colors",D===M?"bg-sys-blue/15 text-sys-blue font-semibold":"bg-subtle-fill text-fg-muted hover:text-fg-secondary"),children:[e.jsx(Je,{className:"w-2.5 h-2.5"}),C.hops.length||k,C.snr!=null&&e.jsxs("span",{className:"ml-0.5 opacity-70",children:[C.snr>0?"+":"",C.snr.toFixed(1)]})]},D))}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx(Je,{className:"w-3 h-3 text-fg-muted flex-shrink-0"}),k===0&&!p?e.jsx("span",{className:"text-[10px] text-fg-muted font-medium",children:"Direct"}):p&&p.hops.length>0?p.hops.map((C,D)=>{const $=zc(C,a);return e.jsxs("span",{className:"contents",children:[D>0&&e.jsx(Fl,{className:"w-2.5 h-2.5 text-fg-muted/50 flex-shrink-0"}),e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded bg-subtle-fill text-[10px]",children:[e.jsx("span",{className:"font-mono text-fg-primary",children:C}),$&&e.jsxs("span",{className:"text-fg-muted",children:["(",$,")"]})]})]},D)}):e.jsxs("span",{className:"text-[10px] text-fg-muted font-medium",children:[k," hop",k>1?"s":""]}),_!=null&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-fg-muted ml-0.5",children:[e.jsx(pl,{className:"w-2.5 h-2.5"}),_>0?"+":"",_.toFixed(1),"dB"]}),(p==null?void 0:p.rssi)!=null&&e.jsxs("span",{className:"text-[10px] text-fg-muted",children:[p.rssi,"dBm"]})]}),p&&p.hops.length>=1&&e.jsx(l.Suspense,{fallback:qs,children:e.jsx(Tc,{hops:p.hops,contacts:a,selfInfo:r,snr:_,wardriveCoords:v??void 0,wardriveSenderName:t.sender_name,channelMessages:R?u:void 0,messageTimestamp:t.timestamp})})]}),x&&I&&e.jsx("div",{className:"mt-1.5",children:e.jsx(l.Suspense,{fallback:qs,children:e.jsx($c,{text:t.text,timestamp:t.timestamp,contacts:a})})})]})})]})}),Uc=l.memo(function({messages:t,contacts:n,className:a,conversationKey:r,onRetry:i,onRetryAsFlood:o,onMentionClick:u,historyLoading:d,historyExhausted:f,onLoadOlder:c,channelName:x,contactPubKey:y}){const g=l.useRef(null),m=l.useRef(null),[j,k]=l.useState(!1),h=l.useRef(t.length),w=l.useRef(0),I=l.useRef(r);l.useEffect(()=>{if(r!==I.current){I.current=r,h.current=t.length,w.current=0,k(!1);const $=g.current;$&&($.scrollTop=$.scrollHeight)}},[r,t.length]);const R=l.useMemo(()=>Oc(n),[n]),v=l.useMemo(()=>Dc(n),[n]),S=gt(),T=qo(t),M=ia(y??""),p=y?v.get(y):void 0,N=l.useMemo(()=>{if(!p)return!1;const $=t.filter(G=>!G.is_outgoing).slice(-5).map(G=>G.text);return So(p.name,M,$)},[p,M,t]),{combinedTexts:_,skipIds:b}=l.useMemo(()=>{const $=new Map,G=new Set;for(let F=0;F3)continue;const H=[...q.text][0];if(!H||!Hc.has(H)||[...X.text][0]!==H)continue;const A=X.text.slice(H.length).trimStart();$.set(q.id,q.text+` +`).map(a=>a.trim()).filter(Boolean),n=[];for(const a of t){let r="";for(const d of No)if(a.startsWith(d)){r=d;break}if(!r)continue;const i=a.slice(r.length).trim(),o=i.match(/^(.+?)\s+(\d+)\s*[-–]\s*(.+?)\s+(\d+)\s*\((.+)\)$/);if(o){const d=o[5].trim(),f=/final/i.test(d),c=!f&&/\d/.test(d);n.push({sportEmoji:r,away:o[1].trim(),home:o[3].trim(),awayScore:parseInt(o[2],10),homeScore:parseInt(o[4],10),status:d,isLive:c,isFinal:f});continue}const u=i.match(/^(.+?)\s*[-–]\s*(.+?)\s*\((.+)\)$/);u&&n.push({sportEmoji:r,away:u[1].trim(),home:u[2].trim(),status:u[3].trim(),isLive:!1,isFinal:!1})}return n.length>=1?{games:n}:null}function ea(s){var f,c,x,y;const t=[],n=/^(\d+)\.\s+(.+?):\s*(\d+)/gm;let a;for(;(a=n.exec(s))!==null;)t.push({rank:parseInt(a[1],10),name:a[2].trim(),value:parseInt(a[3],10)});if(t.length>=2){const g=s.match(/^(.+?)\n/i);return{type:"leaderboard",entries:t,title:(f=g==null?void 0:g[1])==null?void 0:f.replace(/📊\s*/,"").trim()}}const r=s.match(/Cmds?:\s*(\d+)/i),i=s.match(/Replies?:\s*(\d+)/i);if(!r&&!i)return null;const o=s.match(/Top\s*Cmd:\s*(.+?)\s*\(/i),u=s.match(/Top\s*User:\s*(.+?)\s*\(/i),d=s.match(/^(.+?)\n/i);return{type:"basic",commands:r?parseInt(r[1],10):void 0,replies:i?parseInt(i[1],10):void 0,topCommand:(c=o==null?void 0:o[1])==null?void 0:c.trim(),topUser:(x=u==null?void 0:u[1])==null?void 0:x.trim(),title:(y=d==null?void 0:d[1])==null?void 0:y.replace(/📊\s*/,"").trim()}}const wo=new Set(["🐱","🐈","😺","😸","😹","😻","😼","😽","🙀","😿","😾","🐾","👂","🐟","🧶","🥛"]);function ta(s){if(!/\bcats?\b/i.test(s))return null;const t=s.slice(-4);for(const n of wo)if(t.includes(n))return s;return null}const ko=[{type:"dice",test:Dn},{type:"joke",test:Ln},{type:"dadjoke",test:zn},{type:"magic8",test:Hn},{type:"weather-alert",test:Bn},{type:"satpass",test:Xn},{type:"aurora",test:Yn},{type:"moon",test:Qn},{type:"sun",test:Jn},{type:"hfcond",test:Vn},{type:"solar",test:qn},{type:"aqi",test:Kn},{type:"sports",test:Zn},{type:"stats",test:ea},{type:"path",test:Gn},{type:"weather-multiday",test:Wn},{type:"weather-hourly",test:Un},{type:"test",test:On},{type:"weather",test:Fn},{type:"catfact",test:ta}];function sa(s){for(const{type:t,test:n}of ko)if(n(s)!=null)return t;return null}function Co(s,t){switch(t){case"weather":return Fn(s);case"weather-multiday":return Wn(s);case"weather-hourly":return Un(s);case"weather-alert":return Bn(s);case"test":return On(s);case"path":return Gn(s);case"aqi":return Kn(s);case"solar":return qn(s);case"hfcond":return Vn(s);case"sun":return Jn(s);case"moon":return Qn(s);case"satpass":return Xn(s);case"aurora":return Yn(s);case"dice":return Dn(s);case"joke":return Ln(s);case"dadjoke":return zn(s);case"magic8":return Hn(s);case"sports":return Zn(s);case"stats":return ea(s);case"catfact":return ta(s);default:return null}}const na=/[\u{1F916}\u{1F9BE}\u{1F9BF}]/u;function So(s,t,n){if(t==="bot")return!0;if(t==="not-bot")return!1;if(na.test(s)||/bot\b/i.test(s))return!0;if(n&&n.length>0){let a=0;const r=n.slice(-5);for(const i of r)sa(i)!=null&&a++;if(a>=Math.ceil(r.length*.6))return!0}return!1}function aa(s){return na.test(s)||/bot\b/i.test(s)}const ra="pymc_howl_bot_overrides";function Io(){try{const s=localStorage.getItem(ra);if(!s)return new Map;const t=JSON.parse(s);return new Map(t)}catch{return new Map}}function zs(s){try{localStorage.setItem(ra,JSON.stringify([...s]))}catch{}}const la=gr(s=>({overrides:Io(),setOverride:(t,n)=>s(a=>{const r=new Map(a.overrides);return r.set(t,n),zs(r),{overrides:r}}),clearOverride:t=>s(n=>{const a=new Map(n.overrides);return a.delete(t),zs(a),{overrides:a}})}));function ia(s){return la(t=>t.overrides.get(s))}function _o(){return la(s=>s.setOverride)}const oa="pymc_companion_contacts_micro",ca="pymc_companion_favorites",St=56;function Hs(){try{return localStorage.getItem(oa)==="1"}catch{return!1}}function Mo(s){try{localStorage.setItem(oa,s?"1":"0")}catch{}}function Ro(){try{const s=localStorage.getItem(ca);return s?new Set(JSON.parse(s)):new Set}catch{return new Set}}function Eo(s){try{localStorage.setItem(ca,JSON.stringify([...s]))}catch{}}function Po({name:s,pubkey:t,advType:n,size:a="md",signal:r}){const i=(n??0)&15,o=a==="sm"?"w-5 h-5":"w-6 h-6",u=a==="sm"?"size-3":"size-3.5";if(i===2){const x=r&&r.rssi!==0,y=x?`RSSI: ${r.rssi} dBm · SNR: ${r.snr.toFixed(1)} dB${r.rtt_ms!=null?` · RTT: ${r.rtt_ms} ms`:""}`:void 0;return e.jsx("div",{className:E(o,"relative rounded-full flex items-center justify-center flex-shrink-0 ring-[1.5px]",x?"ring-transparent":"ring-sys-blue"),title:y,children:x?e.jsx(ml,{rssi:r.rssi,snr:r.snr,compact:!0,showValues:!1}):e.jsx(Ke,{className:E(u,"text-sys-blue")})})}if(i===3)return e.jsx("div",{className:E(o,"relative rounded-full flex items-center justify-center flex-shrink-0 ring-[1.5px] ring-sys-pink"),children:e.jsx(ht,{className:E(u,"text-sys-pink")})});if(!s)return e.jsx("div",{className:E(o,"relative rounded-full bg-sys-blue/12 flex items-center justify-center flex-shrink-0"),children:e.jsx("span",{className:"text-sys-blue font-mono text-[10px] font-bold",children:t.slice(0,4)})});const{emoji:d}=yt(s),f=bt(s),c=vt(s);return e.jsx("div",{className:E(o,"relative clay-avatar",d?"text-base":"text-white text-[11px] font-bold"),style:{"--avatar-color":f},children:d||c})}const Bs=[{key:"companion",label:"Companions",icon:je,color:"text-sys-blue"},{key:"room",label:"Room Servers",icon:ht,color:"text-sys-pink"},{key:"repeater",label:"Repeaters",icon:Ke,color:"text-sys-blue"}];function To(s){const t=(s.adv_type??0)&15;return t===3?"room":t===2?"repeater":"companion"}const $o=4e3,Ao=5e3,Fo=2e3,Oo=8,Do=l.forwardRef(function({contact:t,isActive:n,unread:a,lastMsg:r,isFav:i,microContent:o,onSelect:u,onShowDetails:d,onShareContact:f,onResetPath:c,onRemoveContact:x,onPingContact:y,repeaterNeighborHashes:g,repeaterSignal:m,toggleFavorite:j},k){const h=yr(t.public_key),w=br(t.public_key),I=ia(t.public_key),R=_o(),v=I==="bot"||I==null&&aa(t.name||""),[S,T]=l.useState(!1),[M,p]=l.useState(!1),N=l.useRef(null),[_,b]=l.useState("idle"),L=l.useRef(!1),C=l.useRef(null),[D,$]=l.useState({w:0,h:0});l.useEffect(()=>{if(h)L.current=!0,b("idle");else if(L.current){L.current=!1;const O=re.getState().pingResults.get(t.public_key),W=O!=null&&O.rssi!==0;b(W?"success":"failed")}},[h,t.public_key]),l.useEffect(()=>{if(_==="idle")return;const W=setTimeout(()=>b("idle"),_==="success"?Ao:Fo);return()=>clearTimeout(W)},[_]);const G=(h||_!=="idle")&&!S;l.useEffect(()=>{if(!G)return;const O=C.current;if(!O)return;const W=()=>{const pe=O.offsetWidth,xe=O.offsetHeight;$(Ae=>Ae.w===pe&&Ae.h===xe?Ae:{w:pe,h:xe})};W();const J=new ResizeObserver(W);return J.observe(O),()=>J.disconnect()},[G]);const F=l.useCallback(()=>{T(!0),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>T(!1),$o)},[]),q=l.useCallback(()=>{T(!1),N.current&&clearTimeout(N.current)},[]),X=l.useCallback(async()=>{x&&(N.current&&clearTimeout(N.current),p(!0),await x(t.public_key),p(!1),T(!1))},[x,t.public_key]),H=l.useMemo(()=>{const O=w&&w.rssi!==0,W=m&&m.rssi!==0;if(!O&&!W)return null;if(O&&!W)return{rssi:w.rssi,snr:w.snr_db,rtt_ms:w.rtt_ms};if(!O&&W)return{rssi:m.rssi,snr:m.snr};const J=m.advertCount,pe=3,xe=J+pe;return{rssi:Math.round((m.rssi*J+w.rssi*pe)/xe),snr:(m.snr*J+w.snr_db*pe)/xe,rtt_ms:w.rtt_ms}},[w,m]),A=l.useCallback(O=>{C.current=O,typeof k=="function"?k(O):k&&(k.current=O)},[k]),z=S?"":_==="success"?"bg-sys-green/5":_==="failed"?"bg-sys-red/5":h?"bg-sys-blue/5":n?"bg-sys-blue":"hover:bg-elevated";return e.jsxs(me.div,{ref:A,layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:ue.fade,className:E("group relative w-full flex items-center gap-2.5 px-2.5 py-[3px] radius-inner overflow-hidden","transition-[background-color,box-shadow] duration-150",z),children:[e.jsx(ve,{children:G&&D.w>0&&(_!=="idle"?e.jsx(me.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{opacity:{duration:.15}},className:E("absolute inset-0 radius-inner ring-2 ring-inset pointer-events-none z-[2]",_==="success"?"ring-sys-green":"ring-sys-red")},`ping-${_}`):e.jsx(vr,{borderRadius:Oo,width:D.w,height:D.h,color:"blue"},"ping-crawl"))}),e.jsxs("div",{className:"grid flex-1 min-w-0 [&>*]:col-start-1 [&>*]:row-start-1",children:[e.jsxs("div",{className:E("flex items-center gap-2.5",S&&!o&&"invisible pointer-events-none"),children:[e.jsxs("button",{onClick:()=>u({type:"contact",id:t.public_key}),className:"flex items-center gap-2.5 flex-1 min-w-0 text-left",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Po,{name:t.name,pubkey:t.public_key,advType:t.adv_type,signal:H}),a>0&&e.jsx("span",{className:"absolute -top-0.5 -right-0.5 h-2.5 w-2.5 rounded-full bg-sys-red ring-2 ring-body"}),v&&!a&&e.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 flex items-center justify-center w-3 h-3 rounded-full bg-sys-violet ring-[1.5px] ring-body",title:"HOWL Bot",children:e.jsx(Ds,{className:"w-2 h-2 text-white"})})]}),!o&&e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("span",{className:E("text-sm truncate flex-1",n?"text-white font-medium":i?"text-sys-amber font-bold":"text-fg-primary font-medium"),children:t.name||t.public_key.slice(0,12)+"…"})}),_==="success"&&w?e.jsxs("div",{className:"text-[11px] text-sys-green font-medium truncate tabular-nums",children:[w.rssi," dBm · ",w.snr_db.toFixed(1)," dB",w.rtt_ms!=null&&` · ${w.rtt_ms} ms`]}):_==="failed"?e.jsx("div",{className:"text-[11px] text-sys-red font-medium truncate",children:"No response"}):r?e.jsx("div",{className:E("text-[11px] truncate",n?"text-white/70":"text-fg-muted"),children:r.text}):null]})]}),!o&&e.jsx("div",{className:"relative flex-shrink-0 w-[18px] h-[18px] flex items-center justify-center",children:e.jsx(ui,{as:"div",className:"absolute inset-0",children:({open:O})=>e.jsxs(e.Fragment,{children:[e.jsx(En,{className:E("absolute inset-0 flex items-center justify-center rounded transition-[opacity,background-color] duration-100","focus:outline-none",n?"hover:bg-white/15":"hover:bg-subtle-fill",O?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":"Contact options",children:e.jsx(Ai,{className:E("h-3.5 w-3.5 transition-colors",n?"text-white/60 hover:text-white":"text-fg-muted hover:text-sys-blue")})}),e.jsxs(Pn,{anchor:"right start",transition:!0,className:E("min-w-[10rem] max-w-[20rem]","radius-inset p-1 ml-1","surface-elevated","focus:outline-none z-50","transition-[opacity,transform]","data-[closed]:opacity-0 data-[closed]:scale-[0.98] data-[closed]:translate-x-[-4px]","data-[enter]:duration-150 data-[leave]:duration-100","data-[enter]:ease-out data-[leave]:ease-in"),children:[e.jsx(ke,{icon:e.jsx(ct,{className:"w-4 h-4"}),onClick:()=>{d==null||d({type:"contact",id:t.public_key})},children:"Details"}),f&&e.jsx(ke,{icon:e.jsx(Ml,{className:"w-4 h-4"}),onClick:()=>f(t.public_key),children:"Share"}),e.jsx(ke,{icon:e.jsx(Je,{className:"w-4 h-4"}),onClick:()=>u({type:"contact",id:t.public_key}),children:"Set Path"}),c&&e.jsx(ke,{icon:e.jsx(jn,{className:"w-4 h-4"}),onClick:()=>c(t.public_key),children:"Reset Path"}),y&&e.jsx(ke,{icon:e.jsx(Ti,{className:"w-4 h-4"}),onClick:()=>y(t.public_key),disabled:!(g!=null&&g.has(t.public_key)),children:"Ping"}),x&&e.jsx(ke,{icon:e.jsx(Qe,{className:"w-4 h-4"}),destructive:!0,onClick:F,children:"Remove Contact"}),e.jsx(no,{}),e.jsx(ke,{icon:v?e.jsx(Mi,{className:"w-4 h-4 text-fg-muted"}):e.jsx(Ds,{className:"w-4 h-4 text-sys-violet"}),onClick:()=>R(t.public_key,v?"not-bot":"bot"),children:v?"Not a Bot":"Mark as HOWL Bot"}),e.jsx(ke,{icon:e.jsx(Ji,{className:E("w-4 h-4 group-data-[focus]:text-white group-data-[focus]:fill-white",i?"text-sys-amber fill-sys-amber":"text-fg-muted")}),onClick:()=>j(t.public_key),children:i?"Unfavorite":"Favorite"})]})]})})})]}),!o&&e.jsx("div",{className:E("flex items-center gap-1.5 self-center",!S&&"invisible pointer-events-none"),children:M?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"w-3.5 h-3.5 animate-spin rounded-full border-2 border-white border-t-transparent"})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:q,className:"flex-1 flex items-center justify-center py-1 radius-inner bg-zinc-500/80 hover:bg-zinc-500 depth-stroke-raised transition-colors",children:e.jsx("span",{className:"text-[11px] font-semibold text-white",children:"Cancel"})}),e.jsx("button",{onClick:X,className:"flex-1 flex items-center justify-center py-1 radius-inner bg-sys-red/80 hover:bg-sys-red depth-stroke-raised transition-colors",children:e.jsx(Qe,{className:"w-4 h-4 text-white"})})]})})]})]},t.public_key)}),Ws={excellent:4,good:3,fair:2,weak:1,poor:0};function Us(s,t,n){const a=t==null?void 0:t.get(s),r=a&&a.rssi!==0,i=n==null?void 0:n.get(s),o=i&&typeof i.rssi=="number"&&i.rssi!==0;if(!r&&!o)return null;if(o&&!r)return i.rssi;if(!o&&r)return a.rssi;const u=a.advertCount,d=3;return Math.round((a.rssi*u+i.rssi*d)/(u+d))}function Lo(s,t,n,a,r){return[...s].sort((i,o)=>{const u=t.has(i.public_key)?0:1,d=t.has(o.public_key)?0:1;if(u!==d)return u-d;if(n){const f=n.get(i.public_key),c=f&&f.length>0?f[f.length-1].timestamp:0,x=n.get(o.public_key),y=x&&x.length>0?x[x.length-1].timestamp:0;if(c!==y)return y-c}if(a){const f=Us(i.public_key,a,r),c=Us(o.public_key,a,r);if(f!=null&&c==null)return-1;if(f==null&&c!=null)return 1;if(f!=null&&c!=null){const x=Ws[Ps(f)]??0,y=Ws[Ps(c)]??0;if(x!==y)return y-x}}return(i.name||"").localeCompare(o.name||"")})}const zo=l.memo(l.forwardRef(function({contacts:t,selectedConversation:n,unreadMap:a,messages:r,onSelect:i,onShowDetails:o,onShareContact:u,onResetPath:d,onRemoveContact:f,onPingContact:c,repeaterNeighborHashes:x,repeaterSignalMap:y,isLoading:g,splitPercent:m=50,onMicroChange:j,className:k},h){const[w,I]=l.useState(Hs),[R,v]=l.useState(Hs),[S,T]=l.useState(""),[M,p]=l.useState(!1),[N,_]=l.useState(Ro),b=l.useRef(null),L=l.useRef(null),C=l.useCallback(A=>{L.current=A,typeof h=="function"?h(A):h&&(h.current=A)},[h]),D=l.useCallback(()=>{I(A=>{const z=!A;Mo(z);const O=L.current;if(z&&v(!0),O){let W=0;const J=O.parentElement;if(z)W=(J==null?void 0:J.offsetWidth)??O.offsetWidth;else if(J){const xe=J.style.width;J.style.width="var(--companion-side)",W=J.offsetWidth,J.style.width=xe}const pe=z?St:Math.round(m/100*W);lt(O,{width:`${pe}px`},{...ue.layoutResize,onComplete(){O.style.width=z?`${St}px`:`${m}%`,z||v(!1)}})}return j==null||j(z),z})},[m,j]),$=l.useCallback(A=>{_(z=>{const O=new Set(z);return O.has(A)?O.delete(A):O.add(A),Eo(O),O})},[]),G=M||S.length>0,F=l.useMemo(()=>{const A=new Set,z=t.filter(W=>A.has(W.public_key)?!1:(A.add(W.public_key),!0));if(!S.trim())return z;const O=S.toLowerCase();return z.filter(W=>{var J;return((J=W.name)==null?void 0:J.toLowerCase().includes(O))||W.public_key.toLowerCase().includes(O)})},[t,S]),q=re(A=>A.pingResults),X=l.useMemo(()=>{const A=new Map;for(const z of Bs)A.set(z.key,[]);for(const z of F)A.get(To(z)).push(z);return Bs.map(z=>({...z,items:Lo(A.get(z.key),N,r,z.key==="repeater"?y:void 0,z.key==="repeater"?q:void 0)})).filter(z=>z.items.length>0)},[F,N,r,y,q]),H=(n==null?void 0:n.type)==="contact"?n.id:null;return e.jsxs("div",{ref:C,className:E("flex-shrink-0 overflow-hidden flex flex-col h-full",k),style:{width:w?St:`${m}%`},children:[e.jsx("div",{className:E("flex items-center border-b border-edge-subtle flex-shrink-0",R?"justify-center p-2":"gap-2 px-3 py-2"),children:R?e.jsx("button",{onClick:D,className:"p-1 hover:bg-subtle-fill rounded transition-colors",title:"Expand contacts",children:e.jsx(Bi,{className:"w-3.5 h-3.5 text-fg-muted"})}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide flex-shrink-0",children:"Contacts"}),e.jsxs("div",{className:"flex items-center gap-1 ml-auto flex-shrink-0",children:[e.jsx("button",{onClick:()=>{G?(T(""),p(!1)):(p(!0),setTimeout(()=>{var A;return(A=b.current)==null?void 0:A.focus()},50))},className:E("p-1 rounded transition-colors flex-shrink-0",G?"bg-sys-blue/10 text-sys-blue":"hover:bg-subtle-fill text-fg-muted"),title:G?"Close search":"Search contacts",children:e.jsx(Ts,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:D,className:"p-1 hover:bg-subtle-fill rounded transition-colors flex-shrink-0",title:"Collapse contacts",children:e.jsx(zi,{className:"w-3.5 h-3.5 text-fg-muted"})})]})]})}),!R&&G&&e.jsxs("div",{className:"relative px-2.5 py-2 border-b border-edge-subtle/50 flex-shrink-0",children:[e.jsx(Ts,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-muted pointer-events-none"}),e.jsx("input",{ref:b,type:"text",value:S,onChange:A=>T(A.target.value),onFocus:()=>p(!0),onBlur:()=>p(!1),placeholder:"Search contacts…",className:"w-full pl-8 pr-8 py-1.5 text-sm radius-inner bg-input-bg border border-input-border text-fg-primary placeholder:text-fg-muted/50 ring-focus-inset hover:border-edge-strong transition-colors",autoFocus:!0}),e.jsx("button",{onClick:()=>{T(""),p(!1)},className:"absolute right-5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-subtle-fill rounded",children:e.jsx(ft,{className:"w-3.5 h-3.5 text-fg-muted"})})]}),g&&e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsx("div",{className:"w-5 h-5 animate-spin rounded-full border-2 border-sys-blue border-t-transparent"})}),!g&&e.jsxs("div",{className:E("flex-1 overflow-y-auto min-h-0",R?"px-0":"px-1.5"),style:{contain:"layout style paint"},children:[X.map(A=>{const z=A.icon;return e.jsxs(Re,{defaultOpen:!0,className:"mb-1",children:[e.jsxs(Ee,{className:E("px-2 py-1 flex items-center gap-1.5 w-full","text-left radius-inner hover:bg-subtle-fill-strong transition-colors"),children:[e.jsx(z,{className:E("w-3.5 h-3.5",A.color)}),!R&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:A.label}),e.jsx("span",{className:"type-data-xs text-fg-muted/50 ml-auto",children:A.items.length})]})]}),e.jsx(Pe,{children:e.jsx(ve,{initial:!1,mode:"popLayout",children:A.items.map(O=>e.jsx(Do,{contact:O,isActive:H===O.public_key,unread:a.get(O.public_key)??0,lastMsg:(()=>{const W=r.get(O.public_key);return W&&W.length>0?W[W.length-1]:void 0})(),isFav:N.has(O.public_key),microContent:R,onSelect:i,onShowDetails:o,onShareContact:u,onResetPath:d,onRemoveContact:f,onPingContact:c,repeaterNeighborHashes:x,repeaterSignal:y==null?void 0:y.get(O.public_key),toggleFavorite:$},O.public_key))})})]},A.key)}),F.length===0&&e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-sm text-fg-muted",children:S?"No matches":"No contacts yet"})})]})]})}));function Ho({open:s,onClose:t}){const n=re(p=>p.discoverImportableChannels),a=re(p=>p.getEmptyChannelSlots),r=re(p=>p.importChannel),i=re(p=>p.refreshChannels),[o,u]=l.useState("discover"),[d,f]=l.useState([]),[c,x]=l.useState([]),[y,g]=l.useState(null),m=l.useRef(!1);l.useEffect(()=>{if(!s)return;u("discover"),f([]),x([]),g(null),m.current=!1;let p=!1;return(async()=>{try{const[N,_]=await Promise.all([n(),a()]);if(p)return;if(x(_),N.length===0){g("No channels found in repeater history. Decoded messages may still be loading."),u("select");return}_.length===0&&g("No empty channel slots on device. Delete a channel first to make room."),f(N.map(b=>({name:b.name,alreadyOnDevice:b.alreadyOnDevice,selected:!b.alreadyOnDevice,status:"pending"}))),u("select")}catch(N){p||(g(N instanceof Error?N.message:"Discovery failed"),u("select"))}})(),()=>{p=!0}},[s,n,a]);const j=l.useCallback(p=>{f(N=>N.map(_=>_.name===p&&!_.alreadyOnDevice?{..._,selected:!_.selected}:_))},[]),k=l.useCallback(()=>{f(p=>p.map(N=>N.alreadyOnDevice?N:{...N,selected:!0}))},[]),h=l.useCallback(()=>{f(p=>p.map(N=>N.alreadyOnDevice?N:{...N,selected:!1}))},[]),w=l.useMemo(()=>d.filter(p=>!p.alreadyOnDevice).length,[d]),I=l.useMemo(()=>d.filter(p=>p.selected&&!p.alreadyOnDevice).length,[d]),R=l.useMemo(()=>d.filter(p=>p.status==="done").length,[d]),v=l.useMemo(()=>d.filter(p=>p.status==="failed").length,[d]),S=l.useCallback(async()=>{u("import"),m.current=!1;const p=d.filter(_=>_.selected&&!_.alreadyOnDevice),N=[...c];for(const _ of p){if(m.current)break;const b=N.shift();if(b===void 0){f(C=>C.map(D=>D.name===_.name&&D.status==="pending"?{...D,status:"failed"}:D));continue}f(C=>C.map(D=>D.name===_.name?{...D,status:"sending"}:D)),await new Promise(C=>setTimeout(C,150));const L=await r(_.name,b);f(C=>C.map(D=>D.name===_.name?{...D,status:L?"done":"failed"}:D)),L||N.unshift(b),m.current||await new Promise(C=>setTimeout(C,300))}await i(),u("complete")},[d,c,r,i]),T=l.useCallback(()=>{m.current=!0},[]),M=p=>{switch(p){case"pending":return e.jsx($n,{className:"w-3.5 h-3.5 text-fg-muted"});case"sending":return e.jsx(ce,{className:"w-3.5 h-3.5 text-sys-blue animate-spin"});case"done":return e.jsx(Ne,{className:"w-3.5 h-3.5 text-sys-green"});case"failed":return e.jsx(ft,{className:"w-3.5 h-3.5 text-sys-red"})}};return e.jsxs(Ce,{open:s,onClose:o==="import"?()=>{}:t,size:"sm",children:[e.jsx(Te,{icon:e.jsx(qe,{className:"w-5 h-5"}),title:"Import Channels",onClose:o==="import"?void 0:t}),e.jsxs(Se,{className:"!py-3 !px-0",children:[o==="discover"&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-8 px-6",children:[e.jsx(ce,{className:"w-6 h-6 text-sys-blue animate-spin"}),e.jsx("p",{className:"text-sm text-fg-secondary",children:"Scanning repeater history…"}),e.jsx("p",{className:"text-[11px] text-fg-muted",children:"Waiting for decoded messages"})]}),o==="select"&&e.jsxs(e.Fragment,{children:[y&&e.jsxs("div",{className:"flex items-start gap-2 mx-4 mb-3 p-2.5 radius-inner bg-sys-amber/8 border border-sys-amber/20",children:[e.jsx(Ve,{className:"w-3.5 h-3.5 text-sys-amber flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-fg-secondary",children:y})]}),d.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-4 pb-2 border-b border-edge-subtle",children:[e.jsxs("span",{className:"text-[11px] text-fg-muted",children:[w," discoverable · ",c.length," slot",c.length!==1?"s":""," free"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:k,className:"text-[11px] text-sys-blue hover:underline",children:"All"}),e.jsx("span",{className:"text-fg-muted/40",children:"·"}),e.jsx("button",{onClick:h,className:"text-[11px] text-sys-blue hover:underline",children:"None"})]})]}),e.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:d.map(p=>e.jsxs("button",{onClick:()=>j(p.name),disabled:p.alreadyOnDevice,className:E("w-full flex items-center gap-3 px-4 py-2 transition-colors",p.alreadyOnDevice?"opacity-40 cursor-default":"hover:bg-subtle-fill"),children:[e.jsx("div",{className:E("w-4 h-4 rounded border flex items-center justify-center flex-shrink-0 transition-colors",p.alreadyOnDevice?"border-fg-muted/30 bg-fg-muted/10":p.selected?"border-sys-blue bg-sys-blue":"border-edge-subtle"),children:(p.selected||p.alreadyOnDevice)&&e.jsx(Ne,{className:"w-3 h-3 text-white"})}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(He,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-primary truncate",children:p.name})]}),p.alreadyOnDevice&&e.jsx("span",{className:"text-[10px] text-fg-muted bg-subtle-fill px-1.5 py-0.5 rounded flex-shrink-0",children:"on device"})]},p.name))})]})]}),(o==="import"||o==="complete")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-4 pb-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"text-[11px] text-fg-muted",children:o==="import"?"Importing channels…":"Import complete"}),e.jsxs("span",{className:"text-[11px] tabular-nums text-fg-secondary",children:[R+v," / ",d.filter(p=>p.selected&&!p.alreadyOnDevice).length]})]}),e.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:d.filter(p=>p.selected&&!p.alreadyOnDevice).map(p=>e.jsxs("div",{className:E("flex items-center gap-3 px-4 py-2",p.status==="sending"&&"bg-sys-blue/5",p.status==="done"&&"bg-sys-green/5",p.status==="failed"&&"bg-sys-red/5"),children:[e.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:M(p.status)}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(He,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:E("text-sm truncate",p.status==="done"?"text-fg-primary":"text-fg-secondary"),children:p.name})]}),e.jsx("span",{className:E("text-[10px] flex-shrink-0",p.status==="sending"&&"text-sys-blue",p.status==="done"&&"text-sys-green",p.status==="failed"&&"text-sys-red",p.status==="pending"&&"text-fg-muted"),children:p.status==="sending"?"sending…":p.status==="done"?"added":p.status==="failed"?"failed":"waiting"})]},p.name))})]})]}),e.jsxs($e,{children:[o==="select"&&e.jsxs(e.Fragment,{children:[e.jsx(U,{plain:!0,onClick:t,children:"Cancel"}),e.jsxs(U,{color:"primary",onClick:S,disabled:I===0||c.length===0,children:[e.jsx(qe,{className:"w-4 h-4"}),"Import ",I," ",I===1?"Channel":"Channels"]})]}),o==="import"&&e.jsx(U,{plain:!0,onClick:T,children:"Stop"}),o==="complete"&&e.jsxs(e.Fragment,{children:[v>0&&e.jsxs("span",{className:"text-xs text-sys-red flex items-center gap-1 mr-auto",children:[e.jsx(Ve,{className:"w-3.5 h-3.5"}),v," failed"]}),e.jsxs(U,{color:"primary",onClick:t,children:[e.jsx(El,{className:"w-4 h-4"}),"Done — ",R," imported"]})]})]})]})}const Bo=4e3;function Wo(s){const t=s.frequency_hz/1e3,n=s.bandwidth_hz/1e3;return`${t} · SF${s.spreading_factor} · ${n}k`}const Uo=l.forwardRef(function({channel:t,isActive:n,unread:a,lastMsg:r,isLoadingMessages:i,selfInfo:o,onSelect:u,onDeleteChannel:d},f){const[c,x]=l.useState(!1),[y,g]=l.useState(!1),m=l.useRef(null),j=l.useCallback(()=>{x(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>x(!1),Bo)},[]),k=l.useCallback(()=>{x(!1),m.current&&clearTimeout(m.current)},[]),h=l.useCallback(async()=>{d&&(m.current&&clearTimeout(m.current),g(!0),await d(t.index),g(!1),x(!1))},[d,t.index]),w=t.name.toLowerCase()==="public",I=d&&!w;return e.jsx(me.div,{ref:f,layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:ue.fade,className:E("group w-full flex items-center gap-2.5 px-2.5 py-1 radius-inner","transition-[background-color] duration-150",c?"":n?"bg-sys-blue":"hover:bg-subtle-fill-strong"),children:e.jsxs("div",{className:"grid flex-1 min-w-0 [&>*]:col-start-1 [&>*]:row-start-1",children:[e.jsxs("div",{className:E("flex items-center gap-2.5 min-w-0",c&&"invisible pointer-events-none"),children:[e.jsx("button",{onClick:()=>u({type:"channel",id:String(t.index)}),className:"flex items-center gap-2.5 flex-1 min-w-0 text-left",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:E("text-sm flex-shrink-0",n?"text-white font-semibold":r?"text-fg-primary font-semibold":"text-fg-secondary font-normal"),children:t.name}),w&&o&&e.jsx("span",{className:E("text-[9px] font-medium px-1.5 py-px rounded-full whitespace-nowrap truncate",n?"text-white/80 bg-white/15":"text-fg-muted/70 bg-subtle-fill"),children:Wo(o)})]}),r&&e.jsx("div",{className:E("text-[11px] truncate pl-2",n?"text-white/70":"text-fg-muted"),children:r.text})]})}),e.jsx("div",{className:"flex items-center flex-shrink-0",children:i?e.jsx("span",{className:"h-1.5 w-6 rounded-full bg-fg-muted/20 animate-pulse"}):I?e.jsxs("div",{className:"relative w-[18px] h-[18px] flex items-center justify-center",children:[a>0&&e.jsx("span",{className:"absolute inset-0 flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded-full bg-sys-red text-white text-[10px] font-bold leading-none group-hover:invisible transition-[visibility] duration-100",children:a>99?"99+":a}),e.jsx("button",{onClick:j,className:E("absolute inset-0 flex items-center justify-center rounded opacity-0 group-hover:opacity-100 transition-[opacity,background-color] duration-100",n?"hover:bg-white/15":"hover:bg-subtle-fill"),title:"Remove channel",children:e.jsx(Qe,{className:E("w-3 h-3 transition-colors",n?"text-white/60 hover:text-white":"text-fg-muted hover:text-sys-red")})})]}):a>0?e.jsx("span",{className:"min-w-[18px] h-[18px] px-1 rounded-full bg-sys-red text-white text-[10px] font-bold flex items-center justify-center leading-none",children:a>99?"99+":a}):null})]}),e.jsx("div",{className:E("flex items-center gap-1.5 self-center",!c&&"invisible pointer-events-none"),children:y?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"w-3.5 h-3.5 animate-spin rounded-full border-2 border-white border-t-transparent"})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:k,className:"flex-1 flex items-center justify-center py-1 radius-inner bg-zinc-500/80 hover:bg-zinc-500 depth-stroke-raised transition-colors",children:e.jsx("span",{className:"text-[11px] font-semibold text-white",children:"Cancel"})}),e.jsx("button",{onClick:h,className:"flex-1 flex items-center justify-center py-1 radius-inner bg-sys-red/80 hover:bg-sys-red depth-stroke-raised transition-colors",children:e.jsx(Qe,{className:"w-4 h-4 text-white"})})]})})]})})}),Go=l.memo(l.forwardRef(function({channels:t,selectedConversation:n,unreadMap:a,messages:r,onSelect:i,onAddChannel:o,onDeleteChannel:u,className:d},f){const c=jr(),x=gt(),[y,g]=l.useState(!1),m=l.useMemo(()=>{const k=new Set,h=t.filter(w=>k.has(w.index)?!1:(k.add(w.index),!0));return h.sort((w,I)=>{const R=w.name.toLowerCase()==="public",v=I.name.toLowerCase()==="public";if(R&&!v)return-1;if(!R&&v)return 1;const S=r.get(`ch:${w.index}`),T=S&&S.length>0?S[S.length-1].timestamp:0,M=r.get(`ch:${I.index}`),p=M&&M.length>0?M[M.length-1].timestamp:0;return T!==p?p-T:w.name.localeCompare(I.name)}),h},[t,r]),j=(n==null?void 0:n.type)==="channel"?n.id:null;return e.jsxs("div",{ref:f,className:E("flex-1 min-w-0 overflow-hidden flex flex-col h-full",d),children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-edge-subtle flex-shrink-0 overflow-hidden whitespace-nowrap",children:[e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide flex-shrink-0",children:"Channels"}),e.jsxs("div",{className:"flex items-center gap-1 ml-auto flex-shrink-0",children:[e.jsx("button",{onClick:()=>g(!0),className:"p-1 rounded hover:bg-subtle-fill transition-colors flex-shrink-0",title:"Import channels from repeater history",children:e.jsx(qe,{className:"w-3.5 h-3.5 text-fg-muted"})}),o&&e.jsx("button",{onClick:o,className:"p-1 rounded hover:bg-subtle-fill transition-colors flex-shrink-0",title:"Add channel",children:e.jsx(Xe,{className:"w-3.5 h-3.5 text-fg-muted"})})]})]}),e.jsx(Ho,{open:y,onClose:()=>g(!1)}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 px-1.5 py-1",style:{contain:"layout style paint"},children:m.length===0?e.jsxs("div",{className:"px-1.5 py-4 space-y-2",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"No channels"}),o&&e.jsxs("button",{onClick:o,className:"inline-flex items-center gap-1.5 px-2 py-1.5 text-xs font-medium text-sys-blue hover:bg-sys-blue/8 rounded transition-colors",children:[e.jsx(Xe,{className:"w-3.5 h-3.5"}),"Add Channel"]})]}):e.jsx(ve,{initial:!1,mode:"popLayout",children:m.map(k=>e.jsx(Uo,{channel:k,isActive:j===String(k.index),unread:a.get(`ch:${k.index}`)??0,lastMsg:(()=>{const h=r.get(`ch:${k.index}`);return h&&h.length>0?h[h.length-1]:void 0})(),isLoadingMessages:c,selfInfo:x,onSelect:i,onDeleteChannel:u},k.index))})})]})}));function Ko(s,t){const n=new Map;for(const[a,r]of s){const i=r.decoded;if(!(i!=null&&i.decrypted)||i.senderName!==t)continue;const o=i.timestamp??r.timestamp,u=Math.floor(o/30),d=`${i.text}:${u}`;n.has(d)||n.set(d,a)}return n}function qo(s){const t=gt(),n=Nr(),a=wr(),r=t==null?void 0:t.node_name,i=l.useMemo(()=>r?Ko(n,r):new Map,[n,r]);return l.useMemo(()=>{const o=new Map;if(!r||i.size===0)return o;const u=new Map;for(const c of s){if(!c.is_outgoing||!c.is_channel)continue;const x=Math.floor(c.timestamp/30);let y=!1;for(const g of[x-1,x,x+1]){const m=i.get(`${c.text}:${g}`);if(m){const j=u.get(m)??[];j.push(c.id),u.set(m,j),y=!0;break}}}if(u.size===0)return o;const d=new Set(u.keys()),f=new Map;for(const c of a)d.has(c.packet_hash)&&f.set(c.packet_hash,(f.get(c.packet_hash)??0)+1);for(const[c,x]of u){const y=f.get(c)??0,g=Math.max(0,y-1);for(const m of x)o.set(m,g)}return o},[s,r,i,a])}const Z=l.memo(function({children:t,className:n,bgClassName:a,hideBadge:r,compact:i}){return e.jsxs("div",{className:E("relative max-w-full animate-bot-widget-in","rounded-2xl rounded-tl-md overflow-hidden","ring-1 ring-inset ring-edge-subtle",a||"bg-chat-incoming",i?"px-3 py-2":"px-3.5 py-3",n),children:[!r&&e.jsx("span",{className:"absolute top-1.5 right-2 text-[9px] text-sys-indigo/50 select-none pointer-events-none",children:"🤖"}),t]})}),Vo=new Set(["☀️","🌤","🌤️"]),Jo=new Set(["⛅","⛅️"]),Qo=new Set(["☁️","🌫","🌫️"]),Xo=new Set(["🌧","🌧️","🌦","🌦️","⛈","⛈️","🌩","🌩️"]),Yo=new Set(["❄️","🌨","🌨️"]);function Zo(s){return Vo.has(s)?"bg-gradient-to-br from-[var(--sys-blue)]/20 to-[var(--sys-indigo)]/10":Jo.has(s)?"bg-gradient-to-br from-[var(--zinc-800)]/80 to-[var(--sys-blue)]/15":Qo.has(s)?"bg-gradient-to-br from-[var(--zinc-800)]/80 to-[var(--zinc-700)]/60":Xo.has(s)?"bg-gradient-to-br from-[var(--zinc-900)]/80 to-[var(--zinc-700)]/60":Yo.has(s)?"bg-gradient-to-br from-[var(--zinc-800)]/80 to-[var(--sys-cyan)]/10":"bg-gradient-to-br from-[var(--zinc-800)]/80 to-[var(--zinc-700)]/60"}function Ue({label:s}){return e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md bg-fg-primary/10 text-[10px] text-fg-primary/80 tabular-nums",children:s})}function ec({period:s}){return e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"text-fg-muted min-w-[56px]",children:s.label}),e.jsx("span",{className:"text-sm",children:s.conditionEmoji}),e.jsx("span",{className:"text-fg-primary/70",children:s.condition}),e.jsxs("span",{className:"text-fg-primary font-medium tabular-nums",children:[s.temp,s.unit]}),s.wind&&e.jsx("span",{className:"text-fg-muted tabular-nums",children:s.wind})]})}const tc=l.memo(function({data:t}){const n=t.periods[0],a=t.periods.slice(1),r=Zo(n.conditionEmoji);return e.jsxs(Z,{bgClassName:r,children:[e.jsx("div",{className:"text-[11px] text-fg-muted font-medium mb-1 pr-6",children:n.label}),e.jsxs("div",{className:"flex items-start gap-1.5 mb-2",children:[e.jsx("span",{className:"text-2xl leading-none",children:n.conditionEmoji}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsxs("span",{className:"text-3xl font-light text-fg-primary tabular-nums leading-none",children:[n.temp,"°"]}),e.jsx("span",{className:"text-xs text-fg-muted",children:n.unit.replace("°","")})]}),e.jsx("div",{className:"text-xs text-fg-primary/70 mt-0.5",children:n.condition})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-2",children:[n.wind&&e.jsx(Ue,{label:`💨 ${n.wind}`}),n.humidity&&e.jsx(Ue,{label:`💧 ${n.humidity}`}),n.dewPoint&&e.jsx(Ue,{label:`💧 ${n.dewPoint}`}),n.visibility&&e.jsx(Ue,{label:`👁️ ${n.visibility}`}),n.pressure&&e.jsx(Ue,{label:`📊 ${n.pressure}`})]}),n.high!=null&&n.low!=null&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] mb-2",children:[e.jsxs("span",{className:"text-fg-muted tabular-nums",children:["L ",n.low,"°"]}),e.jsx("div",{className:"flex-1 h-1 rounded-full bg-fg-primary/15 relative",children:e.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full bg-fg-primary/35",style:{width:n.high!==n.low?`${Math.max(0,Math.min(100,(n.temp-n.low)/(n.high-n.low)*100))}%`:"50%"}})}),e.jsxs("span",{className:"text-fg-primary/70 tabular-nums font-medium",children:["H ",n.high,"°"]})]}),a.length>0&&e.jsx("div",{className:"border-t border-edge-subtle pt-1.5 mt-1 space-y-0.5",children:a.map((i,o)=>e.jsx(ec,{period:i},o))})]})}),sc=l.memo(function({data:t}){return e.jsx(Z,{compact:!0,children:e.jsx("div",{className:"flex gap-3 overflow-x-auto pb-0.5 -mx-1 px-1 scrollbar-none",children:t.map((n,a)=>e.jsxs("div",{className:"flex flex-col items-center gap-1 flex-shrink-0 min-w-[52px]",children:[e.jsx("span",{className:"text-[11px] text-fg-muted font-medium",children:n.dayAbbrev}),e.jsx("span",{className:"text-lg leading-none",children:n.conditionEmoji}),e.jsx("span",{className:"text-[10px] text-fg-primary/70 text-center leading-tight",children:n.condition}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] tabular-nums",children:[n.high!=null&&e.jsxs("span",{className:"text-fg-primary font-medium",children:[n.high,"°"]}),n.low!=null&&e.jsxs("span",{className:"text-fg-muted",children:[n.low,"°"]})]})]},a))})})}),nc=l.memo(function({data:t}){return e.jsx(Z,{compact:!0,children:e.jsx("div",{className:"flex gap-2.5 overflow-x-auto pb-0.5 -mx-1 px-1 scrollbar-none",children:t.map((n,a)=>e.jsxs("div",{className:"flex flex-col items-center gap-0.5 flex-shrink-0 min-w-[44px]",children:[e.jsx("span",{className:"text-[10px] text-fg-muted font-medium tabular-nums",children:n.hour}),e.jsx("span",{className:"text-base leading-none",children:n.conditionEmoji}),e.jsxs("span",{className:"text-xs text-fg-primary font-medium tabular-nums",children:[n.temp,"°"]}),n.precipChance!=null&&n.precipChance>0&&e.jsxs("span",{className:E("text-[9px] tabular-nums font-medium",n.precipChance>=50?"text-sys-blue":"text-sys-blue/60"),children:[n.precipChance,"%"]})]},a))})})});function ac(s){if(!s)return"amber";const t=s.toUpperCase();return t.includes("EXTREME")||t.includes("TORNADO")||t.includes("HURRICANE")||t.includes("SEVERE")||t.includes("WARNING")?"red":"amber"}const rc={red:"border-l-sys-red",amber:"border-l-sys-amber"},lc={red:"text-sys-red",amber:"text-sys-amber"},ic=l.memo(function({data:t}){const n=ac(t.severity);return e.jsx(Z,{compact:!0,hideBadge:!0,children:e.jsxs("div",{className:E("border-l-[3px] pl-2.5 -ml-0.5",rc[n]),children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:"text-sm leading-none",children:"⚠️"}),t.severity&&e.jsx("span",{className:E("text-[10px] font-bold uppercase tracking-wider",lc[n]),children:t.severity})]}),e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed whitespace-pre-wrap break-words",children:t.headline}),t.body&&e.jsx("p",{className:"text-xs text-fg-muted mt-1 leading-relaxed whitespace-pre-wrap break-words",children:t.body})]})})}),oc={high:"🎯",medium:"📍",low:"❓"};function cc({hop:s}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-mono text-[11px] text-sys-blue font-bold tabular-nums min-w-[20px]",children:s.hex}),e.jsx("span",{className:"text-fg-muted/40 text-xs",children:"→"}),s.unknown?e.jsx("span",{className:"text-xs text-fg-muted/50 italic",children:"unknown"}):s.matchCount!=null?e.jsxs("span",{className:"text-xs text-sys-amber",children:[s.matchCount," matches"]}):e.jsxs("span",{className:E("text-xs font-medium truncate max-w-[140px]",s.confidence==="low"?"text-fg-muted":"text-fg-primary"),children:[s.name,s.confidence&&e.jsx("span",{className:"ml-0.5 text-[10px]",children:oc[s.confidence]})]})]})}const dc=l.memo(function({data:t}){return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1.5 pr-6",children:[e.jsx("span",{className:"text-[11px] font-medium text-fg-muted",children:"🛤️ Path"}),e.jsxs("span",{className:"text-[10px] text-fg-muted/60 tabular-nums",children:[t.hops.length," hop",t.hops.length!==1?"s":""]})]}),e.jsx("div",{className:"space-y-1",children:t.hops.map((n,a)=>e.jsx(cc,{hop:n},a))})]})});function uc(s){return s>=10?5:s>=6?4:s>=3?3:s>=0?2:s>=-5?1:0}function mc(s){return s>=4?"bg-sys-green":s>=3?"bg-sys-amber":s>=2?"bg-sys-orange":"bg-sys-red"}function pc({bars:s}){const t=mc(s);return e.jsx("div",{className:"flex items-end gap-[2px] h-[20px]",children:[6,10,14,18,20].map((n,a)=>e.jsx("div",{className:E("w-[4px] rounded-sm transition-colors",a0?"+":"",t.snr.toFixed(1),e.jsx("span",{className:"text-[10px] text-fg-muted font-normal ml-0.5",children:"dB"})]}),t.rssi!=null&&e.jsxs("span",{className:"text-[11px] text-fg-muted tabular-nums",children:[t.rssi," dBm"]})]})]}),(t.hops!=null||t.pathHops)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap mb-1.5",children:[t.hops!=null&&e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded bg-sys-blue/10 text-[10px] text-sys-blue font-semibold tabular-nums",children:[t.hops," hop",t.hops!==1?"s":""]}),t.pathHops&&t.pathHops.length>0&&e.jsx("div",{className:"flex items-center gap-0.5 text-[10px]",children:t.pathHops.map((a,r)=>e.jsxs("span",{className:"contents",children:[r>0&&e.jsx("span",{className:"text-fg-muted/40",children:"›"}),e.jsx("span",{className:"font-mono text-fg-muted",children:a})]},r))})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-[10px] text-fg-muted",children:[t.distance&&e.jsx("span",{className:"tabular-nums",children:t.distance}),t.receivedAt&&e.jsxs("span",{className:"tabular-nums",children:["@ ",t.receivedAt]}),t.elapsed&&e.jsx("span",{className:"tabular-nums",children:t.elapsed}),t.phrase&&e.jsxs("span",{className:"text-fg-muted/60 italic truncate max-w-[120px]",children:['"',t.phrase,'"']})]})]})});function hc(s){return s<=50?{text:"text-sys-green",bg:"bg-sys-green/10"}:s<=100?{text:"text-sys-amber",bg:"bg-sys-amber/10"}:s<=150?{text:"text-sys-orange",bg:"bg-sys-orange/10"}:s<=200?{text:"text-sys-red",bg:"bg-sys-red/10"}:s<=300?{text:"text-sys-violet",bg:"bg-sys-violet/10"}:{text:"text-sys-red",bg:"bg-sys-red/10"}}const fc=l.memo(function({data:t}){const{text:n,bg:a}=hc(t.aqi);return e.jsxs(Z,{compact:!0,children:[t.location&&e.jsx("div",{className:"text-[11px] text-fg-muted font-medium mb-1 pr-6",children:t.location}),e.jsxs("div",{className:"flex items-center gap-2.5 mb-2",children:[e.jsx("div",{className:E("flex items-center justify-center w-12 h-12 rounded-xl",a),children:e.jsx("span",{className:E("text-xl font-bold tabular-nums",n),children:t.aqi})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-base leading-none",children:t.colorEmoji}),e.jsx("span",{className:E("text-sm font-semibold",n),children:t.category})]}),e.jsx("span",{className:"text-[10px] text-fg-muted",children:"Air Quality Index"})]})]}),t.pollutants.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:t.pollutants.map(r=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-fg-primary/5 text-[10px] tabular-nums",children:[e.jsx("span",{className:"text-fg-muted font-medium",children:r.name}),e.jsx("span",{className:"text-fg-primary",children:r.value})]},r.name))})]})});function gc(s){return s<=3?"text-sys-green":s<=4?"text-sys-amber":s<=6?"text-sys-orange":"text-sys-red"}function Oe({label:s,value:t,className:n}){return e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[9px] text-fg-muted uppercase tracking-wider",children:s}),e.jsx("span",{className:E("text-sm font-semibold tabular-nums text-fg-primary",n),children:t})]})}const yc=l.memo(function({data:t}){return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 pr-6",children:[e.jsx("span",{className:"text-sm leading-none",children:"☀️"}),e.jsx("span",{className:"text-[11px] font-medium text-fg-muted",children:"Solar Conditions"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2",children:[t.aIndex!=null&&e.jsx(Oe,{label:"A-Index",value:t.aIndex}),t.kIndex!=null&&e.jsx(Oe,{label:"K-Index",value:t.kIndex,className:gc(t.kIndex)}),t.sunspots!=null&&e.jsx(Oe,{label:"Sunspots",value:t.sunspots}),t.xrayFlux!=null&&e.jsx(Oe,{label:"X-Ray",value:t.xrayFlux}),t.solarFlux!=null&&e.jsx(Oe,{label:"Flux",value:t.solarFlux}),t.signalNoise!=null&&e.jsx(Oe,{label:"Noise",value:t.signalNoise})]})]})});function bc(s){const t=s.toLowerCase();return t==="excellent"||t==="good"?"text-sys-green bg-sys-green/10":t==="fair"?"text-sys-amber bg-sys-amber/10":"text-sys-red bg-sys-red/10"}function Gs({band:s}){return e.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[e.jsx("span",{className:"text-[11px] text-fg-primary font-mono tabular-nums",children:s.name}),e.jsx("span",{className:E("text-[10px] font-semibold px-1.5 py-0.5 rounded",bc(s.condition)),children:s.condition})]})}const vc=l.memo(function({data:t}){const n=t.bands.filter(r=>r.time==="day"),a=t.bands.filter(r=>r.time==="night");return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 pr-6",children:[e.jsx("span",{className:"text-sm leading-none",children:"📻"}),e.jsx("span",{className:"text-[11px] font-medium text-fg-muted",children:"HF Band Conditions"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] text-fg-muted uppercase tracking-wider",children:"Day"}),n.map((r,i)=>e.jsx(Gs,{band:r},i))]}),a.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[9px] text-fg-muted uppercase tracking-wider",children:"Night"}),a.map((r,i)=>e.jsx(Gs,{band:r},i))]})]})]})});function jc({progress:s}){if(s==null)return null;const t=Math.max(0,Math.min(1,s)),n=Math.PI*(1-t),a=50-40*Math.cos(n),r=45-40*Math.sin(n);return e.jsxs("svg",{viewBox:"0 0 100 50",className:"w-full h-8 mb-1","aria-hidden":"true",children:[e.jsx("line",{x1:"8",y1:"45",x2:"92",y2:"45",stroke:"var(--fg-muted)",strokeWidth:"0.5",opacity:"0.3"}),e.jsx("path",{d:"M 10 45 A 40 40 0 0 1 90 45",fill:"none",stroke:"var(--sys-amber)",strokeWidth:"1",opacity:"0.3",strokeDasharray:"3 2"}),e.jsx("circle",{cx:a,cy:r,r:"3.5",fill:"var(--sys-amber)"}),e.jsx("text",{x:"10",y:"49",fontSize:"4.5",fill:"var(--fg-muted)",textAnchor:"middle",children:"↑"}),e.jsx("text",{x:"90",y:"49",fontSize:"4.5",fill:"var(--fg-muted)",textAnchor:"middle",children:"↓"})]})}const Nc=l.memo(function({data:t}){let n=null;if(t.daylightHours!=null&&t.daylightMinutes!=null&&t.remainingHours!=null&&t.remainingMinutes!=null){const u=t.daylightHours*60+t.daylightMinutes,d=t.remainingHours*60+t.remainingMinutes;u>0&&(n=1-d/u)}const a=t.isEvening?t.setTime:t.riseTime,r=t.isEvening?t.riseTime:t.setTime,i=t.isEvening?"Sunset":"Sunrise",o=t.isEvening?"Sunrise":"Sunset";return e.jsxs(Z,{compact:!0,children:[e.jsx(jc,{progress:n}),e.jsxs("div",{className:"flex justify-between items-center mb-1.5",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[9px] text-fg-muted uppercase",children:i}),e.jsx("span",{className:"text-xs text-fg-primary font-medium tabular-nums",children:a??"—"})]}),e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("span",{className:"text-[9px] text-fg-muted uppercase",children:o}),e.jsx("span",{className:"text-xs text-fg-primary font-medium tabular-nums",children:r??"—"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px]",children:[t.daylightHours!=null&&e.jsxs("span",{className:"text-fg-muted",children:["Daylight: ",e.jsxs("span",{className:"text-fg-primary font-medium tabular-nums",children:[t.daylightHours,"h ",t.daylightMinutes,"m"]})]}),t.remainingHours!=null&&e.jsxs("span",{className:"text-sys-amber",children:["Remaining: ",e.jsxs("span",{className:"font-medium tabular-nums",children:[t.remainingHours,"h ",t.remainingMinutes,"m"]})]})]}),(t.azimuth!=null||t.altitude!=null)&&e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[10px] text-fg-muted tabular-nums",children:[t.azimuth!=null&&e.jsxs("span",{children:["Az: ",t.azimuth.toFixed(1),"°"]}),t.altitude!=null&&e.jsxs("span",{children:["Alt: ",t.altitude.toFixed(1),"°"]})]})]})}),wc=l.memo(function({data:t}){return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-2",children:[e.jsx("span",{className:"text-3xl leading-none",children:t.phaseEmoji}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-fg-primary font-medium",children:t.phaseName}),t.illumination!=null&&e.jsxs("div",{className:"text-[11px] text-fg-muted tabular-nums",children:[t.illumination.toFixed(1),"% illuminated"]})]})]}),e.jsxs("div",{className:"flex gap-4 mb-1.5 text-[10px]",children:[t.riseTime&&e.jsxs("span",{className:"text-fg-muted",children:["Rise: ",e.jsx("span",{className:"text-fg-primary font-medium tabular-nums",children:t.riseTime})]}),t.setTime&&e.jsxs("span",{className:"text-fg-muted",children:["Set: ",e.jsx("span",{className:"text-fg-primary font-medium tabular-nums",children:t.setTime})]})]}),(t.nextFullMoon||t.nextNewMoon)&&e.jsxs("div",{className:"flex gap-3 text-[10px] text-fg-muted",children:[t.nextFullMoon&&e.jsxs("span",{children:["🌕 ",t.nextFullMoon]}),t.nextNewMoon&&e.jsxs("span",{children:["🌑 ",t.nextNewMoon]})]}),(t.azimuth!=null||t.altitude!=null)&&e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[10px] text-fg-muted tabular-nums",children:[t.azimuth!=null&&e.jsxs("span",{children:["Az: ",t.azimuth.toFixed(1),"°"]}),t.altitude!=null&&e.jsxs("span",{children:["Alt: ",t.altitude.toFixed(1),"°"]})]})]})}),kc=l.memo(function({data:t}){return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"text-sm font-semibold text-fg-primary mb-2 flex items-center gap-1.5",children:[e.jsx("span",{className:"text-base leading-none",children:"🛰"}),t.satName]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2 text-[11px]",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-fg-muted",children:"Rise"}),e.jsx("div",{className:"text-fg-primary font-medium tabular-nums",children:t.riseTime}),e.jsx("div",{className:"text-fg-muted",children:t.startAz})]}),e.jsxs("div",{className:"flex flex-col items-center flex-1",children:[e.jsxs("div",{className:"text-[10px] font-semibold tabular-nums",style:{color:t.maxEl>=60?"var(--sys-green)":t.maxEl>=30?"var(--sys-amber)":"var(--sys-red)"},children:[t.maxEl,"° max"]}),e.jsx("div",{className:"w-full h-px my-0.5",style:{background:"var(--edge-subtle)"}})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-fg-muted",children:"Set"}),e.jsx("div",{className:"text-fg-primary font-medium tabular-nums",children:t.setTime}),e.jsx("div",{className:"text-fg-muted",children:t.endAz})]})]}),e.jsxs("div",{className:"text-[10px] text-fg-muted tabular-nums",children:["Duration: ",e.jsx("span",{className:"text-fg-primary font-medium",children:t.duration})]})]})});function Cc(s){return s<=1?"var(--sys-green)":s<=3?"var(--sys-lime)":s<=4?"var(--sys-amber)":s<=6?"var(--sys-orange)":"var(--sys-red)"}const Sc=l.memo(function({data:t}){const n=Cc(t.kpIndex);return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center text-lg font-bold",style:{background:n,color:"var(--zinc-950)"},children:t.kpIndex}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary",children:t.status}),e.jsx("div",{className:"text-[10px] text-fg-muted",children:"Kp Index"})]})]}),t.probability!=null&&e.jsxs("div",{className:"mb-1.5",children:[e.jsxs("div",{className:"flex justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"text-fg-muted",children:"Probability"}),e.jsxs("span",{className:"text-fg-primary font-medium tabular-nums",children:[t.probability,"%"]})]}),e.jsx("div",{className:"w-full h-1.5 rounded-full",style:{background:"var(--edge-subtle)"},children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.min(t.probability,100)}%`,background:n}})})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-fg-muted",children:[t.location&&e.jsx("span",{children:t.location}),t.timestamp&&e.jsx("span",{className:"tabular-nums",children:t.timestamp})]})]})}),Ic=l.memo(function({data:t}){return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("span",{className:"text-base leading-none",children:"🎲"}),e.jsx("span",{className:"text-[11px] font-medium text-fg-muted",children:"Dice Roll"})]}),e.jsx("div",{className:"space-y-1.5",children:t.rolls.map((n,a)=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"text-fg-muted font-mono w-8 shrink-0",children:n.count>1?`${n.count}${n.dieType}`:n.dieType}),n.results.length>1?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-fg-primary tabular-nums",children:["[",n.results.join(", "),"]"]}),e.jsx("span",{className:"text-fg-muted",children:"="}),e.jsx("span",{className:"text-fg-primary font-semibold tabular-nums",children:n.total})]}):e.jsx("span",{className:"text-fg-primary font-semibold tabular-nums",children:n.total})]},a))}),t.grandTotal!=null&&t.rolls.length>1&&e.jsxs("div",{className:"mt-2 pt-1.5 flex items-center justify-between text-xs",style:{borderTop:"1px solid var(--edge-subtle)"},children:[e.jsx("span",{className:"text-fg-muted",children:"Total"}),e.jsx("span",{className:"text-fg-primary font-bold tabular-nums",children:t.grandTotal})]})]})}),Ks=l.memo(function({data:t,isDadJoke:n}){const a=n?"🥸":"🎭";return e.jsx(Z,{compact:!0,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-lg leading-none shrink-0 mt-0.5",children:a}),e.jsx("div",{className:"min-w-0",children:t.isTwoPart?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed whitespace-pre-wrap break-words",children:t.setup}),e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed whitespace-pre-wrap break-words mt-2 pt-2 italic",style:{borderTop:"1px solid var(--edge-subtle)"},children:t.delivery})]}):e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed whitespace-pre-wrap break-words",children:t.text})})]})})}),_c=l.memo(function({data:t}){return e.jsx(Z,{compact:!0,children:e.jsx("div",{className:"space-y-1.5",children:t.games.map((n,a)=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",style:a>0?{borderTop:"1px solid var(--edge-subtle)",paddingTop:"6px"}:void 0,children:[e.jsx("span",{className:"text-sm leading-none shrink-0",children:n.sportEmoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-1",children:[e.jsx("span",{className:"text-fg-primary font-medium truncate",children:n.away}),n.awayScore!=null&&e.jsx("span",{className:"text-fg-primary font-bold tabular-nums",children:n.awayScore})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-1",children:[e.jsx("span",{className:"text-fg-primary font-medium truncate",children:n.home}),n.homeScore!=null&&e.jsx("span",{className:"text-fg-primary font-bold tabular-nums",children:n.homeScore})]})]}),e.jsxs("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded shrink-0 tabular-nums",style:{color:n.isLive?"var(--sys-green)":n.isFinal?"var(--fg-muted)":"var(--sys-blue)",background:n.isLive?"color-mix(in srgb, var(--sys-green) 12%, transparent)":n.isFinal?"color-mix(in srgb, var(--fg-muted) 10%, transparent)":"color-mix(in srgb, var(--sys-blue) 12%, transparent)"},children:[n.isLive&&e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full mr-1 align-middle",style:{background:"var(--sys-green)",animation:"pulse 2s ease-in-out infinite"}}),n.status]})]},a))})})}),Mc=l.memo(function({data:t}){var n;return e.jsxs(Z,{compact:!0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("span",{className:"text-sm leading-none",children:"📊"}),e.jsx("span",{className:"text-[11px] font-medium text-fg-muted",children:t.title??"Bot Stats"})]}),t.type==="basic"?e.jsxs("div",{className:"space-y-1 text-[11px]",children:[t.commands!=null&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-fg-muted",children:"Commands"}),e.jsx("span",{className:"text-fg-primary font-semibold tabular-nums",children:t.commands})]}),t.replies!=null&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-fg-muted",children:"Replies"}),e.jsx("span",{className:"text-fg-primary font-semibold tabular-nums",children:t.replies})]}),t.topCommand&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-fg-muted",children:"Top Cmd"}),e.jsx("span",{className:"text-fg-primary font-medium",children:t.topCommand})]}),t.topUser&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-fg-muted",children:"Top User"}),e.jsx("span",{className:"text-fg-primary font-medium",children:t.topUser})]})]}):e.jsx("div",{className:"space-y-1",children:(n=t.entries)==null?void 0:n.map(a=>{const r=t.entries[0].value,i=r>0?a.value/r*100:0;return e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsxs("span",{className:"text-fg-muted w-4 text-right tabular-nums shrink-0",children:[a.rank,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex justify-between mb-0.5",children:[e.jsx("span",{className:"text-fg-primary font-medium truncate",children:a.name}),e.jsx("span",{className:"text-fg-primary font-semibold tabular-nums shrink-0 ml-2",children:a.value})]}),e.jsx("div",{className:"w-full h-1 rounded-full",style:{background:"var(--edge-subtle)"},children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${i}%`,background:"var(--sys-blue)"}})})]})]},a.rank)})})]})}),Rc=l.memo(function({data:t}){return e.jsx(Z,{compact:!0,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-lg leading-none shrink-0 mt-0.5",children:"🐱"}),e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed whitespace-pre-wrap break-words",children:t})]})})});function Ec({text:s}){return e.jsx(Z,{compact:!0,children:e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed tracking-wide whitespace-pre-wrap break-words",children:dl(s)})})}const Pc=l.memo(function({text:t,messageType:n}){const a=l.useMemo(()=>n?Co(t,n):null,[t,n]);if(a)switch(n){case"weather":return e.jsx(tc,{data:a});case"weather-multiday":return e.jsx(sc,{data:a});case"weather-hourly":return e.jsx(nc,{data:a});case"weather-alert":return e.jsx(ic,{data:a});case"path":return e.jsx(dc,{data:a});case"test":return e.jsx(xc,{data:a});case"aqi":return e.jsx(fc,{data:a});case"solar":return e.jsx(yc,{data:a});case"hfcond":return e.jsx(vc,{data:a});case"sun":return e.jsx(Nc,{data:a});case"moon":return e.jsx(wc,{data:a});case"satpass":return e.jsx(kc,{data:a});case"aurora":return e.jsx(Sc,{data:a});case"dice":return e.jsx(Ic,{data:a});case"joke":return e.jsx(Ks,{data:a});case"dadjoke":return e.jsx(Ks,{data:a,isDadJoke:!0});case"sports":return e.jsx(_c,{data:a});case"stats":return e.jsx(Mc,{data:a});case"catfact":return e.jsx(Rc,{data:a})}return e.jsx(Ec,{text:t})}),Tc=l.lazy(()=>fn(()=>import("./CompanionPathMap-CPxxakse.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(s=>({default:s.CompanionPathMap}))),$c=l.lazy(()=>fn(()=>import("./CompanionEchoMap-ui9UBOvI.js"),__vite__mapDeps([10,1,2,3,7,8,9])).then(s=>({default:s.CompanionEchoMap}))),qs=e.jsx("div",{className:"rounded-lg bg-elevated flex items-center justify-center",style:{aspectRatio:"16 / 10"},children:e.jsx("div",{className:"w-4 h-4 border-2 border-fg-muted/30 border-t-fg-muted rounded-full animate-spin"})});function Ac(s){const t=new Date(s*1e3),a=Math.floor((new Date().getTime()-t.getTime())/864e5);return a===0?"Today":a===1?"Yesterday":t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Fc(s){const t=new Date(s*1e3);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function Oc(s){const t=new Map;for(const n of s)n.name&&t.set(n.public_key,n.name);return t}function Dc(s){const t=new Map;for(const n of s)t.set(n.public_key,n);return t}function Lc(s){if(!s)return[];const t=[];for(let n=0;na.public_key.startsWith(s));return(n==null?void 0:n.name)||null}function Vs(s,t){return s.is_outgoing?"You":s.sender_name?s.sender_name:t.get(s.sender_key)??s.sender_key.slice(0,8)}const Hc=new Set(["🎭","🥸"]);function Bc({senderName:s,timestamp:t,signed:n,children:a}){const{emoji:r,cleanName:i}=yt(s),o=bt(i),u=vt(s);return e.jsxs("div",{className:"group flex items-start gap-4 w-full p-2",children:[e.jsxs("div",{className:"flex-shrink-0 w-9 flex flex-col items-center gap-1",children:[e.jsx("div",{className:E("clay-avatar w-9 h-9",r?"text-lg":"text-white text-[13px] font-bold tracking-tight"),style:{"--avatar-color":o},children:r||u}),e.jsx("span",{className:"text-xs text-chat-timestamp tabular-nums h-4 leading-4",children:ul(t)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 -mt-[3px] mb-1",children:[e.jsx("span",{className:"text-[13px] font-normal text-chat-incoming-name truncate leading-tight tabular-nums",children:i}),n&&e.jsxs("svg",{className:"w-3.5 h-3.5 text-sys-green flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("title",{children:"Ed25519 signed message"}),e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"}),e.jsx("polyline",{points:"9 12 11 14 15 10"})]})]}),e.jsx("div",{className:"flex items-end gap-1.5 min-w-0",children:a})]})]})}const Wc=l.memo(function({msg:t,contact:n,contacts:a,selfInfo:r,echoCount:i,channelName:o,allMessages:u,children:d}){const[f,c]=l.useState(!1),[x,y]=l.useState(!1),[g,m]=l.useState(0),j=l.useRef(null),k=t.path_len,h=!t.is_outgoing,w=h&&k!=null,I=t.is_outgoing&&t.is_channel&&(i??0)>0,R=(o==null?void 0:o.toLowerCase().includes("wardrive"))??!1,v=l.useMemo(()=>R&&h?$l(t.text):null,[R,h,t.text]),S=w||I,T=l.useMemo(()=>{const C=[];if(t.path_hops&&t.path_hops.length>0)C.push({hops:t.path_hops,snr:t.path_snr,rssi:t.path_rssi});else if(h&&(n!=null&&n.out_path)){const D=Lc(n.out_path);D.length>0&&C.push({hops:D})}if(t.alternate_paths)for(const D of t.alternate_paths)C.push(D);return C},[t.path_hops,t.path_snr,t.path_rssi,t.alternate_paths,h,n==null?void 0:n.out_path]),M=g1,_=(p==null?void 0:p.snr)??t.msg_snr,b=()=>{y(!0),c(C=>!C)},L=l.useCallback(C=>{var D;C.propertyName==="grid-template-rows"&&(f?(D=j.current)==null||D.scrollIntoView({block:"nearest",behavior:"smooth"}):y(!1))},[f]);return e.jsxs("div",{ref:j,className:E("rounded-xl px-2 py-1 -mx-2 transition-colors duration-150",S&&"hover:bg-subtle-fill cursor-pointer"),onClick:()=>S&&b(),children:[d,S&&e.jsx("div",{className:"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.83,0,0.17,1)]",style:{gridTemplateRows:f?"1fr":"0fr"},onTransitionEnd:L,children:e.jsxs("div",{className:"overflow-hidden",children:[x&&w&&e.jsxs("div",{className:"mt-1.5 ml-13 space-y-1",children:[N&&e.jsx("div",{className:"flex items-center gap-1 flex-wrap",onClick:C=>C.stopPropagation(),children:T.map((C,D)=>e.jsxs("button",{onClick:()=>m(D),className:E("flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] transition-colors",D===M?"bg-sys-blue/15 text-sys-blue font-semibold":"bg-subtle-fill text-fg-muted hover:text-fg-secondary"),children:[e.jsx(Je,{className:"w-2.5 h-2.5"}),C.hops.length||k,C.snr!=null&&e.jsxs("span",{className:"ml-0.5 opacity-70",children:[C.snr>0?"+":"",C.snr.toFixed(1)]})]},D))}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx(Je,{className:"w-3 h-3 text-fg-muted flex-shrink-0"}),k===0&&!p?e.jsx("span",{className:"text-[10px] text-fg-muted font-medium",children:"Direct"}):p&&p.hops.length>0?p.hops.map((C,D)=>{const $=zc(C,a);return e.jsxs("span",{className:"contents",children:[D>0&&e.jsx(Fl,{className:"w-2.5 h-2.5 text-fg-muted/50 flex-shrink-0"}),e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded bg-subtle-fill text-[10px]",children:[e.jsx("span",{className:"font-mono text-fg-primary",children:C}),$&&e.jsxs("span",{className:"text-fg-muted",children:["(",$,")"]})]})]},D)}):e.jsxs("span",{className:"text-[10px] text-fg-muted font-medium",children:[k," hop",k>1?"s":""]}),_!=null&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-fg-muted ml-0.5",children:[e.jsx(pl,{className:"w-2.5 h-2.5"}),_>0?"+":"",_.toFixed(1),"dB"]}),(p==null?void 0:p.rssi)!=null&&e.jsxs("span",{className:"text-[10px] text-fg-muted",children:[p.rssi,"dBm"]})]}),p&&p.hops.length>=1&&e.jsx(l.Suspense,{fallback:qs,children:e.jsx(Tc,{hops:p.hops,contacts:a,selfInfo:r,snr:_,wardriveCoords:v??void 0,wardriveSenderName:t.sender_name,channelMessages:R?u:void 0,messageTimestamp:t.timestamp})})]}),x&&I&&e.jsx("div",{className:"mt-1.5",children:e.jsx(l.Suspense,{fallback:qs,children:e.jsx($c,{text:t.text,timestamp:t.timestamp,contacts:a})})})]})})]})}),Uc=l.memo(function({messages:t,contacts:n,className:a,conversationKey:r,onRetry:i,onRetryAsFlood:o,onMentionClick:u,historyLoading:d,historyExhausted:f,onLoadOlder:c,channelName:x,contactPubKey:y}){const g=l.useRef(null),m=l.useRef(null),[j,k]=l.useState(!1),h=l.useRef(t.length),w=l.useRef(0),I=l.useRef(r);l.useEffect(()=>{if(r!==I.current){I.current=r,h.current=t.length,w.current=0,k(!1);const $=g.current;$&&($.scrollTop=$.scrollHeight)}},[r,t.length]);const R=l.useMemo(()=>Oc(n),[n]),v=l.useMemo(()=>Dc(n),[n]),S=gt(),T=qo(t),M=ia(y??""),p=y?v.get(y):void 0,N=l.useMemo(()=>{if(!p)return!1;const $=t.filter(G=>!G.is_outgoing).slice(-5).map(G=>G.text);return So(p.name,M,$)},[p,M,t]),{combinedTexts:_,skipIds:b}=l.useMemo(()=>{const $=new Map,G=new Set;for(let F=0;F3)continue;const H=[...q.text][0];if(!H||!Hc.has(H)||[...X.text][0]!==H)continue;const A=X.text.slice(H.length).trimStart();$.set(q.id,q.text+` `+A),G.add(X.id),F++}return{combinedTexts:$,skipIds:G}},[t]);l.useEffect(()=>{var G;const $=g.current;if($){if(t.length>h.current&&w.current>0){const F=$.scrollHeight-w.current;if(F>0&&$.scrollTop<200){$.scrollTop+=F,h.current=t.length,w.current=0;return}}h.current=t.length,j||(G=m.current)==null||G.scrollIntoView({behavior:"smooth"})}},[t.length,j]);const L=l.useCallback(()=>{const $=g.current;if(!$)return;const G=$.scrollHeight-$.scrollTop-$.clientHeight;k(G>100),$.scrollTop<80&&c&&!d&&!f&&(w.current=$.scrollHeight,c())},[c,d,f]),C=l.useCallback(()=>{var $;($=m.current)==null||$.scrollIntoView({behavior:"smooth"}),k(!1)},[]);let D="";return e.jsxs("div",{className:E("relative flex flex-col",a),children:[e.jsxs("div",{ref:g,onScroll:L,className:"flex-1 overflow-y-auto min-h-0 px-4 py-3",style:{contain:"layout style paint"},children:[d&&e.jsx("div",{className:"flex items-center justify-center py-3",children:e.jsx(ce,{className:"w-4 h-4 text-fg-muted animate-spin"})}),t.length===0?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-sm text-fg-muted",children:f?"No messages yet":"Loading messages…"})}):t.map($=>{if(b.has($.id))return null;const G=Fc($.timestamp),F=G!==D;D=G;const q=$.unconfirmed&&$.is_channel&&(T.get($.id)??0)>0,X=$.is_outgoing?$.failed?"failed":$.confirmed||q?"confirmed":$.unconfirmed?"unconfirmed":($.retryAttempt??0)>0?"retrying":$.sent?"sent":"pending":void 0,H=$.is_channel&&$.channel_idx!=null?`ch:${$.channel_idx}`:$.sender_key;return e.jsxs("div",{children:[F&&e.jsx(Pl,{text:Ac($.timestamp)}),e.jsx(Wc,{msg:$,contact:v.get($.sender_key),contacts:n,selfInfo:S,echoCount:T.get($.id),channelName:x,allMessages:x!=null&&x.toLowerCase().includes("wardrive")?t:void 0,children:(()=>{if(!$.is_outgoing){const A=Vs($,R);if($.is_channel?aa(A):N){const O=_.get($.id)??$.text,W=sa(O);return e.jsx(Bc,{senderName:A,timestamp:$.timestamp,signed:$.txt_type===Ss.SignedPlain,children:e.jsx(Pc,{text:O,messageType:W})})}}return e.jsx(Tl,{senderName:Vs($,R),text:$.text,timestamp:$.timestamp,isOutgoing:$.is_outgoing,status:X,onRetry:i&&$.failed?()=>i(H,$.id):void 0,onRetryAsFlood:o&&$.failed&&!$.is_channel?()=>o(H,$.id):void 0,retryAttempt:$.retryAttempt,maxRetries:$.maxRetries,echoCount:T.get($.id),signed:!$.is_outgoing&&$.txt_type===Ss.SignedPlain,bubbleVariant:"subtle",onMentionClick:u})})()})]},$.id)}),e.jsx("div",{ref:m})]}),e.jsx("button",{onClick:C,className:E("absolute bottom-4 right-4 w-8 h-8 rounded-full bg-sys-blue flex items-center justify-center shadow-lg","hover:bg-sys-blue/90 transition-all duration-200",j?"opacity-100 translate-y-0":"opacity-0 translate-y-2 pointer-events-none"),children:e.jsx(Al,{className:"w-4 h-4 text-white"})})]})}),Gc=6,Kc=l.memo(function({onSend:t,disabled:n,placeholder:a="Type a message…",className:r,mentionNames:i=[]}){const[o,u]=l.useState(""),[d,f]=l.useState(!1),c=l.useRef(null),[x,y]=l.useState(null),[g,m]=l.useState(-1),[j,k]=l.useState(0),h=l.useMemo(()=>{if(x==null)return[];const M=x.toLowerCase();return i.filter(p=>p.toLowerCase().includes(M)).slice(0,Gc)},[x,i]),w=h.length>0;l.useEffect(()=>{k(0)},[h]);const I=l.useCallback(()=>{y(null),m(-1),k(0)},[]),R=l.useCallback(M=>{var C;if(g<0)return;const p=o.slice(0,g),N=((C=c.current)==null?void 0:C.selectionStart)??o.length,_=o.slice(N),b=`@[${M}] `,L=p+b+_;u(L),I(),requestAnimationFrame(()=>{var $,G;const D=p.length+b.length;($=c.current)==null||$.setSelectionRange(D,D),(G=c.current)==null||G.focus()})},[o,g,I]),v=l.useCallback(async()=>{var p;const M=o.trim();!M||d||n||(f(!0),I(),u(""),await t(M),f(!1),(p=c.current)==null||p.focus())},[o,d,n,t,I]),S=l.useCallback(M=>{const p=M.target.value;u(p);const N=M.target.selectionStart??p.length,_=p.slice(0,N),b=_.lastIndexOf("@");if(b>=0){const L=b>0?_[b-1]:" ";if(/\s/.test(L)||b===0){const C=_.slice(b+1);if(!C.includes(" ")&&!C.includes("[")){y(C),m(b);return}}}I()},[I]),T=l.useCallback(M=>{if(w){if(M.key==="ArrowDown"){M.preventDefault(),k(p=>(p+1)%h.length);return}if(M.key==="ArrowUp"){M.preventDefault(),k(p=>(p-1+h.length)%h.length);return}if(M.key==="Enter"||M.key==="Tab"){M.preventDefault(),R(h[j]);return}if(M.key==="Escape"){M.preventDefault(),I();return}}M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),v())},[v,w,h,j,R,I]);return e.jsxs("div",{className:E("relative flex items-center gap-2 p-3 border-t border-edge-subtle",r),children:[w&&e.jsx("div",{className:"absolute bottom-full left-3 right-3 mb-1 radius-inset surface-elevated depth-raised overflow-hidden z-50",children:h.map((M,p)=>{const N=bt(M),{emoji:_,cleanName:b}=yt(M),L=vt(M);return e.jsxs("button",{onMouseDown:C=>{C.preventDefault(),R(M)},className:E("w-full flex items-center gap-2.5 px-3 py-1.5 text-left transition-colors",p===j?"bg-sys-blue/10":"hover:bg-subtle-fill"),children:[e.jsx("div",{className:E("clay-avatar w-5 h-5",_?"text-xs":"text-white text-[9px] font-bold"),style:{"--avatar-color":N},children:_||L}),e.jsx("span",{className:"text-sm text-fg-primary truncate",children:b})]},M)})}),e.jsx("input",{ref:c,type:"text",value:o,onChange:S,onKeyDown:T,onBlur:()=>{setTimeout(I,150)},placeholder:a,disabled:n,className:"flex-1 min-w-0 w-full px-4 py-3 text-sm radius-inner bg-input-bg border border-input-border text-fg-primary placeholder:text-fg-muted/50 ring-focus-inset hover:border-edge-strong transition-colors"}),e.jsx("button",{onClick:v,disabled:!o.trim()||d||n,className:E("flex-shrink-0 w-10 h-10 rounded-full flex items-center justify-center transition-colors",o.trim()&&!n?"clay-send text-white":"bg-subtle-fill text-fg-muted cursor-not-allowed"),children:e.jsx(kr,{className:"w-4.5 h-4.5 -translate-x-[0.5px] translate-y-[0.5px]",strokeWidth:2.5})})]})}),Kt="pymc_companion_room_pwd_";function qc(s){try{return localStorage.getItem(`${Kt}${s}`)}catch{return null}}function Vc(s,t){try{localStorage.setItem(`${Kt}${s}`,t)}catch{}}function Js(s){try{localStorage.removeItem(`${Kt}${s}`)}catch{}}const Jc=l.memo(function({contact:t,loginStatus:n,onLogin:a,className:r}){const[i,o]=l.useState(""),[u,d]=l.useState(!0),[f,c]=l.useState(null),[x,y]=l.useState(!1),g=l.useRef(null),m=l.useRef(!0),j=t.public_key,k=l.useRef(j);k.current!==j&&(k.current=j,y(!1),c(null),o("")),l.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]),l.useEffect(()=>{if(x||n==="success")return;const R=qc(j);if(!R){y(!0);return}y(!0),(async()=>{const v=await a(j,R);m.current&&(v||(Js(j),c("Saved password rejected — please re-enter.")))})()},[j,x,n,a]);const h=l.useCallback(async()=>{c(null);const R=await a(j,i);m.current&&(R?u&&i?Vc(j,i):Js(j):c("Login failed — check your password and try again."))},[j,i,u,a]),w=l.useCallback(R=>{R.key==="Enter"&&(R.preventDefault(),h())},[h]),I=n==="pending";return I&&!i?e.jsxs("div",{className:E("flex-1 flex flex-col items-center justify-center gap-3",r),children:[e.jsx(ce,{className:"w-6 h-6 text-sys-pink animate-spin"}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Connecting to ",t.name||"room server","…"]})]}):e.jsx(me.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:E("flex-1 flex flex-col items-center justify-center px-6",r),children:e.jsxs("div",{className:"w-full max-w-xs space-y-5",children:[e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-pink bg-sys-pink/8",children:e.jsx(ht,{className:"size-7 text-sys-pink"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"type-body font-medium text-fg-primary",children:t.name||"Room Server"}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Enter the room password to join, or try logging in without one — some servers allow open access."})]})]}),(f||n==="failed")&&e.jsxs("div",{className:"flex items-start gap-2 p-2.5 rounded-lg bg-sys-red/8 border border-sys-red/15",children:[e.jsx(Nn,{className:"w-3.5 h-3.5 text-sys-red flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-sys-red leading-relaxed",children:f||"Login failed — check your password and try again."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{ref:g,type:"password",value:i,onChange:R=>o(R.target.value),onKeyDown:w,placeholder:"Room password",disabled:I,autoFocus:!0,className:"w-full surface-input rounded-lg px-3 py-2.5 text-sm text-fg-primary placeholder:text-fg-muted/50 focus:outline-none focus:ring-1 focus:ring-sys-pink/40"}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:R=>d(R.target.checked),disabled:I,className:"surface-checkbox w-3.5 h-3.5 rounded accent-sys-pink"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Remember password"})]}),e.jsxs(U,{color:"pink",className:"w-full justify-center",disabled:I,onClick:h,children:[I?e.jsx(ce,{"data-slot":"icon",className:"animate-spin"}):e.jsx(Pt,{"data-slot":"icon"}),I?"Connecting…":"Login"]})]}),e.jsx("p",{className:"text-[10px] text-fg-muted/60 text-center leading-relaxed",children:"The server determines your permissions based on the password. Admin and guest passwords grant different access levels."})]})})});function Qs(s,t){return[s,t].sort().join("-")}function it(s){return s.substring(0,2)}function Qc(s){var n,a;const t=(a=(n=s.traceQuality)==null?void 0:n.composite)==null?void 0:a.mean;return t!=null&&t!==0?Math.max(.1,t+20):Math.max(.1,s.strength*20)}function Xc(s,t,n,a){const{edgeMap:r}=n;if(r.size===0)return null;const i=new Map;for(const[,v]of r){const S=v.fromHash,T=v.toHash;i.has(S)||i.set(S,[]),i.has(T)||i.set(T,[]),i.get(S).push({neighbor:T,edge:v}),i.get(T).push({neighbor:S,edge:v})}const o=new Set(i.keys()),u=Xs(s,o),d=Xs(t,o);if(!u||!d||u===d)return null;const f=new Map,c=new Map,x=new Set,y=[];for(f.set(u,0),c.set(u,null),y.push({node:u,cost:0});y.length>0;){y.sort((T,M)=>T.cost-M.cost);const v=y.shift();if(x.has(v.node))continue;if(x.add(v.node),v.node===d)break;const S=i.get(v.node)??[];for(const{neighbor:T,edge:M}of S){if(x.has(T))continue;const p=Qc(M),N=v.cost+1/p,_=f.get(T)??1/0;N<_&&(f.set(T,N),c.set(T,v.node),y.push({node:T,cost:N}))}}if(!c.has(d))return null;const g=[];let m=d;for(;m!==null;)g.unshift(m),m=c.get(m)??null;if(g[0]!==u||g.length<2)return null;const j=new Map;for(const v of a)j.set(it(v.public_key),v);const k=g.slice(1,-1),h=k.map((v,S)=>{var L,C;const T=it(v),M=j.get(T);let p=0;const N=g[S],_=Qs(N,v),b=r.get(_);return(C=(L=b==null?void 0:b.traceQuality)==null?void 0:L.composite)!=null&&C.mean?p=b.traceQuality.composite.mean:(b==null?void 0:b.avgSnr)!=null&&(p=b.avgSnr),{hash:v,prefix:T,name:(M==null?void 0:M.name)||null,snr:p}});let w=0,I=0;for(let v=0;v0?w/I:0;return{hops:k.map(it),confidence:R,via:h}}function Xs(s,t){if(t.has(s))return s;const n=it(s);let a=null,r=0;for(const i of t)if(i.startsWith(n)||s.startsWith(i.substring(0,2))){let o=0;const u=Math.min(s.length,i.length);for(let d=0;dr&&(r=o,a=i)}return a}function Ys(s){switch(s&15){case 1:return"Companion";case 2:return"Repeater";case 3:return"Room Server";default:return"Unknown"}}function Zs(s){switch(s&15){case 1:return"blue";case 2:return"green";case 3:return"indigo";default:return"zinc"}}function Yc(s){return(s&15)===2}const en=l.memo(function({contact:t,channel:n,contacts:a=[],selfPubKey:r,embedded:i=!1,onResetPath:o,onRequestStatus:u,onRequestTelemetry:d,onLoginToRepeater:f,onLogoutFromRepeater:c,onGetNeighbours:x,onTraceContactPath:y,onDiscoverPath:g,onExportContact:m,onSetContactPath:j,className:k}){const[h,w]=l.useState({}),I=(t==null?void 0:t.public_key)??null,[R,v]=l.useState(I);if(I!==R&&(v(I),w({})),!t&&!n)return i?null:e.jsx("div",{className:E("flex items-center justify-center h-full",k),children:e.jsx("p",{className:"text-sm text-fg-muted",children:"Select a conversation"})});async function S(N,_){w(L=>({...L,[N]:"loading"}));const b=await _();w(L=>({...L,[N]:b?"done":"error"})),setTimeout(()=>w(L=>({...L,[N]:"idle"})),2e3)}const T=n?e.jsxs("div",{className:"space-y-4",children:[!i&&e.jsxs("div",{className:"flex flex-col items-center gap-2 pb-3 border-b border-edge-subtle",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-sys-indigo/15 flex items-center justify-center shadow-md",children:e.jsx(He,{className:"size-7 text-sys-indigo"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"type-body font-medium text-fg-primary",children:n.name}),e.jsxs(ze,{color:"indigo",children:["Channel ",n.index]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted w-20",children:"Index"}),e.jsx("span",{className:"font-mono text-fg-primary",children:n.index})]}),e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted w-20",children:"Type"}),e.jsx("span",{className:"text-fg-primary",children:"Broadcast"})]})]}),e.jsx("div",{className:"pt-2 border-t border-edge-subtle",children:e.jsx("p",{className:"type-data-xs text-fg-muted/70",children:"Channel messages are broadcast-encrypted. Sender identity is not available due to MeshCore protocol limitations."})})]}):null,M=t?e.jsxs("div",{className:"space-y-4",children:[!i&&e.jsxs("div",{className:"flex flex-col items-center gap-2 pb-3 border-b border-edge-subtle",children:[e.jsx(nd,{contact:t}),e.jsxs("div",{className:"text-center",children:[e.jsxs("h3",{className:"type-body font-medium text-fg-primary flex items-center justify-center gap-1",children:[t.name||"Unknown",e.jsx(sn,{pubkey:t.public_key})]}),e.jsx(ze,{color:Zs(t.adv_type),children:Ys(t.adv_type)})]})]}),i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{color:Zs(t.adv_type),children:Ys(t.adv_type)}),e.jsx(sn,{pubkey:t.public_key})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted w-20",children:"Public Key"}),e.jsx("span",{className:"font-mono text-fg-primary break-all text-[10px]",children:t.public_key})]}),e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx(Je,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted",children:"Path Length"}),e.jsx("span",{className:"text-fg-primary ml-auto",children:t.out_path_len})]}),(t.gps_lat!==0||t.gps_lon!==0)&&e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx(vn,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted",children:"GPS"}),e.jsxs("span",{className:"text-fg-primary ml-auto font-mono text-[10px]",children:[t.gps_lat.toFixed(5),", ",t.gps_lon.toFixed(5)]})]}),(t.lastmod>0||t.last_advert_timestamp>0)&&e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx(wn,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted",children:"Last Heard"}),e.jsx("span",{className:"text-fg-primary ml-auto",children:new Date((t.lastmod||t.last_advert_timestamp)*1e3).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),t.last_advert_timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted",children:"Last Advert"}),e.jsx("span",{className:"text-fg-primary ml-auto",children:new Date(t.last_advert_timestamp*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})]}),e.jsx(rd,{contact:t,contacts:a,selfPubKey:r,onSetContactPath:j,onDiscoverPath:g,actionState:h,setActionState:w,runAction:S}),e.jsxs("div",{className:"space-y-2 pt-2 border-t border-edge-subtle",children:[e.jsxs(U,{color:h.reset==="done"?"success":h.reset==="error"?"danger":"primary",outline:!0,className:"w-full justify-center",disabled:h.reset==="loading",onClick:()=>S("reset",()=>o(t.public_key)),children:[e.jsx(jn,{"data-slot":"icon"}),h.reset==="loading"?"Resetting…":h.reset==="done"?"Reset!":"Reset Path"]}),e.jsxs(U,{color:h.status==="done"?"success":h.status==="error"?"danger":"primary",outline:!0,className:"w-full justify-center",disabled:h.status==="loading",onClick:()=>S("status",()=>u(t.public_key)),children:[e.jsx(kn,{"data-slot":"icon"}),h.status==="loading"?"Requesting…":"Request Status"]}),e.jsxs(U,{color:h.telemetry==="done"?"success":h.telemetry==="error"?"danger":"primary",outline:!0,className:"w-full justify-center",disabled:h.telemetry==="loading",onClick:()=>S("telemetry",()=>d(t.public_key)),children:[e.jsx(Cn,{"data-slot":"icon"}),h.telemetry==="loading"?"Requesting…":"Request Telemetry"]})]}),m&&e.jsxs(U,{color:"primary",outline:!0,className:"w-full justify-center",onClick:()=>m(t.public_key),children:[e.jsx(Gt,{"data-slot":"icon"}),"Export Contact"]}),Yc(t.adv_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ld,{pubkey:t.public_key,onLogin:f,onLogout:c,actionState:h,runAction:S}),e.jsx(id,{pubkey:t.public_key,onGetNeighbours:x,actionState:h,runAction:S}),e.jsx(od,{pubkey:t.public_key,contact:t,onTrace:y,actionState:h,runAction:S})]}),e.jsx(Zc,{pubkey:t.public_key}),e.jsx(sd,{pubkey:t.public_key})]}):null,p=T??M;return i?e.jsx("div",{className:k,children:p}):e.jsx("div",{className:E("flex flex-col h-full overflow-y-auto",k),children:e.jsx(ve,{mode:"wait",children:n?e.jsx(me.div,{variants:Ol,initial:"hidden",animate:"visible",exit:"exit",className:"p-4",children:T},`ch-${n.index}`):t?e.jsx(me.div,{variants:Dl,initial:"hidden",animate:"visible",exit:"exit",className:"p-4",children:M},`contact-${t.public_key}`):null})})});function tn(s){const t=Math.floor(s/86400),n=Math.floor(s%86400/3600),a=Math.floor(s%3600/60);return t>0?`${t}d ${n}h`:n>0?`${n}h ${a}m`:`${a}m`}function Zc({pubkey:s}){const t=Rr(s);return t?e.jsxs(Re,{defaultOpen:!0,className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Ee,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(kn,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:"Status"})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsx(se,{label:"Battery",value:`${(t.battMilliVolts/1e3).toFixed(2)}V`}),e.jsx(se,{label:"Noise Floor",value:`${t.noiseFloor} dBm`}),e.jsx(se,{label:"Last RSSI",value:`${t.lastRssi} dBm`}),e.jsx(se,{label:"Last SNR",value:`${(t.lastSnr/4).toFixed(1)} dB`}),e.jsx(se,{label:"Uptime",value:tn(t.totalUpTimeSecs)}),e.jsx(se,{label:"Air Time",value:tn(t.totalAirTimeSecs)}),e.jsx(se,{label:"TX Queue",value:String(t.currTxQueueLen)}),e.jsx(se,{label:"Packets Rx",value:String(t.nPacketsRecv)}),e.jsx(se,{label:"Packets Tx",value:String(t.nPacketsSent)}),e.jsx(se,{label:"Flood Rx/Tx",value:`${t.nRecvFlood}/${t.nSentFlood}`}),e.jsx(se,{label:"Direct Rx/Tx",value:`${t.nRecvDirect}/${t.nSentDirect}`}),e.jsx(se,{label:"Dups (D/F)",value:`${t.nDirectDups}/${t.nFloodDups}`}),t.errEvents>0&&e.jsx(se,{label:"Errors",value:String(t.errEvents)})]})})]}):null}function se({label:s,value:t}){return e.jsxs("div",{className:"flex items-center justify-between type-data-xs",children:[e.jsx("span",{className:"text-fg-muted",children:s}),e.jsx("span",{className:"text-fg-primary font-mono text-[10px]",children:t})]})}function ed(s){switch(s){case 100:return"Generic";case 101:return"Luminosity";case 102:return"Presence";case 103:return"Temperature";case 104:return"Humidity";case 115:return"Pressure";case 116:return"Voltage";case 117:return"Current";case 120:return"Percentage";case 125:return"Concentration";case 128:return"Power";case 136:return"GPS";default:return`Type ${s}`}}function td(s){switch(s){case 103:return"°C";case 104:return"%";case 115:return" hPa";case 116:return"V";case 117:return"A";case 120:return"%";case 125:return" ppm";case 128:return"W";default:return""}}function sd({pubkey:s}){const t=Er(s);if(!t)return null;const n=go(t.lppSensorData);return n.length===0?null:e.jsxs(Re,{defaultOpen:!0,className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Ee,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(Cn,{className:"w-3.5 h-3.5 text-sys-amber"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:"Telemetry"})]}),e.jsx(Pe,{children:e.jsx("div",{className:"space-y-1.5 py-1",children:n.map((a,r)=>typeof a.value=="object"?e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(se,{label:`Ch${a.channel} GPS Lat`,value:a.value.latitude.toFixed(5)}),e.jsx(se,{label:`Ch${a.channel} GPS Lon`,value:a.value.longitude.toFixed(5)}),e.jsx(se,{label:`Ch${a.channel} GPS Alt`,value:`${a.value.altitude.toFixed(1)}m`})]},r):e.jsx(se,{label:`Ch${a.channel} ${ed(a.type)}`,value:`${typeof a.value=="number"?a.value.toFixed(a.type===103||a.type===116?2:0):a.value}${td(a.type)}`},r))})})]})}function nd({contact:s}){const{emoji:t}=yt(s.name||""),n=bt(s.name||s.public_key),a=s.name?vt(s.name):s.public_key.slice(0,2).toUpperCase();return(s.adv_type&15)===2?e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center shadow-md ring-[1.5px] ring-sys-blue",children:e.jsx(Ke,{className:"size-7 text-sys-blue"})}):(s.adv_type&15)===3?e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center shadow-md ring-[1.5px] ring-sys-pink",children:e.jsx(ht,{className:"size-7 text-sys-pink"})}):e.jsx("div",{className:E("w-14 h-14 clay-avatar",t?"text-2xl":"text-white text-lg font-bold"),style:{"--avatar-color":n},children:t||a})}function sn({pubkey:s}){return Cr().get(s)!==!0?null:e.jsx("span",{title:"Ed25519 verified identity",children:e.jsx(Hl,{className:"w-4 h-4 text-sys-green flex-shrink-0"})})}const It=64;function ad(s){if(!s)return[];const t=[];for(let n=0;n0,v=ad(s.out_path),S=l.useCallback(async()=>{if(!a)return;const p=c.split(",").map(b=>b.trim()).filter(Boolean);if(p.length===0){g("Enter at least one hop");return}if(p.length>It){g(`Max ${It} hops`);return}if(!p.every(b=>/^[0-9a-fA-F]{1,2}$/.test(b))){g("Each hop must be 1-2 hex characters");return}g(null),o(b=>({...b,path:"loading"}));const _=await a(s.public_key,p);o(b=>({...b,path:_?"done":"error"})),_&&f(!1),setTimeout(()=>o(b=>({...b,path:"idle"})),2e3)},[a,c,s.public_key,o]),T=l.useCallback(()=>{if(!n){h("Self identity not available");return}const p=Xc(n,s.public_key,w,t);p?(j(p),h(null)):(j(null),h("No route found in topology"))},[n,s.public_key,w,t]),M=l.useCallback(async()=>{if(!a||!m)return;o(N=>({...N,path:"loading"}));const p=await a(s.public_key,m.hops);o(N=>({...N,path:p?"done":"error"})),p&&(j(null),h(null)),setTimeout(()=>o(N=>({...N,path:"idle"})),2e3)},[a,m,s.public_key,o]);return e.jsxs(Re,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Ee,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(Je,{className:"w-3.5 h-3.5 text-sys-blue"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:"Path"}),e.jsx("span",{className:"ml-auto text-[10px] text-fg-muted font-mono",children:R?`${I} hop${I>1?"s":""}`:"direct"})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"space-y-2 py-1",children:[v.length>0&&e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx("span",{className:"text-fg-muted type-data-xs",children:"Route"}),v.map((p,N)=>e.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill font-mono text-[10px] text-fg-primary",children:p},N))]}),m&&e.jsxs("div",{className:"space-y-1.5 p-2 rounded-md bg-sys-green/5 border border-sys-green/20",children:[e.jsxs("div",{className:"flex items-center gap-1 type-data-xs text-sys-green",children:[e.jsx($s,{className:"w-3 h-3"}),e.jsxs("span",{children:["Auto-route (",m.via.length," hop",m.via.length!==1?"s":"",", ",Math.round(m.confidence*100),"% confidence)"]})]}),e.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:m.via.map((p,N)=>e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-subtle-fill text-[10px]",children:[e.jsx("span",{className:"font-mono text-fg-primary",children:p.prefix}),p.name&&e.jsxs("span",{className:"text-fg-muted",children:["(",p.name,")"]}),p.snr!==0&&e.jsx("span",{className:E("font-mono",ut(p.snr)),children:p.snr.toFixed(1)})]},N))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(U,{color:i.path==="done"?"success":"primary",outline:!0,className:"flex-1 justify-center text-xs",disabled:i.path==="loading",onClick:M,children:[e.jsx(Ne,{"data-slot":"icon"}),i.path==="loading"?"Saving…":"Accept"]}),e.jsxs(U,{plain:!0,className:"text-xs",onClick:()=>{j(null),h(null)},children:[e.jsx(ft,{"data-slot":"icon"}),"Dismiss"]})]})]}),k&&!m&&e.jsx("p",{className:"text-[9px] text-sys-amber",children:k}),a&&!m&&e.jsx("div",{className:"flex items-center gap-2",children:d?e.jsxs("div",{className:"space-y-1.5 flex-1",children:[e.jsx("input",{type:"text",value:c,onChange:p=>{x(p.target.value),g(null)},placeholder:"e.g. a3, f7, 1b",className:"w-full surface-input rounded-md px-2 py-1 text-[10px] font-mono text-fg-primary placeholder:text-fg-muted/50"}),e.jsxs("p",{className:"text-[9px] text-fg-muted/60",children:["Comma-separated hex hop bytes (max ",It,")"]}),y&&e.jsx("p",{className:"text-[9px] text-sys-red",children:y}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(U,{color:i.path==="done"?"success":i.path==="error"?"danger":"primary",outline:!0,className:"flex-1 justify-center text-xs",disabled:i.path==="loading"||!c.trim(),onClick:S,children:[e.jsx(qi,{"data-slot":"icon"}),i.path==="loading"?"Saving…":"Save"]}),e.jsx(U,{plain:!0,className:"text-xs",onClick:()=>{f(!1),g(null)},children:"Cancel"})]})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{f(!0),x(v.length>0?v.join(", "):""),g(null)},className:"text-[10px] text-sys-blue hover:text-sys-blue/80 transition-colors",children:"Edit path…"}),n&&w.edgeMap.size>0&&e.jsxs("button",{onClick:T,className:"inline-flex items-center gap-0.5 text-[10px] text-sys-indigo hover:text-sys-indigo/80 transition-colors",children:[e.jsx($s,{className:"w-3 h-3"}),"Auto-route"]}),r&&e.jsxs("button",{onClick:()=>u("discover",()=>r(s.public_key)),disabled:i.discover==="loading",className:E("inline-flex items-center gap-0.5 text-[10px] transition-colors disabled:opacity-50",i.discover==="error"?"text-sys-red":"text-sys-green hover:text-sys-green/80"),children:[e.jsx(Bl,{className:"w-3 h-3"}),i.discover==="loading"?"Discovering…":i.discover==="done"?"Discovered!":i.discover==="error"?"Failed":"Discover"]})]})})]})})]})}function ld({pubkey:s,onLogin:t,onLogout:n,actionState:a,runAction:r}){const[i,o]=l.useState(""),u=Ot(s);return t?e.jsxs(Re,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Ee,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(Pt,{className:"w-3.5 h-3.5 text-sys-amber"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:"Login"}),u!=="idle"&&e.jsx(ze,{color:u==="success"?"green":u==="failed"?"red":"amber",className:"ml-auto text-[9px]",children:u})]}),e.jsx(Pe,{children:e.jsx("div",{className:"space-y-1.5 py-1",children:u==="success"&&n?e.jsxs(U,{color:a.logout==="done"?"success":a.logout==="error"?"danger":"primary",outline:!0,className:"w-full justify-center text-xs",disabled:a.logout==="loading",onClick:()=>r("logout",()=>n(s)),children:[e.jsx(Ir,{"data-slot":"icon"}),a.logout==="loading"?"Disconnecting…":"Disconnect"]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"password",value:i,onChange:d=>o(d.target.value),placeholder:"Repeater password",className:"w-full surface-input rounded-md px-2 py-1 text-[10px] text-fg-primary placeholder:text-fg-muted/50"}),e.jsxs(U,{color:u==="failed"?"danger":"primary",outline:!0,className:"w-full justify-center text-xs",disabled:a.login==="loading"||!i.trim(),onClick:()=>r("login",()=>t(s,i)),children:[e.jsx(Pt,{"data-slot":"icon"}),a.login==="loading"?"Logging in…":"Login"]})]})})})]}):null}function id({pubkey:s,onGetNeighbours:t,actionState:n,runAction:a}){const r=_r(s),i=Ot(s);return t?e.jsxs(Re,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Ee,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(Rt,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:"Neighbours"}),r&&e.jsx("span",{className:"ml-auto text-[10px] text-fg-muted",children:r.total})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsxs(U,{color:"primary",outline:!0,className:"w-full justify-center text-xs",disabled:n.neighbours==="loading"||i!=="success",onClick:()=>a("neighbours",()=>t(s)),children:[e.jsx(Rt,{"data-slot":"icon"}),n.neighbours==="loading"?"Loading…":"Get Neighbours"]}),i!=="success"&&e.jsx("p",{className:"text-[9px] text-fg-muted/60",children:"Login required to query neighbours"}),r&&r.neighbours.length>0&&e.jsx("div",{className:"space-y-1",children:[...r.neighbours].sort((o,u)=>u.snr-o.snr).map((o,u)=>e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx("span",{className:"text-fg-primary font-mono text-[10px] w-16 truncate",children:o.name||o.prefixHex.slice(0,8)}),e.jsx("span",{className:"text-fg-muted text-[9px]",children:dd(o.heardAgo)}),e.jsxs("div",{className:"flex-1 flex items-center gap-1 ml-auto",children:[e.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-subtle-fill overflow-hidden",children:e.jsx("div",{className:E("h-full rounded-full",cd(o.snr)),style:{width:`${Math.min(100,Math.max(5,(o.snr+20)/35*100))}%`}})}),e.jsx("span",{className:E("font-mono text-[9px] w-8 text-right",ut(o.snr)),children:o.snr.toFixed(1)})]})]},u))})]})})]}):null}function od({pubkey:s,contact:t,onTrace:n,actionState:a,runAction:r}){const i=Mr(s);if(!n)return null;const o=t.out_path_len>0;return e.jsxs(Re,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Ee,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(As,{className:"w-3.5 h-3.5 text-sys-indigo"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:"Trace"}),i&&e.jsxs("span",{className:"ml-auto text-[10px] text-fg-muted",children:[i.pathLen," hops"]})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsxs(U,{color:"primary",outline:!0,className:"w-full justify-center text-xs",disabled:a.trace==="loading"||!o,onClick:()=>r("trace",()=>n(s)),children:[e.jsx(As,{"data-slot":"icon"}),a.trace==="loading"?"Tracing…":"Trace Path"]}),!o&&e.jsx("p",{className:"text-[9px] text-fg-muted/60",children:"Direct neighbour — no path to trace"}),i&&i.hops.length>0&&e.jsxs("div",{className:"space-y-1",children:[i.hops.map((u,d)=>e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted text-[9px] w-3",children:d+1}),e.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill font-mono text-[10px] text-fg-primary",children:u.hash}),u.name&&e.jsx("span",{className:"text-fg-muted text-[10px] truncate",children:u.name}),e.jsxs("span",{className:E("font-mono text-[10px] ml-auto",ut(u.snr)),children:[u.snr.toFixed(1)," dB"]})]},d)),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-1 border-t border-edge-subtle",children:[e.jsx("span",{className:"text-fg-muted",children:"Last SNR"}),e.jsxs("span",{className:E("font-mono text-[10px]",ut(i.lastSnr)),children:[i.lastSnr.toFixed(1)," dB"]})]})]})]})})]})}function ut(s){return s>5?"text-sys-green":s>0?"text-sys-amber":"text-sys-red"}function cd(s){return s>5?"bg-sys-green":s>0?"bg-sys-amber":"bg-sys-red"}function dd(s){return s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m`:s<86400?`${Math.floor(s/3600)}h`:`${Math.floor(s/86400)}d`}const nn=128,an=/^[0-9a-fA-F]+$/;function ud({open:s,onClose:t}){const n=re(C=>C.exportPrivateKey),a=re(C=>C.importPrivateKey),[r,i]=l.useState("export"),[o,u]=l.useState(null),[d,f]=l.useState(!1),[c,x]=l.useState(!1),[y,g]=l.useState(""),[m,j]=l.useState(!1),[k,h]=l.useState(!1),[w,I]=l.useState(!1),[R,v]=l.useState(!1),[S,T]=l.useState(null),[M,p]=l.useState(!1);s!==M&&(p(s),s&&(i("export"),u(null),f(!1),x(!1),g(""),j(!1),h(!1),I(!1),v(!1),T(null)));const N=l.useCallback(async()=>{f(!0),T(null),v(!1);try{const C=await n();C==="disabled"?v(!0):u(C.hex)}catch(C){T(C instanceof Error?C.message:"Export failed")}finally{f(!1)}},[n]),_=l.useCallback(async()=>{if(o)try{await navigator.clipboard.writeText(o),x(!0),setTimeout(()=>x(!1),2e3)}catch{T("Failed to copy to clipboard")}},[o]),b=y.length===nn&&an.test(y),L=l.useCallback(async()=>{h(!1),j(!0),T(null),v(!1);try{await a(y)==="disabled"?v(!0):I(!0)}catch(C){T(C instanceof Error?C.message:"Import failed")}finally{j(!1)}},[a,y]);return e.jsxs(e.Fragment,{children:[e.jsxs(Ce,{open:s,onClose:t,size:"md",children:[e.jsx(Te,{icon:e.jsx(In,{className:"w-5 h-5"}),title:"Key Management",onClose:t}),e.jsxs(Se,{children:[R&&e.jsxs("div",{className:"flex items-start gap-2.5 p-3 mb-4 rounded-lg bg-sys-amber/10 border border-sys-amber/20",children:[e.jsx(Pr,{className:"w-4 h-4 text-sys-amber flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"type-body-sm font-medium text-sys-amber",children:"Key operations disabled"}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-0.5",children:"This device's firmware has disabled private key export/import. This is a security setting configured at build time and cannot be changed remotely."})]})]}),e.jsx("div",{className:"flex gap-1 mb-4 p-0.5 rounded-lg bg-subtle-fill",children:["export","import"].map(C=>e.jsxs("button",{onClick:()=>{i(C),T(null)},className:E("flex-1 flex items-center justify-center gap-1.5 py-1.5 px-3 rounded-md text-sm font-medium transition-colors",r===C?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:[C==="export"?e.jsx(qe,{className:"w-3.5 h-3.5"}):e.jsx(Gt,{className:"w-3.5 h-3.5"}),C==="export"?"Export":"Import"]},C))}),r==="export"&&e.jsx("div",{className:"space-y-4",children:o?e.jsxs(ie,{children:[e.jsx(oe,{children:"Private Key (64 bytes)"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"p-3 rounded-lg bg-subtle-fill border border-edge-subtle font-mono text-xs break-all select-all leading-relaxed",children:o}),e.jsx("button",{onClick:_,className:"absolute top-2 right-2 p-1.5 rounded-md hover:bg-subtle-fill-strong transition-colors",title:"Copy to clipboard",children:c?e.jsx(Ne,{className:"w-3.5 h-3.5 text-sys-green"}):e.jsx(Dt,{className:"w-3.5 h-3.5 text-fg-muted"})})]}),e.jsx(Ie,{children:e.jsxs("span",{className:"flex items-start gap-1.5 mt-1",children:[e.jsx(Ve,{className:"w-3 h-3 text-sys-amber flex-shrink-0 mt-0.5"}),"This key controls your mesh identity. Never share it."]})})]}):e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"type-body-sm text-fg-muted mb-3",children:"Export your device's private key for backup. Keep it secret — anyone with this key can impersonate your mesh identity."}),e.jsx(U,{color:"primary",onClick:N,disabled:d||R,children:d?"Exporting…":"Export Private Key"})]})}),r==="import"&&e.jsx("div",{className:"space-y-4",children:w?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-sys-green/10 mx-auto mb-3 flex items-center justify-center",children:e.jsx(Ne,{className:"w-5 h-5 text-sys-green"})}),e.jsx("p",{className:"type-body-sm font-medium text-fg-primary",children:"Key imported successfully"}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-1",children:"The device identity has been updated. You may need to reconnect."})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"Private Key (128 hex characters)"}),e.jsx("textarea",{value:y,onChange:C=>g(C.target.value.replace(/\s/g,"")),placeholder:"Paste your 128-character hex private key here…",rows:3,className:"w-full p-3 rounded-lg bg-subtle-fill border border-edge-subtle font-mono text-xs resize-none focus:outline-none focus:ring-2 focus:ring-sys-blue/50 placeholder:text-fg-muted/40"}),e.jsxs(Ie,{children:[y.length>0&&!b&&e.jsx("span",{className:"text-sys-red",children:an.test(y)?`${y.length}/${nn} characters`:"Invalid characters — hex only (0-9, a-f)"}),y.length>0&&b&&e.jsx("span",{className:"text-sys-green",children:"Valid key format ✓"})]})]}),e.jsxs("div",{className:"flex items-start gap-2.5 p-3 rounded-lg bg-sys-red/5 border border-sys-red/10",children:[e.jsx(Ve,{className:"w-4 h-4 text-sys-red flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"type-data-xs text-fg-muted",children:["Importing a key ",e.jsx("strong",{className:"text-fg-secondary",children:"permanently replaces"})," the device's current identity. All existing contacts will see you as a new node."]})]})]})}),S&&e.jsx("p",{className:"type-data-xs text-sys-red mt-3",children:S})]}),e.jsxs($e,{children:[e.jsx(U,{plain:!0,onClick:t,children:"Close"}),r==="import"&&!w&&e.jsx(U,{color:"danger",onClick:()=>h(!0),disabled:!b||m||R,children:m?"Importing…":"Import Key"})]})]}),e.jsx(Sn,{isOpen:k,title:"Replace Device Identity?",message:"This will permanently replace the device's Ed25519 private key. The current identity cannot be recovered unless you have a backup. Continue?",confirmLabel:"Replace Key",cancelLabel:"Cancel",variant:"danger",onConfirm:L,onCancel:()=>h(!1)})]})}function da(s){return s.settings??{}}const ua="pymc_companion_recent_regions",qt=8;function ma(){try{const s=localStorage.getItem(ua);return s?JSON.parse(s).slice(0,qt):[]}catch{return[]}}function md(s){try{localStorage.setItem(ua,JSON.stringify(s.slice(0,qt)))}catch{}}function pd(s){const t=ma().filter(a=>a!==s);t.unshift(s);const n=t.slice(0,qt);return md(n),n}function rn(s){return s.toLowerCase().replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}function xd({open:s,onClose:t,mode:n,identity:a,onSave:r}){const i=n==="edit"&&a,[o,u]=l.useState(""),[d,f]=l.useState(""),[c,x]=l.useState(""),[y,g]=l.useState(!1),[m,j]=l.useState(""),[k,h]=l.useState(5e3),[w,I]=l.useState("0.0.0.0"),[R,v]=l.useState(!1),[S,T]=l.useState(null),[M,p]=l.useState(""),N=`${s}-${(a==null?void 0:a.name)??""}-${n}`;if(N!==M)if(p(N),T(null),v(!1),g(!1),i){const b=da(a);u(a.name),f(""),x(a.identity_key??""),j(b.node_name??a.name),h(b.tcp_port??5e3),I(b.bind_address??"0.0.0.0")}else u(""),f(""),x(""),j(""),h(5e3),I("0.0.0.0");const _=l.useCallback(async()=>{var b,L;if(!i&&!o.trim()){T("Name is required");return}v(!0),T(null);try{if(i){const C={name:a.name,new_name:d,identity_key:c,type:"companion",settings:{node_name:m,tcp_port:k,bind_address:w}},D=await zr(C);if(!D.success&&!((b=D.data)!=null&&b.message))throw new Error(D.error||"Failed")}else{const C={name:o.trim(),identity_key:c,type:"companion",settings:{node_name:m||o.trim(),tcp_port:k??5e3,bind_address:w||"0.0.0.0"}},D=await Hr(C);if(!D.success&&!((L=D.data)!=null&&L.message))throw new Error(D.error||"Failed")}await r(),t()}catch(C){T(C instanceof Error?C.message:"Operation failed")}finally{v(!1)}},[i,a,o,d,c,m,k,w,r,t]);return e.jsxs(Ce,{open:s,onClose:t,size:"md",children:[e.jsx(Te,{icon:i?void 0:e.jsx(je,{className:"w-5 h-5"}),title:i?"Edit Companion":"Add Companion",onClose:t}),e.jsx(Se,{children:e.jsxs("div",{className:"space-y-5",children:[i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{color:a.registered?"green":"red",children:a.registered?"Active":"Inactive"}),a.hash&&e.jsx("span",{className:"type-data-xs text-fg-muted",children:a.hash})]}),i?e.jsxs(e.Fragment,{children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"Current Name"}),e.jsx(fe,{value:a.name,disabled:!0})]}),e.jsxs(ie,{children:[e.jsxs(oe,{children:["New Name ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(fe,{value:d,onChange:b=>f(b.target.value),placeholder:"Leave empty to keep current name"})]})]}):e.jsxs(ie,{children:[e.jsx(oe,{children:"Name"}),e.jsx(fe,{value:o,onChange:b=>u(b.target.value),placeholder:"e.g., TestCompanion",autoFocus:!0})]}),e.jsxs(ie,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(oe,{children:["Identity Key ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx("button",{type:"button",onClick:()=>g(b=>!b),className:"type-data-xs text-fg-muted underline hover:text-fg-secondary",children:y?"Hide":"Show"})]}),y&&e.jsxs(e.Fragment,{children:[e.jsx(fe,{value:c,onChange:b=>x(b.target.value),placeholder:i?"Leave empty to keep current key":"Leave empty to auto-generate",className:"font-mono"}),e.jsx(Ie,{children:"32 or 64 bytes hex."})]})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Node Name"}),e.jsx(fe,{value:m,onChange:b=>j(b.target.value),placeholder:"Display name"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"TCP Port"}),e.jsx(fe,{type:"number",min:1,max:65535,value:k,onChange:b=>h(parseInt(b.target.value,10)||5e3)})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Bind Address"}),e.jsx(fe,{value:w,onChange:b=>I(b.target.value),placeholder:"0.0.0.0"})]})]}),S&&e.jsx("p",{className:"type-data-xs text-sys-red",children:S})]})}),e.jsxs($e,{children:[e.jsx(U,{plain:!0,onClick:t,children:"Cancel"}),e.jsx(U,{color:"primary",onClick:_,disabled:R,children:R?"Saving…":i?"Save":"Create"})]})]})}function hd(){const s=Dr(),t=yn(),{setFloodScope:n,clearFloodScope:a}=re.getState(),[r,i]=l.useState(""),[o,u]=l.useState(!1),[d,f]=l.useState(ma),[c,x]=l.useState(null),y=l.useRef(null),g=r.trim()?rn(r.trim()):"",m=l.useCallback(async h=>{const w=rn(h);if(!w)return;u(!0),x(null),i(""),f(pd(w)),await n(w)||x("Failed to set transport key on device"),u(!1)},[n]),j=l.useCallback(async()=>{u(!0),x(null),await a()||x("Failed to clear transport key on device"),u(!1)},[a]),k=l.useCallback(h=>{h.key==="Enter"&&g&&(h.preventDefault(),m(g))},[g,m]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-2.5 p-3 rounded-lg bg-sys-blue/5 border border-sys-blue/10",children:[e.jsx(ct,{className:"w-4 h-4 text-sys-blue flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"type-data-xs text-fg-muted",children:["A transport key filters which flood packets the companion device forwards. Set a region name to derive a SHA-256 transport key from ",e.jsx("code",{className:"text-fg-secondary",children:"#name"}),". Only one transport key can be active at a time."]})]}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_n,{className:"w-4 h-4 text-fg-muted"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Active Transport Key"})]}),s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-sys-green/10 text-sys-green type-data font-medium",children:[e.jsx(vn,{className:"w-3.5 h-3.5"}),"#",s]}),e.jsx("button",{onClick:j,disabled:o||!t,className:"p-1.5 rounded-lg hover:bg-sys-red/10 transition-colors disabled:opacity-50",title:"Clear transport key",children:o?e.jsx(ce,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsx(ft,{className:"w-3.5 h-3.5 text-fg-muted hover:text-sys-red"})})]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-subtle-fill-strong text-fg-muted type-data",children:[e.jsx(Lr,{className:"w-3.5 h-3.5"}),"Global (no filter)"]})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Set Region"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-muted/50 type-data",children:"#"}),e.jsx("input",{ref:y,type:"text",value:r,onChange:h=>i(h.target.value),onKeyDown:k,placeholder:"e.g., south-bay",disabled:!t,className:"w-full pl-7 pr-3 py-2 rounded-lg bg-subtle-fill border border-edge-subtle text-sm text-fg-primary placeholder:text-fg-muted/40 focus:outline-none focus:ring-2 focus:ring-sys-blue/50 disabled:opacity-50"})]}),e.jsxs(U,{color:"primary",onClick:()=>m(g),disabled:!g||o||!t,children:[o?e.jsx(ce,{"data-slot":"icon",className:"animate-spin"}):null,"Set"]})]}),g&&g!==r.trim().toLowerCase()&&e.jsxs("p",{className:"type-data-xs text-fg-muted mt-1",children:["Will set as ",e.jsxs("span",{className:"font-mono text-fg-secondary",children:["#",g]})]})]}),d.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(wn,{className:"w-3.5 h-3.5 text-fg-muted/50"}),e.jsx("span",{className:"type-label text-fg-muted",children:"Recent Regions"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:d.map(h=>e.jsx("button",{onClick:()=>m(h),disabled:o||!t,className:E("inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-medium transition-colors","disabled:opacity-50 disabled:cursor-not-allowed",h===s?"bg-sys-green/10 text-sys-green":"bg-subtle-fill hover:bg-subtle-fill-strong text-fg-secondary"),children:e.jsxs("span",{className:"font-mono",children:["#",h]})},h))})]}),!t&&e.jsx("p",{className:"type-data-xs text-sys-amber",children:"Companion device is not connected. Connect to a companion to manage transport keys."}),c&&e.jsx("p",{className:"type-data-xs text-sys-red",children:c})]})}function ln({open:s,onClose:t,onRefresh:n}){const[a,r]=l.useState("companions"),[i,o]=l.useState(null),[u,d]=l.useState(!0),[f,c]=l.useState(!1),[x,y]=l.useState("create"),[g,m]=l.useState(null),[j,k]=l.useState(null),[h,w]=l.useState(!1),[I,R]=l.useState(!1),v=l.useRef(!0);l.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const[S,T]=l.useState(!1);s!==S&&(T(s),s&&r("companions"));const M=l.useCallback(async()=>{d(!0);try{const H=await Tr();v.current&&H.success&&H.data&&o(H.data)}catch{}finally{v.current&&d(!1)}},[]);l.useEffect(()=>{s&&M()},[s,M]);const p=(i==null?void 0:i.configured_companions)??[],N=l.useCallback(async()=>{await M(),n==null||n()},[M,n]),_=l.useCallback(async()=>{if(j){w(!0);try{await $r(j.name,"companion"),await N()}catch{}finally{v.current&&(w(!1),k(null))}}},[j,N]),b=Ar(),L=gn(),{setCompanionPaused:C}=re.getState(),[D,$]=l.useState({});l.useEffect(()=>{if(!(i!=null&&i.configured_companions))return;const H={};for(const A of i.configured_companions)H[A.name]=Fr(A.name);$(H)},[i]);const G=l.useCallback(H=>H===L?b:D[H]??!1,[L,b,D]),[F,q]=l.useState(null),X=l.useCallback(async(H,A)=>{q(H);try{await C(H,!A),$(z=>({...z,[H]:!A}))}finally{v.current&&q(null)}},[C]);return e.jsxs(e.Fragment,{children:[e.jsxs(Ce,{open:s,onClose:t,size:"md",children:[e.jsx(Te,{icon:e.jsx(je,{className:"w-5 h-5"}),title:"Companion Configuration",onClose:t}),e.jsxs(Se,{children:[e.jsx("div",{className:"flex gap-1 mb-4 p-0.5 rounded-lg bg-subtle-fill",children:[["companions","Companions",je],["transport","Transport Key",_n]].map(([H,A,z])=>e.jsxs("button",{onClick:()=>r(H),className:E("flex-1 flex items-center justify-center gap-1.5 py-1.5 px-3 rounded-md text-sm font-medium transition-colors",a===H?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:[e.jsx(z,{className:"w-3.5 h-3.5"}),A]},H))}),a==="companions"&&e.jsx(e.Fragment,{children:u?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(ce,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"text-sm text-fg-muted",children:"Loading…"})]}):p.length>0?e.jsx("div",{className:"space-y-3",children:p.map(H=>{const A=da(H),z=G(H.name),O=!z&&H.registered,W=F===H.name;return e.jsxs("div",{className:E("bg-subtle-fill radius-inner p-3 hover:bg-subtle-fill-strong transition-base",z&&"opacity-60"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:E("h-2 w-2 rounded-full flex-shrink-0",O?"bg-sys-green":z?"bg-fg-muted":"bg-sys-red")}),e.jsx("h3",{className:"type-body-sm text-fg-primary font-medium truncate flex-1",children:H.name}),e.jsx(ze,{color:O?"green":z?"zinc":"red",children:z?"Paused":O?"Active":"Inactive"}),e.jsx(U,{color:"primary",plain:!0,onClick:()=>{m(H),y("edit"),c(!0)},children:e.jsx(Wl,{"data-slot":"icon"})}),e.jsx(Or,{enabled:!z,onChange:J=>X(H.name,J),size:"sm",disabled:W,status:W?"loading":"idle",tooltip:z?"Resume connection":"Pause connection",dangerOff:!0}),e.jsx(U,{color:"danger",plain:!0,onClick:()=>k(H),children:e.jsx(Qe,{"data-slot":"icon"})})]}),e.jsxs("div",{className:"mt-1.5 type-data-xs text-fg-muted pl-5",children:[A.node_name||H.name," · Port ",A.tcp_port??5e3," · ",A.bind_address||"0.0.0.0"]})]},H.name)})}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-subtle-fill mx-auto mb-3 flex items-center justify-center",children:e.jsx(je,{className:"w-5 h-5 text-fg-muted/50"})}),e.jsx("p",{className:"text-sm text-fg-muted",children:"No companions configured"})]})}),a==="transport"&&e.jsx(hd,{})]}),e.jsxs($e,{children:[a==="companions"&&e.jsx(U,{plain:!0,onClick:()=>R(!0),title:"Key Management",children:e.jsx(In,{"data-slot":"icon"})}),e.jsx("div",{className:"flex-1"}),e.jsx(U,{plain:!0,onClick:t,children:"Close"}),a==="companions"&&e.jsxs(U,{color:"primary",onClick:()=>{m(null),y("create"),c(!0)},children:[e.jsx(Xe,{"data-slot":"icon"})," Add Companion"]})]})]}),e.jsx(xd,{open:f,onClose:()=>c(!1),mode:x,identity:g,onSave:N}),e.jsx(Sn,{isOpen:!!j,title:"Delete Companion",message:`Delete '${j==null?void 0:j.name}'? A service restart is required.`,confirmLabel:h?"Deleting…":"Delete",cancelLabel:"Cancel",variant:"danger",onConfirm:_,onCancel:()=>k(null)}),e.jsx(ud,{open:I,onClose:()=>R(!1)})]})}const fd=l.memo(function({companions:t,selected:n,onSelect:a}){return t.length<2?null:e.jsx("select",{value:n??"",onChange:r=>a(r.target.value),className:"px-2 py-1 text-sm bg-transparent border border-edge-subtle radius-inner text-fg-primary focus:outline-none focus:ring-1 focus:ring-sys-blue/40",children:t.map(r=>e.jsx("option",{value:r.companion_name,children:r.node_name||r.companion_name},r.companion_name))})}),Ge=[{value:"Chat Node",label:"Companions"},{value:"Room Server",label:"Room Servers"},{value:"Repeater",label:"Repeaters"}],gd=[{value:"all",label:"All time"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function yd(s){switch(s){case"24h":return 24;case"7d":return 168;case"30d":return 720;default:return}}function bd({open:s,onClose:t,companionName:n,onImport:a}){const[r,i]=l.useState(()=>new Set(Ge.map(R=>R.value))),[o,u]=l.useState("all"),[d,f]=l.useState(""),[c,x]=l.useState(!1),[y,g]=l.useState(null),[m,j]=l.useState(s);s!==m&&(j(s),s&&(i(new Set(Ge.map(R=>R.value))),u("all"),f(""),x(!1),g(null)));const k=r.size===Ge.length;function h(R){i(v=>{const S=new Set(v);return S.has(R)?S.delete(R):S.add(R),S})}function w(){i(k?new Set:new Set(Ge.map(R=>R.value)))}const I=l.useCallback(async()=>{if(!(r.size===0||c)){x(!0),g(null);try{const R={types:[...r],hours:yd(o)},v=parseInt(d,10);v>0&&(R.limit=v);const S=await a(R);g(S)}finally{x(!1)}}},[r,o,d,c,a]);return e.jsxs(Ce,{open:s,onClose:t,size:"sm",children:[e.jsx(Te,{title:"Import repeater contacts",onClose:t}),e.jsx(Se,{children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("p",{className:"text-sm text-fg-secondary",children:["Seed ",e.jsx("strong",{className:"text-fg-primary",children:n})," with contacts from the repeater's adverts. Results are ordered by most recent first."]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Contact types"}),e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsx(Is,{checked:k,indeterminate:r.size>0&&!k,onChange:w,label:"All types",size:"sm"}),e.jsx("div",{className:"ml-6 space-y-1.5",children:Ge.map(R=>e.jsx(Is,{checked:r.has(R.value),onChange:()=>h(R.value),label:R.label,size:"sm"},R.value))})]})]}),e.jsx(so,{label:"Recency",value:o,onChange:u,options:gd,orientation:"horizontal",size:"sm"}),e.jsxs(ie,{children:[e.jsxs(oe,{children:["Import at most ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(optional)"})]}),e.jsx(fe,{type:"number",min:1,value:d,onChange:R=>f(R.target.value),placeholder:"No limit",className:"mt-1"}),e.jsx(Ie,{children:"Leave empty for no cap."})]}),y&&e.jsxs("p",{className:"text-sm text-sys-green font-medium",children:["Imported ",y.added," new contact",y.added!==1?"s":""," (",y.total," total)"]})]})}),e.jsxs($e,{children:[e.jsx(U,{plain:!0,onClick:t,children:"Cancel"}),e.jsx(U,{color:"primary",onClick:I,disabled:c||r.size===0,children:c?e.jsxs(e.Fragment,{children:[e.jsx(ce,{"data-slot":"icon",className:"animate-spin"}),"Importing…"]}):"Import"})]})]})}const vd=["alameda","alpine","amador","butte","calaveras","colusa","contracosta","contra-costa","delnorte","del-norte","eldorado","el-dorado","fresno","glenn","humboldt","imperial","inyo","kern","kings","lake","lassen","losangeles","los-angeles","la-county","madera","marin","mariposa","mendocino","merced","modoc","mono","monterey","napa","nevada","orange","oc","placer","plumas","riverside","sacramento","sac","sanbenito","san-benito","sanbernardino","san-bernardino","sandiego","san-diego","sd","sanfrancisco","san-francisco","sf","sanjoaquin","san-joaquin","sanluisobispo","san-luis-obispo","slo","sanmateo","san-mateo","santabarbara","santa-barbara","sb","santaclara","santa-clara","santacruz","santa-cruz","shasta","sierra","siskiyou","solano","sonoma","stanislaus","sutter","tehama","trinity","tulare","tuolumne","ventura","yolo","yuba","losangeles","los-angeles","la","hollywood","westhollywood","west-hollywood","weho","beverlyhills","beverly-hills","santamonica","santa-monica","culvercity","culver-city","marinadelrey","marina-del-rey","venice","venicebeach","venice-beach","malibu","palisades","pacificpalisades","pacific-palisades","brentwood","westwood","westla","west-la","dtla","downtown","downtownla","downtown-la","koreatown","ktown","silverlake","silver-lake","losfeliz","los-feliz","echopark","echo-park","eastla","east-la","boyleheights","boyle-heights","highlandpark","highland-park","eaglerock","eagle-rock","pasadena","southpasadena","south-pasadena","glendale","burbank","tolucalake","toluca-lake","studiocity","studio-city","shermanoaks","sherman-oaks","encino","tarzana","reseda","vannuys","van-nuys","northhollywood","north-hollywood","noho","woodlandhills","woodland-hills","calabasas","topanga","agourahills","agoura-hills","thousandoaks","thousand-oaks","simivalley","simi-valley","simi","moorpark","camarillo","oxnard","porthueneme","port-hueneme","ventura","ojai","sfv","sfvalley","sf-valley","thevalley","the-valley","sanfernando","san-fernando","sanfernandovalley","san-fernando-valley","pacoima","sylmar","sunland","tujunga","sunlandtujunga","lakeviewterrace","lakeview-terrace","shadowhills","shadow-hills","chatsworth","northridge","granadahills","granada-hills","missionhills","mission-hills","panoramacity","panorama-city","arleta","sunvalley","sun-valley","santaclarita","santa-clarita","scv","valencia","newhall","saugus","canyoncountry","canyon-country","castaic","stevenson","stevensonranch","stevenson-ranch","acton","agua-dulce","aguadulce","palmdale","lancaster","antelopevalley","antelope-valley","av","avmesh","av-mesh","quartz-hill","quartzhill","littlerock","little-rock","pearblossom","pear-blossom","lakelosangeles","lake-los-angeles","highdesert","high-desert","hd","hdmesh","hd-mesh","victorville","hesperia","applevalley","apple-valley","barstow","adelanto","phelan","pinon-hills","pinonhills","wrightwood","bigbear","big-bear","lakeisabella","lake-isabella","inlandempire","inland-empire","ie","riverside","corona","moreno-valley","morenovalley","fontana","ontario","rancho","ranchocucamonga","rancho-cucamonga","upland","claremont","pomona","azusa","glendora","covina","westcovina","west-covina","diamondbar","diamond-bar","chino","chinohills","chino-hills","sanbernardinocity","rialto","colton","redlands","yuciapa","yucaipa","beaumont","banning","hemet","perris","menifee","temecula","murrieta","wildomar","lakeland","lakeelsinore","lake-elsinore","orangecounty","orange-county","oc","anaheim","fullerton","santaana","santa-ana","irvine","costamesa","costa-mesa","newportbeach","newport-beach","newport","huntingtonbeach","huntington-beach","hb","surfcity","surf-city","lagunabeach","laguna-beach","lagunaniguel","laguna-niguel","sanclemente","san-clemente","danapoint","dana-point","missionviejo","mission-viejo","lakeforest","lake-forest","rsm","ranchosantamargarita","rancho-santa-margarita","alisoviejo","aliso-viejo","tustin","orange","yorbalinda","yorba-linda","brea","lahabra","la-habra","placentia","buenapark","buena-park","cypress","losalamitojos","sealbeach","seal-beach","gardengrove","garden-grove","westminster","stanton","fountainvalley","sandiego","san-diego","sd","sdmesh","sd-mesh","lajolla","la-jolla","pacificbeach","pacific-beach","pb","missionbeach","mission-beach","oceanbeach","ocean-beach","ob","pointloma","point-loma","coronado","hillcrest","northpark","north-park","southpark","south-park","normalheights","normal-heights","cityheights","city-heights","lamesa","la-mesa","elcajon","el-cajon","santee","lakeside","poway","ramona","julian","alpine","escondido","sanmarcos","san-marcos","vista","oceanside","carlsbad","encinitas","delmar","del-mar","solanabeanch","solana-beach","chulavista","chula-vista","nationalcity","national-city","imperialbeach","imperial-beach","ib","southbay","south-bay","torrance","gardena","hawthorne","lawndale","redondo","redondobeach","hermosa","hermosabeach","manhattan","manhattanbeach","manhattan-beach","elsegundo","el-segundo","palosverdes","palos-verdes","pv","ranchopalosverdes","rancho-palos-verdes","sanpedro","san-pedro","wilmington","carson","compton","longbeach","long-beach","lb","signalhill","signal-hill","lakewood","cerritos","artesia","lamirada","la-mirada","norwalk","whittier","lahabra","la-habra-heights","downey","bellflower","paramount","southgate","south-gate","lynwood","bellgardens","bell-gardens","cudahy","huntingtonpark","maywood","vernon","commerce","montebello","picorivera","pico-rivera","montereypark","monterey-park","alhambra","sanmarinno","san-marino","arcadia","monrovia","duarte","azusa","irwindale","baldwinpark","baldwin-park","elmonbte","el-monte","southelmonte","south-el-monte","rosemead","temple-city","templecity","sangabriel","san-gabriel","santabarbara","santa-barbara","sb","goleta","carpinteria","montecito","islavista","isla-vista","iv","ucsb","slo","sanluisobispo","san-luis-obispo","morrobay","morro-bay","pismobeach","pismo-beach","pismo","shellbeach","shell-beach","arroyogrande","arroyo-grande","groverbeach","grover-beach","oceano","santamaria","santa-maria","lompoc","vandenberg","solvang","buellton","losalamos","los-alamos","atascadero","pasorobles","paso-robles","paso","cambria","cayucos","sansiemon","san-simeon","hearst","fresno","clovis","visalia","tulare","hanford","porterville","bakersfield","bako","delano","wasco","shafter","taft","tehachapi","stockton","tracy","manteca","lodi","modesto","turlock","merced","madera","chowchilla","losabnos","los-banos","sacramento","sac","sactown","westsacramento","west-sacramento","westsac","elkgrove","elk-grove","folsom","ranchocordova","rancho-cordova","roseville","rocklin","lincoln","citrus-heights","citrusheights","fair-oaks","fairoaks","carmichael","orangevale","davis","woodland","dixon","vacaville","fairfield","vallejo","bayarea","bay-area","sfbay","sf-bay","sanfrancisco","san-francisco","sf","sfmesh","sf-mesh","oakland","eastbay","east-bay","berkeley","emeryville","alameda","sanleandro","san-leandro","hayward","fremont","unioncity","union-city","newark","milpitas","sanjose","san-jose","sj","campbell","saratoga","losgartos","los-gatos","sunnyvale","santaclara","santa-clara","cupertino","mountainview","mountain-view","paloalto","palo-alto","menlopark","menlo-park","atherton","redwoodcity","redwood-city","sancarlos","san-carlos","belmont","sanmateo","san-mateo","fostercity","foster-city","burlingame","sanbruno","san-bruno","southsanfrancisco","ssf","dalycity","daly-city","pacifica","halfmoonbay","half-moon-bay","hmb","santacruz","santa-cruz","capitola","scottsvalley","scotts-valley","watsonville","aptos","soquel","concord","walnutcreek","walnut-creek","pleasant-hill","pleasanthill","martinez","antioch","pittsburg","brentwood","oakley","discovery-bay","livermore","pleasanton","dublin","sanramon","san-ramon","danville","richmond","sanpablo","san-pablo","pinole","hercules","napa","sonoma","petaluma","santarosa","santa-rosa","rohnertpark","novato","sanrafael","san-rafael","sausalito","tiburon","millvalley","mill-valley","redding","chico","oroville","paradise","reddingbluff","redbluff","red-bluff","shasta","mtshasta","mt-shasta","eureka","arcata","fortuna","mckibleyville","ukiah","fortbragg","fort-bragg","willits","yreka","weed","dunsmuir","tahoe","laketahoe","lake-tahoe","southlaketahoe","south-lake-tahoe","truckee","squaw","squawvalley","squaw-valley","northstar","mammoth","mammothlakes","mammoth-lakes","bishopca","bishop","placerville","tahoe-city","tahoecity","kings-beach","kingsbeach","incline","inclinevillage","incline-village","maricopa","pima","pinal","yavapai","yuma","mohave","coconino","cochise","navajo","apache","gila","santacruzaz","graham","lapaz","la-paz","greenlee","arizona","az","azmesh","az-mesh","phoenix","phx","phoenixmesh","phoenix-mesh","scottsdale","tempe","mesa","gilbert","chandler","glendale","peoria","surprize","avondale","goodyear","buckeye","litchfieldpark","litchfield-park","tolleson","laveen","paradisevalley","paradise-valley","pv","carefree","cavekreek","cave-creek","fountainhills","fountain-hills","rioverde","rio-verde","queencreek","queen-creek","santan","san-tan","santanvalley","ahwatukee","southmountain","south-mountain","anthem","newriver","new-river","apachejunction","apache-junction","aj","goldcanyon","gold-canyon","tucson","tucsomesh","tucson-mesh","orovalley","oro-valley","marana","catalina","catalinafoothills","saddlebrooke","casagrande","casa-grande","eloy","coolidge","florence","sierravista","sierra-vista","bisbee","tombstone","benson","douglas","nogales","tubac","greenvalley","green-valley","sahuarita","flagstaff","flag","flagmesh","sedona","cottonwood","clarkdale","prescott","prescottvalley","prescott-valley","dewey","chino-valley","chinovalley","williams","grandcanyon","grand-canyon","tusayan","page","marble-canyon","showlow","show-low","pinetop","pinetoplakeside","lakeside","snowflake","taylor","payson","pine","strawberry","camp-verde","campverde","winslow","holbrook","stjohns","springerville","eagar","yuma","yumamesh","fortuna-foothills","sanluisaz","san-luis","lakehavasu","lake-havasu","havasu","havasucity","lake-havasu-city","bullheadcity","bullhead-city","bullhead","laughlin","kingman","goldenkvalley","golden-valley","parker","quartzsite","wickenburg","lasvegas","las-vegas","vegas","vegasmesh","vegas-mesh","lv","henderson","boulder-city","bouldercity","northlasvegas","north-las-vegas","nlv","summerlin","enterprise","pahrump","mesquite","reno","sparks","carsoncity","carson-city","incline","bajacalifornia","baja-california","baja","bajamesh","tijuana","tj","mexicali","ensenada","tecate","rosarito","sanfelipe","san-felipe","sanluis","sanluisriocoalorado","brabant","flevoland","gelderland","noordbrabant","noordholland","zuid-holland","zuidholland","zeeland","twente","alkmaar","almere","amsterdam","amstelland","capelleaandenijssel","denhaag","dordrecht","drechtsteden","eindhoven","haarlem","hellevoetsluis","hilversum","katwijk","lelystad","maassluis","middelburg","rijnmond","rotterdam","tilburg","utrecht","vlissingen","voorburg","voorne-putten","walcheren","west-friesland","zaandam","zaanstreek-waterland","024-bot","afrithonbot","ai","amradio","analyser","angrynerds","bemesh","bot","buch","burgernet","chat","chatgpt","dares","dekroeg","dtis","emergency","english","evenvroegopstaan","fosdem","gezellig","gmr","gmrbot","goedemorgen","gyverbot","haagscourant","hackerspacenijmegen","hamradio","hamradionederland","hetweerinjegemeente","hsnl","jokes","kanalen","koffie","linux","meshcore","nerd","nl-alert","nl-prio","noodkanaal","nsagov","pi4hm","pi4utr","pingbot","sensemakers","sports","survival","test","testing","uitdagingen","valleibot","valleirug","vleesboek","wardrive","weer","swl","qso","qrz","cq","dx","sstv","aprs","winlink","aredn","hamnet","emcomm","emcommplanning","races","ares","auxcomm","simplex","repeater","uhf","vhf","2m","70cm","440"],jd=new Set(vd);function Nd(){return crypto.getRandomValues(new Uint8Array(16))}function on(s){return Array.from(s).map(t=>t.toString(16).padStart(2,"0")).join("")}function _t(s){const t=s.replace(/\s/g,"");if(t.length!==32||!/^[0-9a-fA-F]+$/.test(t))return null;const n=new Uint8Array(16);for(let a=0;a<16;a++)n[a]=parseInt(t.slice(a*2,a*2+2),16);return n}async function wd(s){const n=`#${bn(s)}`,a=new TextEncoder().encode(n);return(await Br(a)).slice(0,16)}const cn=[{key:"create-private",label:"Create Private",icon:Rl,desc:"Generate a new private channel with a random key"},{key:"join-private",label:"Join Private",icon:Oi,desc:"Join an existing private channel using a shared key"},{key:"join-hashtag",label:"Join Hashtag",icon:He,desc:"Join a public hashtag channel (key derived from name)"}];function kd({open:s,onClose:t,channels:n,onAddChannel:a}){var _;const[r,i]=l.useState("join-hashtag"),[o,u]=l.useState(""),[d,f]=l.useState(""),[c,x]=l.useState(null),[y,g]=l.useState(!1),[m,j]=l.useState(""),[k,h]=l.useState(!1),[w,I]=l.useState(s);s!==w&&(I(s),s&&(i("join-hashtag"),u(""),f(""),x(null),g(!1),j(""),h(!1)));const R=l.useMemo(()=>n.length===0?0:Math.max(...n.map(b=>b.index))+1,[n]),v=l.useMemo(()=>r!=="join-hashtag"?"":bn(o),[r,o]),S=l.useMemo(()=>{if(!o.trim())return null;const b=r==="join-hashtag"&&v?`#${v}`:o.trim();return n.find(L=>L.name===b)??null},[o,r,v,n]),T=l.useMemo(()=>r==="join-hashtag"&&v?jd.has(v):!1,[r,v]),M=l.useMemo(()=>{if(!o.trim()||S)return!1;switch(r){case"create-private":return o.trim().length>0&&o.trim().length<=32;case"join-private":return o.trim().length>0&&_t(d)!==null;case"join-hashtag":return v.length>0;default:return!1}},[r,o,d,v,S]),p=l.useCallback(async()=>{c&&(await navigator.clipboard.writeText(on(c)),h(!0),setTimeout(()=>h(!1),2e3))},[c]),N=l.useCallback(async()=>{if(!(!M||y)){g(!0),j("");try{let b,L;switch(r){case"create-private":{b=Nd(),L=o.trim();break}case"join-private":{const D=_t(d);if(!D){j("Invalid hex key (must be 32 hex chars = 16 bytes)");return}b=D,L=o.trim();break}case"join-hashtag":{b=await wd(o),L=`#${v}`;break}default:return}if(await a(R,L,b)){if(r==="create-private"){x(b);return}t()}else j("Failed to add channel — device may be unreachable")}catch(b){j(b instanceof Error?b.message:"Unknown error")}finally{g(!1)}}},[M,y,r,o,d,v,R,a,t]);return e.jsxs(Ce,{open:s,onClose:t,size:"sm",children:[e.jsx(Te,{title:"Add Channel",onClose:t}),e.jsx(Se,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex gap-1 p-0.5 radius-inner bg-zinc-950/5",children:cn.map(b=>{const L=b.icon,C=r===b.key;return e.jsxs("button",{onClick:()=>{i(b.key),j(""),x(null)},className:E("flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors",C?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:[e.jsx(L,{className:"w-3.5 h-3.5"}),b.label]},b.key)})}),e.jsx("p",{className:"text-xs text-fg-muted",children:(_=cn.find(b=>b.key===r))==null?void 0:_.desc}),c&&r==="create-private"&&e.jsxs("div",{className:"p-3 radius-inner bg-sys-green/8 border border-sys-green/20 space-y-2",children:[e.jsx("p",{className:"text-xs text-sys-green font-medium",children:"Channel created! Share this key with others:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 text-[11px] font-mono text-fg-primary bg-zinc-950/10 px-2 py-1 rounded break-all",children:on(c)}),e.jsx("button",{onClick:p,className:"p-1.5 rounded hover:bg-subtle-fill transition-colors flex-shrink-0",title:"Copy key",children:k?e.jsx(Ne,{className:"w-3.5 h-3.5 text-sys-green"}):e.jsx(Dt,{className:"w-3.5 h-3.5 text-fg-muted"})})]}),e.jsx("p",{className:"text-[11px] text-fg-muted",children:"Save this key — it cannot be recovered later."})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:r==="join-hashtag"?"Hashtag name":"Channel name"}),e.jsx(fe,{type:"text",value:o,onChange:b=>u(b.target.value),placeholder:r==="join-hashtag"?"e.g. south-bay":"e.g. My Channel",maxLength:32,className:"mt-1",disabled:!!c}),r==="join-hashtag"&&v&&v!==o&&e.jsxs(Ie,{className:"mt-1",children:["Will be registered as ",e.jsxs("code",{className:"text-fg-primary font-mono text-[11px]",children:["#",v]})]}),r==="join-hashtag"&&T&&e.jsx(Ie,{className:"mt-1 text-sys-green",children:"Known region channel"})]}),S&&e.jsxs("div",{className:"flex items-start gap-2 p-2.5 radius-inner bg-sys-red/8 border border-sys-red/20",children:[e.jsx(Ve,{className:"w-3.5 h-3.5 text-sys-red flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs text-fg-secondary",children:["Channel ",e.jsx("strong",{className:"text-fg-primary",children:S.name})," already exists at slot ",S.index,". Remove it first to re-add."]})]}),r==="join-private"&&e.jsxs(ie,{children:[e.jsxs(oe,{children:["Channel key ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(32 hex chars)"})]}),e.jsx(fe,{type:"text",value:d,onChange:b=>f(b.target.value),placeholder:"e.g. a1b2c3d4e5f6...",maxLength:32,className:"mt-1 font-mono text-xs"}),d&&!_t(d)&&e.jsx(Ie,{className:"mt-1 text-sys-red",children:"Must be exactly 32 hex characters (16 bytes)"})]}),e.jsxs("p",{className:"text-[11px] text-fg-muted",children:["Will be assigned to channel slot ",e.jsx("strong",{className:"text-fg-primary",children:R})]}),m&&e.jsx("p",{className:"text-xs text-sys-red font-medium",children:m})]})}),e.jsxs($e,{children:[e.jsx(U,{plain:!0,onClick:t,children:c?"Done":"Cancel"}),!c&&e.jsx(U,{color:"primary",onClick:N,disabled:!M||y,children:y?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"}),"Adding…"]}):r==="create-private"?"Create Channel":"Join Channel"})]})]})}const Cd=202,Sd=/^[0-9a-fA-F]+$/;function Id(s){const t=s.replace(/\s/g,"");return t.length>=Cd&&t.length%2===0&&Sd.test(t)}const _d=l.memo(function({open:t,onClose:n,contacts:a,exportPubKey:r,onExport:i,onImport:o}){const[u,d]=l.useState(r?"export":"import"),[f,c]=l.useState(r??""),[x,y]=l.useState(""),[g,m]=l.useState(""),[j,k]=l.useState(!1),[h,w]=l.useState(!1),[I,R]=l.useState(!1),[v,S]=l.useState(null),[T,M]=l.useState(!1),p=l.useRef(null);l.useEffect(()=>{t&&(d(r?"export":"import"),c(r??""),y(""),m(""),k(!1),w(!1),R(!1),S(null),M(!1))},[t,r]);const N=l.useCallback(()=>{n()},[n]),_=l.useCallback(async()=>{if(!f)return;k(!0),S(null),y("");const C=await i(f);k(!1),C?y(C):S("Failed to export contact advert")},[f,i]),b=l.useCallback(async()=>{if(x)try{await navigator.clipboard.writeText(x),R(!0),setTimeout(()=>R(!1),2e3)}catch{S("Failed to copy to clipboard")}},[x]),L=l.useCallback(async()=>{const C=g.replace(/\s/g,"");if(!Id(C)){S("Invalid hex — must be at least 202 hex characters (101 bytes)");return}w(!0),S(null);const D=await o(C);w(!1),D?(M(!0),m(""),setTimeout(()=>N(),1500)):S("Import failed — check the hex string and try again")},[g,o,N]);return e.jsxs(Ce,{open:t,onClose:N,children:[e.jsx(Wr,{children:"Contact Import / Export"}),e.jsxs(Se,{children:[e.jsxs("div",{className:"flex gap-1 p-0.5 rounded-lg bg-subtle-fill mb-4",children:[e.jsxs("button",{onClick:()=>{d("export"),S(null)},className:E("flex-1 flex items-center justify-center gap-1.5 py-1.5 rounded-md text-xs font-medium transition-colors",u==="export"?"bg-surface shadow-sm text-fg-primary":"text-fg-muted hover:text-fg-secondary"),children:[e.jsx(Gt,{className:"w-3.5 h-3.5"}),"Export"]}),e.jsxs("button",{onClick:()=>{d("import"),S(null)},className:E("flex-1 flex items-center justify-center gap-1.5 py-1.5 rounded-md text-xs font-medium transition-colors",u==="import"?"bg-surface shadow-sm text-fg-primary":"text-fg-muted hover:text-fg-secondary"),children:[e.jsx(qe,{className:"w-3.5 h-3.5"}),"Import"]})]}),u==="export"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-fg-muted mb-1",children:"Select contact"}),e.jsxs("select",{value:f,onChange:C=>{c(C.target.value),y(""),S(null)},className:"w-full surface-input rounded-lg px-3 py-2 text-sm text-fg-primary",children:[e.jsx("option",{value:"",children:"Choose a contact…"}),a.map(C=>e.jsx("option",{value:C.public_key,children:C.name||C.public_key.slice(0,12)},C.public_key))]})]}),e.jsx(U,{color:"primary",outline:!0,className:"w-full justify-center",disabled:!f||j,onClick:_,children:j?"Exporting…":"Export Advert"}),x&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{readOnly:!0,value:x,rows:4,className:"w-full surface-input rounded-lg px-3 py-2 text-[10px] font-mono text-fg-primary break-all resize-none"}),e.jsxs(U,{color:I?"success":"primary",outline:!0,className:"w-full justify-center",onClick:b,children:[I?e.jsx(Ne,{"data-slot":"icon"}):e.jsx(Dt,{"data-slot":"icon"}),I?"Copied!":"Copy to Clipboard"]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-fg-muted mb-1",children:"Paste advert hex string"}),e.jsx("textarea",{ref:p,value:g,onChange:C=>{m(C.target.value),S(null),M(!1)},placeholder:"Paste exported advert hex here…",rows:4,className:"w-full surface-input rounded-lg px-3 py-2 text-[10px] font-mono text-fg-primary break-all resize-none placeholder:text-fg-muted/50"}),e.jsx("p",{className:"text-[10px] text-fg-muted/70 mt-1",children:"Minimum 101 bytes (202 hex characters): 32B pubkey + 4B timestamp + 64B signature + appData"})]}),T&&e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-sys-green/10 text-sys-green text-xs font-medium",children:[e.jsx(Ne,{className:"w-3.5 h-3.5"}),"Contact imported successfully"]}),e.jsx(U,{color:"primary",outline:!0,className:"w-full justify-center",disabled:!g.trim()||h,onClick:L,children:h?"Importing…":"Import Contact"})]}),v&&e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 mt-3 rounded-lg bg-sys-red/10 text-sys-red text-xs",children:[e.jsx(Nn,{className:"w-3.5 h-3.5 flex-shrink-0"}),v]})]}),e.jsx($e,{children:e.jsx(U,{plain:!0,onClick:N,children:"Close"})})]})});function cu(){var hs,fs,gs,ys,bs,vs;const s=Ur(),t=gn(),n=Gr(),a=Kr(),r=qr(),i=Vr(),o=gt(),u=Jr(),d=Qr(),f=Xr(),c=Yr(),x=l.useMemo(()=>{if(r.length===0)return a;const P=new Set(a.map(B=>B.public_key));return[...a,...r.filter(B=>!P.has(B.public_key))]},[a,r]),y=l.useMemo(()=>{const P=new Set;if(!(c!=null&&c.neighbors))return P;const B=[];for(const[K,te]of Object.entries(c.neighbors))te.zero_hop&&B.push((K.startsWith("0x")?K.slice(2):K).toLowerCase());for(const K of x){const te=K.public_key.toLowerCase();for(const de of B)if(te===de||te.startsWith(de)){P.add(K.public_key);break}}return P},[c==null?void 0:c.neighbors,x]),g=l.useMemo(()=>{const P=new Map;if(!(c!=null&&c.neighbors))return P;const B=[];for(const[K,te]of Object.entries(c.neighbors))te.zero_hop&&te.rssi!=null&&te.snr!=null&&te.rssi!==0&&B.push({hash:(K.startsWith("0x")?K.slice(2):K).toLowerCase(),rssi:te.rssi,snr:te.snr,advertCount:te.advert_count??1});if(B.length===0)return P;for(const K of x){const te=K.public_key.toLowerCase();for(const de of B)if(te===de.hash||te.startsWith(de.hash)){P.set(K.public_key,{rssi:de.rssi,snr:de.snr,advertCount:de.advertCount});break}}return P},[c==null?void 0:c.neighbors,x]),m=Zr(),j=el(),k=yn(),h=tl(),w=sl(),I=nl(),R=al(),v=rl(),[S,T]=ll(),[M,p]=l.useState(!1),[N,_]=l.useState(!1),[b,L]=l.useState(!1),[C,D]=l.useState(!1),[$,G]=l.useState(null),[F,q]=l.useState(!1),[X,H]=l.useState(!1),[A,z]=l.useState(!0),O="pymc_companion_contacts_micro",W="pymc_companion_split",[J,pe]=l.useState(()=>{try{return localStorage.getItem(O)==="1"}catch{return!1}}),xe=25,Ae=75,[wt,Vt]=l.useState(()=>{try{const P=Number(localStorage.getItem(W));return P>=xe&&P<=Ae?P:50}catch{return 50}}),et=l.useRef(null),Be=l.useRef(null),Jt=l.useRef(null),tt=l.useRef(!1),We=l.useRef(wt);We.current=wt;const pa=l.useCallback(P=>{P.preventDefault(),P.target.setPointerCapture(P.pointerId),tt.current=!0},[]),xa=l.useCallback(P=>{if(!tt.current||!et.current)return;const B=et.current.getBoundingClientRect(),K=Math.round(Math.min(Ae,Math.max(xe,(P.clientX-B.left)/B.width*100)));We.current=K,Be.current&&(Be.current.style.width=`${K}%`)},[]),Qt=l.useCallback(()=>{if(!tt.current)return;tt.current=!1;const P=We.current;Vt(P);try{localStorage.setItem(W,String(P))}catch{}},[]),ha=l.useCallback(()=>{We.current=50,Be.current&<(Be.current,{width:"50%"},ue.layoutResize),Vt(50);try{localStorage.setItem(W,String(50))}catch{}},[]),fa=l.useCallback(P=>{pe(P);const B=et.current,K=Jt.current;if(!B)return;const te=B.getBoundingClientRect().width;B.style.width=P?"var(--companion-side-micro)":"var(--companion-side)";const de=B.getBoundingClientRect().width;if(B.style.width=`${te}px`,K){const La=P?56:We.current/100*de,za=K.offsetWidth,Ha=Math.max(0,de-La-12);K.style.flex="none",K.style.width=`${za}px`,lt(K,{width:`${Ha}px`},{...ue.layoutResize,onComplete(){K.style.flex="",K.style.width=""}})}lt(B,{width:`${de}px`},{...ue.layoutResize,onComplete(){B.style.width=P?"var(--companion-side-micro)":"var(--companion-side)"}})},[]),{selectCompanion:ga,selectConversation:we,sendMessage:Xt,sendChannelMessage:Yt,retryMessage:ya,retryMessageAsFlood:ba,resetPath:kt,shareContact:va,removeContact:ja,addChannel:Na,requestStatus:Zt,requestTelemetry:es,loginToRepeater:Ct,logoutFromRepeater:ts,getNeighbours:ss,traceContactPath:ns,discoverPath:as,pingContact:wa,markAsRead:rs,fetchCompanions:ls,seedFromRepeater:ka,exportContactAdvert:Ca,importContactAdvert:Sa,setContactPath:is,deleteChannel:Ia,loadOlderMessages:_a}=re.getState(),Ma=l.useCallback(P=>{we(P),window.innerWidth>=1280?q(!0):H(!0)},[we]),os=re(P=>P.messages),cs=re(P=>P.unreadMap);l.useEffect(()=>{rs()},[m,rs]),l.useEffect(()=>{const P=S.get("dm");P&&x.length>0&&x.find(K=>K.public_key===P)&&(we({type:"contact",id:P}),T({},{replace:!0}))},[S,x,we,T]);const Ra=l.useMemo(()=>{const P=new Set;for(const B of x)B.name&&P.add(B.name);for(const B of j)B.sender_name&&!B.is_outgoing&&P.add(B.sender_name);return[...P].sort((B,K)=>B.localeCompare(K))},[x,j]),ds=l.useMemo(()=>{const P=new Map;for(const B of x)B.name&&P.set(B.name.toLowerCase(),B.public_key);for(const B of j)if(B.sender_name&&B.sender_key&&B.sender_key!=="unknown"&&!B.is_outgoing){const K=B.sender_name.toLowerCase();P.has(K)||P.set(K,B.sender_key)}return P},[x,j]),Ea=l.useCallback(P=>{const B=ds.get(P.toLowerCase());B&&(we({type:"contact",id:B}),q(!0))},[ds,we]),Pa=l.useCallback(async P=>m?m.type==="channel"?Yt(Number(m.id),P):Xt(m.id,P):!1,[m,Xt,Yt]),Ta=k&&!h,us=I!=null&&(I.adv_type&15)===3,ms=Ot(us?I.public_key:null),$a=us&&ms!=="success",ps=il(),[he,Fe]=l.useState("idle"),Aa=l.useCallback(async()=>{Fe("flood-sending");const P=await re.getState().sendFloodAdvert();Fe(P?"flood-done":"idle"),P&&setTimeout(()=>Fe(B=>B==="flood-done"?"idle":B),2e3)},[]),Fa=l.useCallback(async()=>{Fe("zero-sending");const P=await re.getState().sendZeroHopAdvert();Fe(P?"zero-done":"idle"),P&&setTimeout(()=>Fe(B=>B==="zero-done"?"idle":B),2e3)},[]),Oa=e.jsxs("div",{className:"flex items-center gap-2",children:[k&&n&&e.jsxs("div",{className:"hidden sm:flex items-center gap-2",children:[e.jsxs("button",{onClick:Aa,disabled:he!=="idle"&&he!=="zero-done",className:E("inline-flex items-center gap-2 px-3.5 py-2 rounded-xl text-xs font-semibold transition-all duration-150","bg-surface depth-raised-soft hover:depth-raised active:depth-inset","disabled:opacity-50 disabled:cursor-not-allowed",he==="flood-done"?"text-sys-green":"text-fg-secondary hover:text-fg-primary"),title:"A Flood Advert will announce your presence and broadcast your node ID and name anywhere a repeater will repeat it",children:[he==="flood-sending"?e.jsx(ce,{className:"w-4 h-4 animate-spin"}):e.jsx(Gi,{className:"w-4 h-4"}),e.jsx("span",{children:he==="flood-done"?"Sent!":"Flood Advert"})]}),e.jsxs("button",{onClick:Fa,disabled:he!=="idle"&&he!=="flood-done",className:E("inline-flex items-center gap-2 px-3.5 py-2 rounded-xl text-xs font-semibold transition-all duration-150","bg-surface depth-raised-soft hover:depth-raised active:depth-inset","disabled:opacity-50 disabled:cursor-not-allowed",he==="zero-done"?"text-sys-green":"text-fg-secondary hover:text-fg-primary"),title:"A Local Advert, or “Zero Hop” advert will not be repeated by local repeaters, but will be heard by those within range",children:[he==="zero-sending"?e.jsx(ce,{className:"w-4 h-4 animate-spin"}):e.jsx($n,{className:"w-4 h-4"}),e.jsx("span",{children:he==="zero-done"?"Sent!":"Local Advert"})]})]}),e.jsx("button",{onClick:()=>ol.getState().toggleFocusMode(),className:"hidden lg:flex p-1.5 hover:bg-subtle-fill rounded transition-colors",title:ps?"Collapse view":"Expand view",children:ps?e.jsx(Ll,{className:"w-4 h-4 text-fg-muted"}):e.jsx(zl,{className:"w-4 h-4 text-fg-muted"})})]}),Da=e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[e.jsx(ve,{children:f.length>0&&e.jsx(me.div,{layout:!0,initial:{opacity:0,scale:.9,width:0},animate:{opacity:1,scale:1,width:"auto"},exit:{opacity:0,scale:.9,width:0},transition:ue.fade,className:"flex items-center gap-1 overflow-hidden",children:f.map(P=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-sys-green/10 text-[11px] text-sys-green font-medium whitespace-nowrap",children:[e.jsx(Ke,{className:"w-2.5 h-2.5"}),P.name]},P.pubHex))},"advert-notifs")}),e.jsx(ve,{children:!k&&e.jsxs(me.span,{initial:{opacity:0,scale:.9,width:0},animate:{opacity:1,scale:1,width:"auto"},exit:{opacity:0,scale:.9,width:0},transition:ue.fade,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-sys-amber/10 text-[11px] text-sys-amber font-medium whitespace-nowrap overflow-hidden",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5 flex-shrink-0",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-sys-amber opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-sys-amber"})]}),"Reconnecting…"]},"disconnected")}),n&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>_(!0),disabled:u,className:"data-box flex items-center gap-1 cursor-pointer hover:bg-subtle-fill-strong transition-colors disabled:opacity-50",title:d>0?`${d} contacts seeded from repeater — click to refresh`:"Seed contacts from repeater adverts",children:[u?e.jsx(ce,{className:"w-3.5 h-3.5 text-sys-blue animate-spin"}):e.jsx(Yi,{className:"w-3.5 h-3.5 text-sys-blue"}),d>0&&e.jsxs("span",{className:"text-sys-blue",children:["+",d]})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${x.length} contacts${d>0?` (${d} from repeater)`:""}`,children:[e.jsx(Rt,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:x.length})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${n.channels_count} channels`,children:[e.jsx(He,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:n.channels_count})]})]}),e.jsx(fd,{companions:s,selected:t,onSelect:ga}),e.jsx(U,{plain:!0,onClick:()=>p(!0),title:"Companion configuration",children:e.jsx(cl,{"data-slot":"icon"})})]});if(s.length===0&&!h)return e.jsxs(_s,{children:[e.jsx(Ms,{title:"Companion",icon:e.jsx(je,{}),controls:e.jsxs(U,{color:"primary",outline:!0,onClick:()=>p(!0),children:[e.jsx(Xe,{"data-slot":"icon"}),"Add Companion"]})}),e.jsx(Rs,{ready:!0,children:e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(je,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted mb-1",children:"No companions configured"}),e.jsx("p",{className:"type-body-sm text-fg-muted/70 mb-4",children:"Add a companion to start messaging mesh contacts"}),e.jsxs(U,{color:"primary",outline:!0,onClick:()=>p(!0),children:[e.jsx(Xe,{"data-slot":"icon"}),"Add Companion"]})]})}),e.jsx(ln,{open:M,onClose:()=>p(!1),onRefresh:ls})]});const xs=m?m.type==="channel"?((hs=i.find(P=>String(P.index)===m.id))==null?void 0:hs.name)??"Channel":((fs=x.find(P=>P.public_key===m.id))==null?void 0:fs.name)??m.id.slice(0,8):null;return e.jsxs(_s,{children:[e.jsx(Ms,{title:(o==null?void 0:o.node_name)||"Companion",icon:e.jsx(je,{}),leading:Oa,controls:Da}),e.jsx(Rs,{children:e.jsxs("div",{className:"companion-layout flex gap-4",style:{height:"calc(100vh - 11rem)",minHeight:400},children:[e.jsxs("div",{ref:et,className:E("flex-shrink-0 flex h-full overflow-hidden radius-inner bg-surface/80 backdrop-blur-lg depth-raised",A?"":"hidden md:flex"),style:{width:J?"var(--companion-side-micro)":"var(--companion-side)"},children:[e.jsx(zo,{ref:Be,contacts:x,selectedConversation:m,unreadMap:cs,messages:os,onSelect:P=>{we(P),window.innerWidth<768&&z(!1)},onShowDetails:Ma,onShareContact:va,onResetPath:kt,onRemoveContact:ja,onPingContact:wa,repeaterNeighborHashes:y,repeaterSignalMap:g,isLoading:h,splitPercent:wt,onMicroChange:fa}),e.jsx("div",{className:"group/divider flex-shrink-0 self-stretch flex items-center justify-center w-3 cursor-col-resize select-none touch-none",onPointerDown:pa,onPointerMove:xa,onPointerUp:Qt,onPointerCancel:Qt,onDoubleClick:ha,children:e.jsx("div",{className:"w-px h-full my-2 bg-edge-subtle/50 group-hover/divider:bg-sys-blue/50 group-active/divider:bg-sys-blue transition-colors"})}),e.jsx(Go,{ref:Jt,channels:i,selectedConversation:m,unreadMap:cs,messages:os,onSelect:P=>{we(P),window.innerWidth<768&&z(!1)},onAddChannel:()=>L(!0),onDeleteChannel:Ia})]}),e.jsxs(Es,{noPadding:!0,radius:"sm",className:"flex-1 flex flex-col min-w-0 overflow-hidden relative",children:[e.jsx(ve,{children:w&&e.jsxs(me.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:ue.fade,className:"flex items-center justify-center gap-2 px-3 py-1.5 bg-sys-red/10 border-b border-sys-red/20",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-sys-red flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-sys-red font-medium truncate",children:w})]},"error-banner")}),!A&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-edge-subtle md:hidden",children:[e.jsx("button",{onClick:()=>z(!0),className:"p-1 hover:bg-subtle-fill rounded transition-colors",children:e.jsx(Ii,{className:"w-4 h-4 text-fg-secondary"})}),e.jsx("span",{className:"text-sm text-fg-primary font-medium truncate flex-1",children:xs}),m&&e.jsx("button",{onClick:()=>H(!0),className:"p-1 hover:bg-subtle-fill rounded transition-colors",title:"Details",children:e.jsx(ct,{className:"w-4 h-4 text-fg-muted"})})]}),e.jsxs("div",{className:"hidden md:flex items-center justify-between px-3 py-1.5 border-b border-edge-subtle",children:[e.jsx("span",{className:"text-sm text-fg-primary font-medium truncate",children:xs??"Select a conversation"}),e.jsx(ve,{children:m&&e.jsx(me.button,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:ue.fade,onClick:()=>{window.innerWidth>=1280?q(P=>!P):H(!0)},className:"p-1 hover:bg-subtle-fill rounded transition-colors",title:F?"Hide detail panel":"Show details",children:F&&window.innerWidth>=1280?e.jsx(Ls,{className:"w-4 h-4 text-fg-muted"}):e.jsx(ct,{className:"w-4 h-4 text-fg-muted"})},"ctx-toggle")})]}),$a&&I?e.jsx(Jc,{contact:I,loginStatus:ms,onLogin:Ct}):e.jsxs(e.Fragment,{children:[e.jsx(Uc,{messages:j,contacts:x,className:"flex-1 min-h-0",conversationKey:m?m.type==="channel"?`ch:${m.id}`:m.id:void 0,onRetry:ya,onRetryAsFlood:ba,onMentionClick:Ea,historyLoading:R,historyExhausted:m?v.get(m.type==="channel"?`ch:${m.id}`:m.id)??!1:!0,onLoadOlder:m?()=>_a(m.type==="channel"?`ch:${m.id}`:m.id):void 0,channelName:(m==null?void 0:m.type)==="channel"?(gs=i.find(P=>String(P.index)===m.id))==null?void 0:gs.name:void 0,contactPubKey:(m==null?void 0:m.type)==="contact"?m.id:void 0}),m&&e.jsx(Kc,{onSend:Pa,disabled:!Ta,mentionNames:Ra,placeholder:m.type==="channel"?`Message ${((ys=i.find(P=>String(P.index)===m.id))==null?void 0:ys.name)??"channel"}`:`Message ${((bs=x.find(P=>P.public_key===m.id))==null?void 0:bs.name)??"contact"}`})]})]}),e.jsx(me.div,{initial:!1,animate:{width:F&&m?"var(--companion-context)":"0px",opacity:F&&m?1:0},transition:ue.layoutResize,className:"hidden xl:block flex-shrink-0 overflow-hidden",style:{pointerEvents:F&&m?"auto":"none"},children:m&&e.jsxs(Es,{neomorphic:!0,noPadding:!0,radius:"sm",className:"h-full relative",children:[e.jsx(ve,{children:F&&e.jsx(me.button,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:ue.fade,onClick:()=>q(!1),className:"absolute top-2 left-2 z-10 p-1 hover:bg-subtle-fill rounded-lg transition-colors",title:"Hide detail panel",children:e.jsx(Ls,{className:"w-4 h-4 text-fg-muted"})},"ctx-close")}),e.jsx(en,{contact:m.type==="contact"?I:null,channel:m.type==="channel"?i.find(P=>String(P.index)===m.id)??null:null,contacts:x,selfPubKey:(o==null?void 0:o.public_key)??null,onResetPath:kt,onRequestStatus:Zt,onRequestTelemetry:es,onLoginToRepeater:Ct,onLogoutFromRepeater:ts,onGetNeighbours:ss,onTraceContactPath:ns,onDiscoverPath:as,onExportContact:P=>{G(P),D(!0)},onSetContactPath:is})]})})]})}),e.jsx(ln,{open:M,onClose:()=>p(!1),onRefresh:ls}),e.jsx(bd,{open:N,onClose:()=>_(!1),companionName:t??"companion",onImport:ka}),e.jsx(_d,{open:C,onClose:()=>{D(!1),G(null)},contacts:x,exportPubKey:$,onExport:Ca,onImport:Sa}),e.jsx(kd,{open:b,onClose:()=>L(!1),channels:i,onAddChannel:Na}),e.jsxs(Ce,{open:X,onClose:()=>H(!1),size:"md",children:[e.jsx(Te,{icon:(m==null?void 0:m.type)==="channel"?e.jsx(He,{className:"w-5 h-5"}):I&&(I.adv_type&15)===2?e.jsx(Ke,{className:"w-5 h-5"}):e.jsx(je,{className:"w-5 h-5"}),title:(m==null?void 0:m.type)==="channel"?((vs=i.find(P=>String(P.index)===m.id))==null?void 0:vs.name)??"Channel":(I==null?void 0:I.name)||"Contact Details",onClose:()=>H(!1)}),e.jsx(Se,{className:"max-h-[70vh] overflow-y-auto",children:e.jsx(en,{embedded:!0,contact:(m==null?void 0:m.type)==="contact"?I:null,channel:(m==null?void 0:m.type)==="channel"?i.find(P=>String(P.index)===m.id)??null:null,contacts:x,selfPubKey:(o==null?void 0:o.public_key)??null,onResetPath:kt,onRequestStatus:Zt,onRequestTelemetry:es,onLoginToRepeater:Ct,onLogoutFromRepeater:ts,onGetNeighbours:ss,onTraceContactPath:ns,onDiscoverPath:as,onExportContact:P=>{G(P),D(!0)},onSetContactPath:is})})]})]})}export{cu as default}; diff --git a/frontend/dist/assets/CompanionEchoMap-Hp02AMdw.js b/frontend/dist/assets/CompanionEchoMap-ui9UBOvI.js similarity index 75% rename from frontend/dist/assets/CompanionEchoMap-Hp02AMdw.js rename to frontend/dist/assets/CompanionEchoMap-ui9UBOvI.js index 14fcade0..c39e7935 100644 --- a/frontend/dist/assets/CompanionEchoMap-Hp02AMdw.js +++ b/frontend/dist/assets/CompanionEchoMap-ui9UBOvI.js @@ -1 +1 @@ -import{r as i,c$ as K,a6 as T,Q as Y,fO as D,au as I,cB as J,g7 as Q,Z as q,O as X,j as a,c as V,V as k,cE as ee}from"./index-C2xvS0Jd.js";import{M as te,S as ne,L as se,a as R}from"./maplibre-gl-C9QYi5T6.js";import{useSrcHashResolverMap as ae,useDiscoveredNodes as oe}from"./usePipelineStore-Do-g28wv.js";import{M as re}from"./map-pin-off-D8fZRJ6M.js";import"./node-types-BD70swWz.js";const le={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},A=X.amber,O=q[400],U=i.memo(function({prefix:c,name:o,isLocal:f,color:n}){const[r,u]=i.useState(!1);return a.jsx("div",{onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{pointerEvents:"auto"},children:a.jsxs(k,{color:n,filled:!0,className:V("type-data-xs shadow-lg border border-current/30 transition-all duration-150 cursor-default",r&&"relative z-50"),children:[f&&a.jsx(ee,{className:"w-2.5 h-2.5 mr-0.5"}),c&&a.jsx("span",{className:"font-mono",children:c}),r&&o&&a.jsx("span",{className:c?"ml-0.5 opacity-75":"",children:o})]})})});function N(p,c){return p==null||c==null?!1:p!==0||c!==0}function ie(p,c,o){var u;const f=p.toUpperCase(),n=c.find(l=>l.public_key.toUpperCase().startsWith(f));if(n&&N(n.gps_lat,n.gps_lon))return{name:n.name||null,lat:n.gps_lat,lng:n.gps_lon,hasGps:!0};if(o.neighbors){const l=Object.entries(o.neighbors).find(([t])=>t.toUpperCase().startsWith(f));if(l){const[,t]=l;if(N(t.latitude,t.longitude))return{name:t.node_name||t.name||null,lat:t.latitude,lng:t.longitude,hasGps:!0}}}const r=o.srcHashMap.get(f);if(r){const l=o.discoveredNodes.get(r);if(l&&N(l.latitude,l.longitude))return{name:l.name||null,lat:l.latitude,lng:l.longitude,hasGps:!0};if(o.neighbors){const t=o.neighbors[r];if(t&&N(t.latitude,t.longitude))return{name:t.node_name||t.name||null,lat:t.latitude,lng:t.longitude,hasGps:!0}}}return{name:(n==null?void 0:n.name)||(r?((u=o.discoveredNodes.get(r))==null?void 0:u.name)??null:null),lat:0,lng:0,hasGps:!1}}function ce(p,c,o,f){const n=Math.floor(c/30);for(const r of[n-1,n,n+1])for(const[u,l]of o){const t=l.decoded;if(!(t!=null&&t.decrypted)||t.senderName!==f)continue;const v=t.timestamp??l.timestamp;if(Math.floor(v/30)===r&&t.text===p)return u}return null}function ue(p,c){const o=new Set,f=[];for(const n of c){if(n.packet_hash!==p||n.packet_origin==="tx_local")continue;const r=n.original_path??n.forwarded_path;if(!r||r.length===0)continue;const u=r[r.length-1].toUpperCase();o.has(u)||(o.add(u),f.push({prefix:u,snr:n.snr}))}return f}function he({text:p,timestamp:c,contacts:o,className:f}){const n=i.useRef(null),r=K(),u=T(),l=Y(),[t,v]=i.useState(!1),m=D(),C=I(),z=u==null?void 0:u.neighbors,E=ae(),B=oe(),M=J(),g=Q(),w=(m==null?void 0:m.node_name)??(g==null?void 0:g.node_name)??null,F=i.useMemo(()=>({neighbors:z,srcHashMap:E,discoveredNodes:B}),[z,E,B]),d=i.useMemo(()=>{const e=(m==null?void 0:m.node_name)||(g==null?void 0:g.node_name)||(g==null?void 0:g.companion_name)||"Me";return m&&N(m.latitude,m.longitude)?{prefix:m.public_key.slice(0,2).toUpperCase(),name:e,lat:m.latitude,lng:m.longitude}:M&&N(M.latitude,M.longitude)?{prefix:"",name:e,lat:M.latitude,lng:M.longitude}:null},[m,g,M]),L=i.useMemo(()=>w?ce(p,c,C,w):null,[p,c,C,w]),G=i.useMemo(()=>L?ue(L,l):[],[L,l]),j=i.useMemo(()=>G.map(e=>{const s=ie(e.prefix,o,F);return{prefix:e.prefix,snr:e.snr,...s}}),[G,o,F]),y=i.useMemo(()=>j.filter(e=>e.hasGps),[j]),$=i.useMemo(()=>j.filter(e=>!e.hasGps),[j]),_=i.useMemo(()=>{if(!d||y.length===0)return[];const e=[d.lng,d.lat];return y.map(s=>{const h=[s.lng,s.lat];return{from:e,to:h,midpoint:[(e[0]+h[0])/2,(e[1]+h[1])/2]}})},[d,y]),W=i.useMemo(()=>_.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[_]),H=i.useMemo(()=>{if(typeof document>"u")return{amber:A,zinc:O};const e=getComputedStyle(document.documentElement),s=e.getPropertyValue("--sys-amber").trim(),h=e.getPropertyValue("--zinc-400").trim();return{amber:s.startsWith("#")?s:A,zinc:h.startsWith("#")?h:O}},[]),x=i.useMemo(()=>{if(!d||y.length===0)return null;let e=d.lat,s=d.lat,h=d.lng,S=d.lng;for(const b of y)b.lats&&(s=b.lat),b.lngS&&(S=b.lng);return[[h,e],[S,s]]},[d,y]),Z=i.useCallback(()=>{var s;const e=(s=n.current)==null?void 0:s.getMap();e&&x&&e.fitBounds(x,{padding:{top:40,bottom:44,left:56,right:56},maxZoom:14,duration:0}),v(!0)},[x]);if(!x||!d)return null;const P=[(x[0][0]+x[1][0])/2,(x[0][1]+x[1][1])/2];return a.jsxs("div",{className:V("relative rounded-lg overflow-hidden",f),style:{aspectRatio:"16 / 10"},children:[!t&&a.jsx("div",{className:"absolute inset-0 bg-subtle-fill flex items-center justify-center pointer-events-none z-10",children:a.jsx("div",{className:"w-4 h-4 border-2 border-fg-muted/30 border-t-fg-muted rounded-full animate-spin"})}),a.jsx("div",{className:"h-full w-full transition-opacity duration-200",style:{opacity:t?1:0},children:a.jsxs(te,{ref:n,initialViewState:{longitude:P[0],latitude:P[1],zoom:10},onLoad:Z,style:{height:"100%",width:"100%"},mapStyle:le[r],attributionControl:!1,interactive:!1,children:[_.map((e,s)=>a.jsx(ne,{id:`cecho-${s}`,type:"geojson",data:W[s],lineMetrics:!0,children:a.jsx(se,{id:`cecho-line-${s}`,type:"line",paint:{"line-width":2,"line-gradient":["interpolate",["linear"],["line-progress"],0,H.amber,1,H.zinc]},layout:{"line-cap":"round","line-join":"round"}})},`cecho-${s}`)),a.jsx(R,{longitude:d.lng,latitude:d.lat,anchor:"center",children:a.jsx(U,{prefix:d.prefix,name:d.name,isLocal:!0,color:"amber"})}),y.map((e,s)=>a.jsx(R,{longitude:e.lng,latitude:e.lat,anchor:"center",children:a.jsx(U,{prefix:e.prefix,name:e.name,isLocal:!1,color:"zinc"})},`cecho-node-${e.prefix}-${s}`))]})}),$.length>0&&a.jsx("div",{className:"absolute bottom-1.5 left-1.5 z-10 flex items-center gap-1 flex-wrap max-w-[60%]",children:$.map((e,s)=>a.jsxs(k,{color:"zinc",className:"type-data-xs shadow-sm opacity-70",children:[a.jsx(re,{className:"w-2 h-2 mr-0.5"}),e.prefix,e.name&&a.jsx("span",{className:"ml-0.5 opacity-60",children:e.name})]},`cecho-unmap-${e.prefix}-${s}`))}),a.jsx("div",{className:"absolute bottom-1.5 right-1.5 z-10",children:a.jsxs(k,{color:"green",className:"type-data-xs shadow-sm",children:[j.length," echo",j.length!==1?"es":""]})})]})}export{he as CompanionEchoMap}; +import{r as i,d0 as K,a6 as T,Q as Y,fO as D,au as I,cC as J,g7 as Q,Z as q,O as X,j as a,c as V,V as C,cF as ee}from"./index-D33fcA3L.js";import{M as te,S as ne,L as se,a as $}from"./maplibre-gl-B42P8ehE.js";import{useSrcHashResolverMap as ae,useDiscoveredNodes as oe}from"./usePipelineStore-DDHEHTlZ.js";import{M as re}from"./map-pin-off-V0MBukP5.js";import"./node-types-BoqnL0Eg.js";const le={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},A=X.amber,O=q[400],U=i.memo(function({prefix:c,name:o,isLocal:f,color:n}){const[r,u]=i.useState(!1);return a.jsx("div",{onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{pointerEvents:"auto"},children:a.jsxs(C,{color:n,filled:!0,className:V("type-data-xs shadow-lg border border-current/30 transition-all duration-150 cursor-default",r&&"relative z-50"),children:[f&&a.jsx(ee,{className:"w-2.5 h-2.5 mr-0.5"}),c&&a.jsx("span",{className:"font-mono",children:c}),r&&o&&a.jsx("span",{className:c?"ml-0.5 opacity-75":"",children:o})]})})});function N(p,c){return p==null||c==null?!1:p!==0||c!==0}function ie(p,c,o){var u;const f=p.toUpperCase(),n=c.find(l=>l.public_key.toUpperCase().startsWith(f));if(n&&N(n.gps_lat,n.gps_lon))return{name:n.name||null,lat:n.gps_lat,lng:n.gps_lon,hasGps:!0};if(o.neighbors){const l=Object.entries(o.neighbors).find(([t])=>t.toUpperCase().startsWith(f));if(l){const[,t]=l;if(N(t.latitude,t.longitude))return{name:t.node_name||t.name||null,lat:t.latitude,lng:t.longitude,hasGps:!0}}}const r=o.srcHashMap.get(f);if(r){const l=o.discoveredNodes.get(r);if(l&&N(l.latitude,l.longitude))return{name:l.name||null,lat:l.latitude,lng:l.longitude,hasGps:!0};if(o.neighbors){const t=o.neighbors[r];if(t&&N(t.latitude,t.longitude))return{name:t.node_name||t.name||null,lat:t.latitude,lng:t.longitude,hasGps:!0}}}return{name:(n==null?void 0:n.name)||(r?((u=o.discoveredNodes.get(r))==null?void 0:u.name)??null:null),lat:0,lng:0,hasGps:!1}}function ce(p,c,o,f){const n=Math.floor(c/30);for(const r of[n-1,n,n+1])for(const[u,l]of o){const t=l.decoded;if(!(t!=null&&t.decrypted)||t.senderName!==f)continue;const v=t.timestamp??l.timestamp;if(Math.floor(v/30)===r&&t.text===p)return u}return null}function ue(p,c){const o=new Set,f=[];for(const n of c){if(n.packet_hash!==p||n.packet_origin==="tx_local")continue;const r=n.original_path??n.forwarded_path;if(!r||r.length===0)continue;const u=r[r.length-1].toUpperCase();o.has(u)||(o.add(u),f.push({prefix:u,snr:n.snr}))}return f}function he({text:p,timestamp:c,contacts:o,className:f}){const n=i.useRef(null),r=K(),u=T(),l=Y(),[t,v]=i.useState(!1),m=D(),k=I(),z=u==null?void 0:u.neighbors,E=ae(),F=oe(),M=J(),g=Q(),w=(m==null?void 0:m.node_name)??(g==null?void 0:g.node_name)??null,B=i.useMemo(()=>({neighbors:z,srcHashMap:E,discoveredNodes:F}),[z,E,F]),d=i.useMemo(()=>{const e=(m==null?void 0:m.node_name)||(g==null?void 0:g.node_name)||(g==null?void 0:g.companion_name)||"Me";return m&&N(m.latitude,m.longitude)?{prefix:m.public_key.slice(0,2).toUpperCase(),name:e,lat:m.latitude,lng:m.longitude}:M&&N(M.latitude,M.longitude)?{prefix:"",name:e,lat:M.latitude,lng:M.longitude}:null},[m,g,M]),L=i.useMemo(()=>w?ce(p,c,k,w):null,[p,c,k,w]),G=i.useMemo(()=>L?ue(L,l):[],[L,l]),j=i.useMemo(()=>G.map(e=>{const s=ie(e.prefix,o,B);return{prefix:e.prefix,snr:e.snr,...s}}),[G,o,B]),y=i.useMemo(()=>j.filter(e=>e.hasGps),[j]),H=i.useMemo(()=>j.filter(e=>!e.hasGps),[j]),_=i.useMemo(()=>{if(!d||y.length===0)return[];const e=[d.lng,d.lat];return y.map(s=>{const h=[s.lng,s.lat];return{from:e,to:h,midpoint:[(e[0]+h[0])/2,(e[1]+h[1])/2]}})},[d,y]),W=i.useMemo(()=>_.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[_]),P=i.useMemo(()=>{if(typeof document>"u")return{amber:A,zinc:O};const e=getComputedStyle(document.documentElement),s=e.getPropertyValue("--sys-amber").trim(),h=e.getPropertyValue("--zinc-400").trim();return{amber:s.startsWith("#")?s:A,zinc:h.startsWith("#")?h:O}},[]),x=i.useMemo(()=>{if(!d||y.length===0)return null;let e=d.lat,s=d.lat,h=d.lng,S=d.lng;for(const b of y)b.lats&&(s=b.lat),b.lngS&&(S=b.lng);return[[h,e],[S,s]]},[d,y]),Z=i.useCallback(()=>{var s;const e=(s=n.current)==null?void 0:s.getMap();e&&x&&e.fitBounds(x,{padding:{top:40,bottom:44,left:56,right:56},maxZoom:14,duration:0}),v(!0)},[x]);if(!x||!d)return null;const R=[(x[0][0]+x[1][0])/2,(x[0][1]+x[1][1])/2];return a.jsxs("div",{className:V("relative rounded-lg overflow-hidden",f),style:{aspectRatio:"16 / 10"},children:[!t&&a.jsx("div",{className:"absolute inset-0 bg-subtle-fill flex items-center justify-center pointer-events-none z-10",children:a.jsx("div",{className:"w-4 h-4 border-2 border-fg-muted/30 border-t-fg-muted rounded-full animate-spin"})}),a.jsx("div",{className:"h-full w-full transition-opacity duration-200",style:{opacity:t?1:0},children:a.jsxs(te,{ref:n,initialViewState:{longitude:R[0],latitude:R[1],zoom:10},onLoad:Z,style:{height:"100%",width:"100%"},mapStyle:le[r],attributionControl:!1,interactive:!1,children:[_.map((e,s)=>a.jsx(ne,{id:`cecho-${s}`,type:"geojson",data:W[s],lineMetrics:!0,children:a.jsx(se,{id:`cecho-line-${s}`,type:"line",paint:{"line-width":2,"line-gradient":["interpolate",["linear"],["line-progress"],0,P.amber,1,P.zinc]},layout:{"line-cap":"round","line-join":"round"}})},`cecho-${s}`)),a.jsx($,{longitude:d.lng,latitude:d.lat,anchor:"center",children:a.jsx(U,{prefix:d.prefix,name:d.name,isLocal:!0,color:"amber"})}),y.map((e,s)=>a.jsx($,{longitude:e.lng,latitude:e.lat,anchor:"center",children:a.jsx(U,{prefix:e.prefix,name:e.name,isLocal:!1,color:"zinc"})},`cecho-node-${e.prefix}-${s}`))]})}),H.length>0&&a.jsx("div",{className:"absolute bottom-1.5 left-1.5 z-10 flex items-center gap-1 flex-wrap max-w-[60%]",children:H.map((e,s)=>a.jsxs(C,{color:"zinc",className:"type-data-xs shadow-sm opacity-70",children:[a.jsx(re,{className:"w-2 h-2 mr-0.5"}),e.prefix,e.name&&a.jsx("span",{className:"ml-0.5 opacity-60",children:e.name})]},`cecho-unmap-${e.prefix}-${s}`))}),a.jsx("div",{className:"absolute bottom-1.5 right-1.5 z-10",children:a.jsxs(C,{color:"green",className:"type-data-xs shadow-sm",children:[j.length," echo",j.length!==1?"es":""]})})]})}export{he as CompanionEchoMap}; diff --git a/frontend/dist/assets/CompanionPathMap-DEvrWwCv.js b/frontend/dist/assets/CompanionPathMap-CPxxakse.js similarity index 73% rename from frontend/dist/assets/CompanionPathMap-DEvrWwCv.js rename to frontend/dist/assets/CompanionPathMap-CPxxakse.js index a8fad785..182cbc6e 100644 --- a/frontend/dist/assets/CompanionPathMap-DEvrWwCv.js +++ b/frontend/dist/assets/CompanionPathMap-CPxxakse.js @@ -1 +1 @@ -import{r as a,c$ as we,a6 as Le,cB as Re,g7 as ke,Z as de,O as J,j as t,c as K,bM as ve,dH as Ee,dI as Pe,V as T,cE as _e}from"./index-C2xvS0Jd.js";import{M as Ge,S as _,L as G,a as O}from"./maplibre-gl-C9QYi5T6.js";import{useSrcHashResolverMap as Fe,useDiscoveredNodes as Ce}from"./usePipelineStore-Do-g28wv.js";import{g as He,u as Oe,l as Ae,a as ze,m as $e,c as Be,j as We,k as Ie,p as De,r as Ke,e as v,R as Te}from"./useReplayTick-DbeD1_Sw.js";import{C as re}from"./car-D35Wwv-5.js";import{M as Je}from"./map-pin-off-D8fZRJ6M.js";import"./node-types-BD70swWz.js";import"./payload-detail-BAEvS7Pl.js";const Ve={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},Ue=de[500],ce=J.orange,ue=J.green,A=J.blue,D={type:"FeatureCollection",features:[]},Ye=a.memo(function({prefix:i,name:l,isLocal:p,color:o}){const[u,y]=a.useState(!1);return t.jsx("div",{onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),style:{pointerEvents:"auto"},children:t.jsxs(T,{color:o,filled:!0,className:K("type-data-xs shadow-lg border border-current/30 transition-all duration-150 cursor-default",u&&"relative z-50"),children:[p&&t.jsx(_e,{className:"w-2.5 h-2.5 mr-0.5"}),i&&t.jsx("span",{className:"font-mono",children:i}),u&&l&&t.jsx("span",{className:i?"ml-0.5 opacity-75":"",children:l})]})})});function E(f,i){return f==null||i==null?!1:f!==0||i!==0}function Ze(f,i,l){var o;const p=[];for(const u of f){const y=u.toUpperCase(),d=i.find(m=>m.public_key.toUpperCase().startsWith(y));if(d&&E(d.gps_lat,d.gps_lon)){p.push({prefix:u,name:d.name||null,lat:d.gps_lat,lng:d.gps_lon,isLocal:!1,hasGps:!0});continue}if(l.neighbors){const m=Object.entries(l.neighbors).find(([c])=>c.toUpperCase().startsWith(y));if(m){const[,c]=m;if(E(c.latitude,c.longitude)){p.push({prefix:u,name:c.node_name||c.name||null,lat:c.latitude,lng:c.longitude,isLocal:!1,hasGps:!0});continue}}}const M=l.srcHashMap.get(y);if(M){const m=l.discoveredNodes.get(M);if(m&&E(m.latitude,m.longitude)){p.push({prefix:u,name:m.name||null,lat:m.latitude,lng:m.longitude,isLocal:!1,hasGps:!0});continue}if(l.neighbors){const c=l.neighbors[M];if(c&&E(c.latitude,c.longitude)){p.push({prefix:u,name:c.node_name||c.name||null,lat:c.latitude,lng:c.longitude,isLocal:!1,hasGps:!0});continue}}}p.push({prefix:u,name:(d==null?void 0:d.name)||(M?((o=l.discoveredNodes.get(M))==null?void 0:o.name)??null:null),lat:0,lng:0,isLocal:!1,hasGps:!1})}return p}function Xe(f,i,l,p){const o=(i==null?void 0:i.node_name)||p||(l==null?void 0:l.name)||"Me";if(i&&E(i.latitude,i.longitude)){const u=i.public_key.slice(0,2).toUpperCase();return[...f,{prefix:u,name:o,lat:i.latitude,lng:i.longitude,isLocal:!0,hasGps:!0}]}return l&&E(l.latitude,l.longitude)?[...f,{prefix:"",name:o,lat:l.latitude,lng:l.longitude,isLocal:!0,hasGps:!0}]:f}function lt({hops:f,contacts:i,selfInfo:l,snr:p,wardriveCoords:o,wardriveSenderName:u,channelMessages:y,messageTimestamp:d,className:M}){const m=a.useRef(null),c=we(),z=Le(),[V,pe]=a.useState(!1),U=z==null?void 0:z.neighbors,Y=Fe(),Z=Ce(),X=Re(),L=ke(),q=a.useMemo(()=>({neighbors:U,srcHashMap:Y,discoveredNodes:Z}),[U,Y,Z]),R=a.useMemo(()=>{if(!(y!=null&&y.length)||!u||!d)return[];const e=He(y),n=d-86400;return e.filter(s=>s.senderName===u&&s.timestampS>=n&&s.timestampS<=d)},[y,u,d]),$=R.length>=2,P=a.useMemo(()=>`${u??"x"}-${d??0}`,[u,d]),me=Oe(),ge=Ae(),Q=ze(),w=$e(),fe=Be(),x=We();Ie();const g=me&&ge===P,B=g&&x.length>0?Math.round(Math.max(0,Math.min(x.length-1,w))):-1,ee=a.useMemo(()=>{var e;return B>=0?((e=x[B])==null?void 0:e.pathHops)??f:f},[B,x,f]),te=(L==null?void 0:L.node_name)??(L==null?void 0:L.companion_name)??null,N=a.useMemo(()=>{const e=Ze(ee,i,q);return Xe(e,l,X,te)},[ee,i,q,l,X,te]),h=a.useMemo(()=>N.filter(e=>e.hasGps),[N]),ne=a.useMemo(()=>N.filter(e=>!e.hasGps),[N]),F=a.useMemo(()=>{const e=[];if(h.length<2)return e;const n=[];for(let s=0;sF.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[F]),se=a.useMemo(()=>{if(typeof document>"u")return Ue;const e=getComputedStyle(document.documentElement).getPropertyValue("--zinc-400").trim();return e.startsWith("#")?e:de[400]},[]),C=a.useMemo(()=>{if(!o||h.length===0)return null;const e=[o.lon,o.lat],n=h[0];return{from:e,to:[n.lng,n.lat]}},[o,h]),oe=a.useMemo(()=>C?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[C.from,C.to]}}]}:null,[C]),ae=a.useMemo(()=>{if(typeof document>"u")return{orange:ce,green:ue};const e=getComputedStyle(document.documentElement),n=e.getPropertyValue("--sys-orange").trim(),s=e.getPropertyValue("--sys-green").trim();return{orange:n.startsWith("#")?n:ce,green:s.startsWith("#")?s:ue}},[]),k=a.useMemo(()=>g?De(x,w):null,[g,x,w]),ye=a.useMemo(()=>{if(!g)return D;const e=Ke(x,w);return e.length<2?D:{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}}]}},[g,x,w]),xe=a.useMemo(()=>!g||x.length===0?D:{type:"FeatureCollection",features:x.map((e,n)=>({type:"Feature",properties:{index:n},geometry:{type:"Point",coordinates:[e.lon,e.lat]}}))},[g,x]);a.useEffect(()=>()=>{const e=v.getState();e.ownerKey===P&&e.stopRewind()},[P]);const be=x.length,H=Math.max(0,be-1),je=H>0?w/H:1,Ne=Math.round(H-w),S=a.useMemo(()=>{if(h.length+(o?1:0)+R.length<2)return null;let n=1/0,s=-1/0,b=1/0,j=-1/0;for(const r of h)r.lats&&(s=r.lat),r.lngj&&(j=r.lng);o&&(o.lats&&(s=o.lat),o.lonj&&(j=o.lon));for(const r of R)r.lats&&(s=r.lat),r.lonj&&(j=r.lon);return[[b,n],[j,s]]},[h,o,R]),Se=a.useCallback(()=>{v.getState().stopRewind()},[]),Me=a.useCallback(()=>{var n;const e=(n=m.current)==null?void 0:n.getMap();e&&S&&e.fitBounds(S,{padding:{top:40,bottom:$?52:44,left:56,right:56},maxZoom:14,duration:0}),pe(!0),$&&v.getState().startRewind(R,P)},[S,$,R,P]);if(!S)return null;const le=[(S[0][0]+S[1][0])/2,(S[0][1]+S[1][1])/2];return t.jsxs("div",{className:K("relative rounded-lg overflow-hidden",M),style:{aspectRatio:"16 / 10"},children:[!V&&t.jsx("div",{className:"absolute inset-0 bg-subtle-fill flex items-center justify-center pointer-events-none z-10",children:t.jsx("div",{className:"w-4 h-4 border-2 border-fg-muted/30 border-t-fg-muted rounded-full animate-spin"})}),t.jsx("div",{className:"h-full w-full transition-opacity duration-200",style:{opacity:V?1:0},children:t.jsxs(Ge,{ref:m,initialViewState:{longitude:le[0],latitude:le[1],zoom:10},onLoad:Me,style:{height:"100%",width:"100%"},mapStyle:Ve[c],attributionControl:!1,interactive:g,children:[oe&&!g&&t.jsx(_,{id:"cwd-edge",type:"geojson",data:oe,lineMetrics:!0,children:t.jsx(G,{id:"cwd-edge-line",type:"line",paint:{"line-width":2,"line-gradient":["interpolate",["linear"],["line-progress"],0,ae.orange,1,ae.green]},layout:{"line-cap":"round","line-join":"round"}})}),o&&!g&&t.jsx(O,{longitude:o.lon,latitude:o.lat,anchor:"center",children:t.jsx("div",{className:"flex items-center",style:{pointerEvents:"auto"},children:t.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-full bg-sys-orange text-white shadow-lg border-2 border-sys-orange/50",children:t.jsx(re,{className:"w-4 h-4",strokeWidth:2.5})})})}),F.map((e,n)=>t.jsx(_,{id:`cedge-${n}`,type:"geojson",data:he[n],children:t.jsx(G,{id:`cedge-line-${n}`,type:"line",paint:{"line-color":se,"line-width":2,"line-opacity":.85},layout:{"line-cap":"round","line-join":"round"}})},`cedge-${n}`)),F.map((e,n)=>t.jsx(O,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx("span",{className:"w-4.5 h-4.5 rounded-full flex items-center justify-center font-mono font-extrabold tabular-nums shadow-md pointer-events-none",style:{backgroundColor:se,color:"#fff",fontSize:"10px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:e.hopNumber})},`chop-${n}`)),h.map((e,n)=>{const s=n===0,b=n===h.length-1,j=e.isLocal?"amber":s?"green":b?"amber":"zinc";return t.jsx(O,{longitude:e.lng,latitude:e.lat,anchor:"center",children:t.jsx(Ye,{prefix:e.prefix,name:e.name,isLocal:e.isLocal,color:j})},`cnode-${e.prefix}-${n}`)}),g&&t.jsxs(t.Fragment,{children:[t.jsx(_,{id:"replay-dots",type:"geojson",data:xe,children:t.jsx(G,{id:"replay-dots-circle",type:"circle",paint:{"circle-radius":3,"circle-color":A,"circle-opacity":.35,"circle-stroke-width":1,"circle-stroke-color":A,"circle-stroke-opacity":.15}})}),t.jsx(_,{id:"replay-trail",type:"geojson",data:ye,children:t.jsx(G,{id:"replay-trail-line",type:"line",paint:{"line-color":A,"line-width":3,"line-opacity":.7},layout:{"line-cap":"round","line-join":"round"}})}),k&&h.length>0&&t.jsx(_,{id:"replay-path-link",type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[[k.lon,k.lat],[h[0].lng,h[0].lat]]}}]},children:t.jsx(G,{id:"replay-path-link-line",type:"line",paint:{"line-color":A,"line-width":1.5,"line-opacity":.5,"line-dasharray":[3,2]},layout:{"line-cap":"round"}})}),k&&t.jsx(O,{longitude:k.lon,latitude:k.lat,anchor:"center",children:t.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-full bg-sys-orange text-white shadow-lg border-2 border-sys-orange/50",children:t.jsx(re,{className:"w-4 h-4",strokeWidth:2.5})})})]})]})}),g&&t.jsx("div",{className:"absolute bottom-1.5 left-1.5 right-1.5 z-10",onClick:e=>e.stopPropagation(),children:t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 rounded-md bg-body/90 backdrop-blur-sm border border-edge-subtle shadow-lg",children:[t.jsx("button",{onClick:Se,className:"p-0.5 rounded text-fg-muted hover:text-fg-primary transition-colors shrink-0",title:"Stop rewind",children:t.jsx(ve,{className:"w-3 h-3"})}),t.jsx("button",{onClick:()=>v.getState().togglePlay(),className:"p-1 rounded-full bg-sys-blue/20 text-sys-blue hover:bg-sys-blue/30 transition-colors shrink-0",title:Q?"Pause":"Rewind",children:Q?t.jsx(Ee,{className:"w-3 h-3"}):t.jsx(Pe,{className:"w-3 h-3"})}),t.jsx("input",{type:"range",min:0,max:100,step:.1,value:je*100,onChange:e=>{const n=parseFloat(e.target.value)/100;v.getState().seek(n)},className:"flex-1 min-w-0 h-1 appearance-none bg-edge-subtle rounded-full cursor-pointer accent-sys-blue"}),t.jsxs("span",{className:"text-[9px] tabular-nums text-fg-muted whitespace-nowrap shrink-0",children:[Ne,"/",H," pkts"]}),t.jsx("div",{className:"flex items-center gap-px shrink-0",children:Te.map(e=>t.jsxs("button",{onClick:()=>v.getState().setSpeed(e),className:K("px-1 py-0.5 rounded text-[9px] font-medium transition-colors",e===fe?"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary"),children:[e,"×"]},e))})]})}),!g&&ne.length>0&&t.jsx("div",{className:"absolute bottom-1.5 left-1.5 z-10 flex items-center gap-1 flex-wrap max-w-[60%]",children:ne.map((e,n)=>t.jsxs(T,{color:"zinc",className:"type-data-xs shadow-sm opacity-70",children:[t.jsx(Je,{className:"w-2 h-2 mr-0.5"}),e.prefix,e.name&&t.jsx("span",{className:"ml-0.5 opacity-60",children:e.name})]},`cunmap-${e.prefix}-${n}`))}),!g&&p!=null&&t.jsx("div",{className:"absolute bottom-1.5 right-1.5 z-10",children:t.jsxs(T,{color:"zinc",className:"type-data-xs shadow-sm",children:[p>0?"+":"",p.toFixed(1)," dB"]})})]})}export{lt as CompanionPathMap}; +import{r as a,d0 as we,a6 as Le,cC as Re,g7 as ke,Z as de,O as T,j as t,c as J,bN as ve,dI as Pe,dJ as Ee,V as K,cF as _e}from"./index-D33fcA3L.js";import{M as Ge,S as _,L as G,a as A}from"./maplibre-gl-B42P8ehE.js";import{useSrcHashResolverMap as Fe,useDiscoveredNodes as Ce}from"./usePipelineStore-DDHEHTlZ.js";import{g as Oe,u as Ae,l as He,a as ze,m as $e,c as We,j as Be,k as Ie,p as De,r as Je,e as v,R as Ke}from"./useReplayTick-BbXJoz75.js";import{C as re}from"./car-CeuvJE3C.js";import{M as Te}from"./map-pin-off-V0MBukP5.js";import"./node-types-BoqnL0Eg.js";import"./payload-detail-DbnSd5NL.js";const Ve={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},Ue=de[500],ce=T.orange,ue=T.green,H=T.blue,D={type:"FeatureCollection",features:[]},Ye=a.memo(function({prefix:i,name:l,isLocal:p,color:o}){const[u,y]=a.useState(!1);return t.jsx("div",{onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),style:{pointerEvents:"auto"},children:t.jsxs(K,{color:o,filled:!0,className:J("type-data-xs shadow-lg border border-current/30 transition-all duration-150 cursor-default",u&&"relative z-50"),children:[p&&t.jsx(_e,{className:"w-2.5 h-2.5 mr-0.5"}),i&&t.jsx("span",{className:"font-mono",children:i}),u&&l&&t.jsx("span",{className:i?"ml-0.5 opacity-75":"",children:l})]})})});function P(f,i){return f==null||i==null?!1:f!==0||i!==0}function Ze(f,i,l){var o;const p=[];for(const u of f){const y=u.toUpperCase(),d=i.find(m=>m.public_key.toUpperCase().startsWith(y));if(d&&P(d.gps_lat,d.gps_lon)){p.push({prefix:u,name:d.name||null,lat:d.gps_lat,lng:d.gps_lon,isLocal:!1,hasGps:!0});continue}if(l.neighbors){const m=Object.entries(l.neighbors).find(([c])=>c.toUpperCase().startsWith(y));if(m){const[,c]=m;if(P(c.latitude,c.longitude)){p.push({prefix:u,name:c.node_name||c.name||null,lat:c.latitude,lng:c.longitude,isLocal:!1,hasGps:!0});continue}}}const M=l.srcHashMap.get(y);if(M){const m=l.discoveredNodes.get(M);if(m&&P(m.latitude,m.longitude)){p.push({prefix:u,name:m.name||null,lat:m.latitude,lng:m.longitude,isLocal:!1,hasGps:!0});continue}if(l.neighbors){const c=l.neighbors[M];if(c&&P(c.latitude,c.longitude)){p.push({prefix:u,name:c.node_name||c.name||null,lat:c.latitude,lng:c.longitude,isLocal:!1,hasGps:!0});continue}}}p.push({prefix:u,name:(d==null?void 0:d.name)||(M?((o=l.discoveredNodes.get(M))==null?void 0:o.name)??null:null),lat:0,lng:0,isLocal:!1,hasGps:!1})}return p}function Xe(f,i,l,p){const o=(i==null?void 0:i.node_name)||p||(l==null?void 0:l.name)||"Me";if(i&&P(i.latitude,i.longitude)){const u=i.public_key.slice(0,2).toUpperCase();return[...f,{prefix:u,name:o,lat:i.latitude,lng:i.longitude,isLocal:!0,hasGps:!0}]}return l&&P(l.latitude,l.longitude)?[...f,{prefix:"",name:o,lat:l.latitude,lng:l.longitude,isLocal:!0,hasGps:!0}]:f}function lt({hops:f,contacts:i,selfInfo:l,snr:p,wardriveCoords:o,wardriveSenderName:u,channelMessages:y,messageTimestamp:d,className:M}){const m=a.useRef(null),c=we(),z=Le(),[V,pe]=a.useState(!1),U=z==null?void 0:z.neighbors,Y=Fe(),Z=Ce(),X=Re(),L=ke(),q=a.useMemo(()=>({neighbors:U,srcHashMap:Y,discoveredNodes:Z}),[U,Y,Z]),R=a.useMemo(()=>{if(!(y!=null&&y.length)||!u||!d)return[];const e=Oe(y),n=d-86400;return e.filter(s=>s.senderName===u&&s.timestampS>=n&&s.timestampS<=d)},[y,u,d]),$=R.length>=2,E=a.useMemo(()=>`${u??"x"}-${d??0}`,[u,d]),me=Ae(),ge=He(),Q=ze(),w=$e(),fe=We(),x=Be();Ie();const g=me&&ge===E,W=g&&x.length>0?Math.round(Math.max(0,Math.min(x.length-1,w))):-1,ee=a.useMemo(()=>{var e;return W>=0?((e=x[W])==null?void 0:e.pathHops)??f:f},[W,x,f]),te=(L==null?void 0:L.node_name)??(L==null?void 0:L.companion_name)??null,N=a.useMemo(()=>{const e=Ze(ee,i,q);return Xe(e,l,X,te)},[ee,i,q,l,X,te]),h=a.useMemo(()=>N.filter(e=>e.hasGps),[N]),ne=a.useMemo(()=>N.filter(e=>!e.hasGps),[N]),F=a.useMemo(()=>{const e=[];if(h.length<2)return e;const n=[];for(let s=0;sF.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[F]),se=a.useMemo(()=>{if(typeof document>"u")return Ue;const e=getComputedStyle(document.documentElement).getPropertyValue("--zinc-400").trim();return e.startsWith("#")?e:de[400]},[]),C=a.useMemo(()=>{if(!o||h.length===0)return null;const e=[o.lon,o.lat],n=h[0];return{from:e,to:[n.lng,n.lat]}},[o,h]),oe=a.useMemo(()=>C?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[C.from,C.to]}}]}:null,[C]),ae=a.useMemo(()=>{if(typeof document>"u")return{orange:ce,green:ue};const e=getComputedStyle(document.documentElement),n=e.getPropertyValue("--sys-orange").trim(),s=e.getPropertyValue("--sys-green").trim();return{orange:n.startsWith("#")?n:ce,green:s.startsWith("#")?s:ue}},[]),k=a.useMemo(()=>g?De(x,w):null,[g,x,w]),ye=a.useMemo(()=>{if(!g)return D;const e=Je(x,w);return e.length<2?D:{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}}]}},[g,x,w]),xe=a.useMemo(()=>!g||x.length===0?D:{type:"FeatureCollection",features:x.map((e,n)=>({type:"Feature",properties:{index:n},geometry:{type:"Point",coordinates:[e.lon,e.lat]}}))},[g,x]);a.useEffect(()=>()=>{const e=v.getState();e.ownerKey===E&&e.stopRewind()},[E]);const be=x.length,O=Math.max(0,be-1),je=O>0?w/O:1,Ne=Math.round(O-w),S=a.useMemo(()=>{if(h.length+(o?1:0)+R.length<2)return null;let n=1/0,s=-1/0,b=1/0,j=-1/0;for(const r of h)r.lats&&(s=r.lat),r.lngj&&(j=r.lng);o&&(o.lats&&(s=o.lat),o.lonj&&(j=o.lon));for(const r of R)r.lats&&(s=r.lat),r.lonj&&(j=r.lon);return[[b,n],[j,s]]},[h,o,R]),Se=a.useCallback(()=>{v.getState().stopRewind()},[]),Me=a.useCallback(()=>{var n;const e=(n=m.current)==null?void 0:n.getMap();e&&S&&e.fitBounds(S,{padding:{top:40,bottom:$?52:44,left:56,right:56},maxZoom:14,duration:0}),pe(!0),$&&v.getState().startRewind(R,E)},[S,$,R,E]);if(!S)return null;const le=[(S[0][0]+S[1][0])/2,(S[0][1]+S[1][1])/2];return t.jsxs("div",{className:J("relative rounded-lg overflow-hidden",M),style:{aspectRatio:"16 / 10"},children:[!V&&t.jsx("div",{className:"absolute inset-0 bg-subtle-fill flex items-center justify-center pointer-events-none z-10",children:t.jsx("div",{className:"w-4 h-4 border-2 border-fg-muted/30 border-t-fg-muted rounded-full animate-spin"})}),t.jsx("div",{className:"h-full w-full transition-opacity duration-200",style:{opacity:V?1:0},children:t.jsxs(Ge,{ref:m,initialViewState:{longitude:le[0],latitude:le[1],zoom:10},onLoad:Me,style:{height:"100%",width:"100%"},mapStyle:Ve[c],attributionControl:!1,interactive:g,children:[oe&&!g&&t.jsx(_,{id:"cwd-edge",type:"geojson",data:oe,lineMetrics:!0,children:t.jsx(G,{id:"cwd-edge-line",type:"line",paint:{"line-width":2,"line-gradient":["interpolate",["linear"],["line-progress"],0,ae.orange,1,ae.green]},layout:{"line-cap":"round","line-join":"round"}})}),o&&!g&&t.jsx(A,{longitude:o.lon,latitude:o.lat,anchor:"center",children:t.jsx("div",{className:"flex items-center",style:{pointerEvents:"auto"},children:t.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-full bg-sys-orange text-white shadow-lg border-2 border-sys-orange/50",children:t.jsx(re,{className:"w-4 h-4",strokeWidth:2.5})})})}),F.map((e,n)=>t.jsx(_,{id:`cedge-${n}`,type:"geojson",data:he[n],children:t.jsx(G,{id:`cedge-line-${n}`,type:"line",paint:{"line-color":se,"line-width":2,"line-opacity":.85},layout:{"line-cap":"round","line-join":"round"}})},`cedge-${n}`)),F.map((e,n)=>t.jsx(A,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx("span",{className:"w-4.5 h-4.5 rounded-full flex items-center justify-center font-mono font-extrabold tabular-nums shadow-md pointer-events-none",style:{backgroundColor:se,color:"#fff",fontSize:"10px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:e.hopNumber})},`chop-${n}`)),h.map((e,n)=>{const s=n===0,b=n===h.length-1,j=e.isLocal?"amber":s?"green":b?"amber":"zinc";return t.jsx(A,{longitude:e.lng,latitude:e.lat,anchor:"center",children:t.jsx(Ye,{prefix:e.prefix,name:e.name,isLocal:e.isLocal,color:j})},`cnode-${e.prefix}-${n}`)}),g&&t.jsxs(t.Fragment,{children:[t.jsx(_,{id:"replay-dots",type:"geojson",data:xe,children:t.jsx(G,{id:"replay-dots-circle",type:"circle",paint:{"circle-radius":3,"circle-color":H,"circle-opacity":.35,"circle-stroke-width":1,"circle-stroke-color":H,"circle-stroke-opacity":.15}})}),t.jsx(_,{id:"replay-trail",type:"geojson",data:ye,children:t.jsx(G,{id:"replay-trail-line",type:"line",paint:{"line-color":H,"line-width":3,"line-opacity":.7},layout:{"line-cap":"round","line-join":"round"}})}),k&&h.length>0&&t.jsx(_,{id:"replay-path-link",type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[[k.lon,k.lat],[h[0].lng,h[0].lat]]}}]},children:t.jsx(G,{id:"replay-path-link-line",type:"line",paint:{"line-color":H,"line-width":1.5,"line-opacity":.5,"line-dasharray":[3,2]},layout:{"line-cap":"round"}})}),k&&t.jsx(A,{longitude:k.lon,latitude:k.lat,anchor:"center",children:t.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-full bg-sys-orange text-white shadow-lg border-2 border-sys-orange/50",children:t.jsx(re,{className:"w-4 h-4",strokeWidth:2.5})})})]})]})}),g&&t.jsx("div",{className:"absolute bottom-1.5 left-1.5 right-1.5 z-10",onClick:e=>e.stopPropagation(),children:t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 rounded-md bg-body/90 backdrop-blur-sm border border-edge-subtle shadow-lg",children:[t.jsx("button",{onClick:Se,className:"p-0.5 rounded text-fg-muted hover:text-fg-primary transition-colors shrink-0",title:"Stop rewind",children:t.jsx(ve,{className:"w-3 h-3"})}),t.jsx("button",{onClick:()=>v.getState().togglePlay(),className:"p-1 rounded-full bg-sys-blue/20 text-sys-blue hover:bg-sys-blue/30 transition-colors shrink-0",title:Q?"Pause":"Rewind",children:Q?t.jsx(Pe,{className:"w-3 h-3"}):t.jsx(Ee,{className:"w-3 h-3"})}),t.jsx("input",{type:"range",min:0,max:100,step:.1,value:je*100,onChange:e=>{const n=parseFloat(e.target.value)/100;v.getState().seek(n)},className:"flex-1 min-w-0 h-1 appearance-none bg-edge-subtle rounded-full cursor-pointer accent-sys-blue"}),t.jsxs("span",{className:"text-[9px] tabular-nums text-fg-muted whitespace-nowrap shrink-0",children:[Ne,"/",O," pkts"]}),t.jsx("div",{className:"flex items-center gap-px shrink-0",children:Ke.map(e=>t.jsxs("button",{onClick:()=>v.getState().setSpeed(e),className:J("px-1 py-0.5 rounded text-[9px] font-medium transition-colors",e===fe?"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary"),children:[e,"×"]},e))})]})}),!g&&ne.length>0&&t.jsx("div",{className:"absolute bottom-1.5 left-1.5 z-10 flex items-center gap-1 flex-wrap max-w-[60%]",children:ne.map((e,n)=>t.jsxs(K,{color:"zinc",className:"type-data-xs shadow-sm opacity-70",children:[t.jsx(Te,{className:"w-2 h-2 mr-0.5"}),e.prefix,e.name&&t.jsx("span",{className:"ml-0.5 opacity-60",children:e.name})]},`cunmap-${e.prefix}-${n}`))}),!g&&p!=null&&t.jsx("div",{className:"absolute bottom-1.5 right-1.5 z-10",children:t.jsxs(K,{color:"zinc",className:"type-data-xs shadow-sm",children:[p>0?"+":"",p.toFixed(1)," dB"]})})]})}export{lt as CompanionPathMap}; diff --git a/frontend/dist/assets/Configuration-BmeDX9th.js b/frontend/dist/assets/Configuration-BMVfY1Wg.js similarity index 95% rename from frontend/dist/assets/Configuration-BmeDX9th.js rename to frontend/dist/assets/Configuration-BMVfY1Wg.js index 815b8bc7..d619da97 100644 --- a/frontend/dist/assets/Configuration-BmeDX9th.js +++ b/frontend/dist/assets/Configuration-BMVfY1Wg.js @@ -1,5 +1,5 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/latin-400-BcR6IdUc.css","assets/latin-500-DCnAHIrw.css","assets/latin-600-CnkPk-vb.css","assets/latin-700-UC1i-VSI.css"])))=>i.map(i=>d[i]); -import{e as we,r as a,j as e,c as m,ev as Is,cT as ie,a2 as G,a0 as J,bM as Z,aE as Ie,ew as Oe,ex as os,ey as as,_ as Me,a8 as fe,E as jt,S as vt,ez as Nt,a7 as W,cu as cs,eA as wt,B as L,V as ns,eB as Ks,bY as Pe,X as Xs,eC as kt,a6 as _t,dK as Os,c3 as St,c7 as ls,dV as Ws,eD as Ct,eE as zs,eF as Tt,eG as Ft,eH as Et,aa as Rt,eI as Je,I as Mt,a1 as Dt,a3 as At}from"./index-C2xvS0Jd.js";import{g as Pt,a as Lt,c as It,r as Kt,s as Ot,b as zt,u as Vt,d as $t}from"./system-Cf6Lcq9I.js";import{C as Ht}from"./ConfirmModal-eC-cl0ep.js";import{S as Ut,A as qt,a as Bt,N as Gt}from"./AutoConfigureDialog-C6zj_Lmv.js";import{W as rs}from"./wand-sparkles-D9rSrVnU.js";import{P as is,F as Vs}from"./pencil-55Hza1I4.js";import{i as Xt,g as Wt,s as Yt,a as Jt,k as Qt}from"./keycap-sfx-ByZp-njj.js";import{C as Y,P as Zt,a as ea,B as sa}from"./PageLayout-Cg7r5tdt.js";import{T as Ys}from"./trash-2-Def3YmfN.js";import{R as ta}from"./rotate-ccw-Sqgw9a-1.js";import{S as aa}from"./shield-DvZvtyKV.js";import{R as na}from"./repeat-CprMAEnr.js";import{G as la}from"./git-branch-BhoB5t-Q.js";import{C as ra}from"./clock-DU0z3qMB.js";import{C as Js}from"./chevron-right-C9GG0xWI.js";import{R as se,C as ue}from"./Grid-kVOI-wJp.js";import{A as ia}from"./antenna-Dr-Egqv0.js";import{P as $s}from"./plus-CH14Vv92.js";import{K as Hs}from"./key-round-DBZOsqH6.js";import"./arrow-right-DySc3ssS.js";/** +import{e as we,r as a,j as e,c as m,ev as Is,cU as ie,a2 as G,a0 as Y,bN as Z,aF as Ie,ew as Oe,ex as os,ey as as,_ as Me,a8 as fe,E as jt,S as vt,ez as Nt,a7 as W,cv as cs,eA as wt,B as L,V as ns,eB as Ks,bZ as Pe,X as Xs,eC as kt,a6 as _t,aE as Os,c4 as St,c8 as ls,dV as Ws,eD as Ct,eE as zs,eF as Tt,eG as Ft,eH as Et,aa as Rt,eI as Ye,I as Mt,a1 as Dt,a3 as At}from"./index-D33fcA3L.js";import{g as Pt,a as Lt,c as It,r as Kt,s as Ot,b as zt,u as Vt,d as $t}from"./system-4FyMIaL1.js";import{C as Ht}from"./ConfirmModal-J2_Sxirm.js";import{S as Ut,A as qt,a as Bt,N as Gt}from"./AutoConfigureDialog-CDgcxIyE.js";import{W as rs}from"./wand-sparkles-CEbXzjVw.js";import{P as is,F as Vs}from"./pencil-Cg0kSr82.js";import{i as Xt,g as Wt,s as Jt,a as Yt,k as Qt}from"./keycap-sfx-ByZp-njj.js";import{C as J,P as Zt,a as ea,B as sa}from"./PageLayout-CRN-E5xi.js";import{T as Js}from"./trash-2-CUY4NG5t.js";import{R as ta}from"./rotate-ccw-B3SnN1wY.js";import{S as aa}from"./shield-Ceq641wy.js";import{R as na}from"./repeat-DUo9RRDi.js";import{G as la}from"./git-branch-Ryinnbc1.js";import{C as ra}from"./clock-D_m2QiHa.js";import{C as Ys}from"./chevron-right-D4kUPDBw.js";import{R as se,C as ue}from"./Grid-DQYUnZsY.js";import{A as ia}from"./antenna-rn7EByqR.js";import{P as $s}from"./plus-C0dCjBh9.js";import{K as Hs}from"./key-round-n5zCigFv.js";import"./arrow-right-aT_K-Mjc.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -24,4 +24,4 @@ import{e as we,r as a,j as e,c as m,ev as Is,cT as ie,a2 as G,a0 as J,bM as Z,aE * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ha=[["path",{d:"M10.17 4.193a2 2 0 0 1 3.666.013",key:"pltmmw"}],["path",{d:"M14 21h2",key:"v4qezv"}],["path",{d:"m15.874 7.743 1 1.732",key:"10m0iw"}],["path",{d:"m18.849 12.952 1 1.732",key:"zadnam"}],["path",{d:"M21.824 18.18a2 2 0 0 1-1.835 2.824",key:"fvwuk4"}],["path",{d:"M4.024 21a2 2 0 0 1-1.839-2.839",key:"1e1kah"}],["path",{d:"m5.136 12.952-1 1.732",key:"1u4ldi"}],["path",{d:"M8 21h2",key:"i9zjee"}],["path",{d:"m8.102 7.743-1 1.732",key:"1zzo4u"}]],pa=we("triangle-dashed",ha),Ke=1500,xe={stacked:"h-[38px]",inline:"h-[32px]"},he={stacked:"px-3",inline:"px-2.5"},pe="rounded-lg";function P({label:t,value:l,editValue:n,onSave:c,type:i="text",suffix:o,placeholder:b,readOnly:h=!1,layout:p="stacked",min:d,max:r,step:j,maxLength:F,description:y,tooltip:E,autoConfigured:k,className:N}){const[x,g]=a.useState(!1),[v,R]=a.useState(""),[M,w]=a.useState("idle"),_=a.useRef(null),C=a.useRef(!0),f=a.useRef(null),A=!h&&!!c;a.useEffect(()=>(C.current=!0,()=>{C.current=!1,f.current&&clearTimeout(f.current)}),[]);const S=a.useCallback(()=>{A&&(R(n??l),g(!0),w("idle"),requestAnimationFrame(()=>{var K;return(K=_.current)==null?void 0:K.select()}))},[A,n,l]),I=a.useCallback(()=>{g(!1),R(""),w("idle")},[]),V=a.useCallback(async()=>{if(!c||M==="loading")return;if(v===(n??l)){I();return}f.current&&clearTimeout(f.current),w("loading");try{if(await c(v),!C.current)return;w("success"),g(!1),f.current=setTimeout(()=>{C.current&&w("idle")},Ke)}catch{if(!C.current)return;w("error"),f.current=setTimeout(()=>{C.current&&w("idle")},Ke)}},[c,v,n,l,I,M]),H=a.useCallback(K=>{K.key==="Enter"?(K.preventDefault(),V()):K.key==="Escape"&&(K.preventDefault(),I())},[V,I]);return p==="inline"?e.jsxs("div",{className:m("group flex items-center justify-between gap-3",N),children:[e.jsxs("div",{className:"flex items-center gap-1 truncate",children:[e.jsx("label",{className:"type-label text-fg-muted truncate",children:t}),E&&e.jsx(Is,{content:E,placement:"top",children:e.jsx("span",{className:"text-fg-muted/50 hover:text-fg-muted cursor-help transition-colors flex-shrink-0",children:e.jsx(ie,{className:"w-3 h-3"})})})]}),x?e.jsxs("div",{className:m(xe.inline,pe,he.inline,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20","min-w-[100px]"),children:[e.jsx("input",{ref:_,type:i,value:v,onChange:K=>R(K.target.value),onKeyDown:H,placeholder:b,min:d,max:r,step:j,maxLength:F,disabled:M==="loading",className:m("bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0",o?"w-12 text-right":"w-full")}),o&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:o}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:M==="loading"?e.jsx(G,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:V,className:"p-0.5 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(J,{className:"w-3 h-3"})}),e.jsx("button",{onClick:I,className:"p-0.5 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(Z,{className:"w-3 h-3"})})]})})]}):e.jsxs("div",{className:m(xe.inline,pe,he.inline,"flex items-center justify-end transition-all min-w-[80px]","bg-input-bg border border-input-border",A&&"cursor-pointer hover:border-edge-strong"),onClick:A?S:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary",children:l}),M==="success"&&e.jsx(J,{className:"w-3 h-3 text-sys-green ml-1.5 shrink-0"}),M==="error"&&e.jsx(Z,{className:"w-3 h-3 text-sys-red ml-1.5 shrink-0"}),M==="idle"&&k&&e.jsx(rs,{className:"w-3 h-3 text-sys-blue ml-1.5 shrink-0"}),M==="idle"&&!k&&A&&e.jsx(is,{className:"w-3 h-3 text-fg-muted ml-1.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]}):e.jsxs("div",{className:m("group",N),children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("label",{className:"type-label text-fg-muted",children:t}),E&&e.jsx(Is,{content:E,placement:"top",children:e.jsx("span",{className:"text-fg-muted/50 hover:text-fg-muted cursor-help transition-colors flex-shrink-0",children:e.jsx(ie,{className:"w-3 h-3"})})})]}),x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:m(xe.stacked,pe,he.stacked,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20"),children:[e.jsx("input",{ref:_,type:i,value:v,onChange:K=>R(K.target.value),onKeyDown:H,placeholder:b,min:d,max:r,step:j,maxLength:F,disabled:M==="loading",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0"}),o&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:o}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:M==="loading"?e.jsx(G,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:V,className:"p-1 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(J,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:I,className:"p-1 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(Z,{className:"w-3.5 h-3.5"})})]})})]}),y&&e.jsx("p",{className:"type-data-xs text-fg-muted mt-1 ml-3",children:y})]}):e.jsxs("div",{className:m(xe.stacked,pe,he.stacked,"flex items-center transition-all","bg-input-bg border border-input-border",A&&"cursor-pointer hover:border-edge-strong"),onClick:A?S:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary flex-1 whitespace-nowrap",children:l}),M==="success"&&e.jsx(J,{className:"w-3.5 h-3.5 text-sys-green shrink-0"}),M==="error"&&e.jsx(Z,{className:"w-3.5 h-3.5 text-sys-red shrink-0"}),M==="idle"&&k&&e.jsx(rs,{className:"w-3.5 h-3.5 text-sys-blue shrink-0"}),M==="idle"&&!k&&A&&e.jsx(is,{className:"w-3.5 h-3.5 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]})}function De({label:t,value:l,editValue:n,options:c,onSave:i,readOnly:o=!1,layout:b="stacked",className:h}){const[p,d]=a.useState(!1),[r,j]=a.useState(""),[F,y]=a.useState("idle"),E=a.useRef(null),k=a.useRef(!0),N=a.useRef(null),x=!o&&!!i;a.useEffect(()=>(k.current=!0,()=>{k.current=!1,N.current&&clearTimeout(N.current)}),[]);const g=a.useCallback(()=>{x&&(j(String(n)),d(!0),y("idle"),requestAnimationFrame(()=>{var S;return(S=E.current)==null?void 0:S.focus()}))},[x,n]),v=a.useCallback(()=>{d(!1),j(""),y("idle")},[]),R=a.useCallback(async()=>{if(!(!i||F==="loading")){if(r===String(n)){v();return}N.current&&clearTimeout(N.current),y("loading");try{if(await i(r),!k.current)return;y("success"),d(!1),N.current=setTimeout(()=>{k.current&&y("idle")},Ke)}catch{if(!k.current)return;y("error"),N.current=setTimeout(()=>{k.current&&y("idle")},Ke)}}},[i,r,n,v,F]),M=a.useCallback(S=>{S.key==="Escape"&&(S.preventDefault(),v())},[v]),w=b==="inline",_=w?xe.inline:xe.stacked,C=w?he.inline:he.stacked,f=e.jsxs("div",{className:m(_,pe,C,"flex items-center transition-all relative","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20",w&&"min-w-[100px]"),children:[e.jsx("select",{ref:E,value:r,onChange:S=>j(S.target.value),onKeyDown:M,disabled:F==="loading",className:m("bg-transparent text-fg-primary focus:outline-none appearance-none cursor-pointer type-data flex-1 min-w-0","pr-6"),children:c.map(S=>e.jsx("option",{value:S.value,children:S.label},String(S.value)))}),e.jsx(Ie,{className:"absolute right-auto w-3.5 h-3.5 text-fg-muted pointer-events-none",style:{right:F==="loading"?"2rem":"3.5rem"}}),e.jsx("div",{className:"flex items-center gap-0.5 ml-1 shrink-0",children:F==="loading"?e.jsx(G,{className:m("text-fg-muted animate-spin",w?"w-3 h-3":"w-3.5 h-3.5")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:R,className:m("rounded hover:bg-sys-green/15 text-sys-green transition-colors",w?"p-0.5":"p-1"),title:"Save",children:e.jsx(J,{className:w?"w-3 h-3":"w-3.5 h-3.5"})}),e.jsx("button",{onClick:v,className:m("rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",w?"p-0.5":"p-1"),title:"Cancel (Esc)",children:e.jsx(Z,{className:w?"w-3 h-3":"w-3.5 h-3.5"})})]})})]}),A=e.jsxs("div",{className:m(_,pe,C,"flex items-center transition-all","bg-input-bg border border-input-border",x&&"cursor-pointer hover:border-edge-strong",w?"justify-end min-w-[80px]":""),onClick:x?g:void 0,children:[e.jsx("span",{className:m("type-data text-fg-primary",!w&&"flex-1"),children:l}),F==="success"&&e.jsx(J,{className:m("text-sys-green shrink-0",w?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),F==="error"&&e.jsx(Z,{className:m("text-sys-red shrink-0",w?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),F==="idle"&&x&&e.jsx(Ie,{className:m("text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0",w?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")})]});return w?e.jsxs("div",{className:m("group flex items-center justify-between",h),children:[e.jsx("label",{className:"type-label text-fg-muted shrink-0",children:t}),p?f:A]}):e.jsxs("div",{className:m("group",h),children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:t}),p?f:A]})}async function ya(){try{return await Oe("/api/auth/tokens")}catch{return{tokens:[]}}}async function ga(t){return Oe("/api/auth/tokens",{method:"POST",body:JSON.stringify({name:t})})}async function ba(t){return Oe(`/api/auth/tokens/${t}`,{method:"DELETE"})}async function Us(t){return Oe("/api/update_web_config",{method:"POST",body:JSON.stringify(t)})}a.memo(function(){const{theme:l}=os(),{themeId:n}=l,c=as.find(i=>i.meta.id===n)??as[0];return e.jsx("div",{className:"h-10 flex items-center justify-center",children:e.jsx("span",{className:"font-medium transition-all duration-300 leading-none text-center text-fg-secondary",style:{fontFamily:"Inter, system-ui, sans-serif",fontSize:"clamp(0.75rem, 0.6rem + 1.5vw, 1.1rem)",letterSpacing:"-0.02em"},children:c.meta.name})})});const Qe=a.memo(function({compact:l=!1}){const{theme:n,setTheme:c}=os(),{themeId:i}=n;return e.jsx("div",{className:m("grid grid-cols-2 gap-2",l?"w-full min-w-0 self-stretch":"w-full"),children:[...as].reverse().map(o=>{const b=i===o.meta.id,h=o.meta.isDark;return e.jsxs("button",{type:"button",title:o.meta.name,className:m("flex flex-row items-stretch radius-inner transition-all duration-200 ease-out overflow-hidden cursor-pointer",l&&"h-6",b?"ring-2 ring-sys-blue scale-[1.02]":"opacity-70 hover:opacity-100"),onClick:()=>c(o.meta.id),children:[e.jsx("div",{className:m("flex-1 h-full",h?"bg-[#18181b]":"bg-[#EFF0F1]")}),e.jsx("div",{className:"flex flex-col h-full",children:o.display.palette.map((p,d)=>e.jsx("div",{className:"flex flex-1",children:p.map((r,j)=>e.jsx("div",{className:"w-2 h-full",style:{backgroundColor:r}},j))},d))})]},o.meta.id)})})});let qs=!1,Ae=null;async function ja(){if(!qs)return Ae||(Ae=(async()=>{try{await Promise.all([Me(()=>Promise.resolve({}),__vite__mapDeps([0])),Me(()=>Promise.resolve({}),__vite__mapDeps([1])),Me(()=>Promise.resolve({}),__vite__mapDeps([2])),Me(()=>Promise.resolve({}),__vite__mapDeps([3]))]),qs=!0}catch(t){console.warn("Failed to load theme fonts:",t)}})(),Ae)}const Ze=a.memo(function(){const{theme:l,setTheme:n}=os(),{themeId:c}=l,i=c==="breeze dark",o=a.useCallback(b=>{n(b?"breeze dark":"breeze light")},[n]);return e.jsx(fe,{enabled:i,onChange:o,label:e.jsxs(e.Fragment,{children:["Dark Mode: ",i?e.jsx(jt,{className:"w-3.5 h-3.5 text-sys-blue inline"}):e.jsx(vt,{className:"w-3.5 h-3.5 text-[#e8a517] inline"})]}),tooltip:"Switch between dark and light mode",size:"md"})}),va=a.memo(function({layout:l="horizontal"}){return a.useEffect(()=>{ja()},[]),l==="toggle-only"?e.jsx(Ze,{}):l==="thumbnails-only"?e.jsx(Qe,{}):l==="vertical"?e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx(Ze,{}),e.jsx(Qe,{})]}):e.jsxs("div",{className:"flex items-stretch gap-4",children:[e.jsx("div",{className:"flex-shrink-0 flex items-start",children:e.jsx(Ze,{})}),e.jsx(Qe,{compact:!0})]})}),Na=1e4,es=2e3;function ss(t,l,n){const[c,i]=a.useState("idle"),[o,b]=a.useState(null),h=a.useRef(!0),p=a.useRef(null),d=a.useRef(null),r=a.useRef(!1),j=a.useRef("idle"),F=a.useRef(t),y=a.useRef(l),E=a.useRef(n);j.current=c,F.current=t,y.current=l,E.current=n,a.useEffect(()=>(h.current=!0,()=>{h.current=!1,p.current&&clearTimeout(p.current),d.current&&clearTimeout(d.current)}),[]);const k=a.useCallback(async x=>{if(j.current==="loading")return;const g=F.current;p.current&&clearTimeout(p.current),d.current&&clearTimeout(d.current),r.current=!1,b(x),i("loading"),p.current=setTimeout(()=>{r.current||!h.current||(b(g),i("error"),d.current=setTimeout(()=>{h.current&&(i("idle"),b(null))},es))},Na);try{if(await y.current(x),r.current=!0,p.current&&clearTimeout(p.current),!h.current)return;i("success"),d.current=setTimeout(()=>{var v;h.current&&(i("idle"),b(null),(v=E.current)==null||v.call(E))},es)}catch{if(r.current=!0,p.current&&clearTimeout(p.current),!h.current)return;b(g),i("error"),d.current=setTimeout(()=>{h.current&&(i("idle"),b(null))},es)}},[]);return{enabled:o!==null?o:t,status:c,toggle:k}}function wa(){const{latitude:t,longitude:l,enabled:n,setLocation:c,enable:i,disable:o,clear:b}=Nt(),[h,p]=a.useState(!1),[d,r]=a.useState(""),[j,F]=a.useState(""),[y,E]=a.useState("idle"),[k,N]=a.useState(null),x=a.useRef(null),g=a.useRef(null),v=a.useRef(!0);a.useEffect(()=>(v.current=!0,()=>{v.current=!1,g.current&&clearTimeout(g.current)}),[]);const R=()=>{r((t==null?void 0:t.toFixed(6))??""),F((l==null?void 0:l.toFixed(6))??""),N(null),p(!0)},M=()=>{p(!1),N(null)};a.useEffect(()=>{if(!h)return;const S=I=>{y!=="loading"&&x.current&&!x.current.contains(I.target)&&M()};return document.addEventListener("mouseup",S),()=>document.removeEventListener("mouseup",S)},[h,y]);const w=(S,I)=>{const V=parseFloat(S),H=parseFloat(I);return isNaN(V)||isNaN(H)?"Please enter valid numbers":V<-90||V>90?"Latitude must be between -90 and 90":H<-180||H>180?"Longitude must be between -180 and 180":V===0&&H===0?"Coordinates (0, 0) are invalid":null},_=()=>{if(y==="loading")return;g.current&&clearTimeout(g.current);const S=w(d,j);if(S){N(S);return}E("loading"),N(null);const I=parseFloat(d),V=parseFloat(j);c(I,V),n||i(),E("success"),g.current=setTimeout(()=>{v.current&&(E("idle"),p(!1))},1e3)},C=()=>{n?o():i()},f=()=>{b(),p(!1)},A=t!==null&&l!==null;return e.jsx(Y,{children:e.jsxs("div",{ref:x,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(W,{icon:e.jsx(pa,{}),title:"Stealth"}),e.jsxs("div",{className:"flex items-center gap-1",children:[A&&!h&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:C,className:m("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2 mr-2",n?"bg-toggle-on border-toggle-on":"bg-toggle-off border-edge-subtle"),title:n?"Disable stealth location":"Enable stealth location",children:e.jsx("span",{className:m("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",n?"translate-x-5":"translate-x-0.5")})}),e.jsx("button",{onClick:f,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-sys-red hover:bg-sys-red/10",title:"Clear stealth location",children:e.jsx(Ys,{className:"w-4 h-4"})})]}),h?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:M,disabled:y==="loading",className:m("p-2 rounded-lg transition-colors",y==="loading"?"text-fg-muted cursor-not-allowed":"text-fg-muted hover:text-sys-red hover:bg-sys-red/10"),title:"Cancel",children:e.jsx(Z,{className:"w-4 h-4"})}),e.jsx("button",{onClick:_,disabled:y==="loading",className:m("p-2 rounded-lg transition-colors",y==="loading"?"text-sys-blue cursor-wait":y==="success"?"text-sys-green":y==="error"?"text-sys-red":"text-sys-green hover:bg-sys-green/10"),title:"Save",children:y==="loading"?e.jsx(G,{className:"w-4 h-4 animate-spin"}):y==="success"?e.jsx(J,{className:"w-4 h-4"}):y==="error"?e.jsx(Z,{className:"w-4 h-4"}):e.jsx(J,{className:"w-4 h-4"})})]}):e.jsx("button",{onClick:R,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-fg-primary hover:bg-subtle",title:A?"Edit stealth location":"Set stealth location",children:e.jsx(is,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"bg-sys-cyan/5 rounded-xl p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ie,{className:"w-4 h-4 text-sys-cyan flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"type-body-sm text-fg-muted",children:[e.jsx("span",{className:"text-fg-secondary",children:"Stealth mode"})," allows you to appear on the map and in topology analysis without broadcasting your location. Coordinates are stored locally in your browser only — ",e.jsx("span",{className:"text-sys-cyan",children:"never sent to config.yaml or the mesh"}),"."]})]})}),k&&e.jsx("div",{className:"text-xs mb-3 px-2 py-1.5 rounded-md text-sys-red bg-sys-red/10",children:k}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:h?"Latitude (°)":"Latitude"}),e.jsx("div",{className:m("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:h?e.jsx("input",{type:"number",value:d,onChange:S=>r(S.target.value),step:"0.000001",min:"-90",max:"90",placeholder:"e.g. 34.052234",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:m("type-data",A&&n?"text-fg-primary":"text-fg-muted"),children:A?t.toFixed(6):"Not set"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:h?"Longitude (°)":"Longitude"}),e.jsx("div",{className:m("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:h?e.jsx("input",{type:"number",value:j,onChange:S=>F(S.target.value),step:"0.000001",min:"-180",max:"180",placeholder:"e.g. -118.243685",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:m("type-data",A&&n?"text-fg-primary":"text-fg-muted"),children:A?l.toFixed(6):"Not set"})})]})]}),A&&!h&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:m("w-2 h-2 rounded-full",n?"bg-sys-green":"bg-fg-muted")}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:n?"Stealth location active — you appear on maps with these coordinates":"Stealth location disabled — coordinates saved but not in use"})]})})]})})}function me(t){if(t<60)return`${t}s`;if(t<3600){const c=Math.floor(t/60),i=t%60;return i>0?`${c}m ${i}s`:`${c}m`}const l=Math.floor(t/3600),n=Math.floor(t%3600/60);return n>0?`${l}h ${n}m`:`${l}h`}function ts({title:t,defaultOpen:l=!1,children:n}){const[c,i]=a.useState(l);return e.jsxs("div",{className:"bg-subtle-fill radius-inner overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>i(!c),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-subtle-fill-hover transition-colors",children:[e.jsx("span",{className:"type-label text-fg-muted",children:t}),e.jsx(Ie,{className:m("w-4 h-4 text-fg-muted transition-transform",c&&"rotate-180")})]}),c&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:n})]})}const Le={off:{label:"Off",description:"All rate limiting disabled. Every advert is forwarded unconditionally.",color:"text-fg-muted",config:Ut},light:{label:"Light",description:"Gentle throttling for sparse meshes. Allows short bursts but penalizes repeat offenders. Good for small networks with few nodes.",color:"text-sys-green",config:{rate_limit_enabled:!0,bucket_capacity:3,refill_tokens:1,refill_interval_seconds:3600,min_interval_seconds:15,penalty_enabled:!0,violation_threshold:2,base_penalty_seconds:1800,penalty_multiplier:2,max_penalty_seconds:43200,violation_decay_seconds:7200,adaptive_enabled:!0,ewma_alpha:.15,hysteresis_seconds:480,quiet_max:2,normal_max:6,busy_max:10}},standard:{label:"Standard",description:"Balanced protection for most meshes. One advert per source is enough for discovery — repeated adverts are suppressed to protect channel capacity.",color:"text-sys-blue",recommended:!0,config:{rate_limit_enabled:!0,bucket_capacity:2,refill_tokens:1,refill_interval_seconds:7200,min_interval_seconds:30,penalty_enabled:!0,violation_threshold:1,base_penalty_seconds:7200,penalty_multiplier:4,max_penalty_seconds:172800,violation_decay_seconds:14400,adaptive_enabled:!0,ewma_alpha:.1,hysteresis_seconds:300,quiet_max:1,normal_max:3,busy_max:8}},strict:{label:"Strict",description:"Maximum suppression for dense or congested meshes. One token, long refill, immediate jail. Protects GRP_TXT capacity at all costs.",color:"text-sys-amber",config:{rate_limit_enabled:!0,bucket_capacity:1,refill_tokens:1,refill_interval_seconds:14400,min_interval_seconds:60,penalty_enabled:!0,violation_threshold:1,base_penalty_seconds:10800,penalty_multiplier:4,max_penalty_seconds:259200,violation_decay_seconds:21600,adaptive_enabled:!0,ewma_alpha:.05,hysteresis_seconds:180,quiet_max:.5,normal_max:2,busy_max:5}}},Zs=["off","light","standard","strict"];function ka(t,l,n){if(!t&&!l&&!n||!((t==null?void 0:t.enabled)||(l==null?void 0:l.enabled)||(n==null?void 0:n.enabled)))return"off";for(const i of Zs){if(i==="off")continue;const o=Le[i].config;if((t==null?void 0:t.bucket_capacity)===o.bucket_capacity&&(t==null?void 0:t.refill_tokens)===o.refill_tokens&&(t==null?void 0:t.refill_interval_seconds)===o.refill_interval_seconds&&(t==null?void 0:t.min_interval_seconds)===o.min_interval_seconds&&(l==null?void 0:l.violation_threshold)===o.violation_threshold&&(l==null?void 0:l.base_penalty_seconds)===o.base_penalty_seconds&&(l==null?void 0:l.penalty_multiplier)===o.penalty_multiplier&&(l==null?void 0:l.max_penalty_seconds)===o.max_penalty_seconds&&(l==null?void 0:l.violation_decay_seconds)===o.violation_decay_seconds&&(n==null?void 0:n.ewma_alpha)===o.ewma_alpha&&(n==null?void 0:n.hysteresis_seconds)===o.hysteresis_seconds)return i}return null}function _a(){var S,I,V,H,K,ee;const{stats:t,fetchStats:l}=cs(),n=a.useRef(!0),[c,i]=a.useState(!0),[o,b]=a.useState(!1),[h,p]=a.useState(null),[d,r]=a.useState("idle"),j=a.useRef(null),[F,y]=a.useState(!1),[E,k]=a.useState(new Set);a.useEffect(()=>(n.current=!0,()=>{n.current=!1,j.current&&clearTimeout(j.current)}),[]);const N=a.useCallback(async()=>{var u;try{const O=await wt();if(!n.current)return;O.success&&O.data&&((u=O.data.adaptive)!=null&&u.current_tier)?i(!0):i(!1)}catch{n.current&&i(!1)}},[]);a.useEffect(()=>{N();const u=setInterval(N,3e4);return()=>clearInterval(u)},[N]);const x=(I=(S=t==null?void 0:t.config)==null?void 0:S.repeater)==null?void 0:I.advert_rate_limit,g=(H=(V=t==null?void 0:t.config)==null?void 0:V.repeater)==null?void 0:H.advert_penalty_box,v=(ee=(K=t==null?void 0:t.config)==null?void 0:K.repeater)==null?void 0:ee.advert_adaptive;if(!c&&!x&&!g&&!v)return null;const R=u=>E.has(u),M=u=>{k(O=>{if(!O.has(u))return O;const X=new Set(O);return X.delete(u),X})},w=ka(x,g,v),_=w?Le[w]:null,C=async(u,O)=>{M(u),b(!0),p(null),j.current&&clearTimeout(j.current);try{const X=await Ks({[u]:O});if(!n.current)return;X.success?(r("success"),await Promise.all([l({force:!0}).catch(()=>{}),N()])):(r("error"),p(X.error||"Failed to save"))}catch{n.current&&(r("error"),p("Failed to save"))}finally{n.current&&(b(!1),j.current=setTimeout(()=>{n.current&&(r("idle"),p(null))},1500))}},f=async u=>{if(!(u===w||o)){b(!0),p(null),k(new Set),j.current&&clearTimeout(j.current);try{const O=await Ks(Le[u].config);if(!n.current)return;O.success?(r("success"),await Promise.all([l({force:!0}).catch(()=>{}),N()])):(r("error"),p(O.error||"Failed to save"))}catch{n.current&&(r("error"),p("Failed to save"))}finally{n.current&&(b(!1),j.current=setTimeout(()=>{n.current&&r("idle")},1500))}}},A=()=>f("off");return e.jsxs(Y,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(aa,{}),title:"Advert Rate Limiting",actions:e.jsxs("div",{className:"flex items-center gap-3",children:[d!=="idle"&&e.jsxs("span",{className:"flex items-center",children:[d==="success"&&e.jsx(J,{className:"w-4 h-4 text-sys-green"}),d==="error"&&e.jsx(Z,{className:"w-4 h-4 text-sys-red"})]}),e.jsxs(L,{plain:!0,onClick:A,className:"flex items-center gap-1.5 text-zinc-500 hover:text-zinc-400 transition-colors",children:[e.jsx(ta,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-body-xs font-medium hidden sm:inline",children:"Reset"})]}),e.jsxs(L,{plain:!0,onClick:()=>y(!0),className:"flex items-center gap-1.5 text-sys-blue hover:text-sys-blue/80 transition-colors",children:[e.jsx(rs,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-body-xs font-medium",children:"Auto"})]})]})}),h&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:h}),e.jsx("div",{className:"toggle-group w-full mb-4",children:Zs.map(u=>{const O=Le[u],X=u===w;return e.jsx("button",{onClick:()=>f(u),disabled:o,className:m("toggle-group-item flex-1",X&&"active",X&&O.color),children:O.label},u)})}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(ie,{className:"w-4 h-4 text-sys-blue"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:m("type-data-xs font-medium uppercase tracking-wide",(_==null?void 0:_.color)??"text-fg-muted"),children:(_==null?void 0:_.label)??"Custom"}),(_==null?void 0:_.recommended)&&e.jsx(ns,{color:"green",children:"Recommended"}),!w&&e.jsx(ns,{color:"zinc",children:"Custom"})]}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:(_==null?void 0:_.description)??"Settings have been manually tuned and don’t match any preset."})]})]})}),e.jsxs("div",{className:m("space-y-3",w==="off"&&"opacity-40 pointer-events-none"),children:[e.jsx(ts,{title:"Token Rules",children:x?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(P,{label:"Bucket Capacity",value:String(x.bucket_capacity),type:"number",suffix:"tokens",min:1,max:100,tooltip:"Max tokens a source can hold — determines burst capacity. Each advert costs one token; tokens refill over time.",autoConfigured:R("bucket_capacity"),onSave:async u=>C("bucket_capacity",parseInt(u,10))}),e.jsx(P,{label:"Refill Tokens",value:String(x.refill_tokens),type:"number",suffix:"tokens",min:1,max:50,tooltip:"Tokens added back each refill cycle. Higher = more forgiving over time.",autoConfigured:R("refill_tokens"),onSave:async u=>C("refill_tokens",parseInt(u,10))}),e.jsx(P,{label:"Refill Interval",value:me(x.refill_interval_seconds),editValue:String(parseFloat((x.refill_interval_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:.5,min:.5,max:24,tooltip:"How often the bucket gets topped up. Shorter = faster recovery from bursts.",autoConfigured:R("refill_interval_seconds"),onSave:async u=>C("refill_interval_seconds",Math.round(parseFloat(u)*3600))}),e.jsx(P,{label:"Min Interval",value:me(x.min_interval_seconds),editValue:String(x.min_interval_seconds),type:"number",suffix:"sec",min:0,max:3600,tooltip:"Minimum gap between adverts from the same source, even if tokens are available. 0 = no minimum.",autoConfigured:R("min_interval_seconds"),onSave:async u=>C("min_interval_seconds",parseInt(u,10))})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})}),e.jsx(ts,{title:"Jail Settings",children:g?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(P,{label:"Violation Threshold",value:String(g.violation_threshold),type:"number",suffix:"violations",min:1,max:100,tooltip:"How many rate-limit violations before a source gets penalized. Think of it as strikes before timeout.",autoConfigured:R("violation_threshold"),onSave:async u=>C("violation_threshold",parseInt(u,10))}),e.jsx(P,{label:"Base Penalty",value:me(g.base_penalty_seconds),editValue:String(parseFloat((g.base_penalty_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:.5,min:.5,max:24,tooltip:"First offense penalty duration. Repeat offenders get this multiplied.",autoConfigured:R("base_penalty_seconds"),onSave:async u=>C("base_penalty_seconds",Math.round(parseFloat(u)*3600))}),e.jsx(P,{label:"Multiplier",value:`${g.penalty_multiplier}x`,editValue:String(g.penalty_multiplier),type:"number",suffix:"x",step:.5,min:1,max:10,tooltip:"Each repeat offense multiplies the penalty by this factor. 2x means penalties double each time.",autoConfigured:R("penalty_multiplier"),onSave:async u=>C("penalty_multiplier",parseFloat(u))}),e.jsx(P,{label:"Max Penalty",value:me(g.max_penalty_seconds),editValue:String(parseFloat((g.max_penalty_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:1,min:1,max:168,tooltip:"Upper limit on penalty duration. No matter how many offenses, it won't exceed this.",autoConfigured:R("max_penalty_seconds"),onSave:async u=>C("max_penalty_seconds",Math.round(parseFloat(u)*3600))}),e.jsx(P,{label:"Violation Decay",value:me(g.violation_decay_seconds),editValue:String(parseFloat((g.violation_decay_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:1,min:1,max:168,tooltip:"How long until a source's violation count resets. Good behavior earns a clean slate.",autoConfigured:R("violation_decay_seconds"),onSave:async u=>C("violation_decay_seconds",Math.round(parseFloat(u)*3600))})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})}),e.jsx(ts,{title:"Traffic Tiers",children:v?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(P,{label:"EWMA α",value:String(v.ewma_alpha),type:"number",step:.01,min:.01,max:1,tooltip:"How quickly the system reacts to traffic changes. Lower = smoother, higher = more responsive.",autoConfigured:R("ewma_alpha"),onSave:async u=>C("ewma_alpha",parseFloat(u))}),e.jsx(P,{label:"Hysteresis",value:me(v.hysteresis_seconds),editValue:String(parseFloat((v.hysteresis_seconds/60).toFixed(2))),type:"number",suffix:"min",step:.5,min:0,max:60,tooltip:"Cooldown before switching tiers again. Prevents rapid flip-flopping during traffic spikes.",autoConfigured:R("hysteresis_seconds"),onSave:async u=>C("hysteresis_seconds",Math.round(parseFloat(u)*60))}),e.jsx(P,{label:"Quiet Max",value:String(v.thresholds.quiet_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic below this = quiet mesh. Rate limits are most relaxed here.",autoConfigured:R("quiet_max"),onSave:async u=>C("quiet_max",parseFloat(u))}),e.jsx(P,{label:"Normal Max",value:String(v.thresholds.normal_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic below this = normal activity. Standard rate limits apply.",autoConfigured:R("normal_max"),onSave:async u=>C("normal_max",parseFloat(u))}),e.jsx(P,{label:"Busy Max",value:String(v.thresholds.busy_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic above this = congested mesh. Strictest rate limits kick in.",autoConfigured:R("busy_max"),onSave:async u=>C("busy_max",parseFloat(u))})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})})]}),e.jsx("div",{className:"bg-sys-blue/5 radius-inner p-4 mt-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(ie,{className:"w-4 h-4 text-sys-blue"})}),e.jsx("div",{className:"type-body-sm text-fg-muted",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Three layers"})," work together: the ",e.jsx("span",{className:"text-sys-blue",children:"Token Rules"})," throttle per-source adverts, the ",e.jsx("span",{className:"text-sys-amber",children:"Jail"})," escalates penalties for repeat violators, and ",e.jsx("span",{className:"text-sys-green",children:"Traffic Tiers"})," adjust limits based on overall mesh activity. The ",e.jsx("span",{className:"text-sys-blue",children:"“Auto”"})," button analyzes 1 week of mesh traffic to suggest optimal settings."]})})]})}),e.jsx(qt,{open:F,onClose:()=>y(!1),currentConfig:{tokenBucket:x,penaltyBox:g,adaptive:v},onApplied:async()=>{k(new Set(Bt)),await Promise.all([l({force:!0}).catch(()=>{}),N()])}})]})}const Bs={off:{label:"Off",threshold:null,description:"No loop detection. All flood packets forwarded regardless of path history.",color:"text-fg-muted"},minimal:{label:"Minimal",threshold:4,description:"Drops flood packets when your local hash appears 4+ times in the path. Catches only the most obvious routing loops.",color:"text-sys-green",recommended:!0},moderate:{label:"Moderate",threshold:2,description:"Drops flood packets when your local hash appears 2+ times in the path. Good balance for most networks.",color:"text-sys-blue"},strict:{label:"Strict",threshold:1,description:"Drops flood packets if your local hash appears even once in the path. Strongest loop prevention — may drop some legitimate retransmissions in dense meshes.",color:"text-sys-amber"}},Sa=["off","minimal","moderate","strict"];function Ca(){var N;const{stats:t,fetchStats:l}=cs(),n=a.useRef(!0),c=(N=t==null?void 0:t.config)==null?void 0:N.mesh,i=!!c,o=(c==null?void 0:c.loop_detect)??"off",b=Bs[o],h=t==null?void 0:t.local_hash,[p,d]=a.useState(!1),[r,j]=a.useState(null),[F,y]=a.useState("idle"),E=a.useRef(null);if(a.useEffect(()=>(n.current=!0,()=>{n.current=!1,E.current&&clearTimeout(E.current)}),[]),a.useEffect(()=>{if(!r)return;const x=setTimeout(()=>{n.current&&j(null)},4e3);return()=>clearTimeout(x)},[r]),!t)return null;const k=async x=>{if(!(!i||x===o||p)){d(!0),j(null),E.current&&clearTimeout(E.current);try{const g=await Xs({loop_detect:x});if(!n.current)return;g.success?(y("success"),await l({force:!0}).catch(()=>{})):(y("error"),j(g.error||"Failed to save"))}catch{n.current&&(y("error"),j("Failed to save"))}finally{n.current&&(d(!1),E.current=setTimeout(()=>{n.current&&y("idle")},1500))}}};return e.jsxs(Y,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(na,{}),title:"Flood Loop Detection",actions:F!=="idle"?e.jsxs("span",{className:"flex items-center",children:[F==="success"&&e.jsx(J,{className:"w-4 h-4 text-sys-green"}),F==="error"&&e.jsx(Z,{className:"w-4 h-4 text-sys-red"})]}):void 0}),!i&&e.jsxs("div",{className:"flex items-start gap-2.5 mb-3 px-3 py-2.5 radius-inner bg-sys-amber/10 text-sys-amber",children:[e.jsx(Pe,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsxs("p",{className:"type-body-sm",children:["Backend does not expose mesh config. Update pyMC_Repeater to enable live configuration. Set ",e.jsx("code",{className:"font-mono text-fg-secondary",children:"loop_detect"})," in"," ",e.jsx("code",{className:"font-mono text-fg-secondary",children:"config.yaml"})," manually."]})]}),r&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:r}),e.jsx("div",{className:m("toggle-group w-full mb-4",!i&&"opacity-50 pointer-events-none"),children:Sa.map(x=>{const g=Bs[x],v=x===o;return e.jsx("button",{onClick:()=>k(x),disabled:p||!i,className:m("toggle-group-item flex-1",v&&"active",v&&g.color),children:g.label},x)})}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(ie,{className:"w-4 h-4 text-sys-blue"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:m("type-data-xs font-medium uppercase tracking-wide",b.color),children:b.label}),b.threshold!==null&&e.jsxs("span",{className:"data-box data-box-compact text-fg-secondary tabular-nums",children:["≥",b.threshold,"× → drop"]}),b.recommended&&e.jsx(ns,{color:"green",children:"Recommended"})]}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:b.description}),h&&o!=="off"&&e.jsxs("p",{className:"type-data-xs text-fg-muted/60 mt-2 font-mono",children:["Local hash: ",h]})]})]})})]})}function Ta(t){if(!t)return"Never";const l=new Date(t).getTime();if(isNaN(l))return"Never";const c=(Date.now()-l)/1e3;return c<60?"Just now":c<3600?`${Math.floor(c/60)}m ago`:c<86400?`${Math.floor(c/3600)}h ago`:`${Math.floor(c/86400)}d ago`}function Fa(){const{status:t,updateAvailable:l,isChecking:n,channels:c,changelog:i,error:o,available:b,checkForUpdate:h,fetchChannels:p,fetchChangelog:d,setChannel:r,openModal:j}=kt(),F=_t(),[y,E]=a.useState(!1),[k,N]=a.useState(!1);if(a.useEffect(()=>{p(),d()},[p,d]),!b)return null;const x=f=>f.split("+")[0],g=f=>f!=null&&f.includes("+")?f.split("+")[1]:null,v=(t==null?void 0:t.current_version)??(F==null?void 0:F.version)??null,R=(t==null?void 0:t.latest_version)??null,M=v?x(v):null,w=R?x(R):null,_=g(v),C=(t==null?void 0:t.channel)??"main";return e.jsxs(Y,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(Os,{}),title:"Software Update"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4 mb-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Installed"}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx("p",{className:"type-data text-fg-primary truncate font-mono",children:M?`v${M}`:"—"}),_&&e.jsx(St,{copy:!0,copyValue:_,title:`Build: ${_}`,children:_})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Git Branch"}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5",children:[e.jsx(la,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-sys-indigo truncate",children:C})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Last Checked"}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5",children:[e.jsx(ra,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:Ta((t==null?void 0:t.last_checked)??null)})]})]})]}),c.length>0&&e.jsxs("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:[e.jsx("div",{className:"flex items-center justify-between gap-3",children:e.jsxs("div",{children:[e.jsx("h4",{className:"type-body-sm text-fg-primary font-medium",children:"Release Channel"}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-0.5",children:"Switch between stable and development branches"})]})}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-3",children:c.map(f=>e.jsxs("button",{onClick:async()=>{f.active||k||(N(!0),await r(f.name),N(!1))},disabled:f.active||k,className:m("px-3 py-1.5 radius-inner type-data-xs font-medium transition-colors",f.active?"bg-sys-indigo/15 text-sys-indigo ring-1 ring-sys-indigo/30":"bg-subtle-fill-strong text-fg-muted hover:text-fg-primary hover:bg-subtle-fill-hover",k&&!f.active&&"opacity-50 cursor-not-allowed"),children:[f.name,f.active&&e.jsx(ls,{className:"w-3 h-3 ml-1.5 inline-block"})]},f.name))})]}),i.length>0&&e.jsxs("div",{className:"bg-subtle-fill radius-inner mb-4",children:[e.jsxs("button",{onClick:()=>E(!y),className:"w-full flex items-center gap-2 px-4 py-3 text-left hover:bg-subtle-fill-hover transition-colors radius-inner",children:[y?e.jsx(Ie,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}):e.jsx(Js,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-body-sm text-fg-primary font-medium flex-1",children:"Changelog"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[i.length," commit",i.length!==1?"s":""]})]}),y&&e.jsx("div",{className:"px-4 pb-3 space-y-1 max-h-[300px] overflow-y-auto",children:i.map(f=>e.jsxs("div",{className:"flex items-start gap-2 py-1.5 group",children:[e.jsx(ma,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[f.url?e.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",className:"type-data-xs text-fg-primary truncate hover:text-sys-blue transition-colors",children:f.title}):e.jsx("p",{className:"type-data-xs text-fg-primary truncate",children:f.title}),f.url&&e.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",className:"opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:e.jsx(Qs,{className:"w-3 h-3 text-fg-muted"})})]}),f.body&&e.jsx("p",{className:"type-data-xs text-fg-muted mt-0.5 line-clamp-2 whitespace-pre-line",children:f.body}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"type-data-xs text-fg-muted font-mono",children:f.short_sha}),e.jsx("span",{className:"text-fg-muted/30",children:"·"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:f.author}),e.jsx("span",{className:"text-fg-muted/30",children:"·"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:f.date?new Date(f.date).toLocaleDateString():""})]})]})]},f.sha))})]}),o&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:o}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l&&e.jsxs(L,{color:"danger",onClick:j,children:[e.jsx(Os,{"data-slot":"icon"}),"Update to v",w]}),e.jsx("div",{className:"flex-1"}),!l&&t&&e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-sys-green",children:[e.jsx(ls,{className:"w-3.5 h-3.5"}),"Up to date"]}),e.jsx(L,{color:"primary",outline:!0,onClick:()=>h(!0),disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-slot":"icon",className:"animate-spin"}),"Checking..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ws,{"data-slot":"icon"}),"Check for Updates"]})})]})]})}const Ea=[{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"}],Ra=[5,6,7,8,9,10,11,12],Ma=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],Da=[{value:0,label:"1-byte — 0x00"},{value:1,label:"2-byte — 0x0000"},{value:2,label:"3-byte — 0x000000"}],Gs={RADIO_CONFIG:"radioConfig"};function Aa(t){if(!t)return"Never";const n=Date.now()-t*1e3,c=Math.floor(n/6e4),i=Math.floor(n/36e5),o=Math.floor(n/864e5);return c<1?"Just now":c<60?`${c}m ago`:i<24?`${i}h ago`:o<365?`${o}d ago`:`${Math.floor(o/365)}y ago`}function et({node:t,level:l,expandedKeys:n,selectedKeyId:c,onSelect:i,onToggle:o}){const b=n.has(t.id),h=c===t.id,p=t.children&&t.children.length>0;return e.jsxs("div",{children:[e.jsxs("div",{className:m("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",h?"bg-sys-blue/15":"hover:bg-subtle-fill"),style:{marginLeft:`${l*16}px`},onClick:()=>i(t.id),children:[p?e.jsx("button",{onClick:d=>{d.stopPropagation(),o(t.id)},className:"p-1 hover:bg-subtle-fill-hover rounded-full transition-colors",children:e.jsx(Js,{className:m("w-3.5 h-3.5 text-fg-muted transition-transform",b&&"rotate-90")})}):e.jsx("span",{className:"w-5"}),e.jsx(da,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary flex-1 truncate",children:t.name}),e.jsx("span",{className:"type-data-xs text-fg-muted hidden sm:inline",title:t.last_used?new Date(t.last_used*1e3).toLocaleString():void 0,children:Aa(t.last_used)}),e.jsx("span",{className:m("type-data-xs px-2 py-0.5 rounded-full",t.floodPolicy==="allow"?"bg-sys-green/15 text-sys-green":"bg-sys-red/15 text-sys-red"),children:t.floodPolicy==="allow"?"Allow":"Deny"})]}),p&&b&&e.jsx("div",{children:t.children.map(d=>e.jsx(et,{node:d,level:l+1,expandedKeys:n,selectedKeyId:c,onSelect:i,onToggle:o},d.id))})]})}function Pa(){const[t,l]=a.useState(Xt),[n,c]=a.useState(Wt),[i,o]=a.useState(!1),b=a.useCallback(d=>{l(d),Yt(d)},[]),h=a.useCallback(d=>{const r=parseFloat(d.target.value);c(r),Jt(r)},[]),p=a.useCallback(async()=>{i||(o(!0),await Qt(),o(!1))},[i]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(fe,{enabled:t,onChange:b,label:e.jsxs(e.Fragment,{children:["Sound: ",e.jsx("span",{className:t?"text-sys-green":"text-sys-red",children:t?"On":"Off"})]}),tooltip:"Enable or disable UI sound effects and haptic audio feedback",size:"md"}),e.jsx(L,{color:"primary",outline:!0,onClick:p,disabled:!t||i,className:"w-16 justify-center",children:i?"…":"Test"})]}),e.jsxs("div",{className:m("flex items-center gap-3",!t&&"opacity-40 pointer-events-none"),children:[e.jsx("span",{className:"type-label text-fg-muted w-14 shrink-0",children:"Volume"}),e.jsx("input",{type:"range",min:0,max:1,step:.05,value:n,onChange:h,className:"flex-1 accent-sys-blue h-1.5 cursor-pointer"}),e.jsxs("span",{className:"data-box w-16 justify-center",children:[Math.round(n*100),"%"]})]})]})}function tn(){var Cs,Ts,Fs,Es,Rs,Ms,Ds,As,Ps,Ls;const{stats:t,setMode:l,clearModeMutation:n,setDutyCycleConfig:c,clearDutyCycleMutation:i,fetchStats:o,startMutation:b,clearMutation:h}=cs(),p=Ct(),d=(Cs=t==null?void 0:t.config)==null?void 0:Cs.radio,r=(Ts=t==null?void 0:t.config)==null?void 0:Ts.repeater,j=(Fs=t==null?void 0:t.config)==null?void 0:Fs.duty_cycle,F=(t==null?void 0:t.node_name)||((Es=t==null?void 0:t.config)==null?void 0:Es.node_name)||"Unknown Node",y=(r==null?void 0:r.mode)??"forward",E=(j==null?void 0:j.enforcement_enabled)??!1,k=(Rs=t==null?void 0:t.config)==null?void 0:Rs.delays,N=a.useRef(!0);a.useEffect(()=>(N.current=!0,()=>{N.current=!1}),[]);const x=(Ms=t==null?void 0:t.config)==null?void 0:Ms.web,[g,v]=a.useState([]),[R,M]=a.useState(!1),[w,_]=a.useState(null),[C,f]=a.useState(!1),[A,S]=a.useState(""),[I,V]=a.useState(null),[H,K]=a.useState(!1),[ee,u]=a.useState(null),[O,X]=a.useState(!1),[ds,us]=a.useState(!1),[ms,fs]=a.useState(!1),[te,st]=a.useState([]),[tt,xs]=a.useState(!1),[hs,$]=a.useState(null),[ze,at]=a.useState(()=>localStorage.getItem("pymc:unscopedFloodPolicy")==="allow"?"allow":"deny"),ps=a.useCallback(s=>{at(s),localStorage.setItem("pymc:unscopedFloodPolicy",s)},[]),[ys,gs]=a.useState(!1),[q,Ve]=a.useState(null),[nt,lt]=a.useState(new Set),[ke,ye]=a.useState(!1),[_e,oe]=a.useState(!1),[Se,ce]=a.useState(!1),[U,ae]=a.useState(null),[ne,ge]=a.useState(null),[Ce,Te]=a.useState(""),[$e,be]=a.useState("allow"),[Q,de]=a.useState(!1),[Fe,bs]=a.useState(!0),[je,He]=a.useState(!1),[rt,js]=a.useState(!0),[ve,le]=a.useState("idle"),[it,Ue]=a.useState(!1),[qe,ot]=a.useState(!1),vs=a.useCallback(()=>{const s=k==null?void 0:k.tx_delay_factor;return s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??1:typeof s=="number"?s:1},[k]),Ns=a.useCallback(()=>{const s=k==null?void 0:k.direct_tx_delay_factor;return typeof s=="number"?s:.5},[k]),Be=a.useCallback(()=>{const s=j==null?void 0:j.max_airtime_percent;return typeof s=="number"?s:s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??6:6},[j]),Ge=ss(y==="forward",async s=>{await l(s?"forward":"monitor")},n),Xe=ss(E,async s=>{await c({max_airtime_percent:Be(),enforcement_enabled:s})},i),We=ss((x==null?void 0:x.cors_enabled)??!1,async s=>{var D;const T=await Us({web:{cors_enabled:s}});if(!T.success&&!((D=T.data)!=null&&D.persisted))throw new Error("CORS update failed");await o()}),B=a.useCallback(async s=>{b(Gs.RADIO_CONFIG);try{const T=await Xs(s);if(!T.success)throw new Error(T.error||"Failed to save");await o({force:!0}).catch(()=>{})}finally{h(Gs.RADIO_CONFIG)}},[b,h,o]);a.useEffect(()=>{(async()=>{js(!0);try{const T=await It();T.success&&T.data?He(T.data.exists):He(!1);const D=x==null?void 0:x.web_path;bs(!D||D==="")}catch{He(!1)}finally{js(!1)}})()},[x==null?void 0:x.web_path]);const ws=async s=>{var T;if(ve!=="loading"){le("loading");try{const D=await Us({web:{web_path:s?null:"/opt/pymc_console/web/html"}});if(!N.current)return;D.success||(T=D.data)!=null&&T.persisted?(bs(s),le("success"),Ue(!0),setTimeout(()=>{N.current&&le("idle")},2e3)):(le("error"),setTimeout(()=>{N.current&&le("idle")},2e3))}catch{if(!N.current)return;le("error"),setTimeout(()=>{N.current&&le("idle")},2e3)}}},ct=async()=>{if(!qe){ot(!0);try{await Kt(),Ue(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{Ue(!1),setTimeout(()=>{window.location.reload()},3e3)}}},Ee=a.useCallback(async()=>{M(!0),_(null);try{const s=await ya();v(s.tokens||[])}catch(s){_(s instanceof Error?s.message:"Failed to fetch tokens")}finally{M(!1)}},[]);a.useEffect(()=>{Ee()},[Ee]);const ks=async()=>{if(!A.trim()){_("Token name is required");return}X(!0),_(null);try{const s=await ga(A.trim());V(s.token||null),f(!1),K(!0),S(""),await Ee()}catch(s){_(s instanceof Error?s.message:"Failed to create token")}finally{X(!1)}},dt=async()=>{if(ee){us(!0),_(null);try{await ba(ee.id),await Ee(),u(null)}catch(s){_(s instanceof Error?s.message:"Failed to revoke token")}finally{us(!1)}}},ut=async()=>{I&&(await At(I),fs(!0),setTimeout(()=>fs(!1),2e3))},mt=s=>s?new Date(s*1e3).toLocaleString():"Never",_s=a.useCallback(s=>{const T=new Map,D=[];return s.forEach(z=>{const Re={id:z.id,name:z.name,floodPolicy:z.flood_policy,transport_key:z.transport_key,last_used:z.last_used,parent_id:z.parent_id,children:[]};T.set(z.id,Re)}),T.forEach(z=>{z.parent_id&&T.has(z.parent_id)?T.get(z.parent_id).children.push(z):D.push(z)}),D},[]),Ne=a.useCallback(async()=>{xs(!0),$(null);try{const s=await Pt();if(s.success&&s.data){const T=_s(s.data);st(T),Ve(D=>{if(D===null)return null;const z=Re=>{for(const Ye of Re)if(Ye.id===D||Ye.children&&z(Ye.children))return!0;return!1};return z(T)?D:null})}else $(s.error||"Failed to load transport keys")}catch(s){$(s instanceof Error?s.message:"Unknown error occurred")}finally{xs(!1)}},[_s]);a.useEffect(()=>{Ne(),Lt().then(s=>{s.success&&s.data&&ps(s.data.unscoped_flood_allow?"allow":"deny")}).catch(()=>{})},[Ne]);const re=a.useCallback((s,T)=>{for(const D of s){if(D.id===T)return D;if(D.children){const z=re(D.children,T);if(z)return z}}return null},[]),ft=a.useCallback(()=>{if(!q)return;const s=re(te,q);return s==null?void 0:s.name},[q,te,re]),xt=a.useCallback(s=>{lt(T=>{const D=new Set(T);return D.has(s)?D.delete(s):D.add(s),D})},[]),ht=async s=>{gs(!0),$(null);try{const T=await Ot(s==="allow");T.success?ps(s):$(T.error||"Failed to update unscoped flood policy")}catch(T){$(T instanceof Error?T.message:"Failed to update unscoped flood policy")}finally{gs(!1)}},Ss=async()=>{if(!Ce.trim()){$("Key name is required");return}de(!0),$(null);try{const s=await zt({name:Ce.trim(),flood_policy:$e,parent_id:q??void 0});s.success?(await Ne(),ye(!1),Te(""),be("allow")):$(s.error||"Failed to add transport key")}catch(s){$(s instanceof Error?s.message:"Failed to add transport key")}finally{de(!1)}},pt=async()=>{if(U){de(!0),$(null);try{const s=await Vt(U.id,{name:U.name,flood_policy:U.floodPolicy});s.success?(await Ne(),oe(!1),ae(null)):$(s.error||"Failed to update transport key")}catch(s){$(s instanceof Error?s.message:"Failed to update transport key")}finally{de(!1)}}},yt=async()=>{if(ne){de(!0),$(null);try{const s=await $t(ne.id);s.success?(await Ne(),ce(!1),ge(null),Ve(null)):$(s.error||"Failed to delete transport key")}catch(s){$(s instanceof Error?s.message:"Failed to delete transport key")}finally{de(!1)}}},gt=a.useCallback(()=>{if(!q)return;const s=re(te,q);s&&(ae({...s}),oe(!0))},[q,te,re]);a.useEffect(()=>{const s=D=>{D.key==="Escape"&&(ke&&(ye(!1),Te(""),be("allow")),_e&&(oe(!1),ae(null)),Se&&(ce(!1),ge(null)),C&&(f(!1),S("")),H&&(K(!1),V(null)))};if(ke||_e||Se||C||H)return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[ke,_e,Se,C,H]);const bt=a.useCallback(()=>{if(!q)return;const s=re(te,q);s&&(ge(s),ce(!0))},[q,te,re]);return e.jsxs(Zt,{children:[e.jsx(ea,{title:"Configuration",icon:e.jsx(zs,{})}),e.jsxs(sa,{ready:p,children:[e.jsxs(se,{template:"standard",children:[e.jsx(ue,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(Tt,{}),title:"Repeater Settings"}),r?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(P,{label:"Node Name",value:F,onSave:async s=>B({node_name:s}),placeholder:"Enter node name",maxLength:50})}),e.jsx(P,{label:"Latitude",value:r.latitude!==0?r.latitude.toFixed(6):"Not set",editValue:String(r.latitude),type:"number",suffix:"°",step:1e-6,min:-90,max:90,onSave:async s=>B({latitude:parseFloat(s)})}),e.jsx(P,{label:"Longitude",value:r.longitude!==0?r.longitude.toFixed(6):"Not set",editValue:String(r.longitude),type:"number",suffix:"°",step:1e-6,min:-180,max:180,onSave:async s=>B({longitude:parseFloat(s)})}),e.jsx(P,{label:"Advert Interval",value:r.send_advert_interval_hours>0?`${r.send_advert_interval_hours}h`:"Disabled",editValue:String(r.send_advert_interval_hours),type:"number",suffix:"hours",min:0,max:48,description:"0 = disabled, 3-48 hours",onSave:async s=>B({flood_advert_interval_hours:parseInt(s,10)})}),e.jsx(P,{label:"Score-based TX",value:r.use_score_for_tx?"Enabled":"Disabled",readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading repeater settings..."})]})}),e.jsx(ue,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(ia,{}),title:"Radio Configuration"}),d?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(P,{label:"Frequency",value:Ft(d.frequency),editValue:(d.frequency/1e6).toFixed(3),type:"number",suffix:"MHz",step:.001,min:400,max:930,onSave:async s=>B({frequency_mhz:parseFloat(s)})}),e.jsx(P,{label:"TX Power",value:`${d.tx_power} dBm`,editValue:String(d.tx_power),type:"number",suffix:"dBm",min:2,max:30,onSave:async s=>B({tx_power:parseInt(s,10)})}),e.jsx(De,{label:"Bandwidth",value:Et(d.bandwidth),editValue:d.bandwidth/1e3,options:Ea,onSave:async s=>B({bandwidth_khz:parseFloat(s)})}),e.jsx(De,{label:"Spreading Factor",value:`SF${d.spreading_factor}`,editValue:d.spreading_factor,options:Ra.map(s=>({value:s,label:`SF${s}`})),onSave:async s=>B({spreading_factor:parseInt(s,10)})}),e.jsx(De,{label:"Coding Rate",value:`4/${d.coding_rate}`,editValue:d.coding_rate,options:Ma,onSave:async s=>B({coding_rate:parseInt(s,10)})}),e.jsx(P,{label:"Preamble",value:`${d.preamble_length} symbols`,readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading radio configuration..."})]})})]}),e.jsxs(se,{template:"standard",children:[e.jsx(ue,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(Rt,{}),title:"Operating Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(fe,{enabled:Ge.enabled,onChange:Ge.toggle,label:"Repeat",tooltip:"Toggles repeater or monitor mode. In monitor mode, the repeater will not repeat packets from the mesh.",status:Ge.status,size:"md"}),e.jsx(fe,{enabled:Xe.enabled,onChange:Xe.toggle,label:"Duty Cycle",tooltip:"Limit transmission time to comply with airtime utilization regulations",status:Xe.status,size:"md"}),e.jsx(P,{label:"Max Airtime",value:`${Be().toFixed(1)}%`,editValue:String(Be()),type:"number",suffix:"%",step:.5,min:.1,max:100,onSave:async s=>{await c({max_airtime_percent:parseFloat(s),enforcement_enabled:E}),i()}}),e.jsx(P,{label:"Flood TX Delay",value:`${vs().toFixed(2)}x`,editValue:String(vs()),type:"number",suffix:"x",step:.1,min:0,max:5,onSave:async s=>B({tx_delay_factor:parseFloat(s)})}),e.jsx(P,{label:"Direct TX Delay",value:`${Ns().toFixed(2)}s`,editValue:String(Ns()),type:"number",suffix:"s",step:.1,min:0,max:5,onSave:async s=>B({direct_tx_delay_factor:parseFloat(s)})}),e.jsx(P,{label:"Max Flood Hops",value:String((r==null?void 0:r.max_flood_hops)??3),type:"number",min:0,max:64,description:"0–64 hops",onSave:async s=>B({max_flood_hops:parseInt(s,10)})})]}),e.jsx("div",{className:"mt-4",children:e.jsx(De,{label:"Path Hash Size",value:`${(((As=(Ds=t==null?void 0:t.config)==null?void 0:Ds.mesh)==null?void 0:As.path_hash_mode)??0)+1}-byte`,editValue:((Ls=(Ps=t==null?void 0:t.config)==null?void 0:Ps.mesh)==null?void 0:Ls.path_hash_mode)??0,options:Da,onSave:async s=>B({path_hash_mode:parseInt(s,10)})})})]})}),e.jsx(ue,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(zs,{}),title:"App Settings"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Appearance and web server options."}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(fe,{enabled:We.enabled,onChange:We.toggle,label:"Enable CORS",tooltip:"Allow cross-origin API access",status:We.status,size:"md"}),e.jsx("div",{children:e.jsx(va,{})}),e.jsx(Pa,{})]})]})})]}),e.jsx(se,{template:"auto",children:e.jsx(_a,{})}),e.jsx(se,{template:"auto",children:e.jsxs(Y,{neomorphic:!0,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[e.jsx(W,{icon:e.jsx(Vs,{}),title:"Regions Transport Keys"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(L,{color:"primary",outline:!0,onClick:()=>ye(!0),children:[e.jsx($s,{"data-slot":"icon"}),"Add"]}),e.jsx(L,{color:"primary",outline:!0,onClick:gt,disabled:!q,children:"Edit"}),e.jsx(L,{color:"danger",outline:!0,onClick:bt,disabled:!q,children:"Delete"})]})]}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:e.jsx(fe,{enabled:ze==="allow",onChange:s=>ht(s?"allow":"deny"),label:e.jsxs(e.Fragment,{children:["Unscoped Flood: ",e.jsx("span",{className:ze==="allow"?"text-sys-green":"text-sys-red",children:ze==="allow"?"Allow":"Deny"})]}),tooltip:"Forward flood packets that have no region transport key. This is independent of region scope configuration.",status:ys?"loading":"idle",disabled:ys,dangerOff:!0,size:"md",className:"flex-row-reverse justify-between w-full"})}),hs&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:hs}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 min-h-[120px]",children:tt?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx(G,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading transport keys..."})]}):te.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-subtle-fill mx-auto mb-3 flex items-center justify-center",children:e.jsx(Vs,{className:"w-6 h-6 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No transport keys found"}),e.jsx("p",{className:"type-body-sm text-fg-muted/70 mt-1",children:"Add your first transport key to get started"})]}):e.jsx("div",{className:"space-y-1",children:te.map(s=>e.jsx(et,{node:s,level:0,expandedKeys:nt,selectedKeyId:q,onSelect:Ve,onToggle:xt},s.id))})})]})}),e.jsxs(se,{template:"standard",children:[e.jsx(ue,{span:12,md:6,children:e.jsx(Ca,{})}),e.jsx(ue,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,className:"h-full flex flex-col",children:[e.jsx(W,{icon:e.jsx(Hs,{}),title:"API Tokens"}),w&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:w}),e.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:R&&g.length===0?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(G,{className:"w-4 h-4 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading tokens..."})]}):g.length>0?e.jsx("div",{className:"space-y-1.5 flex-1 overflow-y-auto mb-3",children:g.map(s=>e.jsxs("div",{className:"bg-subtle-fill hover:bg-subtle-fill-strong radius-inner px-3 py-2 transition-base flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"type-body-sm text-fg-primary font-medium truncate",children:s.name}),e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",children:["Last used: ",mt(s.last_used)]})]}),e.jsx("button",{type:"button",onClick:()=>u({id:s.id,name:s.name}),disabled:ds,className:"text-sys-red/70 hover:text-sys-red transition-colors flex-shrink-0 p-1",title:"Revoke token",children:e.jsx(Ys,{className:"w-3.5 h-3.5"})})]},s.id))}):e.jsxs("div",{className:"bg-subtle-fill radius-inner flex-1 flex flex-col items-center justify-center mb-3",children:[e.jsx(Hs,{className:"w-5 h-5 text-fg-muted/50 mb-2"}),e.jsx("p",{className:"type-body-sm text-fg-muted",children:"No API tokens"})]})}),e.jsxs(L,{color:"primary",outline:!0,onClick:()=>f(!0),className:"w-full justify-center mt-auto",children:[e.jsx($s,{"data-slot":"icon"}),"Create Token"]})]})})]}),e.jsx(se,{template:"auto",children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(xa,{}),title:"Web Frontend"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:m("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Fe?"border-sys-blue bg-sys-blue/5":"border-transparent hover:border-sys-blue/30",ve==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:Fe,onChange:()=>ws(!0),disabled:ve==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"Default Frontend"}),e.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",onClick:s=>s.stopPropagation(),className:"type-data-xs bg-sys-cyan/15 text-sys-cyan px-2.5 py-0.5 rounded-full font-medium hover:bg-sys-cyan/25 transition-colors",children:"@RightUp"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Built-in pyMC Repeater web interface"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_repeater/repeater/web/html"})]})]}),e.jsxs("label",{className:m("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Fe?"border-transparent hover:border-sys-blue/30":"border-sys-blue bg-sys-blue/5",ve==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:!Fe,onChange:()=>ws(!1),disabled:ve==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"PyMC Console"}),e.jsx("span",{className:"type-data-xs bg-sys-indigo/15 text-sys-indigo px-2.5 py-0.5 rounded-full font-medium",children:"@Treehouse ⚡"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Alternative web interface for pyMC Repeater"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_console/web/html"})]})]})]}),!rt&&e.jsx("div",{className:m("bg-subtle-fill radius-card p-4",je?"border border-sys-green/20":"border border-sys-cyan/20"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:m("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",je?"bg-sys-green/20":"bg-sys-cyan/20"),children:je?e.jsx(ls,{className:"w-4 h-4 text-sys-green"}):e.jsx(ie,{className:"w-4 h-4 text-sys-cyan"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:je?"PyMC Console has been detected":"PyMC Console Not Installed"}),je?e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1",children:["PyMC Console is installed at ",e.jsx("code",{className:"type-code bg-sys-green/10 px-1.5 py-0.5 rounded-full text-sys-green",children:"/opt/pymc_console/web/html"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1 mb-3",children:["PyMC Console must be installed at ",e.jsx("code",{className:"type-code bg-sys-cyan/10 px-1.5 py-0.5 rounded-full text-sys-cyan",children:"/opt/pymc_console/web/html"})," before selecting this option."]}),e.jsxs(L,{color:"primary",outline:!0,href:"https://github.com/dmduran12/pymc_console-dist",children:[e.jsx(Qs,{"data-slot":"icon"}),"PyMC Console Install Instructions"]})]})]})]})}),it&&e.jsx("div",{className:"bg-subtle-fill radius-card p-4 border border-sys-indigo/30",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-indigo/20 flex items-center justify-center flex-shrink-0",children:e.jsx(Pe,{className:"w-4 h-4 text-sys-indigo"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:"Service restart required"}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:"Web frontend changes will take effect after restarting the pymc-repeater service."})]})]}),e.jsx(L,{color:"warning",outline:!0,onClick:ct,disabled:qe,children:qe?e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-slot":"icon",className:"animate-spin"}),"Restarting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ws,{"data-slot":"icon"}),"Restart Now"]})})]})})]})]})}),e.jsx(se,{template:"auto",children:e.jsx(Fa,{})}),t&&e.jsx(se,{template:"auto",children:e.jsx(Gt,{nodeName:F,publicKey:t.public_key})}),t&&((r==null?void 0:r.latitude)===0||!(r!=null&&r.latitude))&&((r==null?void 0:r.longitude)===0||!(r!=null&&r.longitude))&&e.jsx(se,{template:"auto",children:e.jsx(wa,{})})]}),C&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&f(!1),role:"dialog","aria-modal":"true","aria-labelledby":"create-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"create-token-modal-title",className:"type-micro mb-4",children:"Create API Token"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Je,{label:"Token Name",type:"text",value:A,onChange:s=>S(s.target.value),placeholder:"e.g., Production Server, CI/CD Pipeline",description:"Give your token a descriptive name to identify its purpose",onKeyDown:s=>s.key==="Enter"&&ks(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(L,{color:"muted",outline:!0,onClick:()=>{f(!1),S(""),_(null)},disabled:O,children:"Cancel"}),e.jsx(L,{color:"primary",onClick:ks,disabled:O||!A.trim(),children:O?e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-slot":"icon",className:"animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),H&&I&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&K(!1),role:"dialog","aria-modal":"true","aria-labelledby":"show-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-lg w-full",children:[e.jsx("h3",{id:"show-token-modal-title",className:"type-micro mb-4",children:"Token Created Successfully"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Pe,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:[e.jsx("strong",{children:"Save this token now!"})," For security reasons, it will not be shown again."]})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-primary block mb-1.5",children:"Your API Token"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Mt,{value:I,readOnly:!0,className:"flex-1 font-mono"}),e.jsxs(L,{color:"primary",outline:!0,onClick:ut,children:[ms?e.jsx(J,{"data-slot":"icon",className:"text-sys-green"}):e.jsx(Dt,{"data-slot":"icon"}),ms?"Copied!":"Copy"]})]})]}),e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3",children:[e.jsx("p",{className:"text-sm text-fg-secondary mb-2",children:e.jsx("strong",{children:"Usage Example:"})}),e.jsxs("code",{className:"block bg-sys-cyan/20 px-3 py-2 rounded type-code text-sys-cyan overflow-x-auto",children:['curl -H "X-API-Key: ',I.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),e.jsx("div",{className:"flex justify-end mt-6",children:e.jsx(L,{color:"primary",onClick:()=>{K(!1),V(null)},children:"Done"})})]})]})}),e.jsx(Ht,{isOpen:!!ee,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${ee==null?void 0:ee.name}'? This action cannot be undone.`,confirmLabel:ds?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:dt,onCancel:()=>u(null)}),ke&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&ye(!1),role:"dialog","aria-modal":"true","aria-labelledby":"add-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"add-key-modal-title",className:"type-micro mb-4",children:"Add Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[q&&e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3 text-sm text-fg-secondary",children:["Adding as child of: ",e.jsx("strong",{className:"text-fg-primary",children:ft()})]}),e.jsx(Je,{label:"Key Name",type:"text",value:Ce,onChange:s=>Te(s.target.value),placeholder:"e.g., Region Name, Group Key",onKeyDown:s=>s.key==="Enter"&&Ss(),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>be("deny"),className:m("toggle-group-item flex-1",$e==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>be("allow"),className:m("toggle-group-item flex-1",$e==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(L,{color:"muted",outline:!0,onClick:()=>{ye(!1),Te(""),be("allow")},disabled:Q,children:"Cancel"}),e.jsx(L,{color:"primary",onClick:Ss,disabled:Q||!Ce.trim(),children:Q?e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-slot":"icon",className:"animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),_e&&U&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&oe(!1),role:"dialog","aria-modal":"true","aria-labelledby":"edit-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"edit-key-modal-title",className:"type-micro mb-4",children:"Edit Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Je,{label:"Key Name",type:"text",value:U.name,onChange:s=>ae({...U,name:s.target.value}),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>ae({...U,floodPolicy:"deny"}),className:m("toggle-group-item flex-1",U.floodPolicy==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>ae({...U,floodPolicy:"allow"}),className:m("toggle-group-item flex-1",U.floodPolicy==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),U.transport_key&&e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Transport Key"}),e.jsx("code",{className:"block bg-input-bg px-3 py-2 radius-inner border border-input-border type-code text-fg-muted overflow-x-auto",children:U.transport_key})]}),e.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[e.jsx(L,{color:"danger",outline:!0,onClick:()=>{oe(!1),ge(U),ce(!0),ae(null)},disabled:Q,children:"Delete"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(L,{color:"muted",outline:!0,onClick:()=>{oe(!1),ae(null)},disabled:Q,children:"Cancel"}),e.jsx(L,{color:"primary",onClick:pt,disabled:Q||!U.name.trim(),children:Q?e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-slot":"icon",className:"animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),Se&&ne&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&ce(!1),role:"dialog","aria-modal":"true","aria-labelledby":"delete-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"delete-key-modal-title",className:"type-micro mb-4",children:"Delete Transport Key"}),e.jsxs("p",{className:"text-fg-secondary mb-4",children:["Are you sure you want to delete ",e.jsxs("strong",{className:"text-fg-primary",children:["'",ne.name,"'"]}),"?"]}),ne.children&&ne.children.length>0&&e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Pe,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:["This key has ",ne.children.length," child key(s). Deleting will also remove all children."]})]})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(L,{color:"muted",outline:!0,onClick:()=>{ce(!1),ge(null)},disabled:Q,children:"Cancel"}),e.jsx(L,{color:"danger",onClick:yt,disabled:Q,children:Q?e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-slot":"icon",className:"animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{tn as default}; + */const ha=[["path",{d:"M10.17 4.193a2 2 0 0 1 3.666.013",key:"pltmmw"}],["path",{d:"M14 21h2",key:"v4qezv"}],["path",{d:"m15.874 7.743 1 1.732",key:"10m0iw"}],["path",{d:"m18.849 12.952 1 1.732",key:"zadnam"}],["path",{d:"M21.824 18.18a2 2 0 0 1-1.835 2.824",key:"fvwuk4"}],["path",{d:"M4.024 21a2 2 0 0 1-1.839-2.839",key:"1e1kah"}],["path",{d:"m5.136 12.952-1 1.732",key:"1u4ldi"}],["path",{d:"M8 21h2",key:"i9zjee"}],["path",{d:"m8.102 7.743-1 1.732",key:"1zzo4u"}]],pa=we("triangle-dashed",ha),Ke=1500,xe={stacked:"h-[38px]",inline:"h-[32px]"},he={stacked:"px-3",inline:"px-2.5"},pe="rounded-lg";function P({label:t,value:l,editValue:n,onSave:c,type:i="text",suffix:o,placeholder:b,readOnly:h=!1,layout:p="stacked",min:d,max:r,step:j,maxLength:F,description:y,tooltip:E,autoConfigured:k,className:N}){const[x,g]=a.useState(!1),[v,R]=a.useState(""),[M,w]=a.useState("idle"),_=a.useRef(null),C=a.useRef(!0),f=a.useRef(null),A=!h&&!!c;a.useEffect(()=>(C.current=!0,()=>{C.current=!1,f.current&&clearTimeout(f.current)}),[]);const S=a.useCallback(()=>{A&&(R(n??l),g(!0),w("idle"),requestAnimationFrame(()=>{var K;return(K=_.current)==null?void 0:K.select()}))},[A,n,l]),I=a.useCallback(()=>{g(!1),R(""),w("idle")},[]),V=a.useCallback(async()=>{if(!c||M==="loading")return;if(v===(n??l)){I();return}f.current&&clearTimeout(f.current),w("loading");try{if(await c(v),!C.current)return;w("success"),g(!1),f.current=setTimeout(()=>{C.current&&w("idle")},Ke)}catch{if(!C.current)return;w("error"),f.current=setTimeout(()=>{C.current&&w("idle")},Ke)}},[c,v,n,l,I,M]),H=a.useCallback(K=>{K.key==="Enter"?(K.preventDefault(),V()):K.key==="Escape"&&(K.preventDefault(),I())},[V,I]);return p==="inline"?e.jsxs("div",{className:m("group flex items-center justify-between gap-3",N),children:[e.jsxs("div",{className:"flex items-center gap-1 truncate",children:[e.jsx("label",{className:"type-label text-fg-muted truncate",children:t}),E&&e.jsx(Is,{content:E,placement:"top",children:e.jsx("span",{className:"text-fg-muted/50 hover:text-fg-muted cursor-help transition-colors flex-shrink-0",children:e.jsx(ie,{className:"w-3 h-3"})})})]}),x?e.jsxs("div",{className:m(xe.inline,pe,he.inline,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20","min-w-[100px]"),children:[e.jsx("input",{ref:_,type:i,value:v,onChange:K=>R(K.target.value),onKeyDown:H,placeholder:b,min:d,max:r,step:j,maxLength:F,disabled:M==="loading",className:m("bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0",o?"w-12 text-right":"w-full")}),o&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:o}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:M==="loading"?e.jsx(G,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:V,className:"p-0.5 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(Y,{className:"w-3 h-3"})}),e.jsx("button",{onClick:I,className:"p-0.5 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(Z,{className:"w-3 h-3"})})]})})]}):e.jsxs("div",{className:m(xe.inline,pe,he.inline,"flex items-center justify-end transition-all min-w-[80px]","bg-input-bg border border-input-border",A&&"cursor-pointer hover:border-edge-strong"),onClick:A?S:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary",children:l}),M==="success"&&e.jsx(Y,{className:"w-3 h-3 text-sys-green ml-1.5 shrink-0"}),M==="error"&&e.jsx(Z,{className:"w-3 h-3 text-sys-red ml-1.5 shrink-0"}),M==="idle"&&k&&e.jsx(rs,{className:"w-3 h-3 text-sys-blue ml-1.5 shrink-0"}),M==="idle"&&!k&&A&&e.jsx(is,{className:"w-3 h-3 text-fg-muted ml-1.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]}):e.jsxs("div",{className:m("group",N),children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("label",{className:"type-label text-fg-muted",children:t}),E&&e.jsx(Is,{content:E,placement:"top",children:e.jsx("span",{className:"text-fg-muted/50 hover:text-fg-muted cursor-help transition-colors flex-shrink-0",children:e.jsx(ie,{className:"w-3 h-3"})})})]}),x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:m(xe.stacked,pe,he.stacked,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20"),children:[e.jsx("input",{ref:_,type:i,value:v,onChange:K=>R(K.target.value),onKeyDown:H,placeholder:b,min:d,max:r,step:j,maxLength:F,disabled:M==="loading",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0"}),o&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:o}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:M==="loading"?e.jsx(G,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:V,className:"p-1 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(Y,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:I,className:"p-1 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(Z,{className:"w-3.5 h-3.5"})})]})})]}),y&&e.jsx("p",{className:"type-data-xs text-fg-muted mt-1 ml-3",children:y})]}):e.jsxs("div",{className:m(xe.stacked,pe,he.stacked,"flex items-center transition-all","bg-input-bg border border-input-border",A&&"cursor-pointer hover:border-edge-strong"),onClick:A?S:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary flex-1 whitespace-nowrap",children:l}),M==="success"&&e.jsx(Y,{className:"w-3.5 h-3.5 text-sys-green shrink-0"}),M==="error"&&e.jsx(Z,{className:"w-3.5 h-3.5 text-sys-red shrink-0"}),M==="idle"&&k&&e.jsx(rs,{className:"w-3.5 h-3.5 text-sys-blue shrink-0"}),M==="idle"&&!k&&A&&e.jsx(is,{className:"w-3.5 h-3.5 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]})}function De({label:t,value:l,editValue:n,options:c,onSave:i,readOnly:o=!1,layout:b="stacked",className:h}){const[p,d]=a.useState(!1),[r,j]=a.useState(""),[F,y]=a.useState("idle"),E=a.useRef(null),k=a.useRef(!0),N=a.useRef(null),x=!o&&!!i;a.useEffect(()=>(k.current=!0,()=>{k.current=!1,N.current&&clearTimeout(N.current)}),[]);const g=a.useCallback(()=>{x&&(j(String(n)),d(!0),y("idle"),requestAnimationFrame(()=>{var S;return(S=E.current)==null?void 0:S.focus()}))},[x,n]),v=a.useCallback(()=>{d(!1),j(""),y("idle")},[]),R=a.useCallback(async()=>{if(!(!i||F==="loading")){if(r===String(n)){v();return}N.current&&clearTimeout(N.current),y("loading");try{if(await i(r),!k.current)return;y("success"),d(!1),N.current=setTimeout(()=>{k.current&&y("idle")},Ke)}catch{if(!k.current)return;y("error"),N.current=setTimeout(()=>{k.current&&y("idle")},Ke)}}},[i,r,n,v,F]),M=a.useCallback(S=>{S.key==="Escape"&&(S.preventDefault(),v())},[v]),w=b==="inline",_=w?xe.inline:xe.stacked,C=w?he.inline:he.stacked,f=e.jsxs("div",{className:m(_,pe,C,"flex items-center transition-all relative","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20",w&&"min-w-[100px]"),children:[e.jsx("select",{ref:E,value:r,onChange:S=>j(S.target.value),onKeyDown:M,disabled:F==="loading",className:m("bg-transparent text-fg-primary focus:outline-none appearance-none cursor-pointer type-data flex-1 min-w-0","pr-6"),children:c.map(S=>e.jsx("option",{value:S.value,children:S.label},String(S.value)))}),e.jsx(Ie,{className:"absolute right-auto w-3.5 h-3.5 text-fg-muted pointer-events-none",style:{right:F==="loading"?"2rem":"3.5rem"}}),e.jsx("div",{className:"flex items-center gap-0.5 ml-1 shrink-0",children:F==="loading"?e.jsx(G,{className:m("text-fg-muted animate-spin",w?"w-3 h-3":"w-3.5 h-3.5")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:R,className:m("rounded hover:bg-sys-green/15 text-sys-green transition-colors",w?"p-0.5":"p-1"),title:"Save",children:e.jsx(Y,{className:w?"w-3 h-3":"w-3.5 h-3.5"})}),e.jsx("button",{onClick:v,className:m("rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",w?"p-0.5":"p-1"),title:"Cancel (Esc)",children:e.jsx(Z,{className:w?"w-3 h-3":"w-3.5 h-3.5"})})]})})]}),A=e.jsxs("div",{className:m(_,pe,C,"flex items-center transition-all","bg-input-bg border border-input-border",x&&"cursor-pointer hover:border-edge-strong",w?"justify-end min-w-[80px]":""),onClick:x?g:void 0,children:[e.jsx("span",{className:m("type-data text-fg-primary",!w&&"flex-1"),children:l}),F==="success"&&e.jsx(Y,{className:m("text-sys-green shrink-0",w?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),F==="error"&&e.jsx(Z,{className:m("text-sys-red shrink-0",w?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),F==="idle"&&x&&e.jsx(Ie,{className:m("text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0",w?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")})]});return w?e.jsxs("div",{className:m("group flex items-center justify-between",h),children:[e.jsx("label",{className:"type-label text-fg-muted shrink-0",children:t}),p?f:A]}):e.jsxs("div",{className:m("group",h),children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:t}),p?f:A]})}async function ya(){try{return await Oe("/api/auth/tokens")}catch{return{tokens:[]}}}async function ga(t){return Oe("/api/auth/tokens",{method:"POST",body:JSON.stringify({name:t})})}async function ba(t){return Oe(`/api/auth/tokens/${t}`,{method:"DELETE"})}async function Us(t){return Oe("/api/update_web_config",{method:"POST",body:JSON.stringify(t)})}a.memo(function(){const{theme:l}=os(),{themeId:n}=l,c=as.find(i=>i.meta.id===n)??as[0];return e.jsx("div",{className:"h-10 flex items-center justify-center",children:e.jsx("span",{className:"font-medium transition-all duration-300 leading-none text-center text-fg-secondary",style:{fontFamily:"Inter, system-ui, sans-serif",fontSize:"clamp(0.75rem, 0.6rem + 1.5vw, 1.1rem)",letterSpacing:"-0.02em"},children:c.meta.name})})});const Qe=a.memo(function({compact:l=!1}){const{theme:n,setTheme:c}=os(),{themeId:i}=n;return e.jsx("div",{className:m("grid grid-cols-2 gap-2",l?"w-full min-w-0 self-stretch":"w-full"),children:[...as].reverse().map(o=>{const b=i===o.meta.id,h=o.meta.isDark;return e.jsxs("button",{type:"button",title:o.meta.name,className:m("flex flex-row items-stretch radius-inner transition-all duration-200 ease-out overflow-hidden cursor-pointer",l&&"h-6",b?"ring-2 ring-sys-blue scale-[1.02]":"opacity-70 hover:opacity-100"),onClick:()=>c(o.meta.id),children:[e.jsx("div",{className:m("flex-1 h-full",h?"bg-[#18181b]":"bg-[#EFF0F1]")}),e.jsx("div",{className:"flex flex-col h-full",children:o.display.palette.map((p,d)=>e.jsx("div",{className:"flex flex-1",children:p.map((r,j)=>e.jsx("div",{className:"w-2 h-full",style:{backgroundColor:r}},j))},d))})]},o.meta.id)})})});let qs=!1,Ae=null;async function ja(){if(!qs)return Ae||(Ae=(async()=>{try{await Promise.all([Me(()=>Promise.resolve({}),__vite__mapDeps([0])),Me(()=>Promise.resolve({}),__vite__mapDeps([1])),Me(()=>Promise.resolve({}),__vite__mapDeps([2])),Me(()=>Promise.resolve({}),__vite__mapDeps([3]))]),qs=!0}catch(t){console.warn("Failed to load theme fonts:",t)}})(),Ae)}const Ze=a.memo(function(){const{theme:l,setTheme:n}=os(),{themeId:c}=l,i=c==="breeze dark",o=a.useCallback(b=>{n(b?"breeze dark":"breeze light")},[n]);return e.jsx(fe,{enabled:i,onChange:o,label:e.jsxs(e.Fragment,{children:["Dark Mode: ",i?e.jsx(jt,{className:"w-3.5 h-3.5 text-sys-blue inline"}):e.jsx(vt,{className:"w-3.5 h-3.5 text-[#e8a517] inline"})]}),tooltip:"Switch between dark and light mode",size:"md"})}),va=a.memo(function({layout:l="horizontal"}){return a.useEffect(()=>{ja()},[]),l==="toggle-only"?e.jsx(Ze,{}):l==="thumbnails-only"?e.jsx(Qe,{}):l==="vertical"?e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx(Ze,{}),e.jsx(Qe,{})]}):e.jsxs("div",{className:"flex items-stretch gap-4",children:[e.jsx("div",{className:"flex-shrink-0 flex items-start",children:e.jsx(Ze,{})}),e.jsx(Qe,{compact:!0})]})}),Na=1e4,es=2e3;function ss(t,l,n){const[c,i]=a.useState("idle"),[o,b]=a.useState(null),h=a.useRef(!0),p=a.useRef(null),d=a.useRef(null),r=a.useRef(!1),j=a.useRef("idle"),F=a.useRef(t),y=a.useRef(l),E=a.useRef(n);j.current=c,F.current=t,y.current=l,E.current=n,a.useEffect(()=>(h.current=!0,()=>{h.current=!1,p.current&&clearTimeout(p.current),d.current&&clearTimeout(d.current)}),[]);const k=a.useCallback(async x=>{if(j.current==="loading")return;const g=F.current;p.current&&clearTimeout(p.current),d.current&&clearTimeout(d.current),r.current=!1,b(x),i("loading"),p.current=setTimeout(()=>{r.current||!h.current||(b(g),i("error"),d.current=setTimeout(()=>{h.current&&(i("idle"),b(null))},es))},Na);try{if(await y.current(x),r.current=!0,p.current&&clearTimeout(p.current),!h.current)return;i("success"),d.current=setTimeout(()=>{var v;h.current&&(i("idle"),b(null),(v=E.current)==null||v.call(E))},es)}catch{if(r.current=!0,p.current&&clearTimeout(p.current),!h.current)return;b(g),i("error"),d.current=setTimeout(()=>{h.current&&(i("idle"),b(null))},es)}},[]);return{enabled:o!==null?o:t,status:c,toggle:k}}function wa(){const{latitude:t,longitude:l,enabled:n,setLocation:c,enable:i,disable:o,clear:b}=Nt(),[h,p]=a.useState(!1),[d,r]=a.useState(""),[j,F]=a.useState(""),[y,E]=a.useState("idle"),[k,N]=a.useState(null),x=a.useRef(null),g=a.useRef(null),v=a.useRef(!0);a.useEffect(()=>(v.current=!0,()=>{v.current=!1,g.current&&clearTimeout(g.current)}),[]);const R=()=>{r((t==null?void 0:t.toFixed(6))??""),F((l==null?void 0:l.toFixed(6))??""),N(null),p(!0)},M=()=>{p(!1),N(null)};a.useEffect(()=>{if(!h)return;const S=I=>{y!=="loading"&&x.current&&!x.current.contains(I.target)&&M()};return document.addEventListener("mouseup",S),()=>document.removeEventListener("mouseup",S)},[h,y]);const w=(S,I)=>{const V=parseFloat(S),H=parseFloat(I);return isNaN(V)||isNaN(H)?"Please enter valid numbers":V<-90||V>90?"Latitude must be between -90 and 90":H<-180||H>180?"Longitude must be between -180 and 180":V===0&&H===0?"Coordinates (0, 0) are invalid":null},_=()=>{if(y==="loading")return;g.current&&clearTimeout(g.current);const S=w(d,j);if(S){N(S);return}E("loading"),N(null);const I=parseFloat(d),V=parseFloat(j);c(I,V),n||i(),E("success"),g.current=setTimeout(()=>{v.current&&(E("idle"),p(!1))},1e3)},C=()=>{n?o():i()},f=()=>{b(),p(!1)},A=t!==null&&l!==null;return e.jsx(J,{children:e.jsxs("div",{ref:x,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(W,{icon:e.jsx(pa,{}),title:"Stealth"}),e.jsxs("div",{className:"flex items-center gap-1",children:[A&&!h&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:C,className:m("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2 mr-2",n?"bg-toggle-on border-toggle-on":"bg-toggle-off border-edge-subtle"),title:n?"Disable stealth location":"Enable stealth location",children:e.jsx("span",{className:m("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",n?"translate-x-5":"translate-x-0.5")})}),e.jsx("button",{onClick:f,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-sys-red hover:bg-sys-red/10",title:"Clear stealth location",children:e.jsx(Js,{className:"w-4 h-4"})})]}),h?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:M,disabled:y==="loading",className:m("p-2 rounded-lg transition-colors",y==="loading"?"text-fg-muted cursor-not-allowed":"text-fg-muted hover:text-sys-red hover:bg-sys-red/10"),title:"Cancel",children:e.jsx(Z,{className:"w-4 h-4"})}),e.jsx("button",{onClick:_,disabled:y==="loading",className:m("p-2 rounded-lg transition-colors",y==="loading"?"text-sys-blue cursor-wait":y==="success"?"text-sys-green":y==="error"?"text-sys-red":"text-sys-green hover:bg-sys-green/10"),title:"Save",children:y==="loading"?e.jsx(G,{className:"w-4 h-4 animate-spin"}):y==="success"?e.jsx(Y,{className:"w-4 h-4"}):y==="error"?e.jsx(Z,{className:"w-4 h-4"}):e.jsx(Y,{className:"w-4 h-4"})})]}):e.jsx("button",{onClick:R,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-fg-primary hover:bg-subtle",title:A?"Edit stealth location":"Set stealth location",children:e.jsx(is,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"bg-sys-cyan/5 rounded-xl p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ie,{className:"w-4 h-4 text-sys-cyan flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"type-body-sm text-fg-muted",children:[e.jsx("span",{className:"text-fg-secondary",children:"Stealth mode"})," allows you to appear on the map and in topology analysis without broadcasting your location. Coordinates are stored locally in your browser only — ",e.jsx("span",{className:"text-sys-cyan",children:"never sent to config.yaml or the mesh"}),"."]})]})}),k&&e.jsx("div",{className:"text-xs mb-3 px-2 py-1.5 rounded-md text-sys-red bg-sys-red/10",children:k}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:h?"Latitude (°)":"Latitude"}),e.jsx("div",{className:m("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:h?e.jsx("input",{type:"number",value:d,onChange:S=>r(S.target.value),step:"0.000001",min:"-90",max:"90",placeholder:"e.g. 34.052234",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:m("type-data",A&&n?"text-fg-primary":"text-fg-muted"),children:A?t.toFixed(6):"Not set"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:h?"Longitude (°)":"Longitude"}),e.jsx("div",{className:m("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:h?e.jsx("input",{type:"number",value:j,onChange:S=>F(S.target.value),step:"0.000001",min:"-180",max:"180",placeholder:"e.g. -118.243685",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:m("type-data",A&&n?"text-fg-primary":"text-fg-muted"),children:A?l.toFixed(6):"Not set"})})]})]}),A&&!h&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:m("w-2 h-2 rounded-full",n?"bg-sys-green":"bg-fg-muted")}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:n?"Stealth location active — you appear on maps with these coordinates":"Stealth location disabled — coordinates saved but not in use"})]})})]})})}function me(t){if(t<60)return`${t}s`;if(t<3600){const c=Math.floor(t/60),i=t%60;return i>0?`${c}m ${i}s`:`${c}m`}const l=Math.floor(t/3600),n=Math.floor(t%3600/60);return n>0?`${l}h ${n}m`:`${l}h`}function ts({title:t,defaultOpen:l=!1,children:n}){const[c,i]=a.useState(l);return e.jsxs("div",{className:"bg-subtle-fill radius-inner overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>i(!c),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-subtle-fill-hover transition-colors",children:[e.jsx("span",{className:"type-label text-fg-muted",children:t}),e.jsx(Ie,{className:m("w-4 h-4 text-fg-muted transition-transform",c&&"rotate-180")})]}),c&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:n})]})}const Le={off:{label:"Off",description:"All rate limiting disabled. Every advert is forwarded unconditionally.",color:"text-fg-muted",config:Ut},light:{label:"Light",description:"Gentle throttling for sparse meshes. Allows short bursts but penalizes repeat offenders. Good for small networks with few nodes.",color:"text-sys-green",config:{rate_limit_enabled:!0,bucket_capacity:3,refill_tokens:1,refill_interval_seconds:3600,min_interval_seconds:15,penalty_enabled:!0,violation_threshold:2,base_penalty_seconds:1800,penalty_multiplier:2,max_penalty_seconds:43200,violation_decay_seconds:7200,adaptive_enabled:!0,ewma_alpha:.15,hysteresis_seconds:480,quiet_max:2,normal_max:6,busy_max:10}},standard:{label:"Standard",description:"Balanced protection for most meshes. One advert per source is enough for discovery — repeated adverts are suppressed to protect channel capacity.",color:"text-sys-blue",recommended:!0,config:{rate_limit_enabled:!0,bucket_capacity:2,refill_tokens:1,refill_interval_seconds:7200,min_interval_seconds:30,penalty_enabled:!0,violation_threshold:1,base_penalty_seconds:7200,penalty_multiplier:4,max_penalty_seconds:172800,violation_decay_seconds:14400,adaptive_enabled:!0,ewma_alpha:.1,hysteresis_seconds:300,quiet_max:1,normal_max:3,busy_max:8}},strict:{label:"Strict",description:"Maximum suppression for dense or congested meshes. One token, long refill, immediate jail. Protects GRP_TXT capacity at all costs.",color:"text-sys-amber",config:{rate_limit_enabled:!0,bucket_capacity:1,refill_tokens:1,refill_interval_seconds:14400,min_interval_seconds:60,penalty_enabled:!0,violation_threshold:1,base_penalty_seconds:10800,penalty_multiplier:4,max_penalty_seconds:259200,violation_decay_seconds:21600,adaptive_enabled:!0,ewma_alpha:.05,hysteresis_seconds:180,quiet_max:.5,normal_max:2,busy_max:5}}},Zs=["off","light","standard","strict"];function ka(t,l,n){if(!t&&!l&&!n||!((t==null?void 0:t.enabled)||(l==null?void 0:l.enabled)||(n==null?void 0:n.enabled)))return"off";for(const i of Zs){if(i==="off")continue;const o=Le[i].config;if((t==null?void 0:t.bucket_capacity)===o.bucket_capacity&&(t==null?void 0:t.refill_tokens)===o.refill_tokens&&(t==null?void 0:t.refill_interval_seconds)===o.refill_interval_seconds&&(t==null?void 0:t.min_interval_seconds)===o.min_interval_seconds&&(l==null?void 0:l.violation_threshold)===o.violation_threshold&&(l==null?void 0:l.base_penalty_seconds)===o.base_penalty_seconds&&(l==null?void 0:l.penalty_multiplier)===o.penalty_multiplier&&(l==null?void 0:l.max_penalty_seconds)===o.max_penalty_seconds&&(l==null?void 0:l.violation_decay_seconds)===o.violation_decay_seconds&&(n==null?void 0:n.ewma_alpha)===o.ewma_alpha&&(n==null?void 0:n.hysteresis_seconds)===o.hysteresis_seconds)return i}return null}function _a(){var S,I,V,H,K,ee;const{stats:t,fetchStats:l}=cs(),n=a.useRef(!0),[c,i]=a.useState(!0),[o,b]=a.useState(!1),[h,p]=a.useState(null),[d,r]=a.useState("idle"),j=a.useRef(null),[F,y]=a.useState(!1),[E,k]=a.useState(new Set);a.useEffect(()=>(n.current=!0,()=>{n.current=!1,j.current&&clearTimeout(j.current)}),[]);const N=a.useCallback(async()=>{var u;try{const O=await wt();if(!n.current)return;O.success&&O.data&&((u=O.data.adaptive)!=null&&u.current_tier)?i(!0):i(!1)}catch{n.current&&i(!1)}},[]);a.useEffect(()=>{N();const u=setInterval(N,3e4);return()=>clearInterval(u)},[N]);const x=(I=(S=t==null?void 0:t.config)==null?void 0:S.repeater)==null?void 0:I.advert_rate_limit,g=(H=(V=t==null?void 0:t.config)==null?void 0:V.repeater)==null?void 0:H.advert_penalty_box,v=(ee=(K=t==null?void 0:t.config)==null?void 0:K.repeater)==null?void 0:ee.advert_adaptive;if(!c&&!x&&!g&&!v)return null;const R=u=>E.has(u),M=u=>{k(O=>{if(!O.has(u))return O;const X=new Set(O);return X.delete(u),X})},w=ka(x,g,v),_=w?Le[w]:null,C=async(u,O)=>{M(u),b(!0),p(null),j.current&&clearTimeout(j.current);try{const X=await Ks({[u]:O});if(!n.current)return;X.success?(r("success"),await Promise.all([l({force:!0}).catch(()=>{}),N()])):(r("error"),p(X.error||"Failed to save"))}catch{n.current&&(r("error"),p("Failed to save"))}finally{n.current&&(b(!1),j.current=setTimeout(()=>{n.current&&(r("idle"),p(null))},1500))}},f=async u=>{if(!(u===w||o)){b(!0),p(null),k(new Set),j.current&&clearTimeout(j.current);try{const O=await Ks(Le[u].config);if(!n.current)return;O.success?(r("success"),await Promise.all([l({force:!0}).catch(()=>{}),N()])):(r("error"),p(O.error||"Failed to save"))}catch{n.current&&(r("error"),p("Failed to save"))}finally{n.current&&(b(!1),j.current=setTimeout(()=>{n.current&&r("idle")},1500))}}},A=()=>f("off");return e.jsxs(J,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(aa,{}),title:"Advert Rate Limiting",actions:e.jsxs("div",{className:"flex items-center gap-3",children:[d!=="idle"&&e.jsxs("span",{className:"flex items-center",children:[d==="success"&&e.jsx(Y,{className:"w-4 h-4 text-sys-green"}),d==="error"&&e.jsx(Z,{className:"w-4 h-4 text-sys-red"})]}),e.jsxs(L,{plain:!0,onClick:A,className:"flex items-center gap-1.5 text-zinc-500 hover:text-zinc-400 transition-colors",children:[e.jsx(ta,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-body-xs font-medium hidden sm:inline",children:"Reset"})]}),e.jsxs(L,{plain:!0,onClick:()=>y(!0),className:"flex items-center gap-1.5 text-sys-blue hover:text-sys-blue/80 transition-colors",children:[e.jsx(rs,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-body-xs font-medium",children:"Auto"})]})]})}),h&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:h}),e.jsx("div",{className:"toggle-group w-full mb-4",children:Zs.map(u=>{const O=Le[u],X=u===w;return e.jsx("button",{onClick:()=>f(u),disabled:o,className:m("toggle-group-item flex-1",X&&"active",X&&O.color),children:O.label},u)})}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(ie,{className:"w-4 h-4 text-sys-blue"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:m("type-data-xs font-medium uppercase tracking-wide",(_==null?void 0:_.color)??"text-fg-muted"),children:(_==null?void 0:_.label)??"Custom"}),(_==null?void 0:_.recommended)&&e.jsx(ns,{color:"green",children:"Recommended"}),!w&&e.jsx(ns,{color:"zinc",children:"Custom"})]}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:(_==null?void 0:_.description)??"Settings have been manually tuned and don’t match any preset."})]})]})}),e.jsxs("div",{className:m("space-y-3",w==="off"&&"opacity-40 pointer-events-none"),children:[e.jsx(ts,{title:"Token Rules",children:x?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(P,{label:"Bucket Capacity",value:String(x.bucket_capacity),type:"number",suffix:"tokens",min:1,max:100,tooltip:"Max tokens a source can hold — determines burst capacity. Each advert costs one token; tokens refill over time.",autoConfigured:R("bucket_capacity"),onSave:async u=>C("bucket_capacity",parseInt(u,10))}),e.jsx(P,{label:"Refill Tokens",value:String(x.refill_tokens),type:"number",suffix:"tokens",min:1,max:50,tooltip:"Tokens added back each refill cycle. Higher = more forgiving over time.",autoConfigured:R("refill_tokens"),onSave:async u=>C("refill_tokens",parseInt(u,10))}),e.jsx(P,{label:"Refill Interval",value:me(x.refill_interval_seconds),editValue:String(parseFloat((x.refill_interval_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:.5,min:.5,max:24,tooltip:"How often the bucket gets topped up. Shorter = faster recovery from bursts.",autoConfigured:R("refill_interval_seconds"),onSave:async u=>C("refill_interval_seconds",Math.round(parseFloat(u)*3600))}),e.jsx(P,{label:"Min Interval",value:me(x.min_interval_seconds),editValue:String(x.min_interval_seconds),type:"number",suffix:"sec",min:0,max:3600,tooltip:"Minimum gap between adverts from the same source, even if tokens are available. 0 = no minimum.",autoConfigured:R("min_interval_seconds"),onSave:async u=>C("min_interval_seconds",parseInt(u,10))})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})}),e.jsx(ts,{title:"Jail Settings",children:g?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(P,{label:"Violation Threshold",value:String(g.violation_threshold),type:"number",suffix:"violations",min:1,max:100,tooltip:"How many rate-limit violations before a source gets penalized. Think of it as strikes before timeout.",autoConfigured:R("violation_threshold"),onSave:async u=>C("violation_threshold",parseInt(u,10))}),e.jsx(P,{label:"Base Penalty",value:me(g.base_penalty_seconds),editValue:String(parseFloat((g.base_penalty_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:.5,min:.5,max:24,tooltip:"First offense penalty duration. Repeat offenders get this multiplied.",autoConfigured:R("base_penalty_seconds"),onSave:async u=>C("base_penalty_seconds",Math.round(parseFloat(u)*3600))}),e.jsx(P,{label:"Multiplier",value:`${g.penalty_multiplier}x`,editValue:String(g.penalty_multiplier),type:"number",suffix:"x",step:.5,min:1,max:10,tooltip:"Each repeat offense multiplies the penalty by this factor. 2x means penalties double each time.",autoConfigured:R("penalty_multiplier"),onSave:async u=>C("penalty_multiplier",parseFloat(u))}),e.jsx(P,{label:"Max Penalty",value:me(g.max_penalty_seconds),editValue:String(parseFloat((g.max_penalty_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:1,min:1,max:168,tooltip:"Upper limit on penalty duration. No matter how many offenses, it won't exceed this.",autoConfigured:R("max_penalty_seconds"),onSave:async u=>C("max_penalty_seconds",Math.round(parseFloat(u)*3600))}),e.jsx(P,{label:"Violation Decay",value:me(g.violation_decay_seconds),editValue:String(parseFloat((g.violation_decay_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:1,min:1,max:168,tooltip:"How long until a source's violation count resets. Good behavior earns a clean slate.",autoConfigured:R("violation_decay_seconds"),onSave:async u=>C("violation_decay_seconds",Math.round(parseFloat(u)*3600))})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})}),e.jsx(ts,{title:"Traffic Tiers",children:v?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(P,{label:"EWMA α",value:String(v.ewma_alpha),type:"number",step:.01,min:.01,max:1,tooltip:"How quickly the system reacts to traffic changes. Lower = smoother, higher = more responsive.",autoConfigured:R("ewma_alpha"),onSave:async u=>C("ewma_alpha",parseFloat(u))}),e.jsx(P,{label:"Hysteresis",value:me(v.hysteresis_seconds),editValue:String(parseFloat((v.hysteresis_seconds/60).toFixed(2))),type:"number",suffix:"min",step:.5,min:0,max:60,tooltip:"Cooldown before switching tiers again. Prevents rapid flip-flopping during traffic spikes.",autoConfigured:R("hysteresis_seconds"),onSave:async u=>C("hysteresis_seconds",Math.round(parseFloat(u)*60))}),e.jsx(P,{label:"Quiet Max",value:String(v.thresholds.quiet_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic below this = quiet mesh. Rate limits are most relaxed here.",autoConfigured:R("quiet_max"),onSave:async u=>C("quiet_max",parseFloat(u))}),e.jsx(P,{label:"Normal Max",value:String(v.thresholds.normal_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic below this = normal activity. Standard rate limits apply.",autoConfigured:R("normal_max"),onSave:async u=>C("normal_max",parseFloat(u))}),e.jsx(P,{label:"Busy Max",value:String(v.thresholds.busy_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic above this = congested mesh. Strictest rate limits kick in.",autoConfigured:R("busy_max"),onSave:async u=>C("busy_max",parseFloat(u))})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})})]}),e.jsx("div",{className:"bg-sys-blue/5 radius-inner p-4 mt-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(ie,{className:"w-4 h-4 text-sys-blue"})}),e.jsx("div",{className:"type-body-sm text-fg-muted",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Three layers"})," work together: the ",e.jsx("span",{className:"text-sys-blue",children:"Token Rules"})," throttle per-source adverts, the ",e.jsx("span",{className:"text-sys-amber",children:"Jail"})," escalates penalties for repeat violators, and ",e.jsx("span",{className:"text-sys-green",children:"Traffic Tiers"})," adjust limits based on overall mesh activity. The ",e.jsx("span",{className:"text-sys-blue",children:"“Auto”"})," button analyzes 1 week of mesh traffic to suggest optimal settings."]})})]})}),e.jsx(qt,{open:F,onClose:()=>y(!1),currentConfig:{tokenBucket:x,penaltyBox:g,adaptive:v},onApplied:async()=>{k(new Set(Bt)),await Promise.all([l({force:!0}).catch(()=>{}),N()])}})]})}const Bs={off:{label:"Off",threshold:null,description:"No loop detection. All flood packets forwarded regardless of path history.",color:"text-fg-muted"},minimal:{label:"Minimal",threshold:4,description:"Drops flood packets when your local hash appears 4+ times in the path. Catches only the most obvious routing loops.",color:"text-sys-green",recommended:!0},moderate:{label:"Moderate",threshold:2,description:"Drops flood packets when your local hash appears 2+ times in the path. Good balance for most networks.",color:"text-sys-blue"},strict:{label:"Strict",threshold:1,description:"Drops flood packets if your local hash appears even once in the path. Strongest loop prevention — may drop some legitimate retransmissions in dense meshes.",color:"text-sys-amber"}},Sa=["off","minimal","moderate","strict"];function Ca(){var N;const{stats:t,fetchStats:l}=cs(),n=a.useRef(!0),c=(N=t==null?void 0:t.config)==null?void 0:N.mesh,i=!!c,o=(c==null?void 0:c.loop_detect)??"off",b=Bs[o],h=t==null?void 0:t.local_hash,[p,d]=a.useState(!1),[r,j]=a.useState(null),[F,y]=a.useState("idle"),E=a.useRef(null);if(a.useEffect(()=>(n.current=!0,()=>{n.current=!1,E.current&&clearTimeout(E.current)}),[]),a.useEffect(()=>{if(!r)return;const x=setTimeout(()=>{n.current&&j(null)},4e3);return()=>clearTimeout(x)},[r]),!t)return null;const k=async x=>{if(!(!i||x===o||p)){d(!0),j(null),E.current&&clearTimeout(E.current);try{const g=await Xs({loop_detect:x});if(!n.current)return;g.success?(y("success"),await l({force:!0}).catch(()=>{})):(y("error"),j(g.error||"Failed to save"))}catch{n.current&&(y("error"),j("Failed to save"))}finally{n.current&&(d(!1),E.current=setTimeout(()=>{n.current&&y("idle")},1500))}}};return e.jsxs(J,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(na,{}),title:"Flood Loop Detection",actions:F!=="idle"?e.jsxs("span",{className:"flex items-center",children:[F==="success"&&e.jsx(Y,{className:"w-4 h-4 text-sys-green"}),F==="error"&&e.jsx(Z,{className:"w-4 h-4 text-sys-red"})]}):void 0}),!i&&e.jsxs("div",{className:"flex items-start gap-2.5 mb-3 px-3 py-2.5 radius-inner bg-sys-amber/10 text-sys-amber",children:[e.jsx(Pe,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsxs("p",{className:"type-body-sm",children:["Backend does not expose mesh config. Update pyMC_Repeater to enable live configuration. Set ",e.jsx("code",{className:"font-mono text-fg-secondary",children:"loop_detect"})," in"," ",e.jsx("code",{className:"font-mono text-fg-secondary",children:"config.yaml"})," manually."]})]}),r&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:r}),e.jsx("div",{className:m("toggle-group w-full mb-4",!i&&"opacity-50 pointer-events-none"),children:Sa.map(x=>{const g=Bs[x],v=x===o;return e.jsx("button",{onClick:()=>k(x),disabled:p||!i,className:m("toggle-group-item flex-1",v&&"active",v&&g.color),children:g.label},x)})}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(ie,{className:"w-4 h-4 text-sys-blue"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:m("type-data-xs font-medium uppercase tracking-wide",b.color),children:b.label}),b.threshold!==null&&e.jsxs("span",{className:"data-box data-box-compact text-fg-secondary tabular-nums",children:["≥",b.threshold,"× → drop"]}),b.recommended&&e.jsx(ns,{color:"green",children:"Recommended"})]}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:b.description}),h&&o!=="off"&&e.jsxs("p",{className:"type-data-xs text-fg-muted/60 mt-2 font-mono",children:["Local hash: ",h]})]})]})})]})}function Ta(t){if(!t)return"Never";const l=new Date(t).getTime();if(isNaN(l))return"Never";const c=(Date.now()-l)/1e3;return c<60?"Just now":c<3600?`${Math.floor(c/60)}m ago`:c<86400?`${Math.floor(c/3600)}h ago`:`${Math.floor(c/86400)}d ago`}function Fa(){const{status:t,updateAvailable:l,isChecking:n,channels:c,changelog:i,error:o,available:b,checkForUpdate:h,fetchChannels:p,fetchChangelog:d,setChannel:r,openModal:j}=kt(),F=_t(),[y,E]=a.useState(!1),[k,N]=a.useState(!1);if(a.useEffect(()=>{p(),d()},[p,d]),!b)return null;const x=f=>f.split("+")[0],g=f=>f!=null&&f.includes("+")?f.split("+")[1]:null,v=(t==null?void 0:t.current_version)??(F==null?void 0:F.version)??null,R=(t==null?void 0:t.latest_version)??null,M=v?x(v):null,w=R?x(R):null,_=g(v),C=(t==null?void 0:t.channel)??"main";return e.jsxs(J,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(Os,{}),title:"Software Update"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4 mb-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Installed"}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx("p",{className:"type-data text-fg-primary truncate font-mono",children:M?`v${M}`:"—"}),_&&e.jsx(St,{copy:!0,copyValue:_,title:`Build: ${_}`,children:_})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Git Branch"}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5",children:[e.jsx(la,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-sys-indigo truncate",children:C})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Last Checked"}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5",children:[e.jsx(ra,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:Ta((t==null?void 0:t.last_checked)??null)})]})]})]}),c.length>0&&e.jsxs("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:[e.jsx("div",{className:"flex items-center justify-between gap-3",children:e.jsxs("div",{children:[e.jsx("h4",{className:"type-body-sm text-fg-primary font-medium",children:"Release Channel"}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-0.5",children:"Switch between stable and development branches"})]})}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-3",children:c.map(f=>e.jsxs("button",{onClick:async()=>{f.active||k||(N(!0),await r(f.name),N(!1))},disabled:f.active||k,className:m("px-3 py-1.5 radius-inner type-data-xs font-medium transition-colors",f.active?"bg-sys-indigo/15 text-sys-indigo ring-1 ring-sys-indigo/30":"bg-subtle-fill-strong text-fg-muted hover:text-fg-primary hover:bg-subtle-fill-hover",k&&!f.active&&"opacity-50 cursor-not-allowed"),children:[f.name,f.active&&e.jsx(ls,{className:"w-3 h-3 ml-1.5 inline-block"})]},f.name))})]}),i.length>0&&e.jsxs("div",{className:"bg-subtle-fill radius-inner mb-4",children:[e.jsxs("button",{onClick:()=>E(!y),className:"w-full flex items-center gap-2 px-4 py-3 text-left hover:bg-subtle-fill-hover transition-colors radius-inner",children:[y?e.jsx(Ie,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}):e.jsx(Ys,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-body-sm text-fg-primary font-medium flex-1",children:"Changelog"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[i.length," commit",i.length!==1?"s":""]})]}),y&&e.jsx("div",{className:"px-4 pb-3 space-y-1 max-h-[300px] overflow-y-auto",children:i.map(f=>e.jsxs("div",{className:"flex items-start gap-2 py-1.5 group",children:[e.jsx(ma,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[f.url?e.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",className:"type-data-xs text-fg-primary truncate hover:text-sys-blue transition-colors",children:f.title}):e.jsx("p",{className:"type-data-xs text-fg-primary truncate",children:f.title}),f.url&&e.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",className:"opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:e.jsx(Qs,{className:"w-3 h-3 text-fg-muted"})})]}),f.body&&e.jsx("p",{className:"type-data-xs text-fg-muted mt-0.5 line-clamp-2 whitespace-pre-line",children:f.body}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"type-data-xs text-fg-muted font-mono",children:f.short_sha}),e.jsx("span",{className:"text-fg-muted/30",children:"·"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:f.author}),e.jsx("span",{className:"text-fg-muted/30",children:"·"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:f.date?new Date(f.date).toLocaleDateString():""})]})]})]},f.sha))})]}),o&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:o}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l&&e.jsxs(L,{color:"danger",onClick:j,children:[e.jsx(Os,{"data-slot":"icon"}),"Update to v",w]}),e.jsx("div",{className:"flex-1"}),!l&&t&&e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-sys-green",children:[e.jsx(ls,{className:"w-3.5 h-3.5"}),"Up to date"]}),e.jsx(L,{color:"primary",outline:!0,onClick:()=>h(!0),disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-slot":"icon",className:"animate-spin"}),"Checking..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ws,{"data-slot":"icon"}),"Check for Updates"]})})]})]})}const Ea=[{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"}],Ra=[5,6,7,8,9,10,11,12],Ma=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],Da=[{value:0,label:"1-byte — 0x00"},{value:1,label:"2-byte — 0x0000"},{value:2,label:"3-byte — 0x000000"}],Gs={RADIO_CONFIG:"radioConfig"};function Aa(t){if(!t)return"Never";const n=Date.now()-t*1e3,c=Math.floor(n/6e4),i=Math.floor(n/36e5),o=Math.floor(n/864e5);return c<1?"Just now":c<60?`${c}m ago`:i<24?`${i}h ago`:o<365?`${o}d ago`:`${Math.floor(o/365)}y ago`}function et({node:t,level:l,expandedKeys:n,selectedKeyId:c,onSelect:i,onToggle:o}){const b=n.has(t.id),h=c===t.id,p=t.children&&t.children.length>0;return e.jsxs("div",{children:[e.jsxs("div",{className:m("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",h?"bg-sys-blue/15":"hover:bg-subtle-fill"),style:{marginLeft:`${l*16}px`},onClick:()=>i(t.id),children:[p?e.jsx("button",{onClick:d=>{d.stopPropagation(),o(t.id)},className:"p-1 hover:bg-subtle-fill-hover rounded-full transition-colors",children:e.jsx(Ys,{className:m("w-3.5 h-3.5 text-fg-muted transition-transform",b&&"rotate-90")})}):e.jsx("span",{className:"w-5"}),e.jsx(da,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary flex-1 truncate",children:t.name}),e.jsx("span",{className:"type-data-xs text-fg-muted hidden sm:inline",title:t.last_used?new Date(t.last_used*1e3).toLocaleString():void 0,children:Aa(t.last_used)}),e.jsx("span",{className:m("type-data-xs px-2 py-0.5 rounded-full",t.floodPolicy==="allow"?"bg-sys-green/15 text-sys-green":"bg-sys-red/15 text-sys-red"),children:t.floodPolicy==="allow"?"Allow":"Deny"})]}),p&&b&&e.jsx("div",{children:t.children.map(d=>e.jsx(et,{node:d,level:l+1,expandedKeys:n,selectedKeyId:c,onSelect:i,onToggle:o},d.id))})]})}function Pa(){const[t,l]=a.useState(Xt),[n,c]=a.useState(Wt),[i,o]=a.useState(!1),b=a.useCallback(d=>{l(d),Jt(d)},[]),h=a.useCallback(d=>{const r=parseFloat(d.target.value);c(r),Yt(r)},[]),p=a.useCallback(async()=>{i||(o(!0),await Qt(),o(!1))},[i]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(fe,{enabled:t,onChange:b,label:e.jsxs(e.Fragment,{children:["Sound: ",e.jsx("span",{className:t?"text-sys-green":"text-sys-red",children:t?"On":"Off"})]}),tooltip:"Enable or disable UI sound effects and haptic audio feedback",size:"md"}),e.jsx(L,{color:"primary",outline:!0,onClick:p,disabled:!t||i,className:"w-16 justify-center",children:i?"…":"Test"})]}),e.jsxs("div",{className:m("flex items-center gap-3",!t&&"opacity-40 pointer-events-none"),children:[e.jsx("span",{className:"type-label text-fg-muted w-14 shrink-0",children:"Volume"}),e.jsx("input",{type:"range",min:0,max:1,step:.05,value:n,onChange:h,className:"flex-1 accent-sys-blue h-1.5 cursor-pointer"}),e.jsxs("span",{className:"data-box w-16 justify-center",children:[Math.round(n*100),"%"]})]})]})}function tn(){var Cs,Ts,Fs,Es,Rs,Ms,Ds,As,Ps,Ls;const{stats:t,setMode:l,clearModeMutation:n,setDutyCycleConfig:c,clearDutyCycleMutation:i,fetchStats:o,startMutation:b,clearMutation:h}=cs(),p=Ct(),d=(Cs=t==null?void 0:t.config)==null?void 0:Cs.radio,r=(Ts=t==null?void 0:t.config)==null?void 0:Ts.repeater,j=(Fs=t==null?void 0:t.config)==null?void 0:Fs.duty_cycle,F=(t==null?void 0:t.node_name)||((Es=t==null?void 0:t.config)==null?void 0:Es.node_name)||"Unknown Node",y=(r==null?void 0:r.mode)??"forward",E=(j==null?void 0:j.enforcement_enabled)??!1,k=(Rs=t==null?void 0:t.config)==null?void 0:Rs.delays,N=a.useRef(!0);a.useEffect(()=>(N.current=!0,()=>{N.current=!1}),[]);const x=(Ms=t==null?void 0:t.config)==null?void 0:Ms.web,[g,v]=a.useState([]),[R,M]=a.useState(!1),[w,_]=a.useState(null),[C,f]=a.useState(!1),[A,S]=a.useState(""),[I,V]=a.useState(null),[H,K]=a.useState(!1),[ee,u]=a.useState(null),[O,X]=a.useState(!1),[ds,us]=a.useState(!1),[ms,fs]=a.useState(!1),[te,st]=a.useState([]),[tt,xs]=a.useState(!1),[hs,$]=a.useState(null),[ze,at]=a.useState(()=>localStorage.getItem("pymc:unscopedFloodPolicy")==="allow"?"allow":"deny"),ps=a.useCallback(s=>{at(s),localStorage.setItem("pymc:unscopedFloodPolicy",s)},[]),[ys,gs]=a.useState(!1),[q,Ve]=a.useState(null),[nt,lt]=a.useState(new Set),[ke,ye]=a.useState(!1),[_e,oe]=a.useState(!1),[Se,ce]=a.useState(!1),[U,ae]=a.useState(null),[ne,ge]=a.useState(null),[Ce,Te]=a.useState(""),[$e,be]=a.useState("allow"),[Q,de]=a.useState(!1),[Fe,bs]=a.useState(!0),[je,He]=a.useState(!1),[rt,js]=a.useState(!0),[ve,le]=a.useState("idle"),[it,Ue]=a.useState(!1),[qe,ot]=a.useState(!1),vs=a.useCallback(()=>{const s=k==null?void 0:k.tx_delay_factor;return s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??1:typeof s=="number"?s:1},[k]),Ns=a.useCallback(()=>{const s=k==null?void 0:k.direct_tx_delay_factor;return typeof s=="number"?s:.5},[k]),Be=a.useCallback(()=>{const s=j==null?void 0:j.max_airtime_percent;return typeof s=="number"?s:s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??6:6},[j]),Ge=ss(y==="forward",async s=>{await l(s?"forward":"monitor")},n),Xe=ss(E,async s=>{await c({max_airtime_percent:Be(),enforcement_enabled:s})},i),We=ss((x==null?void 0:x.cors_enabled)??!1,async s=>{var D;const T=await Us({web:{cors_enabled:s}});if(!T.success&&!((D=T.data)!=null&&D.persisted))throw new Error("CORS update failed");await o()}),B=a.useCallback(async s=>{b(Gs.RADIO_CONFIG);try{const T=await Xs(s);if(!T.success)throw new Error(T.error||"Failed to save");await o({force:!0}).catch(()=>{})}finally{h(Gs.RADIO_CONFIG)}},[b,h,o]);a.useEffect(()=>{(async()=>{js(!0);try{const T=await It();T.success&&T.data?He(T.data.exists):He(!1);const D=x==null?void 0:x.web_path;bs(!D||D==="")}catch{He(!1)}finally{js(!1)}})()},[x==null?void 0:x.web_path]);const ws=async s=>{var T;if(ve!=="loading"){le("loading");try{const D=await Us({web:{web_path:s?null:"/opt/pymc_console/web/html"}});if(!N.current)return;D.success||(T=D.data)!=null&&T.persisted?(bs(s),le("success"),Ue(!0),setTimeout(()=>{N.current&&le("idle")},2e3)):(le("error"),setTimeout(()=>{N.current&&le("idle")},2e3))}catch{if(!N.current)return;le("error"),setTimeout(()=>{N.current&&le("idle")},2e3)}}},ct=async()=>{if(!qe){ot(!0);try{await Kt(),Ue(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{Ue(!1),setTimeout(()=>{window.location.reload()},3e3)}}},Ee=a.useCallback(async()=>{M(!0),_(null);try{const s=await ya();v(s.tokens||[])}catch(s){_(s instanceof Error?s.message:"Failed to fetch tokens")}finally{M(!1)}},[]);a.useEffect(()=>{Ee()},[Ee]);const ks=async()=>{if(!A.trim()){_("Token name is required");return}X(!0),_(null);try{const s=await ga(A.trim());V(s.token||null),f(!1),K(!0),S(""),await Ee()}catch(s){_(s instanceof Error?s.message:"Failed to create token")}finally{X(!1)}},dt=async()=>{if(ee){us(!0),_(null);try{await ba(ee.id),await Ee(),u(null)}catch(s){_(s instanceof Error?s.message:"Failed to revoke token")}finally{us(!1)}}},ut=async()=>{I&&(await At(I),fs(!0),setTimeout(()=>fs(!1),2e3))},mt=s=>s?new Date(s*1e3).toLocaleString():"Never",_s=a.useCallback(s=>{const T=new Map,D=[];return s.forEach(z=>{const Re={id:z.id,name:z.name,floodPolicy:z.flood_policy,transport_key:z.transport_key,last_used:z.last_used,parent_id:z.parent_id,children:[]};T.set(z.id,Re)}),T.forEach(z=>{z.parent_id&&T.has(z.parent_id)?T.get(z.parent_id).children.push(z):D.push(z)}),D},[]),Ne=a.useCallback(async()=>{xs(!0),$(null);try{const s=await Pt();if(s.success&&s.data){const T=_s(s.data);st(T),Ve(D=>{if(D===null)return null;const z=Re=>{for(const Je of Re)if(Je.id===D||Je.children&&z(Je.children))return!0;return!1};return z(T)?D:null})}else $(s.error||"Failed to load transport keys")}catch(s){$(s instanceof Error?s.message:"Unknown error occurred")}finally{xs(!1)}},[_s]);a.useEffect(()=>{Ne(),Lt().then(s=>{s.success&&s.data&&ps(s.data.unscoped_flood_allow?"allow":"deny")}).catch(()=>{})},[Ne]);const re=a.useCallback((s,T)=>{for(const D of s){if(D.id===T)return D;if(D.children){const z=re(D.children,T);if(z)return z}}return null},[]),ft=a.useCallback(()=>{if(!q)return;const s=re(te,q);return s==null?void 0:s.name},[q,te,re]),xt=a.useCallback(s=>{lt(T=>{const D=new Set(T);return D.has(s)?D.delete(s):D.add(s),D})},[]),ht=async s=>{gs(!0),$(null);try{const T=await Ot(s==="allow");T.success?ps(s):$(T.error||"Failed to update unscoped flood policy")}catch(T){$(T instanceof Error?T.message:"Failed to update unscoped flood policy")}finally{gs(!1)}},Ss=async()=>{if(!Ce.trim()){$("Key name is required");return}de(!0),$(null);try{const s=await zt({name:Ce.trim(),flood_policy:$e,parent_id:q??void 0});s.success?(await Ne(),ye(!1),Te(""),be("allow")):$(s.error||"Failed to add transport key")}catch(s){$(s instanceof Error?s.message:"Failed to add transport key")}finally{de(!1)}},pt=async()=>{if(U){de(!0),$(null);try{const s=await Vt(U.id,{name:U.name,flood_policy:U.floodPolicy});s.success?(await Ne(),oe(!1),ae(null)):$(s.error||"Failed to update transport key")}catch(s){$(s instanceof Error?s.message:"Failed to update transport key")}finally{de(!1)}}},yt=async()=>{if(ne){de(!0),$(null);try{const s=await $t(ne.id);s.success?(await Ne(),ce(!1),ge(null),Ve(null)):$(s.error||"Failed to delete transport key")}catch(s){$(s instanceof Error?s.message:"Failed to delete transport key")}finally{de(!1)}}},gt=a.useCallback(()=>{if(!q)return;const s=re(te,q);s&&(ae({...s}),oe(!0))},[q,te,re]);a.useEffect(()=>{const s=D=>{D.key==="Escape"&&(ke&&(ye(!1),Te(""),be("allow")),_e&&(oe(!1),ae(null)),Se&&(ce(!1),ge(null)),C&&(f(!1),S("")),H&&(K(!1),V(null)))};if(ke||_e||Se||C||H)return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[ke,_e,Se,C,H]);const bt=a.useCallback(()=>{if(!q)return;const s=re(te,q);s&&(ge(s),ce(!0))},[q,te,re]);return e.jsxs(Zt,{children:[e.jsx(ea,{title:"Configuration",icon:e.jsx(zs,{})}),e.jsxs(sa,{ready:p,children:[e.jsxs(se,{template:"standard",children:[e.jsx(ue,{span:12,md:6,children:e.jsxs(J,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(Tt,{}),title:"Repeater Settings"}),r?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(P,{label:"Node Name",value:F,onSave:async s=>B({node_name:s}),placeholder:"Enter node name",maxLength:50})}),e.jsx(P,{label:"Latitude",value:r.latitude!==0?r.latitude.toFixed(6):"Not set",editValue:String(r.latitude),type:"number",suffix:"°",step:1e-6,min:-90,max:90,onSave:async s=>B({latitude:parseFloat(s)})}),e.jsx(P,{label:"Longitude",value:r.longitude!==0?r.longitude.toFixed(6):"Not set",editValue:String(r.longitude),type:"number",suffix:"°",step:1e-6,min:-180,max:180,onSave:async s=>B({longitude:parseFloat(s)})}),e.jsx(P,{label:"Advert Interval",value:r.send_advert_interval_hours>0?`${r.send_advert_interval_hours}h`:"Disabled",editValue:String(r.send_advert_interval_hours),type:"number",suffix:"hours",min:0,max:48,description:"0 = disabled, 3-48 hours",onSave:async s=>B({flood_advert_interval_hours:parseInt(s,10)})}),e.jsx(P,{label:"Score-based TX",value:r.use_score_for_tx?"Enabled":"Disabled",readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading repeater settings..."})]})}),e.jsx(ue,{span:12,md:6,children:e.jsxs(J,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(ia,{}),title:"Radio Configuration"}),d?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(P,{label:"Frequency",value:Ft(d.frequency),editValue:(d.frequency/1e6).toFixed(3),type:"number",suffix:"MHz",step:.001,min:400,max:930,onSave:async s=>B({frequency_mhz:parseFloat(s)})}),e.jsx(P,{label:"TX Power",value:`${d.tx_power} dBm`,editValue:String(d.tx_power),type:"number",suffix:"dBm",min:2,max:30,onSave:async s=>B({tx_power:parseInt(s,10)})}),e.jsx(De,{label:"Bandwidth",value:Et(d.bandwidth),editValue:d.bandwidth/1e3,options:Ea,onSave:async s=>B({bandwidth_khz:parseFloat(s)})}),e.jsx(De,{label:"Spreading Factor",value:`SF${d.spreading_factor}`,editValue:d.spreading_factor,options:Ra.map(s=>({value:s,label:`SF${s}`})),onSave:async s=>B({spreading_factor:parseInt(s,10)})}),e.jsx(De,{label:"Coding Rate",value:`4/${d.coding_rate}`,editValue:d.coding_rate,options:Ma,onSave:async s=>B({coding_rate:parseInt(s,10)})}),e.jsx(P,{label:"Preamble",value:`${d.preamble_length} symbols`,readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading radio configuration..."})]})})]}),e.jsxs(se,{template:"standard",children:[e.jsx(ue,{span:12,md:6,children:e.jsxs(J,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(Rt,{}),title:"Operating Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(fe,{enabled:Ge.enabled,onChange:Ge.toggle,label:"Repeat",tooltip:"Toggles repeater or monitor mode. In monitor mode, the repeater will not repeat packets from the mesh.",status:Ge.status,size:"md"}),e.jsx(fe,{enabled:Xe.enabled,onChange:Xe.toggle,label:"Duty Cycle",tooltip:"Limit transmission time to comply with airtime utilization regulations",status:Xe.status,size:"md"}),e.jsx(P,{label:"Max Airtime",value:`${Be().toFixed(1)}%`,editValue:String(Be()),type:"number",suffix:"%",step:.5,min:.1,max:100,onSave:async s=>{await c({max_airtime_percent:parseFloat(s),enforcement_enabled:E}),i()}}),e.jsx(P,{label:"Flood TX Delay",value:`${vs().toFixed(2)}x`,editValue:String(vs()),type:"number",suffix:"x",step:.1,min:0,max:5,onSave:async s=>B({tx_delay_factor:parseFloat(s)})}),e.jsx(P,{label:"Direct TX Delay",value:`${Ns().toFixed(2)}s`,editValue:String(Ns()),type:"number",suffix:"s",step:.1,min:0,max:5,onSave:async s=>B({direct_tx_delay_factor:parseFloat(s)})}),e.jsx(P,{label:"Max Flood Hops",value:String((r==null?void 0:r.max_flood_hops)??3),type:"number",min:0,max:64,description:"0–64 hops",onSave:async s=>B({max_flood_hops:parseInt(s,10)})})]}),e.jsx("div",{className:"mt-4",children:e.jsx(De,{label:"Path Hash Size",value:`${(((As=(Ds=t==null?void 0:t.config)==null?void 0:Ds.mesh)==null?void 0:As.path_hash_mode)??0)+1}-byte`,editValue:((Ls=(Ps=t==null?void 0:t.config)==null?void 0:Ps.mesh)==null?void 0:Ls.path_hash_mode)??0,options:Da,onSave:async s=>B({path_hash_mode:parseInt(s,10)})})})]})}),e.jsx(ue,{span:12,md:6,children:e.jsxs(J,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(zs,{}),title:"App Settings"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Appearance and web server options."}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(fe,{enabled:We.enabled,onChange:We.toggle,label:"Enable CORS",tooltip:"Allow cross-origin API access",status:We.status,size:"md"}),e.jsx("div",{children:e.jsx(va,{})}),e.jsx(Pa,{})]})]})})]}),e.jsx(se,{template:"auto",children:e.jsx(_a,{})}),e.jsx(se,{template:"auto",children:e.jsxs(J,{neomorphic:!0,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[e.jsx(W,{icon:e.jsx(Vs,{}),title:"Regions Transport Keys"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(L,{color:"primary",outline:!0,onClick:()=>ye(!0),children:[e.jsx($s,{"data-slot":"icon"}),"Add"]}),e.jsx(L,{color:"primary",outline:!0,onClick:gt,disabled:!q,children:"Edit"}),e.jsx(L,{color:"danger",outline:!0,onClick:bt,disabled:!q,children:"Delete"})]})]}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:e.jsx(fe,{enabled:ze==="allow",onChange:s=>ht(s?"allow":"deny"),label:e.jsxs(e.Fragment,{children:["Unscoped Flood: ",e.jsx("span",{className:ze==="allow"?"text-sys-green":"text-sys-red",children:ze==="allow"?"Allow":"Deny"})]}),tooltip:"Forward flood packets that have no region transport key. This is independent of region scope configuration.",status:ys?"loading":"idle",disabled:ys,dangerOff:!0,size:"md",className:"flex-row-reverse justify-between w-full"})}),hs&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:hs}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 min-h-[120px]",children:tt?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx(G,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading transport keys..."})]}):te.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-subtle-fill mx-auto mb-3 flex items-center justify-center",children:e.jsx(Vs,{className:"w-6 h-6 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No transport keys found"}),e.jsx("p",{className:"type-body-sm text-fg-muted/70 mt-1",children:"Add your first transport key to get started"})]}):e.jsx("div",{className:"space-y-1",children:te.map(s=>e.jsx(et,{node:s,level:0,expandedKeys:nt,selectedKeyId:q,onSelect:Ve,onToggle:xt},s.id))})})]})}),e.jsxs(se,{template:"standard",children:[e.jsx(ue,{span:12,md:6,children:e.jsx(Ca,{})}),e.jsx(ue,{span:12,md:6,children:e.jsxs(J,{neomorphic:!0,className:"h-full flex flex-col",children:[e.jsx(W,{icon:e.jsx(Hs,{}),title:"API Tokens"}),w&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:w}),e.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:R&&g.length===0?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(G,{className:"w-4 h-4 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading tokens..."})]}):g.length>0?e.jsx("div",{className:"space-y-1.5 flex-1 overflow-y-auto mb-3",children:g.map(s=>e.jsxs("div",{className:"bg-subtle-fill hover:bg-subtle-fill-strong radius-inner px-3 py-2 transition-base flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"type-body-sm text-fg-primary font-medium truncate",children:s.name}),e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",children:["Last used: ",mt(s.last_used)]})]}),e.jsx("button",{type:"button",onClick:()=>u({id:s.id,name:s.name}),disabled:ds,className:"text-sys-red/70 hover:text-sys-red transition-colors flex-shrink-0 p-1",title:"Revoke token",children:e.jsx(Js,{className:"w-3.5 h-3.5"})})]},s.id))}):e.jsxs("div",{className:"bg-subtle-fill radius-inner flex-1 flex flex-col items-center justify-center mb-3",children:[e.jsx(Hs,{className:"w-5 h-5 text-fg-muted/50 mb-2"}),e.jsx("p",{className:"type-body-sm text-fg-muted",children:"No API tokens"})]})}),e.jsxs(L,{color:"primary",outline:!0,onClick:()=>f(!0),className:"w-full justify-center mt-auto",children:[e.jsx($s,{"data-slot":"icon"}),"Create Token"]})]})})]}),e.jsx(se,{template:"auto",children:e.jsxs(J,{neomorphic:!0,children:[e.jsx(W,{icon:e.jsx(xa,{}),title:"Web Frontend"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:m("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Fe?"border-sys-blue bg-sys-blue/5":"border-transparent hover:border-sys-blue/30",ve==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:Fe,onChange:()=>ws(!0),disabled:ve==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"Default Frontend"}),e.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",onClick:s=>s.stopPropagation(),className:"type-data-xs bg-sys-cyan/15 text-sys-cyan px-2.5 py-0.5 rounded-full font-medium hover:bg-sys-cyan/25 transition-colors",children:"@RightUp"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Built-in pyMC Repeater web interface"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_repeater/repeater/web/html"})]})]}),e.jsxs("label",{className:m("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Fe?"border-transparent hover:border-sys-blue/30":"border-sys-blue bg-sys-blue/5",ve==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:!Fe,onChange:()=>ws(!1),disabled:ve==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"PyMC Console"}),e.jsx("span",{className:"type-data-xs bg-sys-indigo/15 text-sys-indigo px-2.5 py-0.5 rounded-full font-medium",children:"@Treehouse ⚡"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Alternative web interface for pyMC Repeater"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_console/web/html"})]})]})]}),!rt&&e.jsx("div",{className:m("bg-subtle-fill radius-card p-4",je?"border border-sys-green/20":"border border-sys-cyan/20"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:m("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",je?"bg-sys-green/20":"bg-sys-cyan/20"),children:je?e.jsx(ls,{className:"w-4 h-4 text-sys-green"}):e.jsx(ie,{className:"w-4 h-4 text-sys-cyan"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:je?"PyMC Console has been detected":"PyMC Console Not Installed"}),je?e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1",children:["PyMC Console is installed at ",e.jsx("code",{className:"type-code bg-sys-green/10 px-1.5 py-0.5 rounded-full text-sys-green",children:"/opt/pymc_console/web/html"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1 mb-3",children:["PyMC Console must be installed at ",e.jsx("code",{className:"type-code bg-sys-cyan/10 px-1.5 py-0.5 rounded-full text-sys-cyan",children:"/opt/pymc_console/web/html"})," before selecting this option."]}),e.jsxs(L,{color:"primary",outline:!0,href:"https://github.com/dmduran12/pymc_console-dist",children:[e.jsx(Qs,{"data-slot":"icon"}),"PyMC Console Install Instructions"]})]})]})]})}),it&&e.jsx("div",{className:"bg-subtle-fill radius-card p-4 border border-sys-indigo/30",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-indigo/20 flex items-center justify-center flex-shrink-0",children:e.jsx(Pe,{className:"w-4 h-4 text-sys-indigo"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:"Service restart required"}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:"Web frontend changes will take effect after restarting the pymc-repeater service."})]})]}),e.jsx(L,{color:"warning",outline:!0,onClick:ct,disabled:qe,children:qe?e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-slot":"icon",className:"animate-spin"}),"Restarting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ws,{"data-slot":"icon"}),"Restart Now"]})})]})})]})]})}),e.jsx(se,{template:"auto",children:e.jsx(Fa,{})}),t&&e.jsx(se,{template:"auto",children:e.jsx(Gt,{nodeName:F,publicKey:t.public_key})}),t&&((r==null?void 0:r.latitude)===0||!(r!=null&&r.latitude))&&((r==null?void 0:r.longitude)===0||!(r!=null&&r.longitude))&&e.jsx(se,{template:"auto",children:e.jsx(wa,{})})]}),C&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&f(!1),role:"dialog","aria-modal":"true","aria-labelledby":"create-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"create-token-modal-title",className:"type-micro mb-4",children:"Create API Token"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ye,{label:"Token Name",type:"text",value:A,onChange:s=>S(s.target.value),placeholder:"e.g., Production Server, CI/CD Pipeline",description:"Give your token a descriptive name to identify its purpose",onKeyDown:s=>s.key==="Enter"&&ks(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(L,{color:"muted",outline:!0,onClick:()=>{f(!1),S(""),_(null)},disabled:O,children:"Cancel"}),e.jsx(L,{color:"primary",onClick:ks,disabled:O||!A.trim(),children:O?e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-slot":"icon",className:"animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),H&&I&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&K(!1),role:"dialog","aria-modal":"true","aria-labelledby":"show-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-lg w-full",children:[e.jsx("h3",{id:"show-token-modal-title",className:"type-micro mb-4",children:"Token Created Successfully"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Pe,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:[e.jsx("strong",{children:"Save this token now!"})," For security reasons, it will not be shown again."]})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-primary block mb-1.5",children:"Your API Token"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Mt,{value:I,readOnly:!0,className:"flex-1 font-mono"}),e.jsxs(L,{color:"primary",outline:!0,onClick:ut,children:[ms?e.jsx(Y,{"data-slot":"icon",className:"text-sys-green"}):e.jsx(Dt,{"data-slot":"icon"}),ms?"Copied!":"Copy"]})]})]}),e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3",children:[e.jsx("p",{className:"text-sm text-fg-secondary mb-2",children:e.jsx("strong",{children:"Usage Example:"})}),e.jsxs("code",{className:"block bg-sys-cyan/20 px-3 py-2 rounded type-code text-sys-cyan overflow-x-auto",children:['curl -H "X-API-Key: ',I.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),e.jsx("div",{className:"flex justify-end mt-6",children:e.jsx(L,{color:"primary",onClick:()=>{K(!1),V(null)},children:"Done"})})]})]})}),e.jsx(Ht,{isOpen:!!ee,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${ee==null?void 0:ee.name}'? This action cannot be undone.`,confirmLabel:ds?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:dt,onCancel:()=>u(null)}),ke&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&ye(!1),role:"dialog","aria-modal":"true","aria-labelledby":"add-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"add-key-modal-title",className:"type-micro mb-4",children:"Add Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[q&&e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3 text-sm text-fg-secondary",children:["Adding as child of: ",e.jsx("strong",{className:"text-fg-primary",children:ft()})]}),e.jsx(Ye,{label:"Key Name",type:"text",value:Ce,onChange:s=>Te(s.target.value),placeholder:"e.g., Region Name, Group Key",onKeyDown:s=>s.key==="Enter"&&Ss(),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>be("deny"),className:m("toggle-group-item flex-1",$e==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>be("allow"),className:m("toggle-group-item flex-1",$e==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(L,{color:"muted",outline:!0,onClick:()=>{ye(!1),Te(""),be("allow")},disabled:Q,children:"Cancel"}),e.jsx(L,{color:"primary",onClick:Ss,disabled:Q||!Ce.trim(),children:Q?e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-slot":"icon",className:"animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),_e&&U&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&oe(!1),role:"dialog","aria-modal":"true","aria-labelledby":"edit-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"edit-key-modal-title",className:"type-micro mb-4",children:"Edit Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ye,{label:"Key Name",type:"text",value:U.name,onChange:s=>ae({...U,name:s.target.value}),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>ae({...U,floodPolicy:"deny"}),className:m("toggle-group-item flex-1",U.floodPolicy==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>ae({...U,floodPolicy:"allow"}),className:m("toggle-group-item flex-1",U.floodPolicy==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),U.transport_key&&e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Transport Key"}),e.jsx("code",{className:"block bg-input-bg px-3 py-2 radius-inner border border-input-border type-code text-fg-muted overflow-x-auto",children:U.transport_key})]}),e.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[e.jsx(L,{color:"danger",outline:!0,onClick:()=>{oe(!1),ge(U),ce(!0),ae(null)},disabled:Q,children:"Delete"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(L,{color:"muted",outline:!0,onClick:()=>{oe(!1),ae(null)},disabled:Q,children:"Cancel"}),e.jsx(L,{color:"primary",onClick:pt,disabled:Q||!U.name.trim(),children:Q?e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-slot":"icon",className:"animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),Se&&ne&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&ce(!1),role:"dialog","aria-modal":"true","aria-labelledby":"delete-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"delete-key-modal-title",className:"type-micro mb-4",children:"Delete Transport Key"}),e.jsxs("p",{className:"text-fg-secondary mb-4",children:["Are you sure you want to delete ",e.jsxs("strong",{className:"text-fg-primary",children:["'",ne.name,"'"]}),"?"]}),ne.children&&ne.children.length>0&&e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Pe,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:["This key has ",ne.children.length," child key(s). Deleting will also remove all children."]})]})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(L,{color:"muted",outline:!0,onClick:()=>{ce(!1),ge(null)},disabled:Q,children:"Cancel"}),e.jsx(L,{color:"danger",onClick:yt,disabled:Q,children:Q?e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-slot":"icon",className:"animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{tn as default}; diff --git a/frontend/dist/assets/ConfirmModal-eC-cl0ep.js b/frontend/dist/assets/ConfirmModal-J2_Sxirm.js similarity index 83% rename from frontend/dist/assets/ConfirmModal-eC-cl0ep.js rename to frontend/dist/assets/ConfirmModal-J2_Sxirm.js index 8bb24f7e..640b1a76 100644 --- a/frontend/dist/assets/ConfirmModal-eC-cl0ep.js +++ b/frontend/dist/assets/ConfirmModal-J2_Sxirm.js @@ -1 +1 @@ -import{r as d,j as s,aC as x,aK as m,bY as g,c as C,aD as f,eJ as j,B as o}from"./index-C2xvS0Jd.js";const u={danger:"text-sys-red",warning:"text-sys-indigo",default:"text-sys-blue"},p={danger:"danger",warning:"warning",default:"primary"};function N({isOpen:n,title:r="Confirm",message:l,confirmLabel:t="Confirm",cancelLabel:i="Cancel",variant:a="default",onConfirm:c,onCancel:e}){return s.jsxs(x,{open:n,onClose:e,size:"sm",children:[s.jsx(m,{icon:s.jsx(g,{className:C("w-5 h-5",u[a])}),title:r,onClose:e}),s.jsx(f,{children:s.jsx("p",{className:"text-sm text-fg-secondary",children:l})}),s.jsxs(j,{children:[s.jsx(o,{color:"muted",onClick:e,className:"flex-1",children:i}),s.jsx(o,{color:p[a],onClick:c,className:"flex-1",children:t})]})]})}const y=d.memo(N);export{y as C}; +import{r as d,j as s,aC as x,aL as m,bZ as g,c as C,aD as f,eJ as j,B as o}from"./index-D33fcA3L.js";const u={danger:"text-sys-red",warning:"text-sys-indigo",default:"text-sys-blue"},p={danger:"danger",warning:"warning",default:"primary"};function N({isOpen:n,title:r="Confirm",message:l,confirmLabel:t="Confirm",cancelLabel:i="Cancel",variant:a="default",onConfirm:c,onCancel:e}){return s.jsxs(x,{open:n,onClose:e,size:"sm",children:[s.jsx(m,{icon:s.jsx(g,{className:C("w-5 h-5",u[a])}),title:r,onClose:e}),s.jsx(f,{children:s.jsx("p",{className:"text-sm text-fg-secondary",children:l})}),s.jsxs(j,{children:[s.jsx(o,{color:"muted",onClick:e,className:"flex-1",children:i}),s.jsx(o,{color:p[a],onClick:c,className:"flex-1",children:t})]})]})}const y=d.memo(N);export{y as C}; diff --git a/frontend/dist/assets/Contacts-CTRl8l-x.js b/frontend/dist/assets/Contacts-2M50JufT.js similarity index 79% rename from frontend/dist/assets/Contacts-CTRl8l-x.js rename to frontend/dist/assets/Contacts-2M50JufT.js index afd3ab94..d82bbb50 100644 --- a/frontend/dist/assets/Contacts-CTRl8l-x.js +++ b/frontend/dist/assets/Contacts-2M50JufT.js @@ -1,10 +1,10 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-CnXabSF9.js","assets/index-C2xvS0Jd.js","assets/consumer-registry-DJyYnY6J.js","assets/link-scoring-BjtZpDDb.js","assets/ConfirmModal-eC-cl0ep.js","assets/variants-cyDnzhWy.js","assets/git-branch-BhoB5t-Q.js","assets/database-cyku2KnA.js","assets/useMapViewStore-DnPjO7Qt.js","assets/index-QCPybZMd.js","assets/index-wtt5rE5a.js","assets/target-BpFOYbOg.js","assets/funnel-DGVJFdsh.js","assets/plus-CH14Vv92.js","assets/compass-D_q1TimF.js","assets/zap-v3FkQoQ-.js","assets/max-BBb5g8bL.js","assets/trash-2-Def3YmfN.js","assets/wifi-off-omfJv-eS.js","assets/wifi-Bc9OxL0c.js","assets/circle-alert-kdR_gb55.js","assets/clock-DU0z3qMB.js","assets/chevron-right-C9GG0xWI.js","assets/useReplayTick-DbeD1_Sw.js","assets/payload-detail-BAEvS7Pl.js","assets/LightSparkline-Dtyxi9BD.js","assets/badge-colors-Dl76Mz8m.js","assets/map-pin-CQk00ph2.js","assets/node-types-BD70swWz.js","assets/BasemapLayer-DQCsZLc0.js","assets/easing-2tSIucrJ.js","assets/usePipelineStore-Do-g28wv.js","assets/PageLayout-Cg7r5tdt.js","assets/listbox-DnHpTyQt.js","assets/element-movement-CSQuYFsD.js","assets/use-text-value-CU5Ho7TY.js","assets/frozen-Cx4cJH6f.js","assets/MqttModeBadge-DOXwpg3i.js","assets/chat-utils-DnJ-lYj3.js","assets/SignalIndicator-DO8Lkax5.js","assets/CollisionExplorerModal-Du9NEbAu.js","assets/share-2-DLfTr0kI.js","assets/circle-question-mark-CF3fGjhH.js","assets/map-pin-off-D8fZRJ6M.js","assets/activity-BFfde9uG.js","assets/search-DPGHPI2q.js","assets/index-7uzBcJ1E.css","assets/maplibre-gl-B1CfjdFi.css","assets/ContactsMapMapLibre-BwWOEply.css"])))=>i.map(i=>d[i]); -import{e as xe,ar as cs,j as e,r as n,_ as is,cp as He,cq as Ie,ao as W,a0 as Ce,cr as ls,cs as me,aa as de,c3 as ds,az as Oe,ct as ye,a2 as ze,cu as ms,ac as xs,cv as us,cw as ps,cx as hs,ab as fs,cy as gs,cz as js,ad as bs,aA as ys,ae as Ne,cA as Ns,cB as vs,cC as ws,cD as Cs,bI as ee,cE as $e,Y as ks,I as Ms,bM as Ss,c as we}from"./index-C2xvS0Jd.js";import{useDiscoveredNodes as Ps}from"./usePipelineStore-Do-g28wv.js";import{c as ke}from"./node-types-BD70swWz.js";import{P as _s,a as Rs,B as Ls}from"./PageLayout-Cg7r5tdt.js";import{L as Ts,a as le}from"./listbox-DnHpTyQt.js";import{T as Fe,M as $s}from"./MqttModeBadge-DOXwpg3i.js";import{u as Fs,e as Es,f as Hs,r as Is}from"./consumer-registry-DJyYnY6J.js";import{e as Os,g as zs,a as Ds}from"./chat-utils-DnJ-lYj3.js";import{b as Bs}from"./SignalIndicator-DO8Lkax5.js";import{C as As}from"./CollisionExplorerModal-Du9NEbAu.js";import{E as qs,T as Vs}from"./target-BpFOYbOg.js";import{S as Us}from"./share-2-DLfTr0kI.js";import{C as De}from"./circle-question-mark-CF3fGjhH.js";import{M as Ws}from"./map-pin-off-D8fZRJ6M.js";import{A as Be}from"./activity-BFfde9uG.js";import{T as Gs}from"./trash-2-Def3YmfN.js";import{C as Qs}from"./ConfirmModal-eC-cl0ep.js";import{M as Xs}from"./map-pin-CQk00ph2.js";import{S as Ys}from"./search-DPGHPI2q.js";import{C as Zs}from"./clock-DU0z3qMB.js";/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-DlBh136H.js","assets/index-D33fcA3L.js","assets/consumer-registry-DXaeZxMm.js","assets/link-scoring-Chr3N5ba.js","assets/ConfirmModal-J2_Sxirm.js","assets/variants-ByRhxIcL.js","assets/git-branch-Ryinnbc1.js","assets/database-Bm4-qoOy.js","assets/useMapViewStore-Ey8vE9rr.js","assets/index-5slIee7x.js","assets/index-DuiHY5wq.js","assets/target-B3CHoIpd.js","assets/funnel-BBIwSMOb.js","assets/plus-C0dCjBh9.js","assets/compass-CncUthiD.js","assets/zap-C-Mue2DZ.js","assets/max-CkBnBUwN.js","assets/trash-2-CUY4NG5t.js","assets/wifi-off-BQtV63nI.js","assets/wifi-D716s0ef.js","assets/circle-alert-BgZmhbSe.js","assets/clock-D_m2QiHa.js","assets/chevron-right-D4kUPDBw.js","assets/useReplayTick-BbXJoz75.js","assets/payload-detail-DbnSd5NL.js","assets/LightSparkline-r3FtGEtW.js","assets/badge-colors-Dl76Mz8m.js","assets/map-pin-B_Rx-xpd.js","assets/node-types-BoqnL0Eg.js","assets/BasemapLayer-DhvtWc_h.js","assets/easing-D0twVjny.js","assets/usePipelineStore-DDHEHTlZ.js","assets/PageLayout-CRN-E5xi.js","assets/listbox-DkfYDEqr.js","assets/element-movement-BL6huHzq.js","assets/use-text-value-iYUkduzo.js","assets/frozen-C10EXZ59.js","assets/MqttModeBadge-BtcQeS2v.js","assets/chat-utils-DIy1-SG1.js","assets/SignalIndicator-DmWlnzMv.js","assets/CollisionExplorerModal-P8ZOhB65.js","assets/share-2-BAsDxZE2.js","assets/circle-question-mark-CO80vHQp.js","assets/map-pin-off-V0MBukP5.js","assets/activity-D6ySIfuC.js","assets/search-DN8guzpX.js","assets/index-7uzBcJ1E.css","assets/maplibre-gl-B1CfjdFi.css","assets/ContactsMapMapLibre-BwWOEply.css"])))=>i.map(i=>d[i]); +import{e as xe,ar as cs,j as e,r as n,_ as is,cq as He,cr as Oe,ao as W,a0 as Ce,cs as ls,ct as me,aa as de,c4 as ds,az as Ie,cu as ye,a2 as ze,cv as ms,ac as xs,cw as us,cx as ps,cy as hs,ab as fs,cz as gs,cA as js,ad as bs,aA as ys,ae as Ne,cB as Ns,cC as vs,cD as ws,cE as Cs,bJ as ee,cF as $e,Y as ks,I as Ms,bN as Ss,c as we}from"./index-D33fcA3L.js";import{useDiscoveredNodes as Ps}from"./usePipelineStore-DDHEHTlZ.js";import{c as ke}from"./node-types-BoqnL0Eg.js";import{P as _s,a as Rs,B as Ls}from"./PageLayout-CRN-E5xi.js";import{L as Ts,a as le}from"./listbox-DkfYDEqr.js";import{T as Fe,M as $s}from"./MqttModeBadge-BtcQeS2v.js";import{u as Fs,e as Es,f as Hs,r as Os}from"./consumer-registry-DXaeZxMm.js";import{e as Is,g as zs,a as Ds}from"./chat-utils-DIy1-SG1.js";import{b as Bs}from"./SignalIndicator-DmWlnzMv.js";import{C as As}from"./CollisionExplorerModal-P8ZOhB65.js";import{E as qs,T as Vs}from"./target-B3CHoIpd.js";import{S as Us}from"./share-2-BAsDxZE2.js";import{C as De}from"./circle-question-mark-CO80vHQp.js";import{M as Ws}from"./map-pin-off-V0MBukP5.js";import{A as Be}from"./activity-D6ySIfuC.js";import{T as Gs}from"./trash-2-CUY4NG5t.js";import{C as Qs}from"./ConfirmModal-J2_Sxirm.js";import{M as Js}from"./map-pin-B_Rx-xpd.js";import{S as Xs}from"./search-DN8guzpX.js";import{C as Ys}from"./clock-D_m2QiHa.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 Js=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Ks=xe("arrow-up-down",Js);/** + */const Zs=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Ks=xe("arrow-up-down",Zs);/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -19,5 +19,5 @@ import{e as xe,ar as cs,j as e,r as n,_ as is,cp as He,cq as Ie,ao as W,a0 as Ce * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const nt=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],Ae=xe("ruler",nt);class rt extends n.Component{constructor(l){super(l),this.state={hasError:!1}}static getDerivedStateFromError(l){return{hasError:!0,error:l}}render(){var l;return this.state.hasError?e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"text-center text-fg-muted p-4",children:[e.jsx("p",{className:"text-lg mb-2",children:"Map failed to load"}),e.jsx("p",{className:"text-sm text-fg-muted",children:((l=this.state.error)==null?void 0:l.message)||"Unknown error"}),e.jsx("p",{className:"text-xs text-fg-muted mt-2",children:"Try refreshing the page or check your browser's WebGL support."})]})}):this.props.children}}const ot=n.lazy(()=>is(()=>import("./ContactsMapMapLibre-CnXabSF9.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48]))),Ee=()=>e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"status","aria-live":"polite","aria-label":"Loading map",children:e.jsxs("div",{className:"text-fg-muted flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-sys-blue border-t-transparent rounded-full animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading map..."})]})});function ct({neighbors:o,localNode:l,localHash:g,onRemoveNode:u,selectedNodeHash:j,onNodeSelected:N,highlightedEdgeKey:c,highlightedGhost:T}){return cs()===!1?e.jsx(Ee,{}):e.jsx(rt,{children:e.jsx(n.Suspense,{fallback:e.jsx(Ee,{}),children:e.jsx(ot,{neighbors:o,localNode:l,localHash:g,onRemoveNode:u,selectedNodeHash:j,onNodeSelected:N,highlightedEdgeKey:c,highlightedGhost:T})})})}function it({hash:o,className:l="",size:g="sm",collisionInfo:u,isViterbiResolved:j}){const N=He(),c=Ie(),[T,$]=n.useState(!1),w=n.useMemo(()=>W(o),[o]),p=n.useMemo(()=>u!==void 0?u:w?N.find(P=>P.prefix===w)??null:null,[w,N,u]),C=j??(c.totalPaths>0&&c.avgPathConfidence>=.7),D=n.useCallback(P=>{P.preventDefault(),P.stopPropagation(),$(!0)},[]),B=n.useCallback(()=>{$(!1)},[]);if(!p)return null;const A=g==="sm"?"w-3.5 h-3.5":"w-4 h-4",q=C?"text-sys-cyan hover:text-sys-cyan hover:bg-sys-cyan/10 focus:ring-sys-cyan/50":"text-signal-fair hover:text-sys-indigo hover:bg-signal-fair/10 focus:ring-signal-fair/50",S=C?`Prefix conflict resolved by Viterbi HMM (${(c.avgPathConfidence*100).toFixed(0)}% confidence)`:`Prefix conflict: ${p.candidateCount} nodes share prefix "${w}"`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:D,className:`inline-flex items-center justify-center p-0.5 rounded focus:outline-none focus:ring-2 transition-colors cursor-pointer touch-manipulation ${q} ${l}`,title:S,"aria-label":`View prefix conflict for ${w}${C?" (Viterbi resolved)":""}`,children:C?e.jsxs("span",{className:"relative",children:[e.jsx(qs,{className:A}),e.jsx(Ce,{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 text-sys-green"})]}):e.jsx(st,{className:A})}),T&&e.jsx(As,{isOpen:!0,prefix:p.prefix,candidateHashes:p.candidateHashes,onClose:B})]})}const lt=n.memo(it),qe=[{target:"Contacts",fn:"name",minStage:1,when:Es},{target:"Contacts",fn:"traceLinks.directed",minStage:2,when:Hs}];Is(qe);function dt(o){return o<1e3?`${Math.round(o)}m`:`${(o/1e3).toFixed(1)}km`}function mt({hash:o,contact:l,isHub:g,isNeighbor:u,distance:j,centrality:N,neighborSignal:c,collisionInfo:T,isViterbiResolved:$,pingingHash:w,pingResult:p,pingError:C,isMobile:D,metaSummary:B,metaTooltip:A,onRowClick:q,onPing:S,onRemove:P}){Fs(qe);const _=l.latitude&&l.longitude&&l.latitude!==0&&l.longitude!==0,H=l.node_name||l.name||"Unknown",I=u&&c,se=ke(l),{isRepeater:v,isCompanion:G,isRoomServer:R,isClient:Q,label:b}=se,te=u?`${b} — Direct RF contact (zero-hop neighbor)`:`${b} — Flood routing (multi-hop via mesh)`,ae=n.useCallback(()=>q(o),[q,o]);return e.jsxs("div",{className:`contacts-grid-row ${g?"bg-sys-amber/5 border-l-2 border-l-sys-amber":""} ${_?"cursor-pointer":""}`,onClick:ae,children:[e.jsxs("div",{className:"contacts-col-node flex items-center gap-2 min-w-0",children:[I&&(c==null?void 0:c.avgSnr)!==null?e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 self-center ${ls(c.avgSnr)}`}):e.jsx("div",{className:"w-2 flex-shrink-0"}),e.jsx("div",{className:"w-6 h-6 flex items-center justify-center flex-shrink-0",title:te,children:(()=>{if(R&&v)return e.jsxs("div",{className:"relative w-5 h-5",children:[e.jsx(me,{className:"w-5 h-5 absolute inset-0 text-sys-pink"}),e.jsx(Us,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-sys-teal"})]});if(R)return e.jsx(me,{className:"w-5 h-5 text-sys-pink"});if(v)return e.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(de,{className:"w-3.5 h-3.5 text-sys-blue"})});if((G||Q)&&H!=="Unknown"){const{emoji:F,cleanName:ue}=Os(H);return e.jsx("div",{className:"w-6 h-6 clay-avatar",style:{"--avatar-color":zs(ue)},children:F?e.jsx("span",{className:"text-sm leading-none",children:F}):e.jsx("span",{className:"text-white text-[9px] font-bold tracking-tighter",children:Ds(H)})})}return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center bg-zinc-500/20",children:e.jsx(De,{className:"w-3.5 h-3.5 text-sys-amber"})})})()}),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:H,children:H}),u&&e.jsx("span",{className:"contact-tag contact-tag--nbr",children:"NBR"}),g&&e.jsx("span",{className:"contact-tag contact-tag--hub",children:"HUB"}),v&&e.jsx("span",{className:"contact-tag contact-tag--rpt",children:"RPT"}),R&&e.jsx("span",{className:"contact-tag contact-tag--room",children:"ROOM"}),G&&e.jsx("span",{className:"contact-tag contact-tag--comp",children:"COMP"}),Q&&e.jsx("span",{className:"contact-tag contact-tag--client",children:"CLIENT"}),D&&e.jsx("span",{className:"contact-tag contact-tag--mobile",children:"MOB"}),!_&&e.jsx(Ws,{className:"w-3 h-3 flex-shrink-0 text-fg-muted/50"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(ds,{copy:!0,size:"compact",truncate:[8,6],children:o}),e.jsx(lt,{hash:o,collisionInfo:T,isViterbiResolved:$}),B&&e.jsx("span",{className:"contact-meta",title:A,children:B})]})]})]}),e.jsxs("div",{className:"contacts-col-signal flex items-center justify-end gap-2",children:[I&&(c==null?void 0:c.avgRssi)!==null&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Bs,{rssi:c.avgRssi,className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Math.round(c.avgRssi)})]}),I&&(c==null?void 0:c.avgSnr)!==null&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[c.avgSnr.toFixed(1)," dB"]})]}),e.jsx("div",{className:"contacts-col-distance flex items-center justify-end gap-1 text-fg-muted",children:j!=null&&e.jsxs(e.Fragment,{children:[e.jsx(Ae,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs",children:dt(j)})]})}),e.jsx("div",{className:"contacts-col-centrality flex items-center justify-end gap-1",children:N>0&&e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-3 h-3 text-sys-indigo"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[(N*100).toFixed(0),"%"]})]})}),e.jsx("div",{className:"contacts-col-seen flex items-center justify-end",children:e.jsx("span",{className:"type-data-xs text-fg-primary whitespace-nowrap",children:l.last_seen?Oe(l.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[u&&e.jsx(e.Fragment,{children:p?e.jsxs("div",{className:`flex items-center gap-1 ${ye(p)?"text-sys-green":"text-fg-muted"}`,title:`RTT: ${p.rtt_ms.toFixed(0)}ms${ye(p)?` · SNR: ${p.snr_db.toFixed(1)}dB · RSSI: ${p.rssi}dBm`:""}`,children:[e.jsx(Ce,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs hidden sm:inline",children:ye(p)?`${p.snr_db.toFixed(1)}dB`:`${(p.rtt_ms/1e3).toFixed(1)}s`})]}):C?e.jsxs("span",{className:"text-sys-red text-xs font-medium",title:C,children:[e.jsx("span",{className:"hidden sm:inline",children:C}),e.jsx("span",{className:"sm:hidden",children:"✗"})]}):e.jsx("button",{onClick:F=>S(o,F),disabled:w!==null,className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-blue hover:bg-sys-blue/10 transition-base disabled:opacity-50 disabled:cursor-not-allowed",title:"Ping neighbor for updated signal info",children:w===o?e.jsx(ze,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(Vs,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})}),e.jsx("button",{onClick:F=>{F.stopPropagation(),P(o,H)},className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-red hover:bg-sys-red/10 transition-base",title:"Remove contact",children:e.jsx(Gs,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]})}const xt=n.memo(mt),ut=6371e3,pt=[{field:"lastHeard",icon:Zs,label:"Recent"},{field:"distance",icon:Ae,label:"Distance"},{field:"centrality",icon:Be,label:"Centrality"}];function ht(o){switch(o){case"room_server":return"room";case"repeater":return"repeater";case"companion":return"companion";case"unknown":return"companion"}}function ft(o){const l=ke(o);return ht(l.type)}function ve(o,l){const{color:g="primary",border:u=!1}=l??{};return we("flex items-center gap-1.5 px-2 py-1.5 text-sm radius-inner transition-base",o?g==="success"?"bg-sys-green/20 text-sys-green":"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary hover-bg",u&&(o?g==="success"?"border border-sys-green/30":"border border-sys-blue/30":"border border-transparent"))}function gt(o,l,g,u){const j=(g-o)*Math.PI/180,N=(u-l)*Math.PI/180,c=Math.sin(j/2)*Math.sin(j/2)+Math.cos(o*Math.PI/180)*Math.cos(g*Math.PI/180)*Math.sin(N/2)*Math.sin(N/2),T=2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c));return ut*T}function jt(){var Le,Te;const{stats:o}=ms(),l=xs(),g=us(),u=ps(),j=hs(),N=fs(),c=gs(),T=js(),$=bs(),w=ys(),p=Ne[$],C=He(),D=Ie(),B=Ns(),A=D.totalPaths>0&&D.avgPathConfidence>=.7,q=n.useMemo(()=>{const s=new Map;for(const a of C)s.set(a.prefix,a);return s},[C]),[S,P]=n.useState(null),[_,H]=n.useState("lastHeard"),[I,se]=n.useState("desc"),[v,G]=n.useState(""),[R,Q]=n.useState(!1),[b,te]=n.useState(new Set),[ae,F]=n.useState(!1),[ue,Me]=n.useState(null),[pe,Se]=n.useState(null),[Ve,he]=n.useState(new Map),[Ue,X]=n.useState(new Map),[k,We]=n.useState(25),[V,ne]=n.useState(25),fe=n.useRef(null),Y=n.useMemo(()=>(o==null?void 0:o.neighbors)??{},[o==null?void 0:o.neighbors]),ge=Ps(),re=n.useMemo(()=>{if(ge.size===0)return Y;const s=new Set;for(const t of Object.keys(Y))s.add((t.startsWith("0x")?t.slice(2):t).toLowerCase());let a=null;for(const[t,r]of ge){const i=(t.startsWith("0x")?t.slice(2):t).toLowerCase();s.has(i)||(a||(a={...Y}),a[t]={last_seen:r.lastSeen,name:r.name??void 0,node_name:r.name??void 0,latitude:r.latitude,longitude:r.longitude,is_repeater:r.nodeType==="repeater",contact_type:r.nodeType==="repeater"?"Repeater":r.nodeType==="companion"?"Companion":r.nodeType==="room_server"?"Room Server":void 0})}return a??Y},[Y,ge]),O=n.useMemo(()=>{const a=Date.now()/1e3-p.minutes*60;return Object.fromEntries(Object.entries(re).filter(([t,r])=>l.has(t)?!1:(r.last_seen??0)>=a))},[re,l,p.minutes]),L=vs(),z=o==null?void 0:o.local_hash,Ge=n.useMemo(()=>{const s=new Map;if(!z||c.size===0)return s;for(const[a,t]of c)if(a.endsWith(`→${z}`)&&t.hops.length>1){const r=a.split("→")[0],i=t.hops[t.hops.length-1];s.set(r,i)}return s},[c,z]),Qe=n.useMemo(()=>{const s=new Map;if(!z||c.size===0)return s;const a=new Map;for(const[t,r]of Object.entries(re)){const i=(t.startsWith("0x")?t.slice(2):t).toLowerCase();a.set(i,r)}for(const[t,r]of c){if(!t.endsWith(`→${z}`)||r.hops.length===0)continue;const i=t.split("→")[0],d=r.hops[0];let h=null;for(const[f,y]of a)if(f.startsWith(d.toLowerCase())){h=y.node_name??y.name??null;break}s.set(i,{prefix:d,name:h,hopCount:r.hopCount})}return s},[c,z,re]),oe=n.useMemo(()=>{const s=new Map;if(!(L!=null&&L.latitude)||!(L!=null&&L.longitude))return s;for(const[a,t]of Object.entries(O))t.latitude&&t.longitude&&t.latitude!==0&&t.longitude!==0?s.set(a,gt(L.latitude,L.longitude,t.latitude,t.longitude)):s.set(a,null);return s},[O,L]),{neighborHashSet:ce,neighborSignalMap:Xe}=n.useMemo(()=>{const s=new Set,a=new Map;for(const t of N)s.add(t.hash),a.set(t.hash,{avgRssi:t.avgRssi,avgSnr:t.avgSnr});return{neighborHashSet:s,neighborSignalMap:a}},[N]),Pe=n.useMemo(()=>{const s=v.toLowerCase().trim(),a=s==="neighbor"||s==="neighbors",t=R||a,r=b.size>0;return Object.fromEntries(Object.entries(O).filter(([i,d])=>{if(r){const y=ft(d);if(!b.has(y))return!1}if(t&&!ce.has(i))return!1;if(a||!s)return!0;const h=(d.node_name||d.name||"").toLowerCase(),f=W(i).toLowerCase();return h.includes(s)||f.includes(s)||i.toLowerCase().includes(s)}))},[O,v,R,ce,b]),x=n.useMemo(()=>{const s=Object.entries(Pe),a=v.toLowerCase().trim(),t=/^[0-9a-f]{2}(?:[0-9a-f]{2}){0,2}$/i.test(a);return s.sort(([r,i],[d,h])=>{if(t){const y=W(r).toLowerCase(),E=W(d).toLowerCase(),M=y===a,U=E===a;if(M&&!U)return-1;if(U&&!M)return 1}let f=0;switch(_){case"lastHeard":f=(i.last_seen||0)-(h.last_seen||0);break;case"distance":{const y=oe.get(r)??null,E=oe.get(d)??null;y===null&&E===null?f=0:y===null?f=1:E===null?f=-1:f=y-E;break}case"centrality":{const y=j.get(r)||0,E=j.get(d)||0;f=y-E;break}}return I==="desc"?-f:f})},[Pe,_,I,oe,j,v]),m=n.useMemo(()=>{let s=0,a=0,t=0,r=0,i=0;for(const[,d]of x){const h=ke(d),f=d.latitude&&d.longitude&&d.latitude!==0&&d.longitude!==0;switch(h.type){case"room_server":t++;break;case"repeater":a++;break;case"companion":s++;break;case"unknown":i++;break}f&&r++}return{companions:s,repeaters:a,roomServers:t,total:x.length,withLocation:r,unknown:i}},[x]),Ye=n.useMemo(()=>new Set(u),[u]),_e=n.useMemo(()=>k===0?x:x.slice(0,V),[x,V,k]);n.useEffect(()=>{ne(k||x.length)},[_,I,v,R,b,k,x.length]),n.useEffect(()=>{const s=a=>{a.target.closest("[data-dropdown]")||F(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[]),n.useEffect(()=>{if(k===0)return;const s=new IntersectionObserver(a=>{a[0].isIntersecting&&VMath.min(t+k,x.length))},{threshold:.1,rootMargin:"100px"});return fe.current&&s.observe(fe.current),()=>s.disconnect()},[k,V,x.length]);const Ze=n.useCallback(s=>{We(s),ne(s||x.length)},[x.length]),Je=n.useCallback(s=>{_===s?se(a=>a==="desc"?"asc":"desc"):(H(s),se("desc"))},[_]),Ke=n.useCallback(s=>{const a=O[s];a!=null&&a.latitude&&(a!=null&&a.longitude)&&a.latitude!==0&&a.longitude!==0&&Me(s)},[O]),es=n.useCallback(()=>{Me(null)},[]),ss=n.useCallback((s,a)=>{P({hash:s,name:a})},[]),Re=ws((Te=(Le=o==null?void 0:o.config)==null?void 0:Le.mesh)==null?void 0:Te.path_hash_mode),ts=n.useCallback(async(s,a)=>{if(a.stopPropagation(),!pe){Se(s),he(t=>{const r=new Map(t);return r.delete(s),r}),X(t=>{const r=new Map(t);return r.delete(s),r});try{const r=`0x${W(s,Re)}`,i=await Cs(r,30);i.success&&i.data?(he(d=>new Map(d).set(s,i.data)),setTimeout(()=>{he(d=>{const h=new Map(d);return h.delete(s),h})},1e4)):(X(d=>new Map(d).set(s,i.error||"Ping failed")),setTimeout(()=>{X(d=>{const h=new Map(d);return h.delete(s),h})},5e3))}catch(t){const r=t instanceof Error?t.message:"Ping failed";X(i=>new Map(i).set(s,r)),setTimeout(()=>{X(i=>{const d=new Map(i);return d.delete(s),d})},5e3)}finally{Se(null)}}},[pe,Re]);return e.jsxs(_s,{children:[e.jsx(Rs,{title:"Contacts",icon:e.jsx(ee,{}),subtitle:e.jsx($s,{}),controls:e.jsxs("div",{className:"flex items-center gap-3 sm:gap-5",children:[e.jsxs("div",{className:"hidden sm:flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Total:"}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${m.total} discovered node${m.total!==1?"s":""} on the mesh network`,children:[e.jsx(ee,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:m.total})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Types:"}),m.repeaters>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Repeaters",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-sys-blue"}),e.jsx("span",{children:m.repeaters})]}),m.companions>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Companions",children:[e.jsx($e,{className:"w-3.5 h-3.5 text-fg-muted"}),e.jsx("span",{children:m.companions})]}),m.roomServers>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Room Servers",children:[e.jsx(me,{className:"w-3.5 h-3.5 text-sys-pink"}),e.jsx("span",{children:m.roomServers})]}),m.withLocation>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"With GPS location",children:[e.jsx(Xs,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{children:m.withLocation})]}),m.unknown>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Unknown type",children:[e.jsx(De,{className:"w-3.5 h-3.5 text-sys-amber"}),e.jsx("span",{children:m.unknown})]})]})]}),e.jsxs("div",{className:"flex sm:hidden items-center gap-1.5",children:[e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(ee,{className:"w-3 h-3 text-fg-secondary"}),e.jsx("span",{children:m.total})]}),m.repeaters>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(de,{className:"w-3 h-3 text-sys-blue"}),e.jsx("span",{children:m.repeaters})]}),m.companions>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx($e,{className:"w-3 h-3 text-fg-muted"}),e.jsx("span",{children:m.companions})]}),m.roomServers>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(me,{className:"w-3 h-3 text-sys-pink"}),e.jsx("span",{children:m.roomServers})]}),e.jsx(Fe,{ranges:Ne,selectedIndex:$,onSelect:w,size:"sm"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(Fe,{ranges:Ne,selectedIndex:$,onSelect:w})})]})}),e.jsxs(Ls,{children:[e.jsx(ct,{neighbors:O,localNode:L??void 0,localHash:z,onRemoveNode:g,selectedNodeHash:ue,onNodeSelected:es}),e.jsxs(ks,{noPadding:!0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-3 sm:px-4 py-2.5 border-b border-edge-subtle",children:[e.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title flex-shrink-0",children:e.jsx(ee,{})}),e.jsx("span",{className:"type-micro flex-shrink-0 mr-auto hidden sm:block",children:"Discovered Contacts"}),e.jsx(Ms,{type:"search",size:"sm",value:v,onChange:s=>G(s.target.value),placeholder:"Search...",leadingIcon:e.jsx(Ys,{className:"w-3.5 h-3.5"}),trailingIcon:v?e.jsx("button",{onClick:()=>{G(""),(v.toLowerCase().trim()==="neighbor"||v.toLowerCase().trim()==="neighbors")&&Q(!1)},className:"text-fg-muted hover:text-fg-secondary",children:e.jsx(Ss,{className:"w-3 h-3"})}):void 0,className:"w-24 sm:w-32 xl:w-44","aria-label":"Search contacts"}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsxs("div",{className:"relative","data-dropdown":!0,children:[e.jsxs("button",{onClick:()=>F(!ae),className:ve(b.size>0,{border:!0}),title:"Filter by contact type",children:[e.jsx(at,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Filter"}),b.size>0&&e.jsx("span",{className:"tabular-nums text-xs bg-sys-blue/30 px-1 rounded",children:b.size})]}),ae&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 surface-elevated radius-inner py-1 min-w-[140px]",children:[[{key:"repeater",label:"Repeaters"},{key:"companion",label:"Companions"},{key:"room",label:"Rooms"}].map(({key:s,label:a})=>e.jsxs("button",{onClick:()=>{te(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},className:"w-full px-3 py-1.5 text-sm text-left hover-bg transition-base flex items-center gap-2",children:[e.jsx("span",{className:we("w-4 h-4 flex items-center justify-center radius-badge border",b.has(s)?"bg-sys-blue border-sys-blue text-white":"border-edge-subtle"),children:b.has(s)&&e.jsx(Ce,{className:"w-3 h-3"})}),e.jsx("span",{className:b.has(s)?"text-fg-primary":"text-fg-secondary",children:a})]},s)),b.size>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-edge-subtle my-1"}),e.jsx("button",{onClick:()=>te(new Set),className:"w-full px-3 py-1.5 text-sm text-left text-fg-muted hover:text-fg-secondary hover-bg transition-base",children:"Clear filters"})]})]})]}),ce.size>0&&e.jsxs("button",{onClick:()=>Q(!R),className:ve(R,{color:"success",border:!0}),title:R?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(de,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Neighbors"})]})]}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[pt.map(({field:s,icon:a,label:t})=>e.jsxs("button",{onClick:()=>Je(s),className:ve(_===s),title:`Sort by ${t.toLowerCase()}`,children:[e.jsx(a,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:t}),_===s&&e.jsx(Ks,{className:we("w-3 h-3",I==="asc"&&"rotate-180")})]},s)),e.jsx("div",{className:"h-4 w-px bg-border-subtle"}),e.jsxs(Ts,{value:k,onChange:Ze,className:"w-auto min-w-[50px] [&_button]:py-1 [&_button]:px-2 [&_button]:text-xs [&_button]:min-h-0","aria-label":"Items per page",children:[e.jsx(le,{value:25,children:"25"}),e.jsx(le,{value:50,children:"50"}),e.jsx(le,{value:100,children:"100"}),e.jsx(le,{value:0,children:"All"})]})]})]}),x.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden sm:grid contacts-grid-header border-b border-edge-subtle/50 px-3 py-2 type-micro text-fg-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-seen text-right",children:"Last Seen"}),e.jsx("div",{className:"contacts-col-actions"})]}),e.jsx("div",{className:"divide-y divide-edge-subtle/30",style:{contain:"layout paint"},children:_e.map(([s,a])=>{const t=W(s),r=Ye.has(s),i=ce.has(s),d=oe.get(s)??null,h=j.get(s)||0,f=i?Xe.get(s):void 0,y=t?q.get(t)??null:null,E=T.has(s),M=i?null:Qe.get(s)??null,U=Ge.get(s)??null,je=B.get(s);let Z=null;if(je&&je.length>0){const ie=je.reduce((rs,os)=>rs+os.count,0);ie>0&&(Z=ie/24)}const be=a.first_seen?Oe(a.first_seen).replace(/ ago$/i,""):null,J=[],K=[];if(M){const ie=M.name??M.prefix;J.push(`→${ie} +${M.hopCount}`),K.push(`Gateway: ${M.name??M.prefix} (${M.hopCount} hop${M.hopCount!==1?"s":""})`)}U&&(J.push(`↙${U}`),K.push(`Last forwarder: ${U}`)),Z!==null&&(J.push(`${Z<1?"<1":Math.round(Z)}/hr`),K.push(`Packet rate: ${Z.toFixed(1)}/hr`)),be&&(J.push(be),K.push(`First seen: ${be} ago`));const as=J.join(" · "),ns=K.join(` + */const nt=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],Ae=xe("ruler",nt);class rt extends n.Component{constructor(l){super(l),this.state={hasError:!1}}static getDerivedStateFromError(l){return{hasError:!0,error:l}}render(){var l;return this.state.hasError?e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"text-center text-fg-muted p-4",children:[e.jsx("p",{className:"text-lg mb-2",children:"Map failed to load"}),e.jsx("p",{className:"text-sm text-fg-muted",children:((l=this.state.error)==null?void 0:l.message)||"Unknown error"}),e.jsx("p",{className:"text-xs text-fg-muted mt-2",children:"Try refreshing the page or check your browser's WebGL support."})]})}):this.props.children}}const ot=n.lazy(()=>is(()=>import("./ContactsMapMapLibre-DlBh136H.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48]))),Ee=()=>e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"status","aria-live":"polite","aria-label":"Loading map",children:e.jsxs("div",{className:"text-fg-muted flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-sys-blue border-t-transparent rounded-full animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading map..."})]})});function ct({neighbors:o,localNode:l,localHash:g,onRemoveNode:u,selectedNodeHash:j,onNodeSelected:N,highlightedEdgeKey:c,highlightedGhost:T}){return cs()===!1?e.jsx(Ee,{}):e.jsx(rt,{children:e.jsx(n.Suspense,{fallback:e.jsx(Ee,{}),children:e.jsx(ot,{neighbors:o,localNode:l,localHash:g,onRemoveNode:u,selectedNodeHash:j,onNodeSelected:N,highlightedEdgeKey:c,highlightedGhost:T})})})}function it({hash:o,className:l="",size:g="sm",collisionInfo:u,isViterbiResolved:j}){const N=He(),c=Oe(),[T,$]=n.useState(!1),w=n.useMemo(()=>W(o),[o]),p=n.useMemo(()=>u!==void 0?u:w?N.find(P=>P.prefix===w)??null:null,[w,N,u]),C=j??(c.totalPaths>0&&c.avgPathConfidence>=.7),D=n.useCallback(P=>{P.preventDefault(),P.stopPropagation(),$(!0)},[]),B=n.useCallback(()=>{$(!1)},[]);if(!p)return null;const A=g==="sm"?"w-3.5 h-3.5":"w-4 h-4",q=C?"text-sys-cyan hover:text-sys-cyan hover:bg-sys-cyan/10 focus:ring-sys-cyan/50":"text-signal-fair hover:text-sys-indigo hover:bg-signal-fair/10 focus:ring-signal-fair/50",S=C?`Prefix conflict resolved by Viterbi HMM (${(c.avgPathConfidence*100).toFixed(0)}% confidence)`:`Prefix conflict: ${p.candidateCount} nodes share prefix "${w}"`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:D,className:`inline-flex items-center justify-center p-0.5 rounded focus:outline-none focus:ring-2 transition-colors cursor-pointer touch-manipulation ${q} ${l}`,title:S,"aria-label":`View prefix conflict for ${w}${C?" (Viterbi resolved)":""}`,children:C?e.jsxs("span",{className:"relative",children:[e.jsx(qs,{className:A}),e.jsx(Ce,{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 text-sys-green"})]}):e.jsx(st,{className:A})}),T&&e.jsx(As,{isOpen:!0,prefix:p.prefix,candidateHashes:p.candidateHashes,onClose:B})]})}const lt=n.memo(it),qe=[{target:"Contacts",fn:"name",minStage:1,when:Es},{target:"Contacts",fn:"traceLinks.directed",minStage:2,when:Hs}];Os(qe);function dt(o){return o<1e3?`${Math.round(o)}m`:`${(o/1e3).toFixed(1)}km`}function mt({hash:o,contact:l,isHub:g,isNeighbor:u,distance:j,centrality:N,neighborSignal:c,collisionInfo:T,isViterbiResolved:$,pingingHash:w,pingResult:p,pingError:C,isMobile:D,metaSummary:B,metaTooltip:A,onRowClick:q,onPing:S,onRemove:P}){Fs(qe);const _=l.latitude&&l.longitude&&l.latitude!==0&&l.longitude!==0,H=l.node_name||l.name||"Unknown",O=u&&c,se=ke(l),{isRepeater:v,isCompanion:G,isRoomServer:R,isClient:Q,label:b}=se,te=u?`${b} — Direct RF contact (zero-hop neighbor)`:`${b} — Flood routing (multi-hop via mesh)`,ae=n.useCallback(()=>q(o),[q,o]);return e.jsxs("div",{className:`contacts-grid-row ${g?"bg-sys-amber/5 border-l-2 border-l-sys-amber":""} ${_?"cursor-pointer":""}`,onClick:ae,children:[e.jsxs("div",{className:"contacts-col-node flex items-center gap-2 min-w-0",children:[O&&(c==null?void 0:c.avgSnr)!==null?e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 self-center ${ls(c.avgSnr)}`}):e.jsx("div",{className:"w-2 flex-shrink-0"}),e.jsx("div",{className:"w-6 h-6 flex items-center justify-center flex-shrink-0",title:te,children:(()=>{if(R&&v)return e.jsxs("div",{className:"relative w-5 h-5",children:[e.jsx(me,{className:"w-5 h-5 absolute inset-0 text-sys-pink"}),e.jsx(Us,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-sys-teal"})]});if(R)return e.jsx(me,{className:"w-5 h-5 text-sys-pink"});if(v)return e.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(de,{className:"w-3.5 h-3.5 text-sys-blue"})});if((G||Q)&&H!=="Unknown"){const{emoji:F,cleanName:ue}=Is(H);return e.jsx("div",{className:"w-6 h-6 clay-avatar",style:{"--avatar-color":zs(ue)},children:F?e.jsx("span",{className:"text-sm leading-none",children:F}):e.jsx("span",{className:"text-white text-[9px] font-bold tracking-tighter",children:Ds(H)})})}return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center bg-zinc-500/20",children:e.jsx(De,{className:"w-3.5 h-3.5 text-sys-amber"})})})()}),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:H,children:H}),u&&e.jsx("span",{className:"contact-tag contact-tag--nbr",children:"NBR"}),g&&e.jsx("span",{className:"contact-tag contact-tag--hub",children:"HUB"}),v&&e.jsx("span",{className:"contact-tag contact-tag--rpt",children:"RPT"}),R&&e.jsx("span",{className:"contact-tag contact-tag--room",children:"ROOM"}),G&&e.jsx("span",{className:"contact-tag contact-tag--comp",children:"COMP"}),Q&&e.jsx("span",{className:"contact-tag contact-tag--client",children:"CLIENT"}),D&&e.jsx("span",{className:"contact-tag contact-tag--mobile",children:"MOB"}),!_&&e.jsx(Ws,{className:"w-3 h-3 flex-shrink-0 text-fg-muted/50"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(ds,{copy:!0,size:"compact",truncate:[8,6],children:o}),e.jsx(lt,{hash:o,collisionInfo:T,isViterbiResolved:$}),B&&e.jsx("span",{className:"contact-meta",title:A,children:B})]})]})]}),e.jsxs("div",{className:"contacts-col-signal flex items-center justify-end gap-2",children:[O&&(c==null?void 0:c.avgRssi)!==null&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Bs,{rssi:c.avgRssi,className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Math.round(c.avgRssi)})]}),O&&(c==null?void 0:c.avgSnr)!==null&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[c.avgSnr.toFixed(1)," dB"]})]}),e.jsx("div",{className:"contacts-col-distance flex items-center justify-end gap-1 text-fg-muted",children:j!=null&&e.jsxs(e.Fragment,{children:[e.jsx(Ae,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs",children:dt(j)})]})}),e.jsx("div",{className:"contacts-col-centrality flex items-center justify-end gap-1",children:N>0&&e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-3 h-3 text-sys-indigo"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[(N*100).toFixed(0),"%"]})]})}),e.jsx("div",{className:"contacts-col-seen flex items-center justify-end",children:e.jsx("span",{className:"type-data-xs text-fg-primary whitespace-nowrap",children:l.last_seen?Ie(l.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[u&&e.jsx(e.Fragment,{children:p?e.jsxs("div",{className:`flex items-center gap-1 ${ye(p)?"text-sys-green":"text-fg-muted"}`,title:`RTT: ${p.rtt_ms.toFixed(0)}ms${ye(p)?` · SNR: ${p.snr_db.toFixed(1)}dB · RSSI: ${p.rssi}dBm`:""}`,children:[e.jsx(Ce,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs hidden sm:inline",children:ye(p)?`${p.snr_db.toFixed(1)}dB`:`${(p.rtt_ms/1e3).toFixed(1)}s`})]}):C?e.jsxs("span",{className:"text-sys-red text-xs font-medium",title:C,children:[e.jsx("span",{className:"hidden sm:inline",children:C}),e.jsx("span",{className:"sm:hidden",children:"✗"})]}):e.jsx("button",{onClick:F=>S(o,F),disabled:w!==null,className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-blue hover:bg-sys-blue/10 transition-base disabled:opacity-50 disabled:cursor-not-allowed",title:"Ping neighbor for updated signal info",children:w===o?e.jsx(ze,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(Vs,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})}),e.jsx("button",{onClick:F=>{F.stopPropagation(),P(o,H)},className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-red hover:bg-sys-red/10 transition-base",title:"Remove contact",children:e.jsx(Gs,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]})}const xt=n.memo(mt),ut=6371e3,pt=[{field:"lastHeard",icon:Ys,label:"Recent"},{field:"distance",icon:Ae,label:"Distance"},{field:"centrality",icon:Be,label:"Centrality"}];function ht(o){switch(o){case"room_server":return"room";case"repeater":return"repeater";case"companion":return"companion";case"unknown":return"companion"}}function ft(o){const l=ke(o);return ht(l.type)}function ve(o,l){const{color:g="primary",border:u=!1}=l??{};return we("flex items-center gap-1.5 px-2 py-1.5 text-sm radius-inner transition-base",o?g==="success"?"bg-sys-green/20 text-sys-green":"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary hover-bg",u&&(o?g==="success"?"border border-sys-green/30":"border border-sys-blue/30":"border border-transparent"))}function gt(o,l,g,u){const j=(g-o)*Math.PI/180,N=(u-l)*Math.PI/180,c=Math.sin(j/2)*Math.sin(j/2)+Math.cos(o*Math.PI/180)*Math.cos(g*Math.PI/180)*Math.sin(N/2)*Math.sin(N/2),T=2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c));return ut*T}function jt(){var Le,Te;const{stats:o}=ms(),l=xs(),g=us(),u=ps(),j=hs(),N=fs(),c=gs(),T=js(),$=bs(),w=ys(),p=Ne[$],C=He(),D=Oe(),B=Ns(),A=D.totalPaths>0&&D.avgPathConfidence>=.7,q=n.useMemo(()=>{const s=new Map;for(const a of C)s.set(a.prefix,a);return s},[C]),[S,P]=n.useState(null),[_,H]=n.useState("lastHeard"),[O,se]=n.useState("desc"),[v,G]=n.useState(""),[R,Q]=n.useState(!1),[b,te]=n.useState(new Set),[ae,F]=n.useState(!1),[ue,Me]=n.useState(null),[pe,Se]=n.useState(null),[Ve,he]=n.useState(new Map),[Ue,J]=n.useState(new Map),[k,We]=n.useState(25),[V,ne]=n.useState(25),fe=n.useRef(null),X=n.useMemo(()=>(o==null?void 0:o.neighbors)??{},[o==null?void 0:o.neighbors]),ge=Ps(),re=n.useMemo(()=>{if(ge.size===0)return X;const s=new Set;for(const t of Object.keys(X))s.add((t.startsWith("0x")?t.slice(2):t).toLowerCase());let a=null;for(const[t,r]of ge){const i=(t.startsWith("0x")?t.slice(2):t).toLowerCase();s.has(i)||(a||(a={...X}),a[t]={last_seen:r.lastSeen,name:r.name??void 0,node_name:r.name??void 0,latitude:r.latitude,longitude:r.longitude,is_repeater:r.nodeType==="repeater",contact_type:r.nodeType==="repeater"?"Repeater":r.nodeType==="companion"?"Companion":r.nodeType==="room_server"?"Room Server":void 0})}return a??X},[X,ge]),I=n.useMemo(()=>{const a=Date.now()/1e3-p.minutes*60;return Object.fromEntries(Object.entries(re).filter(([t,r])=>l.has(t)?!1:(r.last_seen??0)>=a))},[re,l,p.minutes]),L=vs(),z=o==null?void 0:o.local_hash,Ge=n.useMemo(()=>{const s=new Map;if(!z||c.size===0)return s;for(const[a,t]of c)if(a.endsWith(`→${z}`)&&t.hops.length>1){const r=a.split("→")[0],i=t.hops[t.hops.length-1];s.set(r,i)}return s},[c,z]),Qe=n.useMemo(()=>{const s=new Map;if(!z||c.size===0)return s;const a=new Map;for(const[t,r]of Object.entries(re)){const i=(t.startsWith("0x")?t.slice(2):t).toLowerCase();a.set(i,r)}for(const[t,r]of c){if(!t.endsWith(`→${z}`)||r.hops.length===0)continue;const i=t.split("→")[0],d=r.hops[0];let h=null;for(const[f,y]of a)if(f.startsWith(d.toLowerCase())){h=y.node_name??y.name??null;break}s.set(i,{prefix:d,name:h,hopCount:r.hopCount})}return s},[c,z,re]),oe=n.useMemo(()=>{const s=new Map;if(!(L!=null&&L.latitude)||!(L!=null&&L.longitude))return s;for(const[a,t]of Object.entries(I))t.latitude&&t.longitude&&t.latitude!==0&&t.longitude!==0?s.set(a,gt(L.latitude,L.longitude,t.latitude,t.longitude)):s.set(a,null);return s},[I,L]),{neighborHashSet:ce,neighborSignalMap:Je}=n.useMemo(()=>{const s=new Set,a=new Map;for(const t of N)s.add(t.hash),a.set(t.hash,{avgRssi:t.avgRssi,avgSnr:t.avgSnr});return{neighborHashSet:s,neighborSignalMap:a}},[N]),Pe=n.useMemo(()=>{const s=v.toLowerCase().trim(),a=s==="neighbor"||s==="neighbors",t=R||a,r=b.size>0;return Object.fromEntries(Object.entries(I).filter(([i,d])=>{if(r){const y=ft(d);if(!b.has(y))return!1}if(t&&!ce.has(i))return!1;if(a||!s)return!0;const h=(d.node_name||d.name||"").toLowerCase(),f=W(i).toLowerCase();return h.includes(s)||f.includes(s)||i.toLowerCase().includes(s)}))},[I,v,R,ce,b]),x=n.useMemo(()=>{const s=Object.entries(Pe),a=v.toLowerCase().trim(),t=/^[0-9a-f]{2}(?:[0-9a-f]{2}){0,2}$/i.test(a);return s.sort(([r,i],[d,h])=>{if(t){const y=W(r).toLowerCase(),E=W(d).toLowerCase(),M=y===a,U=E===a;if(M&&!U)return-1;if(U&&!M)return 1}let f=0;switch(_){case"lastHeard":f=(i.last_seen||0)-(h.last_seen||0);break;case"distance":{const y=oe.get(r)??null,E=oe.get(d)??null;y===null&&E===null?f=0:y===null?f=1:E===null?f=-1:f=y-E;break}case"centrality":{const y=j.get(r)||0,E=j.get(d)||0;f=y-E;break}}return O==="desc"?-f:f})},[Pe,_,O,oe,j,v]),m=n.useMemo(()=>{let s=0,a=0,t=0,r=0,i=0;for(const[,d]of x){const h=ke(d),f=d.latitude&&d.longitude&&d.latitude!==0&&d.longitude!==0;switch(h.type){case"room_server":t++;break;case"repeater":a++;break;case"companion":s++;break;case"unknown":i++;break}f&&r++}return{companions:s,repeaters:a,roomServers:t,total:x.length,withLocation:r,unknown:i}},[x]),Xe=n.useMemo(()=>new Set(u),[u]),_e=n.useMemo(()=>k===0?x:x.slice(0,V),[x,V,k]);n.useEffect(()=>{ne(k||x.length)},[_,O,v,R,b,k,x.length]),n.useEffect(()=>{const s=a=>{a.target.closest("[data-dropdown]")||F(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[]),n.useEffect(()=>{if(k===0)return;const s=new IntersectionObserver(a=>{a[0].isIntersecting&&VMath.min(t+k,x.length))},{threshold:.1,rootMargin:"100px"});return fe.current&&s.observe(fe.current),()=>s.disconnect()},[k,V,x.length]);const Ye=n.useCallback(s=>{We(s),ne(s||x.length)},[x.length]),Ze=n.useCallback(s=>{_===s?se(a=>a==="desc"?"asc":"desc"):(H(s),se("desc"))},[_]),Ke=n.useCallback(s=>{const a=I[s];a!=null&&a.latitude&&(a!=null&&a.longitude)&&a.latitude!==0&&a.longitude!==0&&Me(s)},[I]),es=n.useCallback(()=>{Me(null)},[]),ss=n.useCallback((s,a)=>{P({hash:s,name:a})},[]),Re=ws((Te=(Le=o==null?void 0:o.config)==null?void 0:Le.mesh)==null?void 0:Te.path_hash_mode),ts=n.useCallback(async(s,a)=>{if(a.stopPropagation(),!pe){Se(s),he(t=>{const r=new Map(t);return r.delete(s),r}),J(t=>{const r=new Map(t);return r.delete(s),r});try{const r=`0x${W(s,Re)}`,i=await Cs(r,30);i.success&&i.data?(he(d=>new Map(d).set(s,i.data)),setTimeout(()=>{he(d=>{const h=new Map(d);return h.delete(s),h})},1e4)):(J(d=>new Map(d).set(s,i.error||"Ping failed")),setTimeout(()=>{J(d=>{const h=new Map(d);return h.delete(s),h})},5e3))}catch(t){const r=t instanceof Error?t.message:"Ping failed";J(i=>new Map(i).set(s,r)),setTimeout(()=>{J(i=>{const d=new Map(i);return d.delete(s),d})},5e3)}finally{Se(null)}}},[pe,Re]);return e.jsxs(_s,{children:[e.jsx(Rs,{title:"Contacts",icon:e.jsx(ee,{}),subtitle:e.jsx($s,{}),controls:e.jsxs("div",{className:"flex items-center gap-3 sm:gap-5",children:[e.jsxs("div",{className:"hidden sm:flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Total:"}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${m.total} discovered node${m.total!==1?"s":""} on the mesh network`,children:[e.jsx(ee,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:m.total})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Types:"}),m.repeaters>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Repeaters",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-sys-blue"}),e.jsx("span",{children:m.repeaters})]}),m.companions>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Companions",children:[e.jsx($e,{className:"w-3.5 h-3.5 text-fg-muted"}),e.jsx("span",{children:m.companions})]}),m.roomServers>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Room Servers",children:[e.jsx(me,{className:"w-3.5 h-3.5 text-sys-pink"}),e.jsx("span",{children:m.roomServers})]}),m.withLocation>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"With GPS location",children:[e.jsx(Js,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{children:m.withLocation})]}),m.unknown>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Unknown type",children:[e.jsx(De,{className:"w-3.5 h-3.5 text-sys-amber"}),e.jsx("span",{children:m.unknown})]})]})]}),e.jsxs("div",{className:"flex sm:hidden items-center gap-1.5",children:[e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(ee,{className:"w-3 h-3 text-fg-secondary"}),e.jsx("span",{children:m.total})]}),m.repeaters>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(de,{className:"w-3 h-3 text-sys-blue"}),e.jsx("span",{children:m.repeaters})]}),m.companions>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx($e,{className:"w-3 h-3 text-fg-muted"}),e.jsx("span",{children:m.companions})]}),m.roomServers>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(me,{className:"w-3 h-3 text-sys-pink"}),e.jsx("span",{children:m.roomServers})]}),e.jsx(Fe,{ranges:Ne,selectedIndex:$,onSelect:w,size:"sm"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(Fe,{ranges:Ne,selectedIndex:$,onSelect:w})})]})}),e.jsxs(Ls,{children:[e.jsx(ct,{neighbors:I,localNode:L??void 0,localHash:z,onRemoveNode:g,selectedNodeHash:ue,onNodeSelected:es}),e.jsxs(ks,{noPadding:!0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-3 sm:px-4 py-2.5 border-b border-edge-subtle",children:[e.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title flex-shrink-0",children:e.jsx(ee,{})}),e.jsx("span",{className:"type-micro flex-shrink-0 mr-auto hidden sm:block",children:"Discovered Contacts"}),e.jsx(Ms,{type:"search",size:"sm",value:v,onChange:s=>G(s.target.value),placeholder:"Search...",leadingIcon:e.jsx(Xs,{className:"w-3.5 h-3.5"}),trailingIcon:v?e.jsx("button",{onClick:()=>{G(""),(v.toLowerCase().trim()==="neighbor"||v.toLowerCase().trim()==="neighbors")&&Q(!1)},className:"text-fg-muted hover:text-fg-secondary",children:e.jsx(Ss,{className:"w-3 h-3"})}):void 0,className:"w-24 sm:w-32 xl:w-44","aria-label":"Search contacts"}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsxs("div",{className:"relative","data-dropdown":!0,children:[e.jsxs("button",{onClick:()=>F(!ae),className:ve(b.size>0,{border:!0}),title:"Filter by contact type",children:[e.jsx(at,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Filter"}),b.size>0&&e.jsx("span",{className:"tabular-nums text-xs bg-sys-blue/30 px-1 rounded",children:b.size})]}),ae&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 surface-elevated radius-inner py-1 min-w-[140px]",children:[[{key:"repeater",label:"Repeaters"},{key:"companion",label:"Companions"},{key:"room",label:"Rooms"}].map(({key:s,label:a})=>e.jsxs("button",{onClick:()=>{te(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},className:"w-full px-3 py-1.5 text-sm text-left hover-bg transition-base flex items-center gap-2",children:[e.jsx("span",{className:we("w-4 h-4 flex items-center justify-center radius-badge border",b.has(s)?"bg-sys-blue border-sys-blue text-white":"border-edge-subtle"),children:b.has(s)&&e.jsx(Ce,{className:"w-3 h-3"})}),e.jsx("span",{className:b.has(s)?"text-fg-primary":"text-fg-secondary",children:a})]},s)),b.size>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-edge-subtle my-1"}),e.jsx("button",{onClick:()=>te(new Set),className:"w-full px-3 py-1.5 text-sm text-left text-fg-muted hover:text-fg-secondary hover-bg transition-base",children:"Clear filters"})]})]})]}),ce.size>0&&e.jsxs("button",{onClick:()=>Q(!R),className:ve(R,{color:"success",border:!0}),title:R?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(de,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Neighbors"})]})]}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[pt.map(({field:s,icon:a,label:t})=>e.jsxs("button",{onClick:()=>Ze(s),className:ve(_===s),title:`Sort by ${t.toLowerCase()}`,children:[e.jsx(a,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:t}),_===s&&e.jsx(Ks,{className:we("w-3 h-3",O==="asc"&&"rotate-180")})]},s)),e.jsx("div",{className:"h-4 w-px bg-border-subtle"}),e.jsxs(Ts,{value:k,onChange:Ye,className:"w-auto min-w-[50px] [&_button]:py-1 [&_button]:px-2 [&_button]:text-xs [&_button]:min-h-0","aria-label":"Items per page",children:[e.jsx(le,{value:25,children:"25"}),e.jsx(le,{value:50,children:"50"}),e.jsx(le,{value:100,children:"100"}),e.jsx(le,{value:0,children:"All"})]})]})]}),x.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden sm:grid contacts-grid-header border-b border-edge-subtle/50 px-3 py-2 type-micro text-fg-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-seen text-right",children:"Last Seen"}),e.jsx("div",{className:"contacts-col-actions"})]}),e.jsx("div",{className:"divide-y divide-edge-subtle/30",style:{contain:"layout paint"},children:_e.map(([s,a])=>{const t=W(s),r=Xe.has(s),i=ce.has(s),d=oe.get(s)??null,h=j.get(s)||0,f=i?Je.get(s):void 0,y=t?q.get(t)??null:null,E=T.has(s),M=i?null:Qe.get(s)??null,U=Ge.get(s)??null,je=B.get(s);let Y=null;if(je&&je.length>0){const ie=je.reduce((rs,os)=>rs+os.count,0);ie>0&&(Y=ie/24)}const be=a.first_seen?Ie(a.first_seen).replace(/ ago$/i,""):null,Z=[],K=[];if(M){const ie=M.name??M.prefix;Z.push(`→${ie} +${M.hopCount}`),K.push(`Gateway: ${M.name??M.prefix} (${M.hopCount} hop${M.hopCount!==1?"s":""})`)}U&&(Z.push(`↙${U}`),K.push(`Last forwarder: ${U}`)),Y!==null&&(Z.push(`${Y<1?"<1":Math.round(Y)}/hr`),K.push(`Packet rate: ${Y.toFixed(1)}/hr`)),be&&(Z.push(be),K.push(`First seen: ${be} ago`));const as=Z.join(" · "),ns=K.join(` `);return e.jsx(xt,{hash:s,contact:a,isHub:r,isNeighbor:i,distance:d,centrality:h,neighborSignal:f,collisionInfo:y,isViterbiResolved:A,pingingHash:pe,pingResult:Ve.get(s),pingError:Ue.get(s),isMobile:E,metaSummary:as,metaTooltip:ns,onRowClick:Ke,onPing:ts,onRemove:ss},s)})}),k>0&&V0&&Vne(s=>Math.min(s+k,x.length)),className:"text-sys-blue hover:text-sys-blue/80 transition-base",children:"Load more"})]})]}):e.jsxs("div",{className:"roster-empty",children:[e.jsx(ee,{className:"roster-empty-icon"}),e.jsx("div",{className:"type-label text-fg-secondary",children:"No Contacts Discovered"}),e.jsx("div",{className:"type-data-xs text-fg-muted mt-1",children:"Contacts will appear here as they advertise on the mesh network."})]})]})]}),e.jsx(Qs,{isOpen:!!S,title:"Remove Contact",message:`Remove ${(S==null?void 0:S.name)||"this contact"} from the contacts list? The node will reappear if it advertises again.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{S&&g(S.hash),P(null)},onCancel:()=>P(null)})]})}const zt=Object.freeze(Object.defineProperty({__proto__:null,default:jt},Symbol.toStringTag,{value:"Module"}));export{zt as C,lt as P,Ae as R}; diff --git a/frontend/dist/assets/ContactsMapMapLibre-CnXabSF9.js b/frontend/dist/assets/ContactsMapMapLibre-DlBh136H.js similarity index 99% rename from frontend/dist/assets/ContactsMapMapLibre-CnXabSF9.js rename to frontend/dist/assets/ContactsMapMapLibre-DlBh136H.js index 4c2eef63..4e08cd45 100644 --- a/frontend/dist/assets/ContactsMapMapLibre-CnXabSF9.js +++ b/frontend/dist/assets/ContactsMapMapLibre-DlBh136H.js @@ -1,4 +1,4 @@ -import{e as Sr,an as xa,r as j,gz as wa,cu as va,dp as ba,dq as ka,j as m,aC as Co,dr as Ca,aD as Eo,m as Jt,a0 as Wn,dK as So,c as Cn,a2 as Z0,O as lr,Z as vn,gA as q0,gB as Mo,gC as Ea,cj as Sa,cq as Ma,cs as Ba,dV as Bo,ap as Do,aE as _o,d as Cr,b as En,B as Nt,dG as Da,cl as ms,E as Gs,S as Us,dx as To,t as jo,c$ as Ro,aa as Io,bM as Sn,bI as xi,gD as Lo,Q as _a,a6 as Ta,dF as ja,gE as Ra,az as No,bT as wi,bV as Ia,a1 as J0,a3 as X0,cn as La,b9 as Na,f1 as Fo,gF as Fa,gG as Pa,dH as Qa,dI as Oa,gH as za,gI as Ha,aR as Po,V as gt,gJ as Ga,gK as Qo,gL as Ua,ao as Er,bP as Oo,dw as Va,gM as zo,gN as Ho,cb as Wa,gx as Ya,ce as $a,du as Go,dy as Ka,ab as Za,gO as qa,fd as Ja,gP as ps,ga as Xa,fJ as Au,gQ as eu}from"./index-C2xvS0Jd.js";import{u as Or,S as Qr,L as qt,M as tu,b as ru}from"./maplibre-gl-C9QYi5T6.js";import{u as Uo,r as Vo,e as vi,f as bi,g as nu}from"./consumer-registry-DJyYnY6J.js";import{L as U0,c as su}from"./link-scoring-BjtZpDDb.js";import{C as iu}from"./ConfirmModal-eC-cl0ep.js";import{s as ou,a as lu,M as au}from"./variants-cyDnzhWy.js";import{G as Ms}from"./git-branch-BhoB5t-Q.js";import{D as uu}from"./database-cyku2KnA.js";import{H as cu,A as g0,D as ki,p as fu,c as hu,u as mn}from"./useMapViewStore-DnPjO7Qt.js";import{E as Wo}from"./target-BpFOYbOg.js";import{F as du}from"./funnel-DGVJFdsh.js";import{P as mu}from"./plus-CH14Vv92.js";import{C as pu}from"./compass-D_q1TimF.js";import{Z as gu}from"./zap-v3FkQoQ-.js";import{b as yu,e as xu,a as Yo,m as Ci,E as wu,u as vu,G as bu,g as ku,d as Cu,f as Eu}from"./max-BBb5g8bL.js";import{T as Su}from"./trash-2-Def3YmfN.js";import{W as Mu}from"./wifi-off-omfJv-eS.js";import{W as Bu}from"./wifi-Bc9OxL0c.js";import{C as Du}from"./circle-alert-kdR_gb55.js";import{C as $o}from"./clock-DU0z3qMB.js";import{C as _u}from"./chevron-right-C9GG0xWI.js";import{u as Vs,a as Ko,b as Zo,c as Tu,d as ju,e as Ws,f as Ei,R as Ru,g as Iu,h as qo,t as Lu,i as Nu,j as Fu,k as Pu}from"./useReplayTick-DbeD1_Sw.js";import{L as Qu}from"./LightSparkline-Dtyxi9BD.js";import{P as Jo,R as Ou}from"./Contacts-CTRl8l-x.js";import{H as Y0,C as ar,N as zu,a as Hu}from"./badge-colors-Dl76Mz8m.js";import{M as Gu}from"./map-pin-CQk00ph2.js";import{c as Si}from"./node-types-BD70swWz.js";import{B as Uu}from"./BasemapLayer-DQCsZLc0.js";import{a as Xo,b as Bs,c as Vu}from"./easing-2tSIucrJ.js";import"./index-QCPybZMd.js";import"./index-wtt5rE5a.js";import"./payload-detail-BAEvS7Pl.js";import"./usePipelineStore-Do-g28wv.js";import"./PageLayout-Cg7r5tdt.js";import"./listbox-DnHpTyQt.js";import"./element-movement-CSQuYFsD.js";import"./use-text-value-CU5Ho7TY.js";import"./frozen-Cx4cJH6f.js";import"./MqttModeBadge-DOXwpg3i.js";import"./chat-utils-DnJ-lYj3.js";import"./SignalIndicator-DO8Lkax5.js";import"./CollisionExplorerModal-Du9NEbAu.js";import"./share-2-DLfTr0kI.js";import"./circle-question-mark-CF3fGjhH.js";import"./map-pin-off-D8fZRJ6M.js";import"./activity-BFfde9uG.js";import"./search-DPGHPI2q.js";/** +import{e as Sr,an as xa,r as j,gz as wa,cv as va,dq as ba,dr as ka,j as m,aC as Co,ds as Ca,aD as Eo,m as Jt,a0 as Wn,aE as So,c as Cn,a2 as Z0,O as lr,Z as vn,gA as q0,gB as Mo,gC as Ea,ck as Sa,cr as Ma,ct as Ba,dV as Bo,ap as Do,aF as _o,d as Cr,b as En,B as Nt,dH as Da,cm as ms,E as Gs,S as Us,dy as To,t as jo,d0 as Ro,aa as Io,bN as Sn,bJ as xi,gD as Lo,Q as _a,a6 as Ta,dG as ja,gE as Ra,az as No,bU as wi,bW as Ia,a1 as J0,a3 as X0,co as La,ba as Na,f1 as Fo,gF as Fa,gG as Pa,dI as Qa,dJ as Oa,gH as za,gI as Ha,aS as Po,V as gt,gJ as Ga,gK as Qo,gL as Ua,ao as Er,bQ as Oo,dx as Va,gM as zo,gN as Ho,cc as Wa,gx as Ya,cf as $a,dv as Go,dz as Ka,ab as Za,gO as qa,fd as Ja,gP as ps,ga as Xa,fJ as Au,gQ as eu}from"./index-D33fcA3L.js";import{u as Or,S as Qr,L as qt,M as tu,b as ru}from"./maplibre-gl-B42P8ehE.js";import{u as Uo,r as Vo,e as vi,f as bi,g as nu}from"./consumer-registry-DXaeZxMm.js";import{L as U0,c as su}from"./link-scoring-Chr3N5ba.js";import{C as iu}from"./ConfirmModal-J2_Sxirm.js";import{s as ou,a as lu,M as au}from"./variants-ByRhxIcL.js";import{G as Ms}from"./git-branch-Ryinnbc1.js";import{D as uu}from"./database-Bm4-qoOy.js";import{H as cu,A as g0,D as ki,p as fu,c as hu,u as mn}from"./useMapViewStore-Ey8vE9rr.js";import{E as Wo}from"./target-B3CHoIpd.js";import{F as du}from"./funnel-BBIwSMOb.js";import{P as mu}from"./plus-C0dCjBh9.js";import{C as pu}from"./compass-CncUthiD.js";import{Z as gu}from"./zap-C-Mue2DZ.js";import{b as yu,e as xu,a as Yo,m as Ci,E as wu,u as vu,G as bu,g as ku,d as Cu,f as Eu}from"./max-CkBnBUwN.js";import{T as Su}from"./trash-2-CUY4NG5t.js";import{W as Mu}from"./wifi-off-BQtV63nI.js";import{W as Bu}from"./wifi-D716s0ef.js";import{C as Du}from"./circle-alert-BgZmhbSe.js";import{C as $o}from"./clock-D_m2QiHa.js";import{C as _u}from"./chevron-right-D4kUPDBw.js";import{u as Vs,a as Ko,b as Zo,c as Tu,d as ju,e as Ws,f as Ei,R as Ru,g as Iu,h as qo,t as Lu,i as Nu,j as Fu,k as Pu}from"./useReplayTick-BbXJoz75.js";import{L as Qu}from"./LightSparkline-r3FtGEtW.js";import{P as Jo,R as Ou}from"./Contacts-2M50JufT.js";import{H as Y0,C as ar,N as zu,a as Hu}from"./badge-colors-Dl76Mz8m.js";import{M as Gu}from"./map-pin-B_Rx-xpd.js";import{c as Si}from"./node-types-BoqnL0Eg.js";import{B as Uu}from"./BasemapLayer-DhvtWc_h.js";import{a as Xo,b as Bs,c as Vu}from"./easing-D0twVjny.js";import"./index-5slIee7x.js";import"./index-DuiHY5wq.js";import"./payload-detail-DbnSd5NL.js";import"./usePipelineStore-DDHEHTlZ.js";import"./PageLayout-CRN-E5xi.js";import"./listbox-DkfYDEqr.js";import"./element-movement-BL6huHzq.js";import"./use-text-value-iYUkduzo.js";import"./frozen-C10EXZ59.js";import"./MqttModeBadge-BtcQeS2v.js";import"./chat-utils-DIy1-SG1.js";import"./SignalIndicator-DmWlnzMv.js";import"./CollisionExplorerModal-P8ZOhB65.js";import"./share-2-BAsDxZE2.js";import"./circle-question-mark-CO80vHQp.js";import"./map-pin-off-V0MBukP5.js";import"./activity-D6ySIfuC.js";import"./search-DN8guzpX.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/Dashboard-Bn3hcO_4.js b/frontend/dist/assets/Dashboard-Bn3hcO_4.js new file mode 100644 index 00000000..10e27a1c --- /dev/null +++ b/frontend/dist/assets/Dashboard-Bn3hcO_4.js @@ -0,0 +1,69 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-D33fcA3L.js","assets/index-7uzBcJ1E.css"])))=>i.map(i=>d[i]); +import{e as Z,f as bs,h as Dt,k as Rt,J as js,n as ws,o as Ns,p as Ee,q as vs,r as f,M as ks,t as Ms,_ as st,v as nt,w as At,x as Lt,y as Cs,z as te,D as Ts,j as t,d as Ke,m as ge,S as Pt,E as $t,U as Ss,F as _s,G as Le,P as Bs,H as Ds,K as Q,L as Rs,N as As,O as J,Q as we,R as Ft,T as Et,V as ne,W as Ls,X as Ps,Y as je,$ as $s,a0 as at,a1 as Fs,a2 as Pe,a3 as Es,a4 as Is,a5 as Hs,a6 as ie,a7 as It,a8 as Ht,a9 as zs,B as $e,aa as zt,ab as Ot,ac as Os,ad as Ne,ae as ee,af as Gt,ag as Wt,ah as Gs,ai as Ws,aj as qs,ak as Us,al as Xs,am as Ie,u as qt,an as Vs,ao as ot,ap as me,aq as Me,ar as Ut,as as Ys,at as Ce,au as Js,av as Zs,aw as Ks,ax as rt,ay as Qs,c as Y,az as en,aA as Xt,aB as it,aC as Vt,aD as Yt,aE as tn,aF as sn,aG as ve,aH as nn,aI as an,aJ as on,aK as Qe,aL as rn,aM as Jt,aN as Zt,aO as ln,aP as cn,Z as lt,aQ as dn,aR as un,aS as mn,aT as ct}from"./index-D33fcA3L.js";import{C as dt,P as fn,a as pn,B as hn}from"./PageLayout-CRN-E5xi.js";import{u as fe,r as pe,h as xn,a as gn,b as yn,i as bn}from"./consumer-registry-DXaeZxMm.js";import{A as re,D as Ye}from"./DataValue-B0xdrk88.js";import{c as jn}from"./node-types-BoqnL0Eg.js";import{b as Kt,c as ye,a as wn,d as Nn,F as Te}from"./meshcore-tx-constants-DgpFTAmf.js";import{S as vn,u as Je,P as kn,T as Mn,C as Qt}from"./PacketList-CbRsdi2q.js";import{useGetDecodedContent as Cn,useResolveSource as Tn}from"./usePipelineStore-DDHEHTlZ.js";import{A as ut}from"./arrow-right-aT_K-Mjc.js";import{T as es,M as Sn}from"./MqttModeBadge-BtcQeS2v.js";import{L as ts}from"./LightSparkline-r3FtGEtW.js";import{c as _n}from"./link-scoring-Chr3N5ba.js";import{Z as Bn}from"./zap-C-Mue2DZ.js";import{A as Dn,N as Rn}from"./AutoConfigureDialog-CDgcxIyE.js";import{g as An,e as He,a as Ln,f as Pn}from"./chat-utils-DIy1-SG1.js";import{C as $n}from"./ChatBubble-BqRoJxSW.js";import{M as ss}from"./message-square-text-DlzXvsDV.js";import{C as mt}from"./chevron-right-D4kUPDBw.js";import{H as Fn}from"./hash-Ba9bZo8v.js";import{M as En}from"./message-square-DFs8_yFI.js";import{S as In}from"./shield-check-DOoXovft.js";import{W as Hn}from"./wand-sparkles-CEbXzjVw.js";import{u as ue}from"./index-5slIee7x.js";import{H as zn}from"./useMapViewStore-Ey8vE9rr.js";import{R as ft}from"./Grid-DQYUnZsY.js";import"./chevron-up-DyOgmQ5-.js";import"./primitives-C8YoaXqf.js";import"./badge-colors-Dl76Mz8m.js";import"./SignalIndicator-DmWlnzMv.js";import"./arrow-up-C4DdHKHn.js";import"./arrow-down-BI9NpupK.js";import"./payload-detail-DbnSd5NL.js";import"./map-pin-B_Rx-xpd.js";import"./circle-question-mark-CO80vHQp.js";import"./layers-DguV5fdN.js";import"./clock-D_m2QiHa.js";import"./route-5o9tQENO.js";import"./activity-D6ySIfuC.js";import"./database-Bm4-qoOy.js";import"./shield-Ceq641wy.js";import"./index-DuiHY5wq.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 On=[["path",{d:"M15 11a1 1 0 0 0 1 1h2.939a1 1 0 0 1 .75 1.811l-6.835 6.836a1.207 1.207 0 0 1-1.707 0L4.31 13.81a1 1 0 0 1 .75-1.811H8a1 1 0 0 0 1-1V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1z",key:"1eaqc3"}]],pt=Z("arrow-big-down",On);/** + * @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 Gn=[["path",{d:"M9 13a1 1 0 0 0-1-1H5.061a1 1 0 0 1-.75-1.811l6.836-6.835a1.207 1.207 0 0 1 1.707 0l6.835 6.835a1 1 0 0 1-.75 1.811H16a1 1 0 0 0-1 1v6a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1z",key:"lh0v7k"}]],ht=Z("arrow-big-up",Gn);/** + * @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 Wn=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],ns=Z("chart-column",Wn);/** + * @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 qn=[["line",{x1:"12",x2:"18",y1:"12",y2:"18",key:"1rg63v"}],["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Un=Z("copy-x",qn);/** + * @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 Xn=[["path",{d:"m21.12 6.4-6.05-4.06a2 2 0 0 0-2.17-.05L2.95 8.41a2 2 0 0 0-.95 1.7v5.82a2 2 0 0 0 .88 1.66l6.05 4.07a2 2 0 0 0 2.17.05l9.95-6.12a2 2 0 0 0 .95-1.7V8.06a2 2 0 0 0-.88-1.66Z",key:"1u2ovd"}],["path",{d:"M10 22v-8L2.25 9.15",key:"11pn4q"}],["path",{d:"m10 14 11.77-6.87",key:"1kt1wh"}]],Vn=Z("cuboid",Xn);/** + * @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 Yn=[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]],as=Z("ear",Yn);/** + * @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 Jn=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],Zn=Z("megaphone",Jn);/** + * @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 Kn=[["path",{d:"M18 11h-4a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h4",key:"17ldeb"}],["path",{d:"M6 7v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7",key:"nc37y6"}],["rect",{width:"16",height:"5",x:"4",y:"2",rx:"1",key:"3jeezo"}]],Qn=Z("pill-bottle",Kn);/** + * @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 ea=[["path",{d:"M4 10a7.31 7.31 0 0 0 10 10Z",key:"1fzpp3"}],["path",{d:"m9 15 3-3",key:"88sc13"}],["path",{d:"M17 13a6 6 0 0 0-6-6",key:"15cc6u"}],["path",{d:"M21 13A10 10 0 0 0 11 3",key:"11nf8s"}]],ta=Z("satellite-dish",ea);/** + * @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 sa=[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]],os=Z("skull",sa);/** + * @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 na=[["circle",{cx:"7",cy:"7",r:"5",key:"x29byf"}],["circle",{cx:"17",cy:"17",r:"5",key:"1op1d2"}],["path",{d:"M12 17h10",key:"ls21zv"}],["path",{d:"m3.46 10.54 7.08-7.08",key:"1rehiu"}]],aa=Z("tablets",na);/** + * @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 oa=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],ra=Z("timer",oa);function ia(...e){const n=!Array.isArray(e[0]),o=n?0:-1,s=e[0+o],r=e[1+o],a=e[2+o],c=e[3+o],i=bs(r,a,c);return n?i(s):i}function la(e,n,o={}){const s=e.get();let r=null,a=s,c;const i=typeof s=="string"?s.replace(/[\d.-]/g,""):void 0,d=()=>{r&&(r.stop(),r=null)},u=()=>{d();const m=gt(e.get()),w=gt(a);m!==w&&(r=new js({keyframes:[m,w],velocity:e.getVelocity(),type:"spring",restDelta:.001,restSpeed:.01,...o,onUpdate:c}))};if(e.attach((m,w)=>{a=m,c=l=>w(xt(l,i)),Dt.postRender(()=>{var l;u(),(l=e.events.animationStart)==null||l.notify(),r==null||r.then(()=>{var x;(x=e.events.animationComplete)==null||x.notify()})})},d),Rt(n)){const m=n.on("change",l=>e.set(xt(l,i))),w=e.on("destroy",m);return()=>{m(),w()}}return d}function xt(e,n){return n?e+n:e}function gt(e){return typeof e=="number"?e:parseFloat(e)}function rs(e,n){const o=ue(n()),s=()=>o.set(n());return s(),ws(()=>{const r=()=>Dt.preRender(s,!1,!0),a=e.map(c=>c.on("change",r));return()=>{a.forEach(c=>c()),Ns(s)}}),o}function ca(e){Ee.current=[],e();const n=rs(Ee.current,e);return Ee.current=void 0,n}function da(e,n,o,s){if(typeof e=="function")return ca(e);const a=ia(n,o,s);return Array.isArray(e)?yt(e,a):yt([e],([c])=>a(c))}function yt(e,n){const o=vs(()=>[]);return rs(e,()=>{o.length=0;const s=e.length;for(let r=0;rRt(e)?e.get():e;if(o)return da(s);const r=ue(s());return f.useInsertionEffect(()=>la(r,e,n),[r,JSON.stringify(n)]),r}function Se(e,n={}){return ua(e,{type:"spring",...n})}const oe=Ms(()=>({result:null,isComputing:!1})),ma=500,fa=300;let ce=null,_e=null;function pa(e){var o;const n=(o=e==null?void 0:e.config)==null?void 0:o.radio;return`${(n==null?void 0:n.spreading_factor)??7}:${(n==null?void 0:n.bandwidth)??125e3}:${(n==null?void 0:n.coding_rate)??5}:${(n==null?void 0:n.preamble_length)??8}`}function ha(){if(ce)return ce;if(typeof window>"u")return null;try{ce=new Worker(new URL("/assets/dashboard-bucketing.worker-BwrZMAuc.js",import.meta.url),{type:"module"}),ce.onmessage=e=>{if(e.data.type==="error"){console.error("[DashboardBucketing] Worker error:",e.data.error),oe.setState({isComputing:!1});return}oe.setState({result:e.data.payload,isComputing:!1})},ce.onerror=e=>{console.error("[DashboardBucketing] Worker error:",e),oe.setState({isComputing:!1})}}catch(e){console.error("[DashboardBucketing] Failed to init worker:",e)}return ce}function xa(e,n,o,s){const r=ha();if(!r)return;const a=e.length,c=new Float64Array(a),i=new Float64Array(a),d=new Uint16Array(a),u=new Uint8Array(a),m=new Uint8Array(a),w=new Uint8Array(a),l=new Uint8Array(a),x=new Float32Array(a),v=new Float32Array(a),h=new Uint32Array(a),g=new Map;let C=0;for(let A=0;AparseInt(n,10)).filter(n=>e[n]>0).sort((n,o)=>e[o]-e[n])}function ga(e,n,o){const s={...e,received:[...e.received],unique_received:[...e.unique_received],transmitted:[...e.transmitted],forwarded:[...e.forwarded],dropped:[...e.dropped],receivedBytesBuckets:e.receivedBytesBuckets.map(m=>({...m,bytesByType:{...m.bytesByType},countByType:{...m.countByType}})),forwardedBytesBuckets:e.forwardedBytesBuckets.map(m=>({...m,bytesByType:{...m.bytesByType},countByType:{...m.countByType}})),droppedBytesBuckets:e.droppedBytesBuckets.map(m=>({...m,bytesByType:{...m.bytesByType},countByType:{...m.countByType}})),receivedTotalByType:{...e.receivedTotalByType},receivedCountByType:{...e.receivedCountByType},forwardedTotalByType:{...e.forwardedTotalByType},droppedTotalByType:{...e.droppedTotalByType}},{start_time:r,end_time:a,bucket_duration_seconds:c,bucket_count:i}=e,d=new Set;for(const m of n){const w=m.timestamp??0;if(wa)continue;const l=Math.floor((w-r)/c);if(l<0||l>=i)continue;d.has(l)||(d.add(l),s.received[l]={...s.received[l]},s.unique_received[l]={...s.unique_received[l]},s.transmitted[l]={...s.transmitted[l]},s.forwarded[l]={...s.forwarded[l]},s.dropped[l]={...s.dropped[l]});const x=At(m,o),v=m.length??m.payload_length??0,h=m.type??m.payload_type??0,g=m.packet_origin;g==="tx_local"?(s.transmitted[l].count++,s.transmitted[l].airtime_ms+=x):g==="tx_forward"||m.transmitted?(s.forwarded[l].count++,s.forwarded[l].airtime_ms+=x,s.forwardedBytesBuckets[l].bytesByType[h]=(s.forwardedBytesBuckets[l].bytesByType[h]??0)+v,s.forwardedBytesBuckets[l].totalBytes+=v,s.forwardedBytesBuckets[l].countByType[h]=(s.forwardedBytesBuckets[l].countByType[h]??0)+1,s.forwardedBytesBuckets[l].totalCount++,s.forwardedTotalByType[h]=(s.forwardedTotalByType[h]??0)+v,s.totalForwardedCount++):m.drop_reason&&(s.dropped[l].count++,s.dropped[l].airtime_ms+=x,s.droppedBytesBuckets[l].bytesByType[h]=(s.droppedBytesBuckets[l].bytesByType[h]??0)+v,s.droppedBytesBuckets[l].totalBytes+=v,s.droppedBytesBuckets[l].countByType[h]=(s.droppedBytesBuckets[l].countByType[h]??0)+1,s.droppedBytesBuckets[l].totalCount++,s.droppedTotalByType[h]=(s.droppedTotalByType[h]??0)+v,s.totalDroppedCount++),g!=="tx_local"&&(s.received[l].count++,s.received[l].airtime_ms+=x,s.unique_received[l].count++,s.unique_received[l].airtime_ms+=x,s.receivedBytesBuckets[l].bytesByType[h]=(s.receivedBytesBuckets[l].bytesByType[h]??0)+v,s.receivedBytesBuckets[l].totalBytes+=v,s.receivedBytesBuckets[l].countByType[h]=(s.receivedBytesBuckets[l].countByType[h]??0)+1,s.receivedBytesBuckets[l].totalCount++,s.receivedTotalByType[h]=(s.receivedTotalByType[h]??0)+v,s.receivedCountByType[h]=(s.receivedCountByType[h]??0)+1,s.totalReceivedBytes+=v)}const u=s.time_range_minutes/60;return s.kbPerHour=u>0?Math.round(s.totalReceivedBytes/1024/u):0,s.forwardedRatePerHour=u>0?Math.round(s.totalForwardedCount/u):0,s.droppedRatePerHour=u>0?Math.round(s.totalDroppedCount/u):0,s.receivedActiveTypes=ze(s.receivedTotalByType),s.forwardedActiveTypes=ze(s.forwardedTotalByType),s.droppedActiveTypes=ze(s.droppedTotalByType),s}typeof window<"u"&&Promise.all([st(()=>import("./index-D33fcA3L.js").then(e=>e.ho),__vite__mapDeps([0,1])),st(()=>import("./index-D33fcA3L.js").then(e=>e.hn),__vite__mapDeps([0,1]))]).then(([e,n])=>{const{DASHBOARD_TIME_RANGES:o}=n;let s=0,r=-1,a="";e.useStore.subscribe(c=>{const i=c.packets.length,d=c.globalTimeRangeIndex,u=pa(c.stats);if(i===s&&d===r&&u===a)return;const m=s,w=r,l=a;if(s=i,r=d,a=u,i===0)return;const x=o[d]??o[4],v=x.minutes,h=x.buckets,g=c.stats,C=nt(g),S=i-m,A=d!==w,k=u!==l,b=oe.getState().result;if(!A&&!k&&S>0&&S{_e=null;const p=e.useStore.getState();if(p.packets.length===0||!p.stats)return;const D=o[p.globalTimeRangeIndex]??o[4],T=nt(p.stats);xa(p.packets,D.minutes,D.buckets,T)},fa)})});const ya=()=>oe(e=>e.result),is=[{target:"ReceivedChart",fn:"type",minStage:1},{target:"ReceivedChart",fn:"airtime",minStage:1,when:xn}];pe(is);function ba(e){const o=new Date(e*1e3).getHours();return o>=6&&o<18}function bt(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}const he=32,Oe=20,ja=[.25,.5,.75,1];function wa({buckets:e,activeTypes:n,totalByType:o,mode:s="bytes"}){fe(is);const r=Lt(),[a,c]=f.useState(null),[i,d]=f.useState(null),[u,m]=f.useState(null),w=f.useCallback((k,b,j)=>{c(b),d(j)},[]),l=e.length>0&&n.length>0,x=a?ba(a.start):null,v=a?bt(a.start):"",h=u!==null&&x!==null&&u!==x;x!==u&&m(x);const g=f.useMemo(()=>Cs(e),[e]),C=s==="count"?te:Ts,S=f.useMemo(()=>g===0?[]:ja.map(k=>({pct:k,label:C(Math.round(g*k)),pos:(1-k)*100})),[g,C]),A=f.useMemo(()=>{if(e.length===0)return[];const k=e.length,b=Math.max(1,Math.floor(k/6)),j=[];for(let p=0;pt.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${j}%`,transform:k===1?"none":"translateY(-50%)",right:0},children:b},k))}),t.jsx("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:he,right:0,top:0,bottom:Oe},children:l&&t.jsx(Ss,{buckets:e,activeTypes:n,gridColor:r.grid,axisTickColor:r.axisTick,onHover:w,yAxisFormat:s,externalAxes:!0})}),t.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:he,height:Oe},"aria-hidden":"true",children:A.map((k,b)=>t.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${k.pos}%`,transform:b===0?"none":b===A.length-1?"translateX(-100%)":"translateX(-50%)"},children:k.label},b))})]}),t.jsx("div",{className:"pt-2 px-1 pb-2 shrink-0",children:l&&t.jsx(_s,{activeTypes:n,totalByType:o,formatMode:s})})]})}const jt={top:8,right:8,bottom:28,left:48},wt={top:0,right:0,bottom:0,left:0};let Be=null,Nt=0;const Na=1e3;function va(){const e=performance.now();return Be&&e-Nth&&(h=y),L>g&&(g=L)}h===0&&g===0?(h=1,g=1):h===0?h=1:g===0&&(g=1);const C=h*1.05,S=g*1.05,A=C+S;let k=C/A;k=Math.max(Fe,Math.min(1-Fe,k));const b=i-m,j=k*b,p=(1-k)*b,D=a+j,T=a+j+m,R=a+j+m/2;for(let P=0;P0)for(const F of s){const N=_[F]??0;if(N===0)continue;const $=N/C*j,E=L-$;e.fillStyle=Le(F),e.fillRect(y,E,l,$),L=E}let B=T;const M=o[P].countByType;if(v[P]>0){const F=M[Q]??0;if(F>0){const N=F/S*p;e.fillStyle=Le(Q),e.fillRect(y,B,l,N),B+=N}for(const N of s){if(N===Q)continue;const $=M[N]??0;if($===0)continue;const E=$/S*p;e.fillStyle=Le(N),e.fillRect(y,B,l,E),B+=E}}}return{baselineY:R,fwdHalf:j,drpHalf:p,fwdCeil:C,drpCeil:S,gapPx:m}}function Ma(e,n,o,s,r,a,c,i,d,u,m=!1){if(n.length===0)return;const{baselineY:w,fwdHalf:l,drpHalf:x,fwdCeil:v,drpCeil:h,gapPx:g}=d,C=va(),S=w-Math.ceil(g/2),A=w+Math.floor(g/2);e.save(),e.strokeStyle=c,e.lineWidth=1*u,e.setLineDash([]);const k=[.5,1];for(const b of k){const j=Math.round(S-b*l)+.5;e.beginPath(),e.moveTo(o,j),e.lineTo(o+r,j),e.stroke();const p=Math.round(A+b*x)+.5;e.beginPath(),e.moveTo(o,p),e.lineTo(o+r,p),e.stroke()}if(e.restore(),e.clearRect(o,w-Math.ceil(g/2),r,g),!m){e.save(),e.font=`bold ${10*u}px ${C}`,e.textAlign="left";const b=4*u,j=2*u;for(const p of k){const D=Math.round(v*p),T=Math.round(h*p),R=p===1,P=S-p*l,y=A+p*x;D>0&&(e.fillStyle=J.green,e.globalAlpha=.7,R?(e.textBaseline="top",e.fillText(te(D),b,P+j)):(e.textBaseline="middle",e.fillText(te(D),b,P))),T>0&&(e.fillStyle=J.red,e.globalAlpha=.7,R?(e.textBaseline="bottom",e.fillText(te(T),b,y-j)):(e.textBaseline="middle",e.fillText(te(T),b,y)))}e.globalAlpha=1,e.restore()}if(!m){e.save(),e.font=`${12*u}px ${C}`,e.fillStyle=i,e.textBaseline="top",e.textAlign="center";const b=8*u,j=n.length,p=Math.max(1,Math.floor(j/6)),D=r/j;for(let T=0;T{const r=n[s]??0,a=o[s]??0;if(r===0&&a===0)return null;const c=s===Q?"CRC":Bs[s]??`TYPE_${s}`;return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"shrink-0 w-3 h-3 rounded-xs",style:{backgroundColor:Le(s)}}),t.jsx("span",{className:"text-fg-secondary whitespace-nowrap",children:c}),t.jsxs("span",{className:"tabular-nums",children:[t.jsxs("span",{className:"text-sys-green",children:["▲",te(r)]})," ",t.jsxs("span",{className:"text-sys-red",children:["▼",te(a)]})]})]},s)})})}function Ta(e,n,o){const s=e.length;let r=0,a=0;for(let m=0;mr&&(r=w),l>a&&(a=l)}r===0&&a===0?(r=1,a=1):r===0?r=1:a===0&&(a=1);const c=r*1.05,i=a*1.05,d=c+i;let u=c/d;return u=Math.max(Fe,Math.min(1-Fe,u)),{fwdMax:Math.round(c),drpMax:Math.round(i),fwdFrac:u}}function Sa({forwardedBuckets:e,droppedBuckets:n,allTypes:o,onHover:s,gridColor:r,axisTickColor:a,externalAxes:c=!1}){const i=f.useRef(null),d=f.useRef(null),u=f.useRef(e),m=f.useRef(n),w=f.useRef(o),l=f.useRef(c);u.current=e,m.current=n,w.current=o,l.current=c;const x=c?wt:jt,v=typeof document<"u"&&document.documentElement.dataset.mode!=="light",h=r||(v?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)"),g=a||(v?"rgba(255,255,255,0.6)":"rgba(0,0,0,0.6)"),C=f.useRef({gridColor:h,axisTickColor:g});C.current={gridColor:h,axisTickColor:g};const S=e.length,A=f.useMemo(()=>{const j=e.map(D=>D.start),p=e.map(()=>1);return[j,p]},[S]),k=f.useCallback(j=>{if(!i.current||e.length===0)return;const p=i.current.getBoundingClientRect(),D=j.clientX-p.left,T=c?wt:jt,R=T.left,P=p.width-T.left-T.right,L=(D-R)/P;if(L<0||L>1){s==null||s(null,null,null);return}const _=Math.min(e.length-1,Math.max(0,Math.floor(L*e.length)));s==null||s(_,e[_],L)},[e,s]),b=f.useCallback(()=>{s==null||s(null,null,null)},[s]);return f.useEffect(()=>{if(!i.current||S===0)return;const j=i.current;let p=null;const D=Ds(()=>{const T=j.getBoundingClientRect(),R=Math.floor(T.width)||400,P=Math.floor(T.height)||200,y={width:R,height:P,padding:[x.top,x.right,x.bottom,x.left],cursor:{show:!1},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],legend:{show:!1},hooks:{draw:[_=>{const B=_.ctx,{left:M,top:F,width:N,height:$}=_.bbox,E=window.devicePixelRatio||1,z=C.current,I=u.current;I.length>=2&&As(B,I[0].start,I[I.length-1].end,M,F,N,$);const G=ka(B,u.current,m.current,w.current,M,F,N,$);Ma(B,u.current,M,F,N,$,z.gridColor,z.axisTickColor,G,E,l.current)}]}},L=new Rs(y,A,j);d.current=L,p=new ResizeObserver(()=>{const _=j.getBoundingClientRect();_.width>0&&_.height>0&&d.current&&d.current.setSize({width:Math.floor(_.width),height:Math.floor(_.height)})}),p.observe(j)});return()=>{var T;D(),p==null||p.disconnect(),(T=d.current)==null||T.destroy(),d.current=null}},[S]),f.useEffect(()=>{d.current&&d.current.redraw()},[e,n,o]),e.length===0?t.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted",children:"No data available"}):t.jsx("div",{ref:i,className:"w-full h-full",onMouseMove:k,onMouseLeave:b})}const _a=f.memo(Sa),ls=[{target:"RepeaterAnalyticsCard",fn:"type",minStage:1}];pe(ls);function Ba(e){const o=new Date(e*1e3).getHours();return o>=6&&o<18}function vt(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}const xe=32,Ge=20,Da=[.5,1];function Ra({forwardedBuckets:e,droppedBuckets:n,forwardedActiveTypes:o,droppedActiveTypes:s,forwardedCount:r,droppedCount:a,crcCount:c,crcHistory:i,receivedCount:d,forwardedTotalByType:u,droppedTotalByType:m,startTime:w,bucketDurationSeconds:l,bucketCount:x,timeRangeMinutes:v}){fe(ls);const h=Lt(),g=we(),[C,S]=f.useState(null),[A,k]=f.useState(null),[b,j]=f.useState(null),p=f.useCallback((W,H,X)=>{S(H),k(X)},[]),D=Math.max(1,v/60),T=f.useMemo(()=>Ft(g,D),[g,D]),R=f.useMemo(()=>T?Et(T):0,[T]),P=Math.round(R*10)/10,y=Math.round((T==null?void 0:T.avgBackoffMs)??0),{fwdMirror:L,drpMirror:_,allTypes:B,fwdTotals:M,drpTotals:F}=f.useMemo(()=>{const W=e.map(U=>({start:U.start,end:U.end,countByType:{...U.countByType}})),H=new Array(x).fill(0);for(const U of i){let K=Math.floor((U.timestamp-w)/l);K<0&&(K=0),!(K>=x)&&H[K]++}const X=n.map((U,K)=>({start:U.start,end:U.end,countByType:{...U.countByType,...H[K]>0?{[Q]:H[K]}:{}}})),V=new Set([...o,...s]);c>0&&V.add(Q);const se={...u},ae={...m};c>0&&(ae[Q]=c);const ke=[...V].sort((U,K)=>{const ys=(se[U]??0)+(ae[U]??0);return(se[K]??0)+(ae[K]??0)-ys});return{fwdMirror:W,drpMirror:X,allTypes:ke,fwdTotals:se,drpTotals:ae}},[e,n,o,s,i,c,w,l,x,u,m]),N=B.length>0&&L.length>0,$=C?Ba(C.start):null,E=C?vt(C.start):"",z=b!==null&&$!==null&&b!==$;$!==b&&j($);const I=f.useMemo(()=>N?Ta(L,_,B):null,[N,L,_,B]),G=f.useMemo(()=>{if(!I)return[];const{fwdMax:W,drpMax:H,fwdFrac:X}=I,V=[];for(const se of Da){const ae=Math.round(W*se);if(ae>0){const U=(1-se)*X*100;V.push({label:te(ae),pos:U,color:"green"})}const ke=Math.round(H*se);if(ke>0){const U=(X+se*(1-X))*100;V.push({label:te(ke),pos:U,color:"red"})}}return V},[I]),O=f.useMemo(()=>{if(L.length===0)return[];const W=L.length,H=Math.max(1,Math.floor(W/6)),X=[];for(let V=0;Vt.jsx("span",{className:`type-data-xs text-right pr-1.5 ${X==="green"?"text-sys-green/70":"text-sys-red/70"}`,style:{position:"absolute",top:`${H}%`,transform:H<=1?"none":H>=99?"translateY(-100%)":"translateY(-50%)",right:0},children:W},V))}),t.jsxs("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:xe,right:0,top:0,bottom:Ge},children:[N&&I&&t.jsx("div",{className:"absolute inset-x-0 top-0 pointer-events-none",style:{height:`${I.fwdFrac*100}%`,background:"var(--sys-blue)",opacity:.1}}),N&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"data-box data-box-compact flex items-center gap-1 absolute z-10 pointer-events-none",style:{top:8,left:8,background:"var(--surface)",borderColor:"var(--edge-subtle)"},children:[t.jsx(ht,{className:"w-3 h-3 text-sys-green"}),t.jsx("span",{children:"FWD"})]}),t.jsxs("span",{className:"data-box data-box-compact flex items-center gap-1 absolute z-10 pointer-events-none",style:{bottom:8,left:8,background:"var(--surface)",borderColor:"var(--edge-subtle)"},children:[t.jsx(pt,{className:"w-3 h-3 text-sys-red"}),t.jsx("span",{children:"DROP"})]})]}),t.jsx("div",{className:`absolute inset-0 flex items-center transition-opacity duration-300 ${N?"opacity-0 pointer-events-none":"opacity-100"}`,"aria-hidden":N,children:t.jsx("div",{className:"w-full flex items-center gap-1",children:t.jsx("div",{className:"flex-1 flex items-end gap-1 h-1/2",children:[45,72,33,58,80,42,65,28,55,75,38,62].map((W,H)=>t.jsx("div",{className:"flex-1 bg-subtle-fill rounded-sm animate-pulse",style:{height:`${W}%`}},`u${H}`))})})}),t.jsx("div",{className:`h-full transition-opacity duration-300 ${N?"opacity-100":"opacity-0"}`,children:N&&t.jsx(_a,{forwardedBuckets:L,droppedBuckets:_,allTypes:B,gridColor:h.grid,axisTickColor:h.axisTick,onHover:p,externalAxes:!0})}),N&&I&&t.jsx("div",{className:"absolute inset-x-0 bottom-0 pointer-events-none",style:{top:`${I.fwdFrac*100}%`,background:"var(--sys-red)",opacity:.1}})]}),t.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:xe,height:Ge},"aria-hidden":"true",children:O.map((W,H)=>t.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${W.pos}%`,transform:H===0?"none":H===O.length-1?"translateX(-100%)":"translateX(-50%)"},children:W.label},H))})]}),t.jsx("div",{className:"pt-2 px-1 pb-2 shrink-0",children:N&&t.jsx(Ca,{allTypes:B,forwardedTotalByType:M,droppedTotalByType:F})})]})}const Aa=2,La=1;function Pa(e,n,o){const s=d=>(d==null?void 0:d.reduce((u,m)=>u+m.count,0))??0,r=s(n),a=s(o),c=r||(e==null?void 0:e.rx_count)||1,i=a||(e==null?void 0:e.dropped_count)||0;return c>0?i/(c+i)*100:0}function $a(e,n,o){const s=r=>(r==null?void 0:r.reduce((a,c)=>a+c.count,0))??0;if(n!=null&&n.length&&o){const a=s(n)*100,c=n.length*o*1e3;return a/c*100}if(e){const r=(e.uptime_seconds||1)*1e3;return(e.total_airtime_ms||e.airtime_used_ms||0)/r*100}return 0}function kt(e,n,o){return wn(Math.max(n,Math.min(o,e)))}function Fa(e,n,o,s,r){let a=Kt(e);n>20?a+=Te*2:n>12&&(a+=Te),o>8&&(a+=Te);const c=kt(a,0,Aa);let i=Nn(e);o>8&&(i+=Te);const d=kt(i,0,La),u=ye(c),m=ye(d),w=s!==null?ye(s):null;let l="stable";return w!==null&&(u>w?l="increase":u{if(u!=="applying"){m("applying");try{const H=await Ps({tx_delay_factor:O,direct_tx_delay_factor:W});H!=null&&H.success?(m("success"),setTimeout(()=>m("idle"),2e3)):(m("error"),setTimeout(()=>m("idle"),2500))}catch{m("error"),setTimeout(()=>m("idle"),2500)}}},[u]);if(!c)return t.jsx(je,{children:t.jsx($s,{})});const x=10080*60,h=Math.floor(Date.now()/1e3)-x,g=Object.values((e==null?void 0:e.neighbors)??{}).filter(O=>O.zero_hop&&O.last_seen>=h&&jn(O).isRepeater).length,C=w.filter(O=>O.status==="active"||O.lastSeen>=h).length,S=Math.max(g,C),A=Pa(e,n,o),k=$a(e,s,r),b=((z=(E=e==null?void 0:e.config)==null?void 0:E.delays)==null?void 0:z.tx_delay_factor)??null,j=((G=(I=e==null?void 0:e.config)==null?void 0:I.delays)==null?void 0:G.direct_tx_delay_factor)??null,p=Fa(S,A,k,b),D=S!==1,T=Kt(S),R=[`${S} repeater${D?"s":""} heard in the last 7 days (base ×${T.toFixed(1)}).`];p.floodFactor===T&&A<=12&&k<=8?R.push("No modifiers applied — network looks healthy."):(A>20?R.push(`High duplicate rate (${A.toFixed(1)}%) suggests frequent collisions — window widened.`):A>12&&R.push(`Elevated duplicate rate (${A.toFixed(1)}%) — window widened one step.`),k>8&&R.push(`Channel is busy (${k.toFixed(1)}% TX util) — extra spacing added.`));const P=[`Direct uses one forwarder — ×${p.directFactor.toFixed(1)} backoff for channel contention.`];k>8&&P.push("Busy channel — small extra backoff.");const y=[`Flood ×${p.floodFactor.toFixed(1)} (${p.floodSlots} slot${p.floodSlots!==1?"s":""})`,...R,"",`Direct ×${p.directFactor.toFixed(1)}`,...P,"","Click to copy CLI commands"].join(` +`),L=b!==null?ye(b):null,_=j!==null?ye(j):null,B=L!==null&&p.floodSlots!==L,M=_!==null&&p.directSlots!==_,F=B||M,N=async()=>{const O=`set txdelay ${p.floodFactor.toFixed(1)} +set direct.txdelay ${p.directFactor.toFixed(1)}`;await Es(O),d(!0),setTimeout(()=>d(!1),1500)},$=()=>l(p.floodFactor,p.directFactor);return t.jsxs(je,{children:[t.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3 flex-wrap",children:[t.jsx(vn,{className:"w-4 h-4 text-icon-card-title flex-shrink-0"}),t.jsx("span",{className:"type-micro",children:"DELAY DOCTOR"}),a&&t.jsx(ne,{color:"zinc",className:"hidden sm:inline-flex",children:a})]}),t.jsxs("button",{onClick:N,className:"flex gap-3 mb-2 sm:mb-3 w-full text-left hover:bg-subtle-fill radius-inner transition-base p-1 -m-1 group",title:y,children:[t.jsxs("div",{className:"flex-1 flex flex-col",children:[t.jsx("span",{className:"type-data-xl text-fg-primary",children:t.jsxs(Ye,{children:["×",p.floodFactor.toFixed(1)]})}),t.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Flood"})]}),t.jsxs("div",{className:"flex-1 flex flex-col",children:[t.jsx("span",{className:"type-data-xl text-sys-blue",children:t.jsxs(Ye,{children:["×",p.directFactor.toFixed(1)]})}),t.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Direct"})]}),t.jsx("div",{className:"flex items-center self-center opacity-0 group-hover:opacity-100 transition-opacity",children:i?t.jsx(at,{className:"w-4 h-4 text-sys-green"}):t.jsx(Fs,{className:"w-4 h-4 text-fg-muted"})})]}),t.jsx("div",{className:"flex-1 py-2",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"Dupe"}),t.jsxs("div",{className:`data-box data-box-fill data-box-left ${p.duplicateRate>8?"text-status-warning":""}`,children:[p.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:[p.txUtilization.toFixed(2),"%"]})]})]})}),t.jsx("div",{className:"pt-2 mt-auto",children:t.jsxs("div",{className:"flex items-end justify-between gap-2",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"data-box-label",children:"Current"}),t.jsx("div",{className:"flex gap-2",children:b!==null?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:["×",b.toFixed(2)]})}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("div",{className:"data-box data-box-fill data-box-left",style:{color:"var(--sys-blue)"},children:["×",(j==null?void 0:j.toFixed(2))??"—"]})})]}):t.jsx("span",{className:"text-sm text-fg-muted",children:"No config"})})]}),F&&t.jsxs("button",{onClick:$,disabled:u==="applying"||u==="success",className:`flex items-center gap-1.5 px-2.5 py-1.5 radius-inner type-micro font-medium transition-base + ${u==="success"?"bg-sys-green/15 text-sys-green":u==="error"?"bg-sys-red/15 text-sys-red":u==="applying"?"bg-subtle-fill text-fg-muted":"bg-sys-blue/10 text-sys-blue hover:bg-sys-blue/20"}`,title:`Apply ×${p.floodFactor.toFixed(1)} flood, ×${p.directFactor.toFixed(1)} direct`,children:[u==="success"?"Rx'd":u==="error"?"Failed":"Apply",u==="applying"?t.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):u==="success"?t.jsx(at,{className:"w-3.5 h-3.5"}):t.jsxs("span",{className:"relative inline-flex items-end w-6 h-3.5",children:[t.jsx(Qn,{className:"w-3.5 h-3.5 absolute left-0 bottom-0"}),t.jsx(aa,{className:"w-3 h-3 absolute right-0 bottom-0"})]})]})]})})]})}const cs=[{target:"RecentPackets",fn:"rssi",minStage:1},{target:"RecentPackets",fn:"snr",minStage:1}];pe(cs);const Ia=25;function Ha(){fe(cs);const e=we(),n=Is(),o=Hs(),s=ie(),r=Cn(),a=Je(x=>x.requestChannel),[c,i]=f.useState(!0),d=f.useCallback(x=>i(x),[]),u=f.useMemo(()=>[...e.length<=100?e:e.slice(-100)].sort((v,h)=>(h.timestamp??0)-(v.timestamp??0)),[e]),m=s==null?void 0:s.local_hash,w=s==null?void 0:s.neighbors,l=Tn();return t.jsxs(je,{noPadding:!0,className:"!overflow-visible",children:[t.jsx(It,{listHeader:!0,icon:t.jsx(zt,{}),title:"Recent Packets",actions:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Ht,{enabled:c,onChange:d,label:"Hide Dupes",size:"sm"}),o&&t.jsx(zs,{showLabel:!0}),t.jsxs($e,{color:"primary",outline:!0,href:"/packets",children:["View all",t.jsx(ut,{"data-slot":"icon"})]})]})}),t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-1",children:t.jsx(kn,{packets:u,allPackets:e,localHash:m,neighbors:w,resolveSource:l,getDecodedContent:r,onChannelClick:a,loading:n,maxPackets:Ia,showPagination:!1,flashNewest:!0,hideDupes:c,emptyMessage:"No packets received",footerAction:t.jsxs($e,{color:"primary",outline:!0,href:"/packets",children:["View all",t.jsx(ut,{"data-slot":"icon"})]})})})]})}const za={stable:"M5 12h14",up:"M5 15l7-7 7 7",down:"M19 9l-7 7-7-7"};function Oa({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:za[e]})})})}function Ga(){return t.jsx("div",{className:"mini-widget-loading",children:t.jsx("div",{className:"mini-widget-loading-spinner"})})}function Wa({message:e}){return t.jsx("div",{className:"mini-widget-error",children:t.jsx("span",{title:e,children:"No data"})})}function le({title:e,icon:n,value:o,unit:s,valueSize:r="md",status:a,subtitle:c,subtitleValue:i,trend:d,headerRight:u,children:m,isLoading:w=!1,error:l,className:x="",onClick:v,isLoaded:h}){const g=["mini-widget-value",r==="lg"&&"mini-widget-value-lg",r==="sm"&&"mini-widget-value-sm"].filter(Boolean).join(" "),C=["mini-widget",x].filter(Boolean).join(" ");return t.jsxs(je,{noPadding:!0,className:C,onClick:v,isLoaded:h,children:[t.jsxs("div",{className:"mini-widget-header",children:[n,t.jsx("span",{className:"mini-widget-title",children:e}),a&&a!=="unknown"&&t.jsx("div",{className:`mini-widget-status-dot ${a}`}),d&&t.jsx(Oa,{trend:d}),u&&t.jsx("span",{className:"ml-auto flex items-center",children:u})]}),w?t.jsx(Ga,{}):l?t.jsx(Wa,{message:l}):t.jsxs("div",{className:"mini-widget-content",children:[(o!==void 0||c||i)&&t.jsxs("div",{className:"mini-widget-value-row",children:[o!==void 0&&t.jsxs("div",{className:g,children:[typeof o=="number"?t.jsx(re,{value:o,className:"font-mono tabular-nums",priority:"medium",format:Number.isInteger(o)?void 0:{minimumFractionDigits:1,maximumFractionDigits:1}}):t.jsx(Ye,{children:o}),s&&t.jsx("span",{className:"mini-widget-unit",children:s})]}),(c||i)&&t.jsxs("span",{className:"mini-widget-badge-group",children:[c&&!i&&t.jsx("span",{className:"data-box mini-widget-subtitle-box",children:c}),c&&i&&t.jsx("span",{className:"mini-widget-subtitle truncate",children:c}),i&&t.jsx("span",{className:"data-box mini-widget-subtitle-box",children:i})]})]}),m]})]})}const qa={DELTA_CRITICAL:10,SLOPE_CRITICAL:4,JITTER_CRITICAL:6,DELTA_WARNING:5,SLOPE_WARNING:2,JITTER_WARNING:4},ds={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 Ze(e,n){if(e.length===0)return null;const o=[...e].sort((c,i)=>c-i),s=n/100*(o.length-1),r=Math.floor(s),a=Math.ceil(s);return r===a?o[r]:o[r]+(o[a]-o[r])*(s-r)}function Mt(e){return Ze(e,50)}function Ua(e){if(e.length<2)return 0;const n=e.reduce((r,a)=>r+a,0)/e.length,s=e.map(r=>Math.pow(r-n,2)).reduce((r,a)=>r+a,0)/e.length;return Math.sqrt(s)}function Xa(e){if(e.length<2)return 0;const n=e.length;let o=0,s=0,r=0,a=0;const c=e[0].timestamp;for(const d of e){const u=(d.timestamp-c)/3600,m=d.value;o+=u,s+=m,r+=u*m,a+=u*u}const i=n*a-o*o;return Math.abs(i)<1e-4?0:(n*r-o*s)/i}function Va(e,n,o){const s=qa;return e>=s.DELTA_CRITICAL?[2,`Noise floor ${e.toFixed(1)} dB above baseline`]:n>=s.SLOPE_CRITICAL?[2,`Noise floor rising ${n.toFixed(1)} dB/hour`]:o>=s.JITTER_CRITICAL?[2,`Noise floor unstable (±${o.toFixed(1)} dB)`]:e>=s.DELTA_WARNING?[1,`Noise floor ${e.toFixed(1)} dB above baseline`]:n>=s.SLOPE_WARNING?[1,`Noise floor rising ${n.toFixed(1)} dB/hour`]:o>=s.JITTER_WARNING?[1,`Noise floor variable (±${o.toFixed(1)} dB)`]:[0,null]}function Ya(e){if(e.length===0)return{...ds,computedAt:Math.floor(Date.now()/1e3)};const n=Math.floor(Date.now()/1e3),o=e.filter(g=>Number.isFinite(g)),s=e.length>0?[e[e.length-1]]:[],r=e.slice(-4).filter(g=>Number.isFinite(g)),a=Mt(o),c=Ze(o,10),i=Ze(o,90),d=Mt(s),u=d!==null&&c!==null?d-c:0,m=r.map((g,C)=>({timestamp:n-(r.length-1-C)*3600,value:g})),w=Xa(m),l=Ua(r),x=o.length>=12,[v,h]=x?Va(u,w,l):[0,null];return{baselineMedian:a,baselineP10:c,baselineP90:i,currentMedian:d,currentSampleCount:s.length,delta:u,slope:w,jitter:l,penalty:v,penaltyReason:h,computedAt:n,isReliable:x}}const Ja={lbtStats:null,noiseFloor:null,sparklineNoiseFloor:[],noiseFloorWindowHistory:[],linkQuality:null,channelHealth:null,nfTrend:ds,radioConfig:null,trends:null,stats:null,recentPackets:[],quickNeighbors:[],isLoading:!0,error:null,refresh:async()=>{}},us=f.createContext(Ja);function Za({children:e}){var _;const n=ie(),o=we(),s=Ot(),r=Os(),a=Ne(),c=ee[a],i=Math.max(1,c.minutes/60),d=n===null,[u,m]=f.useState(null),w=f.useCallback(async()=>{try{const B=await Gt(Math.ceil(i));if(B.success&&B.data){m(B.data.history);return}const M=await Wt(Math.ceil(i));M.success&&M.data&&M.data.count>0&&m(null)}catch{}},[i]);f.useEffect(()=>{w();const B=setInterval(w,6e4);return()=>clearInterval(B)},[w]);const l=f.useMemo(()=>Ft(o,i,u),[o,i,u]),x=(n==null?void 0:n.noise_floor_dbm)??null,v=f.useMemo(()=>Gs(x)?x:null,[x]),h=f.useMemo(()=>{var M;const B=(M=n==null?void 0:n.config)==null?void 0:M.radio;return B?{sf:B.spreading_factor??7,bwHz:B.bandwidth??125e3}:null},[(_=n==null?void 0:n.config)==null?void 0:_.radio]),g=Ws(i),C=qs(i),S=n==null?void 0:n.neighbors,A=f.useMemo(()=>Object.fromEntries(Object.entries(S??{}).filter(([M])=>!r.has(M))),[S,r]),k=f.useMemo(()=>s.filter(B=>!r.has(B.hash)),[s,r]),b=f.useMemo(()=>Ya(g),[g]),j=f.useMemo(()=>Us(k,A,h),[k,A,h]),p=f.useMemo(()=>Xs(l,v,j),[l,v,j]),[D,T]=f.useState({noiseFloor:null,networkScore:null,channelHealth:null}),R=f.useRef(0);f.useEffect(()=>{const B=()=>{const F=Date.now();F-R.current>3e4&&(R.current=F,T({noiseFloor:v,networkScore:(j==null?void 0:j.networkScore)??null,channelHealth:(p==null?void 0:p.score)??null}))};B();const M=setInterval(B,5e3);return()=>clearInterval(M)},[v,j==null?void 0:j.networkScore,p==null?void 0:p.score]);const P=f.useMemo(()=>({noiseFloor:{current:v,previous:D.noiseFloor,trend:v!==null?Ie(v,D.noiseFloor,2,!0):"stable"},networkScore:{current:(j==null?void 0:j.networkScore)??0,previous:D.networkScore,trend:Ie((j==null?void 0:j.networkScore)??0,D.networkScore,3,!1)},channelHealth:{current:(p==null?void 0:p.score)??0,previous:D.channelHealth,trend:Ie((p==null?void 0:p.score)??0,D.channelHealth,3,!1)}}),[v,j==null?void 0:j.networkScore,p==null?void 0:p.score,D]),L={lbtStats:l,noiseFloor:v,sparklineNoiseFloor:g,noiseFloorWindowHistory:C,linkQuality:j,channelHealth:p,nfTrend:b,radioConfig:h,trends:P,stats:n,recentPackets:o,quickNeighbors:s,isLoading:d,error:null,refresh:async()=>{}};return t.jsx(us.Provider,{value:L,children:e})}function et(){const e=f.useContext(us);if(e===void 0)throw new Error("useLBTData must be used within an LBTDataProvider");return e}function Ka(e){return e<100?"excellent":e<250?"good":e<500?"fair":e<1e3?"congested":"critical"}function Qa(e){return e===0?"No backoffs":"Retries"}function eo(e,n){return e===0?void 0:`${n.toFixed(0)}%`}function to(){const{lbtStats:e,isLoading:n,error:o}=et(),s=qt(),r=(e==null?void 0:e.avgBackoffMs)??0,a=(e==null?void 0:e.retryRate)??0,c=e?Ka(r):"unknown",i=e==null?void 0:e.sparklineBackoff,d=f.useMemo(()=>!i||i.length<2?[]:i.map((u,m)=>({timestamp:Date.now()-(i.length-1-m)*36e5,count:u})),[i]);return t.jsx(le,{title:"LBT Backoff",icon:t.jsx(ra,{className:"mini-widget-icon"}),value:Math.round(r),unit:"ms",status:c,subtitle:e?Qa(r):void 0,subtitleValue:e?eo(r,a):void 0,isLoading:n,error:o,onClick:()=>s("/packets"),children:t.jsx("div",{className:"mini-widget-sparkline w-full",children:t.jsx(ts,{data:d,width:9999,height:24,invertScale:!0,isLoading:n,className:"w-full"})})})}const ms=[{target:"LinkLeaders",fn:"path",minStage:1,when:gn},{target:"LinkLeaders",fn:"src_hash",minStage:1,when:yn}];pe(ms);function so(){fe(ms);const e=qt(),n=Ot(),o=we(),s=ie(),r=Ne(),c=ee[r].minutes*60,i=Vs(),d=f.useMemo(()=>{if(i===0)return o;const p=i-c;return o.filter(D=>D.timestamp>=p)},[o,c,i]),u=s===null,m=s!=null&&s.local_hash?ot(s.local_hash):"",w=(s==null?void 0:s.neighbors)??{},{neighborHashes:l,neighborNames:x}=f.useMemo(()=>{const p=new Set,D=new Map;for(const T of n){p.add(T.hash);const R=w[T.hash],P=(R==null?void 0:R.name)||(R==null?void 0:R.node_name)||T.prefix;D.set(T.hash,P)}return{neighborHashes:p,neighborNames:D}},[n,w]),v=f.useMemo(()=>{if(l.size===0||d.length===0||!m)return{champion:null,listener:null,loudest:null};const{scores:p}=_n(d,l,m),D=[];for(const[y,L]of p)L.blendedScore!==0&&D.push({...L,name:x.get(y)??ot(y)});let T=null,R=null,P=null;for(const y of D)(!T||y.blendedScore>T.blendedScore)&&(T=y),(!R||y.listenerScore>R.listenerScore)&&(R=y),(!P||y.loudScore>P.loudScore)&&(P=y);return{champion:T,listener:R,loudest:P}},[d,l,m,x]),h=p=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["🏆 Champion: ",p.name]}),t.jsxs("div",{className:"text-fg-muted mb-1",children:["Blended Score: ",p.blendedScore,t.jsx("span",{className:"text-fg-muted/60 ml-1",children:"(Listener + Loud)"})]}),t.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1 space-y-0.5",children:[t.jsxs("div",{children:["Listener: ",p.listenerScore,"/100 (",p.listenerCount," shared paths)"]}),t.jsxs("div",{children:["Loud: ",p.loudScore,"/100 (",p.loudCount," packets relayed)"]})]})]}),g=p=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["👂 Best Listener: ",p.name]}),t.jsxs("div",{className:"text-fg-muted mb-1",children:["Score: ",p.listenerScore,"/100"]}),t.jsx("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:t.jsxs("div",{children:[p.listenerCount," packets where they heard your transmissions"]})})]}),C=p=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["📢 Loudest: ",p.name]}),t.jsxs("div",{className:"text-fg-muted mb-1",children:["Score: ",p.loudScore,"/100"]}),t.jsx("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:t.jsxs("div",{children:[p.loudCount," packets they relayed directly to you"]})})]}),{champion:S,listener:A,loudest:k}=v,j=S||A||k?t.jsxs("div",{className:"flex flex-col gap-0 sm:gap-0.5",children:[S&&t.jsx(me,{content:h(S),children:t.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[t.jsx(Mn,{className:"w-2.5 h-2.5 sm:w-3 sm: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:S.name}),t.jsx("span",{className:"text-map-neighbor-color pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:S.blendedScore})]})}),A&&t.jsx(me,{content:g(A),children:t.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[t.jsx(as,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-fg-muted flex-shrink-0"}),t.jsx("span",{className:"text-fg-muted font-mono truncate flex-1 min-w-0",children:A.name}),t.jsx("span",{className:"text-fg-muted pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:A.listenerScore})]})}),k&&t.jsx(me,{content:C(k),children:t.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[t.jsx(Zn,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-fg-muted flex-shrink-0"}),t.jsx("span",{className:"text-fg-muted font-mono truncate flex-1 min-w-0",children:k.name}),t.jsx("span",{className:"text-fg-muted pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:k.loudScore})]})})]}):n.length===0?t.jsx("div",{className:"flex items-center justify-center text-xs sm:text-sm text-fg-muted mt-auto",children:"No direct neighbors"}):t.jsx("div",{className:"flex items-center justify-center text-xs sm:text-sm text-fg-muted mt-auto",children:"No routing data yet"});return t.jsx(le,{title:"Link Leaders",icon:t.jsx(ta,{className:"mini-widget-icon"}),isLoading:u,onClick:()=>e("/contacts"),children:j})}function no(e){return e<15?"excellent":e<30?"good":e<45?"fair":e<60?"congested":"critical"}function ao(e){return e<15?"Clear channel":e<30?"Light traffic":e<45?"Moderate traffic":e<60?"Heavy traffic":e<75?"Congested":"Severe congestion"}function oo(){const{lbtStats:e,isLoading:n,error:o}=et(),s=e?Et(e):0,r=e?no(s):"unknown",a=(e==null?void 0:e.maxBackoffMs)??0,c=e?a>200?"Peak":ao(s):void 0,i=e&&a>200?`${Math.round(a)}ms`:void 0,d=e==null?void 0:e.sparklineCollisionRisk,u=f.useMemo(()=>!d||d.length<2?[]:d.map((w,l)=>({timestamp:Date.now()-(d.length-1-l)*36e5,count:w})),[d]),m=Math.round(s*10)/10;return t.jsx(le,{title:"Collision Risk",icon:t.jsx(Bn,{className:"mini-widget-icon"}),value:m,unit:"%",status:r,subtitle:c,subtitleValue:i,isLoading:n,error:o,children:t.jsx("div",{className:"mini-widget-sparkline w-full",children:t.jsx(ts,{data:u,width:9999,height:24,invertScale:!0,isLoading:n,className:"w-full"})})})}function ro(e){return e<30?"excellent":e<50?"good":e<70?"fair":e<90?"congested":"critical"}function io(e){return e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}function lo(){var h,g;const[e,n]=f.useState(!1),[o]=f.useState(0),{stats:s,lbtStats:r,isLoading:a}=et(),c=((g=(h=s==null?void 0:s.config)==null?void 0:h.duty_cycle)==null?void 0:g.enforcement_enabled)??!1,i=f.useMemo(()=>{if(!s)return null;if(!c){const b=s.airtime_used_ms??0,j=s.max_airtime_ms??1,p=j>0?b/j*100:0;return{usedMs:b,maxMs:j,remainingMs:Math.max(0,j-b),utilizationPercent:p}}const C=s.airtime_used_ms??0,S=s.max_airtime_ms??1,A=s.airtime_remaining_ms??0,k=s.utilization_percent??(S>0?C/S*100:0);return{usedMs:C,maxMs:S,remainingMs:A,utilizationPercent:k}},[s,c]),d=f.useMemo(()=>{if(!r||r.totalPacketsWithLBT===0)return 100;const C=r.totalPacketsWithLBT-r.packetsWithRetries,S=r.totalPacketsWithLBT;return C/S*100},[r]),u=(i==null?void 0:i.utilizationPercent)??0,m=ro(u),w=(i==null?void 0:i.remainingMs)??0,l=d<95?"1st Try":"Remaining",x=d<95?`${d.toFixed(0)}%`:io(w),v=i?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(le,{title:"Duty Cycle",icon:t.jsx(zt,{className:"mini-widget-icon"}),value:u.toFixed(1),unit:"%",status:m,subtitle:l,subtitleValue:x,isLoading:a,children:v})}function co(){return t.jsxs("div",{className:"mini-widget",children:[t.jsxs("div",{className:"mini-widget-header",children:[t.jsx(Me,{className:"w-4 h-4"}),t.jsx(Me,{className:"h-3 w-16"})]}),t.jsx(Me,{className:"h-7 w-12 mt-2"}),t.jsx(Me,{className:"h-3 w-20 mt-2"})]})}function uo(){return t.jsx("div",{className:"widget-row",children:Array.from({length:5}).map((e,n)=>t.jsx(co,{},n))})}const fs=[{target:"MeshHealth",fn:"type",minStage:1}];pe(fs);function mo({className:e="",isLoaded:n,leading:o}){fe(fs);const s=Ut(),r=n??s??!0;return t.jsxs("div",{className:`mesh-health-container relative ${e}`,children:[t.jsxs("div",{className:"mesh-health-header",children:[t.jsx(Ys,{className:"w-4 h-4 text-sys-blue"}),t.jsx("span",{className:"type-label text-fg-muted",children:"MESH HEALTH"})]}),r?t.jsx(Za,{children:t.jsxs("div",{className:"widget-row",children:[o&&t.jsx("div",{className:"widget-leading",children:o}),t.jsx(to,{}),t.jsx(oo,{}),t.jsx(lo,{}),t.jsx(so,{})]})}):t.jsx(uo,{})]})}const ps=[{target:"PublicChannel",fn:"decrypt",minStage:2,when:bn}];pe(ps);let hs="",xs="",Ct="";function fo(){const e=new Date,n=e.toDateString();if(n!==Ct){Ct=n,hs=n;const o=new Date(e);o.setDate(o.getDate()-1),xs=o.toDateString()}}function po(e){fo();const n=new Date(e*1e3).toDateString();return n===hs?"Today":n===xs?"Yesterday":new Date(e*1e3).toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"})}function ho(e,n,o){return`${e||""}|${n}|${o}`}function xo(e,n){const o=e.message,s=n.message;return o.timestamp===s.timestamp&&o.text===s.text&&o.senderName===s.senderName&&o.channelHash===s.channelHash&&o.channelName===s.channelName&&e.isChannelSelected===n.isChannelSelected&&e.onChannelClick===n.onChannelClick}const go=f.memo(function({message:n,onChannelClick:o,isChannelSelected:s}){const r=n.channelName||n.channelHash.slice(0,6);return t.jsx("div",{style:{transform:"translateZ(0)",willChange:"transform"},children:t.jsx($n,{senderName:n.senderName||"Unknown",text:n.text,timestamp:n.timestamp,bubbleVariant:"subtle",nameAccessory:t.jsx(Qt,{channelName:r,active:s,onClick:()=>o==null?void 0:o(n.channelHash)})})})},xo);function yo({open:e,onClose:n,messages:o,onLoadMore:s,hasMoreToLoad:r,isDecoding:a,initialChannel:c}){const i=f.useRef(null),d=f.useRef(!0),u=Ne(),m=Xt(),w=f.useRef(!1);f.useEffect(()=>{e?(w.current=!0,it.resume()):w.current&&it.pause()},[e]);const l=f.useMemo(()=>{const y=Date.now()/1e3,L=ee[u].minutes,_=y-L*60;return[...o].filter(B=>B.timestamp>=_).sort((B,M)=>B.timestamp-M.timestamp)},[o,u]),x=f.useCallback(()=>{const y=i.current;y&&(d.current=y.scrollTop>=-50)},[]),v=f.useMemo(()=>{const y=new Map;for(const L of l){const _=L.channelHash,B=y.get(_);B?B.count++:y.set(_,{name:L.channelName||L.channelHash.slice(0,6),hash:L.channelHash,count:1})}return Array.from(y.values()).sort((L,_)=>_.count-L.count)},[l]),h=v.length,[g,C]=f.useState(null),[S,A]=f.useState(!1);f.useEffect(()=>{e&&c&&C(c)},[e,c]);const k=f.useCallback(()=>{s(g,v)},[s,g,v]),b=f.useMemo(()=>g?l.filter(y=>y.channelHash===g):l,[l,g]),j=f.useMemo(()=>{const y=[];let L="";for(const _ of b){const B=po(_.timestamp);B!==L&&(y.push({type:"date",date:B}),L=B),y.push({type:"message",message:_})}return y},[b]);f.useLayoutEffect(()=>{const y=i.current;y&&d.current&&(y.scrollTop=0)},[b.length]);const p=f.useCallback(()=>{if(b.length===0)return;const y=[...b].sort(($,E)=>$.timestamp-E.timestamp),L=v.find($=>$.hash===g),_=(L==null?void 0:L.name)??"All_Channels";let B=`Chat Export - ${_} +`;B+=`Generated: ${new Date().toLocaleString()} + +`,y.forEach($=>{const E=new Date($.timestamp).toLocaleString(),z=$.senderName||"Unknown",I=$.channelName?`[${$.channelName}] `:"";B+=`[${E}] ${I}${z}: ${$.text} +`});const M=new Blob([B],{type:"text/plain"}),F=URL.createObjectURL(M),N=document.createElement("a");N.href=F,N.download=`chat_export_${_.replace(/\s+/g,"_")}_${Date.now()}.txt`,document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(F)},[b,g,v]),D=19,T=v.slice(0,D),R=v.slice(D),P=R.length>0;return t.jsx(Vt,{open:e,onClose:n,size:"lg",motionPlus:!0,solid:!0,children:t.jsxs(Yt,{className:"p-0 flex flex-col h-[80vh] max-h-[700px] rounded-2xl",children:[t.jsx("div",{className:"flex-shrink-0 px-4 sm:px-5 py-3 sm:py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ss,{className:"size-5 text-icon-card-title flex-shrink-0"}),t.jsx("h2",{className:"type-micro",children:"Public Channels"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:p,disabled:b.length===0,className:Y("hidden sm:flex items-center justify-center p-2 transition-base radius-inner",b.length===0?"text-fg-muted/50 cursor-not-allowed":"text-fg-muted hover:text-fg-primary hover:bg-subtle"),"aria-label":"Export Chat History",title:"Export Chat History",children:t.jsx(tn,{className:"w-5 h-5"})}),t.jsx(es,{ranges:ee,selectedIndex:u,onSelect:m,size:"sm"}),t.jsx("button",{onClick:n,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),t.jsx("button",{onClick:n,className:"hidden sm:flex items-center justify-center p-2 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-subtle","aria-label":"Close",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}),t.jsx("div",{className:"flex-shrink-0 px-3 pb-2 relative z-10 isolate",style:{minHeight:h>0?void 0:0},children:h>0&&t.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.jsxs("button",{onClick:()=>C(null),className:Y("px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",g===null?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:["All ",h]}),T.map(y=>t.jsx("button",{onClick:()=>C(y.hash),className:Y("flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",g===y.hash?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:t.jsx("span",{className:"truncate max-w-[80px]",children:y.name})},y.hash)),P&&t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>A(!S),className:Y("flex items-center gap-0.5 px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",S||R.some(y=>y.hash===g)?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:["+",R.length,t.jsx(sn,{className:Y("size-3 transition-transform",S&&"rotate-180")})]}),S&&t.jsx("div",{className:Y("absolute top-full left-0 mt-1 z-50","min-w-[140px] max-h-[200px] overflow-y-auto","p-1 rounded-lg","bg-elevated backdrop-blur-xl","ring-1 ring-edge-subtle shadow-xl"),children:R.map(y=>t.jsxs("button",{onClick:()=>{C(y.hash),A(!1)},className:Y("w-full flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-all text-left",g===y.hash?"bg-sys-blue/20 text-sys-blue":"text-fg-secondary hover:bg-subtle-fill-strong"),children:[t.jsx(Fn,{className:"size-2.5 opacity-60 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:y.name}),t.jsxs("span",{className:"opacity-60 ml-auto",children:["(",y.count,")"]})]},y.hash))})]})]})}),t.jsx("div",{ref:i,onScroll:x,className:Y("flex-1 overflow-y-auto overflow-x-hidden","mx-3 mb-3 radius-inner depth-stroke-inset","flex flex-col-reverse"),children:a&&b.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[300px] text-fg-muted px-4 py-4",children:[t.jsx(Pe,{className:"size-12 mb-4 text-sys-indigo animate-spin"}),t.jsx("p",{className:"text-lg font-medium",children:"Loading messages..."})]}):b.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[300px] text-fg-muted px-4 py-4",children:[t.jsx(En,{className:"size-16 mb-4 opacity-20"}),t.jsx("p",{className:"text-lg font-medium",children:"No messages yet"}),t.jsx("p",{className:"text-sm mt-1 opacity-70",children:g?"No messages in this channel":"Public channel messages will appear here"})]}):t.jsxs("div",{className:"px-4 py-4",children:[r&&t.jsx("div",{className:"flex justify-center mb-4",children:t.jsx("button",{onClick:k,disabled:a,className:Y("px-4 py-1.5 rounded-full","text-[11px] font-medium","ring-1 ring-inset",a?"bg-subtle-fill text-fg-muted ring-edge-subtle cursor-wait":"bg-sys-blue/10 text-sys-blue ring-sys-blue/20 hover:bg-sys-blue/20 hover:ring-sys-blue/30"),children:a?t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Pe,{className:"size-3 animate-spin"}),"Loading..."]}):"Load older messages"})}),j.map((y,L)=>{if(y.type==="date")return t.jsx("div",{className:"flex justify-center my-4",children:t.jsx("span",{className:Y("px-3.5 py-1.5 rounded-full","bg-subtle-fill backdrop-blur-sm","text-[11px] text-fg-muted/80 font-medium","ring-1 ring-edge-subtle"),children:y.date})},`date-${y.date}-${L}`);const _=`msg-${y.message.timestamp}-${y.message.senderName||"anon"}-${y.message.channelHash}`;return t.jsx("div",{children:t.jsx(go,{message:y.message,onChannelClick:C,isChannelSelected:g===y.message.channelHash})},_)})]})}),t.jsx("div",{className:"flex-shrink-0 px-5 py-2 text-center",children:t.jsxs("p",{className:"text-[11px] text-fg-muted",children:[b.length," messages · ",h," ",h===1?"channel":"channels",a&&t.jsxs("span",{className:"ml-2 text-sys-indigo",children:[t.jsx(Pe,{className:"inline size-3 animate-spin mr-1"}),"Decrypting..."]})]})})]})})}function bo(e){const n=[],o=new Set;for(const s of e.values()){const r=s.decoded;if(!r||!r.decrypted||r.macCorrupted||!r.text)continue;const a=ho(r.senderName,r.channelHash,r.text);o.has(a)||(o.add(a),n.push({timestamp:s.timestamp,channelName:r.channelName,channelHash:r.channelHash,senderName:r.senderName,text:r.text,rssi:s.rssi,snr:s.snr}))}return n}function jo({isLoaded:e}){const n=Ut(),o=e??n??!0;fe(ps);const s=we(),[r,a]=f.useState(!1),[c,i]=f.useState(null),d=Ne(),u=f.useCallback(()=>{i(null),a(!0),Ce.getState().queueDecryption(s)},[s]),m=Je(D=>D.requestedHash),w=Je(D=>D.clearRequest);f.useEffect(()=>{m&&(i(m),a(!0),Ce.getState().queueDecryption(s),w())},[m,w,s]);const l=Js(),x=Zs(),v=Ks(),h=f.useMemo(()=>bo(l),[l]),g=f.useMemo(()=>{const D=Date.now()/1e3,T=ee[d].minutes,R=D-T*60;return h.filter(P=>P.timestamp>=R)},[h,d]),C=f.useMemo(()=>g.length===0?null:g.reduce((D,T)=>T.timestamp>D.timestamp?T:D),[g]),S=x.isDecoding,k=f.useMemo(()=>{const D=Date.now()/1e3,T=ee[d].minutes,R=D-T*60,P=new Set;let y=0;for(const L of s)(L.type??L.payload_type)===rt.GRP_TXT&&((L.timestamp??0){const D=Date.now()/1e3,T=ee[d].minutes,R=D-T*60;for(const P of s)if((P.type??P.payload_type)===rt.GRP_TXT&&!((P.timestamp??0){if(!S){if(D){const R=T.find(P=>P.hash===D);if(R){Ce.getState().queueChannelDecryption(s,R.name);return}}Ce.getState().queueDecryption(s)}},[s,S]);return o?t.jsxs(t.Fragment,{children:[t.jsx("div",{onClick:u,className:Y("group cursor-pointer rounded-2xl transition-all duration-150","bg-surface/80 backdrop-blur-lg depth-raised","hover:bg-subtle-fill","px-3 py-2.5 sm:px-4 sm:py-3"),children:t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-shrink-0",children:[t.jsx(ss,{className:"size-4 text-icon-card-title flex-shrink-0"}),t.jsx("span",{className:"type-micro",children:"CHAT ACTIVITY"}),k>0&&t.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-subtle-fill ring-1 ring-inset ring-edge-subtle text-sm tabular-nums text-fg-secondary",children:k}),t.jsx(mt,{className:"size-4 text-fg-muted group-hover:text-sys-indigo transition-colors ml-auto sm:hidden"})]}),t.jsxs("div",{className:"flex items-center gap-2 sm:gap-1.5 min-w-0 overflow-hidden",children:[t.jsx(Ke,{mode:"wait",initial:!1,children:C?t.jsxs(ge.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex items-center gap-2 sm:gap-1.5 min-w-0",children:[C.channelName&&t.jsx("span",{className:"hidden sm:inline-flex",children:t.jsx(Qt,{channelName:C.channelName})}),t.jsx("div",{className:"hidden sm:flex w-[30px] h-[30px] clay-avatar",style:{"--avatar-color":An(He(C.senderName||"").cleanName)},children:He(C.senderName||"").emoji?t.jsx("span",{className:"text-base",children:He(C.senderName||"").emoji}):t.jsx("span",{className:"text-white text-xs font-bold tracking-tighter",children:Ln(C.senderName||"")})}),t.jsx("div",{className:"inline-flex items-center px-3 py-1.5 rounded-2xl rounded-tr-md bg-[#007AFF] shadow-sm min-w-0 flex-1 sm:flex-initial sm:max-w-xs sm:-ml-px",children:t.jsx("span",{className:"text-sm text-white truncate tracking-wide",children:Pn(C.text,{isOutgoing:!0})})}),t.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-subtle-fill ring-1 ring-inset ring-edge-subtle text-sm tabular-nums text-fg-secondary flex-shrink-0",children:en(C.timestamp)})]},`msg-${C.timestamp}-${C.senderName}-${C.channelHash}`):v?t.jsx(ge.span,{initial:{opacity:0},animate:{opacity:1},className:"text-sm text-fg-muted italic",children:"No messages yet"},"empty"):t.jsxs(ge.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,y:-16},transition:{duration:.15},className:"flex items-center gap-2 sm:gap-1.5",children:[t.jsx("div",{className:"hidden sm:block w-8 h-4 rounded bg-subtle-fill-strong animate-pulse"}),t.jsx("div",{className:"hidden sm:block w-[30px] h-[30px] rounded-full bg-subtle-fill-strong animate-pulse"}),t.jsx("div",{className:"h-8 w-32 sm:w-48 rounded-2xl bg-subtle-fill-strong animate-pulse"}),t.jsx("div",{className:"w-12 h-6 rounded-md bg-subtle-fill-strong animate-pulse"})]},"skeleton")}),t.jsx(mt,{className:"size-4 text-fg-muted group-hover:text-sys-indigo transition-colors flex-shrink-0 hidden sm:block ml-1"})]})]})}),t.jsx(yo,{open:r,onClose:()=>a(!1),messages:h,onLoadMore:p,hasMoreToLoad:j,isDecoding:S,initialChannel:c})]}):t.jsx("div",{className:"h-14 rounded-xl bg-elevated/50 animate-pulse"})}const q=2,wo=2,De=5,Re=4,be=20,We=Qe(J.cyan),qe=Qe(J.amber),Ue=Qe(J.red);function tt(e,n,o){const s=o.length;if(s===0)return null;let r=0,a=0;for(let b=0;br&&(r=j);const p=o[b].newlyGuarded.length;p>a&&(a=p)}if(r===0&&a===0)return null;const c=Math.max(1,De-a),i=r>0?Math.max(1,Math.ceil(r/c)):1,d=e-Re*2,u=n-Re*2,m=(d-q*(be-1))/be,w=(u-q*(De-1))/De,l=Math.max(3,Math.min(m,w)),x=l+q,v=s,h=0,g=be*x-q,C=Re+(d-g)/2,S=De*x-q,A=Re+(u-S),k=Math.min(wo,l/3);return{quantum:i,tileSize:l,colStep:x,visibleCols:v,startIdx:h,offsetX:C,offsetY:A,gridH:S,r:k}}function No(e,n,o,s,r){e.clearRect(0,0,o*(window.devicePixelRatio||1),s*(window.devicePixelRatio||1));const a=tt(o,s,n);if(a)for(let c=0;c0?(h=a.offsetY+a.gridH-d*a.colStep+q,g=d*a.colStep-q):v==="dropped"&&u>0?(h=a.offsetY+a.gridH-(d+u)*a.colStep+q,g=u*a.colStep-q):v==="guarded"&&m>0&&(h=a.offsetY+a.gridH-w*a.colStep+q,g=m*a.colStep-q),g>0&&(e.beginPath(),e.roundRect(l-1,h-1,a.tileSize+2,g+2,a.r+1),e.stroke()),e.restore()}}}function vo(e,n,o,s,r){const a=tt(o,s,r);if(!a)return null;const c=Math.floor((e-a.offsetX+q/2)/a.colStep);if(c<0||c>=a.visibleCols)return null;const i=r[a.startIdx+c],d=Math.ceil(i.allowedDelta/a.quantum),u=Math.ceil(i.droppedDelta/a.quantum),m=i.newlyGuarded.length,w=d+u+m;if(w===0)return null;const l=a.offsetX+c*a.colStep;if(el+a.tileSize)return null;const x=a.offsetY+a.gridH,v=x-d*a.colStep+q,h=x-(d+u)*a.colStep+q,g=x-w*a.colStep+q;return m>0&&n>=g&&n0&&n>=h&&n0&&n>=v&&n<=x?{col:c,segment:"allowed"}:null}function Xe(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}const de=5;function ko(e){if(e<60)return`${Math.round(e)}s`;if(e<3600)return`${Math.floor(e/60)}m`;const n=Math.floor(e/3600),o=Math.floor(e%3600/60);return o>0?`${n}h ${o}m`:`${n}h`}function Mo(e,n,o,s){const r=e.allowedDelta+e.droppedDelta;if(n==="allowed")return t.jsxs("div",{className:"min-w-[120px] space-y-1",children:[t.jsx("div",{className:"text-[10px] text-fg-muted tabular-nums",children:Xe(e.ts)}),t.jsxs("div",{className:"text-xs tabular-nums",children:[t.jsx("span",{className:"text-sys-cyan font-medium",children:e.allowedDelta}),t.jsx("span",{className:"text-fg-muted",children:" adverts allowed"})]}),e.trackedCount>0&&t.jsxs("div",{className:"text-[10px] text-fg-muted tabular-nums",children:[e.trackedCount," sources tracked"]}),r>0&&t.jsxs("div",{className:"text-[10px] text-fg-muted tabular-nums",children:[Math.round(e.allowedDelta/r*100),"% of traffic"]})]});if(n==="dropped"){const a=r>0?Math.round(e.droppedDelta/r*100):0,c=a-o;return t.jsxs("div",{className:"min-w-[140px] max-w-[240px] space-y-1",children:[t.jsx("div",{className:"text-[10px] text-fg-muted tabular-nums",children:Xe(e.ts)}),t.jsxs("div",{className:"text-xs tabular-nums",children:[t.jsx("span",{className:"text-sys-amber font-medium",children:e.droppedDelta}),t.jsx("span",{className:"text-fg-muted",children:" adverts dropped"})]}),r>0&&t.jsxs("div",{className:"text-[10px] tabular-nums",children:[t.jsxs("span",{className:a>50?"text-sys-amber":"text-fg-muted",children:[a,"% drop rate"]}),Math.abs(c)>=5&&t.jsxs("span",{className:c>0?"text-sys-amber":"text-sys-cyan",children:[" ","(",c>0?"+":"",c,"% vs avg)"]})]}),e.drops.length>0&&t.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:[e.drops.slice(0,de).map((i,d)=>t.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[t.jsx("span",{className:"font-mono truncate",children:i.name||i.pubkey.slice(0,8)}),t.jsx("span",{className:"text-fg-muted text-[10px] truncate flex-shrink-0 max-w-[100px]",children:i.reason})]},`${i.pubkey}-${d}`)),e.drops.length>de&&t.jsxs("div",{className:"text-[10px] text-fg-muted",children:["+",e.drops.length-de," more"]})]})]})}return t.jsxs("div",{className:"min-w-[140px] max-w-[220px] space-y-1",children:[t.jsx("div",{className:"text-[10px] text-fg-muted tabular-nums",children:Xe(e.ts)}),t.jsxs("div",{className:"text-xs text-sys-red font-medium",children:[e.newlyGuarded.length," newly guarded"]}),e.newlyGuarded.length>0&&t.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:[e.newlyGuarded.slice(0,de).map(a=>t.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[t.jsx("span",{className:"font-mono truncate",children:s(a.pubkey)}),t.jsx("span",{className:"text-fg-muted tabular-nums flex-shrink-0",children:ko(a.remaining)})]},a.pubkey)),e.newlyGuarded.length>de&&t.jsxs("div",{className:"text-[10px] text-fg-muted",children:["+",e.newlyGuarded.length-de," more"]})]})]})}function Co(e){if(e.length<=be)return e;const n=Math.ceil(e.length/be),o=[];for(let s=0;sCo(n),[n]),s=f.useRef(null),r=f.useRef(null),{show:a,hide:c,updatePosition:i}=an(),d=f.useRef(!1),u=f.useRef(null),m=ie(),w=on(),[l,x]=f.useState(!1),v=(P=(R=m==null?void 0:m.config)==null?void 0:R.repeater)==null?void 0:P.advert_rate_limit,h=(L=(y=m==null?void 0:m.config)==null?void 0:y.repeater)==null?void 0:L.advert_penalty_box,g=(B=(_=m==null?void 0:m.config)==null?void 0:_.repeater)==null?void 0:B.advert_adaptive,C=(e==null?void 0:e.stats.adverts_allowed)??0,S=(e==null?void 0:e.stats.adverts_dropped)??0,A=f.useMemo(()=>{const M=new Set;for(const F of o)for(const N of F.newlyGuarded)M.add(N.pubkey);return M.size},[o]),k=f.useMemo(()=>{const M=new Map;for(const N of(e==null?void 0:e.recent_drops)??[])N.name&&M.set(N.pubkey,N.name);const F=(m==null?void 0:m.neighbors)??{};for(const[N,$]of Object.entries(F))if(!M.has(N)){const E=$.name||$.node_name;E&&M.set(N,E)}return N=>M.get(N)||N.slice(0,8)},[e==null?void 0:e.recent_drops,m==null?void 0:m.neighbors]),b=f.useMemo(()=>{let M=0,F=0;for(const $ of o)M+=$.allowedDelta,F+=$.droppedDelta;const N=M+F;return N>0?Math.round(F/N*100):0},[o]),j="10m",p=f.useCallback(()=>{const M=s.current,F=r.current;if(!M||!F)return;const N=F.getBoundingClientRect(),$=window.devicePixelRatio||1,E=Math.floor(N.width),z=Math.floor(N.height);if(E===0||z===0)return;M.width=E*$,M.height=z*$,M.style.width=`${E}px`,M.style.height=`${z}px`;const I=M.getContext("2d");I&&(I.scale($,$),No(I,o,E,z,u.current))},[o]);f.useEffect(()=>{p();const M=new ResizeObserver(()=>p());return r.current&&M.observe(r.current),()=>M.disconnect()},[p]);const D=f.useCallback(M=>{const F=r.current;if(!F||o.length===0)return;const N=F.getBoundingClientRect(),$=Math.floor(N.width),E=Math.floor(N.height),z=M.clientX-N.left,I=M.clientY-N.top,G=vo(z,I,$,E,o);if(!G){u.current&&(u.current=null,p()),d.current&&(d.current=!1,c());return}const O=u.current;(!O||O.col!==G.col||O.segment!==G.segment)&&(u.current=G,p());const W=tt($,E,o);if(!W)return;const H=o[W.startIdx+G.col],X=Mo(H,G.segment,b,k);d.current?i(M.clientX,M.clientY):d.current=!0,a(X,M.clientX,M.clientY)},[o,b,k,a,c,i,p]),T=f.useCallback(()=>{u.current&&(u.current=null,p()),d.current&&(d.current=!1,c())},[c,p]);return t.jsxs(je,{noPadding:!0,isLoaded:!0,className:"mini-widget overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"mini-widget-header",children:[t.jsx(In,{className:"mini-widget-icon"}),t.jsx("span",{className:"mini-widget-title",children:"Advert Decisions"}),t.jsx(ne,{color:"zinc",children:j})]}),t.jsx("div",{ref:r,className:"h-28 mx-2 overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",onMouseMove:D,onMouseLeave:T,children:o.length>0?t.jsx("canvas",{ref:s,className:"block w-full h-full"}):t.jsx("div",{className:"flex items-center justify-center w-full h-full text-xs text-fg-muted",children:"Waiting for data…"})}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-3 sm:gap-x-4 gap-y-1 px-3 py-2.5 type-data-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"shrink-0 w-3 h-3 rounded-xs bg-sys-cyan"}),t.jsx("span",{className:"text-fg-secondary uppercase tracking-wide whitespace-nowrap",children:"Allow"}),t.jsx("span",{className:"tabular-nums text-fg-muted shrink-0",children:t.jsx(re,{value:C,priority:"low"})})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"shrink-0 w-3 h-3 rounded-xs bg-sys-amber"}),t.jsx("span",{className:"text-fg-secondary uppercase tracking-wide whitespace-nowrap",children:"Drop"}),t.jsx("span",{className:"tabular-nums text-fg-muted shrink-0",children:t.jsx(re,{value:S,priority:"low"})})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"shrink-0 w-3 h-3 rounded-xs bg-sys-red"}),t.jsx("span",{className:"text-fg-secondary uppercase tracking-wide whitespace-nowrap",children:"In Jail"}),t.jsx("span",{className:"tabular-nums text-fg-muted shrink-0",children:A})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"shrink-0 w-3 h-3 rounded-xs bg-zinc-500/30"}),t.jsx("span",{className:"text-fg-secondary uppercase tracking-wide whitespace-nowrap",children:"Tracked"}),t.jsx("span",{className:"tabular-nums text-fg-muted shrink-0",children:(e==null?void 0:e.tracked_pubkeys)??0})]})]}),t.jsx("div",{className:"mt-auto px-2 pb-2",children:t.jsxs($e,{color:"primary",outline:!0,className:"w-full justify-center",onClick:()=>x(!0),children:[t.jsx(Hn,{"data-slot":"icon"}),"Adapt"]})}),t.jsx(Dn,{open:l,onClose:()=>x(!1),currentConfig:{tokenBucket:v,penaltyBox:h,adaptive:g},onApplied:async()=>{await w({force:!0}).catch(()=>{})}})]})}const So=f.memo(To);function _o(e){if(e<60)return`${Math.round(e)}s`;if(e<3600)return`${Math.floor(e/60)}m`;const n=Math.floor(e/3600),o=Math.floor(e%3600/60);return o>0?`${n}h ${o}m`:`${n}h`}function Bo(){const e=ve(),n=ie();return{all:f.useMemo(()=>{if(!(e!=null&&e.active_penalties))return[];const s=new Map;for(const i of e.recent_drops??[])i.name&&s.set(i.pubkey,i.name);const r=(n==null?void 0:n.neighbors)??{};for(const[i,d]of Object.entries(r))if(!s.has(i)){const u=d.name||d.node_name;u&&s.set(i,u)}const a=new Map,c=new Map;for(const i of e.recent_drops??[])a.has(i.pubkey)||a.set(i.pubkey,i.reason),c.set(i.pubkey,(c.get(i.pubkey)??0)+1);return Object.entries(e.active_penalties).sort(([,i],[,d])=>d-i).map(([i,d])=>({pubkey:i,name:s.get(i)||i.slice(0,8),remaining:d,reason:a.get(i),dropCount:c.get(i)??0}))},[e,n==null?void 0:n.neighbors]),isLoading:!e,penaltyCount:e?Object.keys(e.active_penalties??{}).length:0}}function gs({offender:e,rank:n}){const o=n===0;return t.jsx(me,{content:t.jsxs("div",{className:"max-w-[260px]",children:[t.jsx("div",{className:"font-semibold mb-1",children:e.name}),t.jsx("div",{className:"text-fg-muted text-xs font-mono mb-1",children:e.pubkey}),t.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1 space-y-0.5 text-xs",children:[t.jsxs("div",{children:["Penalty: ",_o(e.remaining)," remaining"]}),e.reason&&t.jsxs("div",{children:["Reason: ",e.reason]}),t.jsxs("div",{children:["Recent drops: ",e.dropCount]})]})]}),children:t.jsx("div",{className:"text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:t.jsx("span",{className:`font-mono truncate ${o?"font-semibold text-sys-red":"text-fg-muted"}`,children:e.name})})})}function Do({open:e,onClose:n,offenders:o}){return t.jsxs(Vt,{open:e,onClose:n,size:"sm",children:[t.jsx(rn,{icon:t.jsx(os,{size:20}),title:`Jail (${o.length})`,onClose:n}),t.jsx(Yt,{className:"flex flex-col gap-1 max-h-[60vh] overflow-y-auto",children:o.length===0?t.jsx("div",{className:"text-center text-sm text-fg-muted py-4",children:"No active penalties"}):o.map(s=>t.jsx(gs,{offender:s},s.pubkey))})]})}function Ro(){const{all:e,isLoading:n,penaltyCount:o}=Bo(),s=ve(),[r,a]=f.useState(!1),c=f.useCallback(()=>a(!0),[]),i=f.useCallback(()=>a(!1),[]),d=e.slice(0,3),u=(s==null?void 0:s.recent_drops)??[],m=o===0&&u.length>0&&!n,w=u.slice(0,3);return t.jsxs(t.Fragment,{children:[t.jsxs(le,{title:"Most Wanted",icon:t.jsx(os,{className:"mini-widget-icon"}),isLoading:n,isLoaded:!0,children:[d.length>0?t.jsx("div",{className:"flex flex-col gap-0 sm:gap-0.5",children:d.map((l,x)=>t.jsx(gs,{offender:l,rank:x},l.pubkey))}):m?t.jsx("div",{className:"flex flex-col gap-0 sm:gap-0.5",children:w.map((l,x)=>t.jsx(me,{content:t.jsxs("div",{className:"max-w-[260px]",children:[t.jsx("div",{className:"font-semibold mb-1",children:l.name||l.pubkey}),t.jsx("div",{className:"text-fg-muted text-xs font-mono mb-1",children:l.pubkey}),t.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1 text-xs",children:[t.jsxs("div",{children:["Reason: ",l.reason]}),t.jsxs("div",{children:[Math.round(l.seconds_ago),"s ago"]})]})]}),children:t.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[t.jsx("span",{className:`font-mono truncate flex-1 min-w-0 ${x===0?"font-semibold text-sys-amber":"text-fg-muted"}`,children:l.name||l.pubkey.slice(0,8)}),t.jsx("span",{className:`pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right truncate ${x===0?"text-sys-amber":"text-fg-muted"}`,children:l.reason.replace(/^Token bucket: /,"").replace(/^Penalty: /,"")})]})},l.pubkey))}):o===0&&!n?t.jsx("div",{className:"flex items-center justify-center text-xs text-fg-muted mt-auto",children:"No active penalties"}):null,o>0?t.jsxs("div",{className:"flex items-center mt-auto pt-0.5",children:[t.jsxs("span",{className:"text-[10px] text-fg-muted tabular-nums",children:[o," in jail"]}),o>3&&t.jsx($e,{plain:!0,className:"ml-auto text-[10px] text-sys-blue hover:underline",onClick:c,children:"Show All"})]}):m?t.jsx("div",{className:"flex items-center mt-auto pt-0.5",children:t.jsxs("span",{className:"text-[10px] text-sys-amber tabular-nums",children:[u.length," recent drop",u.length!==1?"s":""]})}):null]}),t.jsx(Do,{open:r,onClose:i,offenders:e})]})}const Tt=[{key:"quiet",color:J.green,label:"Quiet"},{key:"normal",color:J.blue,label:"Normal"},{key:"busy",color:J.amber,label:"Busy"},{key:"congested",color:J.red,label:"Congested"}],St={quiet:"text-sys-green",normal:"text-sys-blue",busy:"text-sys-amber",congested:"text-sys-red"},_t=2,Ao=4;function Lo(e,n,o,s){const{quietMax:r,normalMax:a,busyMax:c,ewmaValue:i}=n;e.clearRect(0,0,o,s);const d=Math.max(c*2,i*1.3,c+.5),u=_t*3,m=o-u,w=[{start:0,end:r,color:J.green},{start:r,end:a,color:J.blue},{start:a,end:c,color:J.amber},{start:c,end:d,color:J.red}],l=[];let x=0;for(const T of w){const R=(T.end-T.start)/d*m;l.push({...T,px:x,pw:R}),x+=R+_t}const v=8,h=v,g=s-v-2;for(const T of l)e.fillStyle=T.color,e.globalAlpha=1,e.beginPath(),e.roundRect(T.px,h,T.pw,g,Ao),e.fill();function C(T){const R=Math.max(0,Math.min(T,d));for(const y of l)if(R<=y.end){const L=y.end>y.start?(R-y.start)/(y.end-y.start):0;return y.px+L*y.pw}const P=l[l.length-1];return P.px+P.pw}const S=C(i),A=4,k=4,b=h-1,j=h+g+1,p=lt[900],D=lt[200];e.fillStyle=p,e.beginPath(),e.moveTo(S-k,b-A),e.lineTo(S+k,b-A),e.lineTo(S,b),e.closePath(),e.fill(),e.fillStyle=D,e.beginPath(),e.moveTo(S-(k-1),b-A+.5),e.lineTo(S+(k-1),b-A+.5),e.lineTo(S,b-.5),e.closePath(),e.fill();for(const[T,R]of[[p,-1],[D,0],[p,1]])e.strokeStyle=T,e.lineWidth=1,e.beginPath(),e.moveTo(S+R,b),e.lineTo(S+R,j),e.stroke()}const Ae={stiffness:120,damping:20,mass:.8};function Po(){var P,y,L,_,B,M,F;const e=ve(),n=Jt(),o=Zt(),s=ln(),r=ie(),a=f.useRef(null),c=f.useRef(null),i=(y=(P=r==null?void 0:r.config)==null?void 0:P.repeater)==null?void 0:y.advert_adaptive,d=(e==null?void 0:e.adaptive.current_tier)??"normal",u=e==null?void 0:e.adaptive.pending_tier,m=!!u&&u!==d,w=((L=i==null?void 0:i.thresholds)==null?void 0:L.quiet_max)??.05,l=((_=i==null?void 0:i.thresholds)==null?void 0:_.normal_max)??.2,x=((B=i==null?void 0:i.thresholds)==null?void 0:B.busy_max)??.5,v=ue(s),h=Se(v,Ae),g=ue(w),C=ue(l),S=ue(x),A=Se(g,Ae),k=Se(C,Ae),b=Se(S,Ae);f.useEffect(()=>{v.set(s)},[s,v]),f.useEffect(()=>{g.set(w)},[w,g]),f.useEffect(()=>{C.set(l)},[l,C]),f.useEffect(()=>{S.set(x)},[x,S]);const j=f.useCallback(()=>{const N=a.current,$=c.current;if(!N||!$)return;const E=$.getBoundingClientRect(),z=window.devicePixelRatio||1,I=Math.floor(E.width),G=Math.floor(E.height);if(I===0||G===0)return;N.width=I*z,N.height=G*z,N.style.width=`${I}px`,N.style.height=`${G}px`;const O=N.getContext("2d");O&&(O.scale(z,z),Lo(O,{quietMax:A.get(),normalMax:k.get(),busyMax:b.get(),ewmaValue:h.get()},I,G))},[A,k,b,h]);f.useEffect(()=>{const N=[h.on("change",()=>j()),A.on("change",()=>j()),k.on("change",()=>j()),b.on("change",()=>j())];return()=>N.forEach($=>$())},[h,A,k,b,j]),f.useEffect(()=>{j();const N=new ResizeObserver(()=>j());return c.current&&N.observe(c.current),()=>N.disconnect()},[j]);const p=((M=Tt.find(N=>N.key===d))==null?void 0:M.label)??d,D=St[d]??"text-fg-muted",T=!e&&!o,R=o&&!n;return t.jsxs(le,{title:"Adaptive Tier",icon:t.jsx(cn,{className:"mini-widget-icon"}),isLoading:T,isLoaded:!0,error:R?"Adaptive tier data unavailable":null,headerRight:t.jsxs("span",{className:"text-[10px] text-fg-muted tabular-nums",children:[t.jsx("span",{className:"data-box data-box-compact",children:s.toFixed(2)}),t.jsx("span",{className:"ml-0.5 text-fg-muted/60",children:"adv/min"})]}),children:[t.jsx("div",{ref:c,className:"w-full h-8 sm:h-10 md:h-12",children:t.jsx("canvas",{ref:a,className:"block w-full h-full"})}),t.jsxs("div",{className:Y("data-box data-box-fill text-center font-semibold uppercase tracking-wide mt-1",D),children:[p,m&&t.jsxs("span",{className:Y("ml-1.5 text-[10px] font-normal animate-pulse",St[u]??"text-fg-muted"),children:["→ ",((F=Tt.find(N=>N.key===u))==null?void 0:F.label)??u]})]})]})}const $o=f.memo(Po);function Bt(e){if(e<60)return`${e}s`;if(e<3600){const s=Math.floor(e/60),r=e%60;return r>0?`${s}m ${r}s`:`${s}m`}const n=Math.floor(e/3600),o=Math.floor(e%3600/60);return o>0?`${n}h ${o}m`:`${n}h`}function Fo(){var l;const e=ve(),n=((e==null?void 0:e.stats.drop_rate)??0)*100,o=(e==null?void 0:e.stats.adverts_allowed)??0,s=(e==null?void 0:e.stats.adverts_dropped)??0,r=(e==null?void 0:e.tracked_pubkeys)??0,a=(e==null?void 0:e.effective_limits)??null,c=((l=e==null?void 0:e.metrics)==null?void 0:l.duplicate_ratio_ewma)??0,i=(e==null?void 0:e.stats.adverts_duplicate_reheard)??0,d=o+s,u=d>0?o/d*100:100,m=!e,w=d>0?s/d*100:0;return t.jsx(le,{title:"Drop Rate",icon:t.jsx(ns,{className:"mini-widget-icon"}),value:Math.round(n),unit:"%",isLoading:m,isLoaded:!0,headerRight:t.jsxs("span",{className:"text-[10px] text-fg-muted tabular-nums",children:["Tracked ",t.jsx("span",{className:"data-box data-box-compact ml-0.5",children:r})]}),children:d>0&&t.jsx(me,{content:t.jsxs("div",{className:"min-w-[140px] space-y-1",children:[t.jsx("div",{className:"text-xs text-fg-secondary font-medium",children:"Effective Limits"}),a?t.jsxs("div",{className:"space-y-0.5 text-[10px] tabular-nums",children:[t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("span",{className:"text-fg-muted",children:"Bucket"}),t.jsxs("span",{children:[a.bucket_capacity," tokens"]})]}),t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("span",{className:"text-fg-muted",children:"Refill"}),t.jsxs("span",{children:[a.refill_tokens," / ",Bt(a.refill_interval_seconds)]})]}),a.min_interval_seconds>0&&t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("span",{className:"text-fg-muted",children:"Min interval"}),t.jsx("span",{children:Bt(a.min_interval_seconds)})]})]}):t.jsx("div",{className:"text-[10px] text-fg-muted",children:"Limits not available"}),t.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1 space-y-0.5 text-[10px] tabular-nums",children:[t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("span",{className:"text-fg-muted",children:"Tracked"}),t.jsxs("span",{children:[r," pubkey",r!==1?"s":""]})]}),i>0&&t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("span",{className:"text-fg-muted",children:"Deduped"}),t.jsxs("span",{children:[i.toLocaleString()," (",Math.round(c*100),"%)"]})]})]})]}),children:t.jsxs("div",{className:"w-full mt-auto cursor-default",children:[t.jsxs("div",{className:"flex h-1.5 gap-0.5",children:[t.jsx("div",{className:"h-full rounded-full bg-sys-cyan transition-all duration-500",style:{width:`${u}%`}}),t.jsx("div",{className:"h-full rounded-full bg-sys-red transition-all duration-500",style:{width:`${w}%`}})]}),t.jsxs("div",{className:"flex justify-between mt-0.5",children:[t.jsx("span",{className:"type-data-xs text-sys-cyan/70 tabular-nums",children:o.toLocaleString()}),t.jsx("span",{className:"type-data-xs text-sys-red/70 tabular-nums",children:s.toLocaleString()})]})]})})})}const Eo="/assets/spam-can-JZXwgFOy.svg",Io=1376,Ve=768,Ho=[{x:0,w:280,stretch:!1},{x:280,w:4,stretch:!0},{x:284,w:808,stretch:!1},{x:1092,w:4,stretch:!0},{x:1096,w:280,stretch:!1}];function zo(){return t.jsx("div",{className:"relative h-full w-full overflow-hidden rounded-[var(--radius-card)]",children:t.jsx("div",{className:"absolute inset-0 flex","data-spam-can":!0,children:Ho.map(({x:e,w:n,stretch:o})=>t.jsx("svg",{viewBox:`${e} 0 ${n} ${Ve}`,preserveAspectRatio:"none",style:o?{height:"100%",flex:"1 1 0",minWidth:0}:{height:"100%",aspectRatio:`${n} / ${Ve}`,flexShrink:0},children:t.jsx("image",{href:Eo,width:Io,height:Ve})},e))})})}const Oo=f.memo(zo);function Go(){const e=Jt();return!Zt()||!e?null:t.jsxs("div",{className:"mesh-health-container relative",children:[t.jsxs("div",{className:"mesh-health-header",children:[t.jsx(Vn,{className:"w-4 h-4 text-sys-blue"}),t.jsx("span",{className:"type-label text-fg-muted",children:"SPAMGUARD"})]}),t.jsxs("div",{className:"widget-row",children:[t.jsx("div",{className:"widget-leading",children:t.jsx(So,{})}),t.jsx($o,{}),t.jsx(Fo,{}),t.jsx(Ro,{}),t.jsx(Oo,{})]})]})}function Rr(){var P,y,L;const e=ie(),n=dn(),o=un(),s=ya(),r=f.useRef(!1);o&&!r.current&&(r.current=!0);const a=r.current,c=Ne(),i=Xt(),d=mn(),u=ee[c]??ee[4],m=d.isBackgroundLoading&&c>=5,[w,l]=f.useState([]),[x,v]=f.useState(0),[h,g]=f.useState(()=>localStorage.getItem("rx-crc-overlay")==="true"),C=f.useCallback(()=>{g(_=>{const B=!_;return localStorage.setItem("rx-crc-overlay",String(B)),B})},[]),[S,A]=f.useState(()=>localStorage.getItem("rx-analytics-view")==="true"),k=f.useCallback(_=>{A(_),localStorage.setItem("rx-analytics-view",String(_))},[]);f.useEffect(()=>{const _=u.minutes/60;Promise.all([Wt(_),Gt(_,5e4)]).then(([B,M])=>{var F,N;v((B.success&&((F=B.data)==null?void 0:F.count)!=null?B.data.count:M.success&&((N=M.data)==null?void 0:N.count)!=null?M.data.count:0)??0),l(M.success&&M.data?M.data.history:[])})},[u.minutes]);const b=f.useMemo(()=>{const _=G=>(G==null?void 0:G.reduce((O,W)=>O+W.count,0))??0,B=_(s==null?void 0:s.received),M=_(s==null?void 0:s.unique_received),F=_(s==null?void 0:s.forwarded),N=_(s==null?void 0:s.dropped),$=_(s==null?void 0:s.transmitted),E=((s==null?void 0:s.time_range_minutes)??u.minutes)/60,z=E>0?Math.round(B/E):0,I=E>0?Math.round(F/E):0;return{received:B,uniqueReceived:M,forwarded:F,dropped:N,transmitted:$,rxPerHour:z,fwdPerHour:I}},[s,u.minutes]),j=f.useMemo(()=>s?{totalBytes:s.totalReceivedBytes,kbPerHour:s.kbPerHour}:{totalBytes:0,kbPerHour:0},[s]),p=f.useMemo(()=>{if(!s)return[];const{receivedBytesBuckets:_,start_time:B,bucket_duration_seconds:M,bucket_count:F}=s,N=new Array(F).fill(0);for(const $ of w){let E=Math.floor(($.timestamp-B)/M);E<0&&(E=0),!(E>=F)&&N[E]++}return _.map(($,E)=>({start:$.start,end:$.end,bytesByType:{...$.countByType,...h&&N[E]>0?{[Q]:N[E]}:{}},totalBytes:$.totalCount}))},[s,w,h]),D=f.useMemo(()=>{if(!s)return[];const{receivedCountByType:_}=s,B=Object.keys(_).map(M=>parseInt(M,10)).filter(M=>(_[M]??0)>0).sort((M,F)=>(_[F]??0)-(_[M]??0));return h&&x>0&&B.unshift(Q),B},[s,x,h]),T=f.useMemo(()=>{if(!s)return{};const _={...s.receivedCountByType??{}};return h&&x>0&&(_[Q]=x),_},[s,x,h]),R=(e==null?void 0:e.node_name)??((P=e==null?void 0:e.config)==null?void 0:P.node_name)??"Unknown Node";return f.useEffect(()=>{R&&R!=="Unknown Node"&&(document.title=`pyMC: ${R}`)},[R]),n?t.jsxs(dt,{neomorphic:!0,className:"p-8 text-center",children:[t.jsx("p",{className:"type-subheading text-sys-red mb-2",children:"Failed to connect to backend"}),t.jsx("p",{className:"type-body text-fg-muted",children:n}),t.jsx("p",{className:"type-data-sm text-fg-muted mt-4",children:"Make sure the backend is running on port 8000"})]}):t.jsxs(fn,{children:[t.jsx(pn,{title:R,icon:t.jsx(zn,{}),subtitle:t.jsx(Sn,{}),controls:t.jsx(es,{ranges:ee,selectedIndex:c,onSelect:i,isPending:m})}),t.jsxs(hn,{ready:a,children:[t.jsx(jo,{}),t.jsx(ft,{template:"hero-auto",children:t.jsxs(dt,{neomorphic:!0,children:[t.jsx(It,{icon:t.jsx(ns,{}),title:"PACKETS RECEIVED",badge:u.label,badgeColor:"zinc",titleExtra:t.jsx(Ht,{enabled:S,onChange:k,size:"sm",label:t.jsx("span",{className:"font-mono text-xs text-fg-muted uppercase tracking-wide",children:"Advanced"})}),actions:a?t.jsx("div",{className:"flex items-center gap-1.5",children:S?t.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"CRC errors — packets corrupted during radio transmission",children:[t.jsx(ct,{className:"w-3.5 h-3.5 text-sys-red"}),t.jsxs("span",{children:["CRC ",x.toLocaleString()]})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:C,className:"p-1 rounded hover:bg-zinc-500/20 active:bg-zinc-500/30 transition-colors touch-manipulation",title:h?"Hide CRC Errors":"Show CRC Errors","aria-label":h?"Hide CRC error overlay":"Show CRC error overlay","aria-pressed":h,children:t.jsx(ct,{className:`w-3.5 h-3.5 transition-colors ${h?"text-sys-red":"text-fg-muted"}`})}),t.jsxs("div",{className:"data-box",children:[j.kbPerHour," KB/hr"]})]})}):void 0}),t.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:S?t.jsx(Ra,{forwardedBuckets:(s==null?void 0:s.forwardedBytesBuckets)??[],droppedBuckets:(s==null?void 0:s.droppedBytesBuckets)??[],forwardedActiveTypes:(s==null?void 0:s.forwardedActiveTypes)??[],droppedActiveTypes:(s==null?void 0:s.droppedActiveTypes)??[],forwardedCount:b.forwarded,droppedCount:b.dropped,crcCount:x,crcHistory:w,receivedCount:b.received,forwardedTotalByType:(s==null?void 0:s.forwardedTotalByType)??{},droppedTotalByType:(s==null?void 0:s.droppedTotalByType)??{},startTime:(s==null?void 0:s.start_time)??0,bucketDurationSeconds:(s==null?void 0:s.bucket_duration_seconds)??1,bucketCount:(s==null?void 0:s.bucket_count)??0,timeRangeMinutes:u.minutes}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-8",children:[t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("div",{className:"type-data-xl text-fg-primary",children:a?t.jsx(re,{value:b.received,className:"font-mono tabular-nums",priority:"high"}):t.jsx("span",{className:"opacity-30",children:"—"})}),t.jsx(ne,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"Total Rx"})]}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("div",{className:"type-data-xl text-fg-primary",children:a?t.jsx(re,{value:b.uniqueReceived,className:"font-mono tabular-nums",priority:"high"}):t.jsx("span",{className:"opacity-30",children:"—"})}),t.jsx(ne,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"Unique"})]})]}),t.jsx("div",{className:"mt-2 flex-1 min-h-0",children:t.jsx(wa,{buckets:p,activeTypes:D,totalByType:T,mode:"count"})})]})})]})}),t.jsx(mo,{leading:t.jsx(Ea,{stats:e,localHash:e==null?void 0:e.local_hash,receivedBuckets:s==null?void 0:s.received,droppedBuckets:s==null?void 0:s.dropped,forwardedBuckets:s==null?void 0:s.forwarded,bucketDurationSeconds:s==null?void 0:s.bucket_duration_seconds,timeRangeLabel:u.label})}),t.jsx(Go,{}),t.jsx(Ha,{}),e&&t.jsx(ft,{template:"auto",children:t.jsx(Rn,{nodeName:R,publicKey:e.public_key,pathHashMode:(L=(y=e.config)==null?void 0:y.mesh)==null?void 0:L.path_hash_mode})})]})]})}export{Rr as default}; diff --git a/frontend/dist/assets/Dashboard-TId1VvOA.js b/frontend/dist/assets/Dashboard-TId1VvOA.js deleted file mode 100644 index 41410400..00000000 --- a/frontend/dist/assets/Dashboard-TId1VvOA.js +++ /dev/null @@ -1,65 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C2xvS0Jd.js","assets/index-7uzBcJ1E.css"])))=>i.map(i=>d[i]); -import{e as Z,f as bs,h as Dt,k as Rt,J as js,n as ws,o as Ns,p as Ee,q as vs,r as f,M as ks,t as Ms,_ as st,v as nt,w as At,x as Pt,y as Cs,z as te,D as Ts,j as t,d as Ke,m as ge,S as Lt,E as $t,U as Ss,F as _s,G as Pe,P as Bs,H as Ds,K as Q,L as Rs,N as As,O as Y,Q as we,R as Ft,T as Et,V as ne,W as Ps,X as Ls,Y as je,$ as $s,a0 as at,a1 as Fs,a2 as Le,a3 as Es,a4 as Is,a5 as Hs,a6 as ie,a7 as It,a8 as Ht,a9 as zs,B as $e,aa as zt,ab as Ot,ac as Os,ad as Ne,ae as ee,af as Gt,ag as Wt,ah as Gs,ai as Ws,aj as qs,ak as Xs,al as Us,am as Ie,u as qt,an as Vs,ao as ot,ap as me,aq as Me,ar as Xt,as as Ys,at as Ce,au as Js,av as Zs,aw as Ks,ax as rt,ay as Qs,c as J,az as en,aA as Ut,aB as it,aC as Vt,aD as Yt,aE as tn,aF as ve,aG as sn,aH as nn,aI as an,aJ as Qe,aK as on,aL as Jt,aM as Zt,aN as rn,aO as ln,Z as lt,aP as cn,aQ as dn,aR as un,aS as ct}from"./index-C2xvS0Jd.js";import{C as dt,P as mn,a as fn,B as pn}from"./PageLayout-Cg7r5tdt.js";import{u as fe,r as pe,h as hn,a as xn,b as gn,i as yn}from"./consumer-registry-DJyYnY6J.js";import{A as re,D as Ye}from"./DataValue-9iNfucjq.js";import{c as bn}from"./node-types-BD70swWz.js";import{b as Kt,c as ye,a as jn,d as wn,F as Te}from"./meshcore-tx-constants-DgpFTAmf.js";import{S as Nn,u as Je,P as vn,T as kn,C as Qt}from"./PacketList-BlTe2eo4.js";import{useGetDecodedContent as Mn,useResolveSource as Cn}from"./usePipelineStore-Do-g28wv.js";import{A as ut}from"./arrow-right-DySc3ssS.js";import{T as es,M as Tn}from"./MqttModeBadge-DOXwpg3i.js";import{L as ts}from"./LightSparkline-Dtyxi9BD.js";import{c as Sn}from"./link-scoring-BjtZpDDb.js";import{Z as _n}from"./zap-v3FkQoQ-.js";import{A as Bn,N as Dn}from"./AutoConfigureDialog-C6zj_Lmv.js";import{g as Rn,e as He,a as An,f as Pn}from"./chat-utils-DnJ-lYj3.js";import{C as Ln}from"./ChatBubble-DsIWWOdr.js";import{M as ss}from"./message-square-text-B47-Hjgn.js";import{C as mt}from"./chevron-right-C9GG0xWI.js";import{H as $n}from"./hash-DjqT3oXN.js";import{M as Fn}from"./message-square-BE66c4_-.js";import{S as En}from"./shield-check-BB1TbeiZ.js";import{W as In}from"./wand-sparkles-D9rSrVnU.js";import{u as ue}from"./index-QCPybZMd.js";import{H as Hn}from"./useMapViewStore-DnPjO7Qt.js";import{R as ft}from"./Grid-kVOI-wJp.js";import"./chevron-up-CTCjpmk_.js";import"./primitives-Ctn6pdEU.js";import"./badge-colors-Dl76Mz8m.js";import"./SignalIndicator-DO8Lkax5.js";import"./arrow-up-C0VG8Et4.js";import"./arrow-down-4OY_dsXk.js";import"./payload-detail-BAEvS7Pl.js";import"./map-pin-CQk00ph2.js";import"./circle-question-mark-CF3fGjhH.js";import"./layers-BICmdhXR.js";import"./clock-DU0z3qMB.js";import"./route-Awj5QSAO.js";import"./activity-BFfde9uG.js";import"./database-cyku2KnA.js";import"./shield-DvZvtyKV.js";import"./index-wtt5rE5a.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 zn=[["path",{d:"M15 11a1 1 0 0 0 1 1h2.939a1 1 0 0 1 .75 1.811l-6.835 6.836a1.207 1.207 0 0 1-1.707 0L4.31 13.81a1 1 0 0 1 .75-1.811H8a1 1 0 0 0 1-1V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1z",key:"1eaqc3"}]],pt=Z("arrow-big-down",zn);/** - * @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 On=[["path",{d:"M9 13a1 1 0 0 0-1-1H5.061a1 1 0 0 1-.75-1.811l6.836-6.835a1.207 1.207 0 0 1 1.707 0l6.835 6.835a1 1 0 0 1-.75 1.811H16a1 1 0 0 0-1 1v6a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1z",key:"lh0v7k"}]],ht=Z("arrow-big-up",On);/** - * @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 Gn=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],ns=Z("chart-column",Gn);/** - * @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 Wn=[["line",{x1:"12",x2:"18",y1:"12",y2:"18",key:"1rg63v"}],["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],qn=Z("copy-x",Wn);/** - * @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 Xn=[["path",{d:"m21.12 6.4-6.05-4.06a2 2 0 0 0-2.17-.05L2.95 8.41a2 2 0 0 0-.95 1.7v5.82a2 2 0 0 0 .88 1.66l6.05 4.07a2 2 0 0 0 2.17.05l9.95-6.12a2 2 0 0 0 .95-1.7V8.06a2 2 0 0 0-.88-1.66Z",key:"1u2ovd"}],["path",{d:"M10 22v-8L2.25 9.15",key:"11pn4q"}],["path",{d:"m10 14 11.77-6.87",key:"1kt1wh"}]],Un=Z("cuboid",Xn);/** - * @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 Vn=[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]],as=Z("ear",Vn);/** - * @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 Yn=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],Jn=Z("megaphone",Yn);/** - * @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 Zn=[["path",{d:"M18 11h-4a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h4",key:"17ldeb"}],["path",{d:"M6 7v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7",key:"nc37y6"}],["rect",{width:"16",height:"5",x:"4",y:"2",rx:"1",key:"3jeezo"}]],Kn=Z("pill-bottle",Zn);/** - * @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 Qn=[["path",{d:"M4 10a7.31 7.31 0 0 0 10 10Z",key:"1fzpp3"}],["path",{d:"m9 15 3-3",key:"88sc13"}],["path",{d:"M17 13a6 6 0 0 0-6-6",key:"15cc6u"}],["path",{d:"M21 13A10 10 0 0 0 11 3",key:"11nf8s"}]],ea=Z("satellite-dish",Qn);/** - * @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 ta=[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]],os=Z("skull",ta);/** - * @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 sa=[["circle",{cx:"7",cy:"7",r:"5",key:"x29byf"}],["circle",{cx:"17",cy:"17",r:"5",key:"1op1d2"}],["path",{d:"M12 17h10",key:"ls21zv"}],["path",{d:"m3.46 10.54 7.08-7.08",key:"1rehiu"}]],na=Z("tablets",sa);/** - * @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 aa=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],oa=Z("timer",aa);function ra(...e){const n=!Array.isArray(e[0]),o=n?0:-1,s=e[0+o],r=e[1+o],a=e[2+o],c=e[3+o],i=bs(r,a,c);return n?i(s):i}function ia(e,n,o={}){const s=e.get();let r=null,a=s,c;const i=typeof s=="string"?s.replace(/[\d.-]/g,""):void 0,d=()=>{r&&(r.stop(),r=null)},u=()=>{d();const m=gt(e.get()),j=gt(a);m!==j&&(r=new js({keyframes:[m,j],velocity:e.getVelocity(),type:"spring",restDelta:.001,restSpeed:.01,...o,onUpdate:c}))};if(e.attach((m,j)=>{a=m,c=l=>j(xt(l,i)),Dt.postRender(()=>{var l;u(),(l=e.events.animationStart)==null||l.notify(),r==null||r.then(()=>{var x;(x=e.events.animationComplete)==null||x.notify()})})},d),Rt(n)){const m=n.on("change",l=>e.set(xt(l,i))),j=e.on("destroy",m);return()=>{m(),j()}}return d}function xt(e,n){return n?e+n:e}function gt(e){return typeof e=="number"?e:parseFloat(e)}function rs(e,n){const o=ue(n()),s=()=>o.set(n());return s(),ws(()=>{const r=()=>Dt.preRender(s,!1,!0),a=e.map(c=>c.on("change",r));return()=>{a.forEach(c=>c()),Ns(s)}}),o}function la(e){Ee.current=[],e();const n=rs(Ee.current,e);return Ee.current=void 0,n}function ca(e,n,o,s){if(typeof e=="function")return la(e);const a=ra(n,o,s);return Array.isArray(e)?yt(e,a):yt([e],([c])=>a(c))}function yt(e,n){const o=vs(()=>[]);return rs(e,()=>{o.length=0;const s=e.length;for(let r=0;rRt(e)?e.get():e;if(o)return ca(s);const r=ue(s());return f.useInsertionEffect(()=>ia(r,e,n),[r,JSON.stringify(n)]),r}function Se(e,n={}){return da(e,{type:"spring",...n})}const oe=Ms(()=>({result:null,isComputing:!1})),ua=500,ma=300;let ce=null,_e=null;function fa(e){var o;const n=(o=e==null?void 0:e.config)==null?void 0:o.radio;return`${(n==null?void 0:n.spreading_factor)??7}:${(n==null?void 0:n.bandwidth)??125e3}:${(n==null?void 0:n.coding_rate)??5}:${(n==null?void 0:n.preamble_length)??8}`}function pa(){if(ce)return ce;if(typeof window>"u")return null;try{ce=new Worker(new URL("/assets/dashboard-bucketing.worker-BwrZMAuc.js",import.meta.url),{type:"module"}),ce.onmessage=e=>{if(e.data.type==="error"){console.error("[DashboardBucketing] Worker error:",e.data.error),oe.setState({isComputing:!1});return}oe.setState({result:e.data.payload,isComputing:!1})},ce.onerror=e=>{console.error("[DashboardBucketing] Worker error:",e),oe.setState({isComputing:!1})}}catch(e){console.error("[DashboardBucketing] Failed to init worker:",e)}return ce}function ha(e,n,o,s){const r=pa();if(!r)return;const a=e.length,c=new Float64Array(a),i=new Float64Array(a),d=new Uint16Array(a),u=new Uint8Array(a),m=new Uint8Array(a),j=new Uint8Array(a),l=new Uint8Array(a),x=new Float32Array(a),N=new Float32Array(a),h=new Uint32Array(a),y=new Map;let C=0;for(let B=0;BparseInt(n,10)).filter(n=>e[n]>0).sort((n,o)=>e[o]-e[n])}function xa(e,n,o){const s={...e,received:[...e.received],unique_received:[...e.unique_received],transmitted:[...e.transmitted],forwarded:[...e.forwarded],dropped:[...e.dropped],receivedBytesBuckets:e.receivedBytesBuckets.map(m=>({...m,bytesByType:{...m.bytesByType},countByType:{...m.countByType}})),forwardedBytesBuckets:e.forwardedBytesBuckets.map(m=>({...m,bytesByType:{...m.bytesByType},countByType:{...m.countByType}})),droppedBytesBuckets:e.droppedBytesBuckets.map(m=>({...m,bytesByType:{...m.bytesByType},countByType:{...m.countByType}})),receivedTotalByType:{...e.receivedTotalByType},receivedCountByType:{...e.receivedCountByType},forwardedTotalByType:{...e.forwardedTotalByType},droppedTotalByType:{...e.droppedTotalByType}},{start_time:r,end_time:a,bucket_duration_seconds:c,bucket_count:i}=e,d=new Set;for(const m of n){const j=m.timestamp??0;if(ja)continue;const l=Math.floor((j-r)/c);if(l<0||l>=i)continue;d.has(l)||(d.add(l),s.received[l]={...s.received[l]},s.unique_received[l]={...s.unique_received[l]},s.transmitted[l]={...s.transmitted[l]},s.forwarded[l]={...s.forwarded[l]},s.dropped[l]={...s.dropped[l]});const x=At(m,o),N=m.length??m.payload_length??0,h=m.type??m.payload_type??0,y=m.packet_origin;y==="tx_local"?(s.transmitted[l].count++,s.transmitted[l].airtime_ms+=x):y==="tx_forward"||m.transmitted?(s.forwarded[l].count++,s.forwarded[l].airtime_ms+=x,s.forwardedBytesBuckets[l].bytesByType[h]=(s.forwardedBytesBuckets[l].bytesByType[h]??0)+N,s.forwardedBytesBuckets[l].totalBytes+=N,s.forwardedBytesBuckets[l].countByType[h]=(s.forwardedBytesBuckets[l].countByType[h]??0)+1,s.forwardedBytesBuckets[l].totalCount++,s.forwardedTotalByType[h]=(s.forwardedTotalByType[h]??0)+N,s.totalForwardedCount++):m.drop_reason&&(s.dropped[l].count++,s.dropped[l].airtime_ms+=x,s.droppedBytesBuckets[l].bytesByType[h]=(s.droppedBytesBuckets[l].bytesByType[h]??0)+N,s.droppedBytesBuckets[l].totalBytes+=N,s.droppedBytesBuckets[l].countByType[h]=(s.droppedBytesBuckets[l].countByType[h]??0)+1,s.droppedBytesBuckets[l].totalCount++,s.droppedTotalByType[h]=(s.droppedTotalByType[h]??0)+N,s.totalDroppedCount++),y!=="tx_local"&&(s.received[l].count++,s.received[l].airtime_ms+=x,s.unique_received[l].count++,s.unique_received[l].airtime_ms+=x,s.receivedBytesBuckets[l].bytesByType[h]=(s.receivedBytesBuckets[l].bytesByType[h]??0)+N,s.receivedBytesBuckets[l].totalBytes+=N,s.receivedBytesBuckets[l].countByType[h]=(s.receivedBytesBuckets[l].countByType[h]??0)+1,s.receivedBytesBuckets[l].totalCount++,s.receivedTotalByType[h]=(s.receivedTotalByType[h]??0)+N,s.receivedCountByType[h]=(s.receivedCountByType[h]??0)+1,s.totalReceivedBytes+=N)}const u=s.time_range_minutes/60;return s.kbPerHour=u>0?Math.round(s.totalReceivedBytes/1024/u):0,s.forwardedRatePerHour=u>0?Math.round(s.totalForwardedCount/u):0,s.droppedRatePerHour=u>0?Math.round(s.totalDroppedCount/u):0,s.receivedActiveTypes=ze(s.receivedTotalByType),s.forwardedActiveTypes=ze(s.forwardedTotalByType),s.droppedActiveTypes=ze(s.droppedTotalByType),s}typeof window<"u"&&Promise.all([st(()=>import("./index-C2xvS0Jd.js").then(e=>e.ho),__vite__mapDeps([0,1])),st(()=>import("./index-C2xvS0Jd.js").then(e=>e.hn),__vite__mapDeps([0,1]))]).then(([e,n])=>{const{DASHBOARD_TIME_RANGES:o}=n;let s=0,r=-1,a="";e.useStore.subscribe(c=>{const i=c.packets.length,d=c.globalTimeRangeIndex,u=fa(c.stats);if(i===s&&d===r&&u===a)return;const m=s,j=r,l=a;if(s=i,r=d,a=u,i===0)return;const x=o[d]??o[4],N=x.minutes,h=x.buckets,y=c.stats,C=nt(y),T=i-m,B=d!==j,v=u!==l,w=oe.getState().result;if(!B&&!v&&T>0&&T{_e=null;const p=e.useStore.getState();if(p.packets.length===0||!p.stats)return;const _=o[p.globalTimeRangeIndex]??o[4],k=nt(p.stats);ha(p.packets,_.minutes,_.buckets,k)},ma)})});const ga=()=>oe(e=>e.result),is=[{target:"ReceivedChart",fn:"type",minStage:1},{target:"ReceivedChart",fn:"airtime",minStage:1,when:hn}];pe(is);function ya(e){const o=new Date(e*1e3).getHours();return o>=6&&o<18}function bt(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}const he=32,Oe=20,ba=[.25,.5,.75,1];function ja({buckets:e,activeTypes:n,totalByType:o,mode:s="bytes"}){fe(is);const r=Pt(),[a,c]=f.useState(null),[i,d]=f.useState(null),[u,m]=f.useState(null),j=f.useCallback((v,w,b)=>{c(w),d(b)},[]),l=e.length>0&&n.length>0,x=a?ya(a.start):null,N=a?bt(a.start):"",h=u!==null&&x!==null&&u!==x;x!==u&&m(x);const y=f.useMemo(()=>Cs(e),[e]),C=s==="count"?te:Ts,T=f.useMemo(()=>y===0?[]:ba.map(v=>({pct:v,label:C(Math.round(y*v)),pos:(1-v)*100})),[y,C]),B=f.useMemo(()=>{if(e.length===0)return[];const v=e.length,w=Math.max(1,Math.floor(v/6)),b=[];for(let p=0;pt.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${b}%`,transform:v===1?"none":"translateY(-50%)",right:0},children:w},v))}),t.jsx("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:he,right:0,top:0,bottom:Oe},children:l&&t.jsx(Ss,{buckets:e,activeTypes:n,gridColor:r.grid,axisTickColor:r.axisTick,onHover:j,yAxisFormat:s,externalAxes:!0})}),t.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:he,height:Oe},"aria-hidden":"true",children:B.map((v,w)=>t.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${v.pos}%`,transform:w===0?"none":w===B.length-1?"translateX(-100%)":"translateX(-50%)"},children:v.label},w))})]}),t.jsx("div",{className:"pt-2 px-1 pb-2 shrink-0",children:l&&t.jsx(_s,{activeTypes:n,totalByType:o,formatMode:s})})]})}const jt={top:8,right:8,bottom:28,left:48},wt={top:0,right:0,bottom:0,left:0};let Be=null,Nt=0;const wa=1e3;function Na(){const e=performance.now();return Be&&e-Nth&&(h=D),P>y&&(y=P)}h===0&&y===0?(h=1,y=1):h===0?h=1:y===0&&(y=1);const C=h*1.05,T=y*1.05,B=C+T;let v=C/B;v=Math.max(Fe,Math.min(1-Fe,v));const w=i-m,b=v*w,p=(1-v)*w,_=a+b,k=a+b+m,A=a+b+m/2;for(let g=0;g0)for(const F of s){const M=R[F]??0;if(M===0)continue;const $=M/C*b,E=P-$;e.fillStyle=Pe(F),e.fillRect(D,E,l,$),P=E}let L=k;const S=o[g].countByType;if(N[g]>0){const F=S[Q]??0;if(F>0){const M=F/T*p;e.fillStyle=Pe(Q),e.fillRect(D,L,l,M),L+=M}for(const M of s){if(M===Q)continue;const $=S[M]??0;if($===0)continue;const E=$/T*p;e.fillStyle=Pe(M),e.fillRect(D,L,l,E),L+=E}}}return{baselineY:A,fwdHalf:b,drpHalf:p,fwdCeil:C,drpCeil:T,gapPx:m}}function ka(e,n,o,s,r,a,c,i,d,u,m=!1){if(n.length===0)return;const{baselineY:j,fwdHalf:l,drpHalf:x,fwdCeil:N,drpCeil:h,gapPx:y}=d,C=Na(),T=j-Math.ceil(y/2),B=j+Math.floor(y/2);e.save(),e.strokeStyle=c,e.lineWidth=1*u,e.setLineDash([]);const v=[.5,1];for(const w of v){const b=Math.round(T-w*l)+.5;e.beginPath(),e.moveTo(o,b),e.lineTo(o+r,b),e.stroke();const p=Math.round(B+w*x)+.5;e.beginPath(),e.moveTo(o,p),e.lineTo(o+r,p),e.stroke()}if(e.restore(),e.clearRect(o,j-Math.ceil(y/2),r,y),!m){e.save(),e.font=`bold ${10*u}px ${C}`,e.textAlign="left";const w=4*u,b=2*u;for(const p of v){const _=Math.round(N*p),k=Math.round(h*p),A=p===1,g=T-p*l,D=B+p*x;_>0&&(e.fillStyle=Y.green,e.globalAlpha=.7,A?(e.textBaseline="top",e.fillText(te(_),w,g+b)):(e.textBaseline="middle",e.fillText(te(_),w,g))),k>0&&(e.fillStyle=Y.red,e.globalAlpha=.7,A?(e.textBaseline="bottom",e.fillText(te(k),w,D-b)):(e.textBaseline="middle",e.fillText(te(k),w,D)))}e.globalAlpha=1,e.restore()}if(!m){e.save(),e.font=`${12*u}px ${C}`,e.fillStyle=i,e.textBaseline="top",e.textAlign="center";const w=8*u,b=n.length,p=Math.max(1,Math.floor(b/6)),_=r/b;for(let k=0;k{const r=n[s]??0,a=o[s]??0;if(r===0&&a===0)return null;const c=s===Q?"CRC":Bs[s]??`TYPE_${s}`;return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"shrink-0 w-3 h-3 rounded-xs",style:{backgroundColor:Pe(s)}}),t.jsx("span",{className:"text-fg-secondary whitespace-nowrap",children:c}),t.jsxs("span",{className:"tabular-nums",children:[t.jsxs("span",{className:"text-sys-green",children:["▲",te(r)]})," ",t.jsxs("span",{className:"text-sys-red",children:["▼",te(a)]})]})]},s)})})}function Ca(e,n,o){const s=e.length;let r=0,a=0;for(let m=0;mr&&(r=j),l>a&&(a=l)}r===0&&a===0?(r=1,a=1):r===0?r=1:a===0&&(a=1);const c=r*1.05,i=a*1.05,d=c+i;let u=c/d;return u=Math.max(Fe,Math.min(1-Fe,u)),{fwdMax:Math.round(c),drpMax:Math.round(i),fwdFrac:u}}function Ta({forwardedBuckets:e,droppedBuckets:n,allTypes:o,onHover:s,gridColor:r,axisTickColor:a,externalAxes:c=!1}){const i=f.useRef(null),d=f.useRef(null),u=f.useRef(e),m=f.useRef(n),j=f.useRef(o),l=f.useRef(c);u.current=e,m.current=n,j.current=o,l.current=c;const x=c?wt:jt,N=typeof document<"u"&&document.documentElement.dataset.mode!=="light",h=r||(N?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)"),y=a||(N?"rgba(255,255,255,0.6)":"rgba(0,0,0,0.6)"),C=f.useRef({gridColor:h,axisTickColor:y});C.current={gridColor:h,axisTickColor:y};const T=e.length,B=f.useMemo(()=>{const b=e.map(_=>_.start),p=e.map(()=>1);return[b,p]},[T]),v=f.useCallback(b=>{if(!i.current||e.length===0)return;const p=i.current.getBoundingClientRect(),_=b.clientX-p.left,k=c?wt:jt,A=k.left,g=p.width-k.left-k.right,P=(_-A)/g;if(P<0||P>1){s==null||s(null,null,null);return}const R=Math.min(e.length-1,Math.max(0,Math.floor(P*e.length)));s==null||s(R,e[R],P)},[e,s]),w=f.useCallback(()=>{s==null||s(null,null,null)},[s]);return f.useEffect(()=>{if(!i.current||T===0)return;const b=i.current;let p=null;const _=Ds(()=>{const k=b.getBoundingClientRect(),A=Math.floor(k.width)||400,g=Math.floor(k.height)||200,D={width:A,height:g,padding:[x.top,x.right,x.bottom,x.left],cursor:{show:!1},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],legend:{show:!1},hooks:{draw:[R=>{const L=R.ctx,{left:S,top:F,width:M,height:$}=R.bbox,E=window.devicePixelRatio||1,W=C.current,I=u.current;I.length>=2&&As(L,I[0].start,I[I.length-1].end,S,F,M,$);const O=va(L,u.current,m.current,j.current,S,F,M,$);ka(L,u.current,S,F,M,$,W.gridColor,W.axisTickColor,O,E,l.current)}]}},P=new Rs(D,B,b);d.current=P,p=new ResizeObserver(()=>{const R=b.getBoundingClientRect();R.width>0&&R.height>0&&d.current&&d.current.setSize({width:Math.floor(R.width),height:Math.floor(R.height)})}),p.observe(b)});return()=>{var k;_(),p==null||p.disconnect(),(k=d.current)==null||k.destroy(),d.current=null}},[T]),f.useEffect(()=>{d.current&&d.current.redraw()},[e,n,o]),e.length===0?t.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted",children:"No data available"}):t.jsx("div",{ref:i,className:"w-full h-full",onMouseMove:v,onMouseLeave:w})}const Sa=f.memo(Ta),ls=[{target:"RepeaterAnalyticsCard",fn:"type",minStage:1}];pe(ls);function _a(e){const o=new Date(e*1e3).getHours();return o>=6&&o<18}function vt(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}const xe=32,Ge=20,Ba=[.5,1];function Da({forwardedBuckets:e,droppedBuckets:n,forwardedActiveTypes:o,droppedActiveTypes:s,forwardedCount:r,droppedCount:a,crcCount:c,crcHistory:i,receivedCount:d,forwardedTotalByType:u,droppedTotalByType:m,startTime:j,bucketDurationSeconds:l,bucketCount:x,timeRangeMinutes:N}){fe(ls);const h=Pt(),y=we(),[C,T]=f.useState(null),[B,v]=f.useState(null),[w,b]=f.useState(null),p=f.useCallback((G,H,U)=>{T(H),v(U)},[]),_=Math.max(1,N/60),k=f.useMemo(()=>Ft(y,_),[y,_]),A=f.useMemo(()=>k?Et(k):0,[k]),g=Math.round(A*10)/10,D=Math.round((k==null?void 0:k.avgBackoffMs)??0),{fwdMirror:P,drpMirror:R,allTypes:L,fwdTotals:S,drpTotals:F}=f.useMemo(()=>{const G=e.map(X=>({start:X.start,end:X.end,countByType:{...X.countByType}})),H=new Array(x).fill(0);for(const X of i){let K=Math.floor((X.timestamp-j)/l);K<0&&(K=0),!(K>=x)&&H[K]++}const U=n.map((X,K)=>({start:X.start,end:X.end,countByType:{...X.countByType,...H[K]>0?{[Q]:H[K]}:{}}})),V=new Set([...o,...s]);c>0&&V.add(Q);const se={...u},ae={...m};c>0&&(ae[Q]=c);const ke=[...V].sort((X,K)=>{const ys=(se[X]??0)+(ae[X]??0);return(se[K]??0)+(ae[K]??0)-ys});return{fwdMirror:G,drpMirror:U,allTypes:ke,fwdTotals:se,drpTotals:ae}},[e,n,o,s,i,c,j,l,x,u,m]),M=L.length>0&&P.length>0,$=C?_a(C.start):null,E=C?vt(C.start):"",W=w!==null&&$!==null&&w!==$;$!==w&&b($);const I=f.useMemo(()=>M?Ca(P,R,L):null,[M,P,R,L]),O=f.useMemo(()=>{if(!I)return[];const{fwdMax:G,drpMax:H,fwdFrac:U}=I,V=[];for(const se of Ba){const ae=Math.round(G*se);if(ae>0){const X=(1-se)*U*100;V.push({label:te(ae),pos:X,color:"green"})}const ke=Math.round(H*se);if(ke>0){const X=(U+se*(1-U))*100;V.push({label:te(ke),pos:X,color:"red"})}}return V},[I]),z=f.useMemo(()=>{if(P.length===0)return[];const G=P.length,H=Math.max(1,Math.floor(G/6)),U=[];for(let V=0;Vt.jsx("span",{className:`type-data-xs text-right pr-1.5 ${U==="green"?"text-sys-green/70":"text-sys-red/70"}`,style:{position:"absolute",top:`${H}%`,transform:H<=1?"none":H>=99?"translateY(-100%)":"translateY(-50%)",right:0},children:G},V))}),t.jsxs("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:xe,right:0,top:0,bottom:Ge},children:[M&&I&&t.jsx("div",{className:"absolute inset-x-0 top-0 pointer-events-none",style:{height:`${I.fwdFrac*100}%`,background:"var(--sys-blue)",opacity:.1}}),M&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"data-box data-box-compact flex items-center gap-1 absolute z-10 pointer-events-none",style:{top:8,left:8,background:"var(--surface)",borderColor:"var(--edge-subtle)"},children:[t.jsx(ht,{className:"w-3 h-3 text-sys-green"}),t.jsx("span",{children:"FWD"})]}),t.jsxs("span",{className:"data-box data-box-compact flex items-center gap-1 absolute z-10 pointer-events-none",style:{bottom:8,left:8,background:"var(--surface)",borderColor:"var(--edge-subtle)"},children:[t.jsx(pt,{className:"w-3 h-3 text-sys-red"}),t.jsx("span",{children:"DROP"})]})]}),t.jsx("div",{className:`absolute inset-0 flex items-center transition-opacity duration-300 ${M?"opacity-0 pointer-events-none":"opacity-100"}`,"aria-hidden":M,children:t.jsx("div",{className:"w-full flex items-center gap-1",children:t.jsx("div",{className:"flex-1 flex items-end gap-1 h-1/2",children:[45,72,33,58,80,42,65,28,55,75,38,62].map((G,H)=>t.jsx("div",{className:"flex-1 bg-subtle-fill rounded-sm animate-pulse",style:{height:`${G}%`}},`u${H}`))})})}),t.jsx("div",{className:`h-full transition-opacity duration-300 ${M?"opacity-100":"opacity-0"}`,children:M&&t.jsx(Sa,{forwardedBuckets:P,droppedBuckets:R,allTypes:L,gridColor:h.grid,axisTickColor:h.axisTick,onHover:p,externalAxes:!0})}),M&&I&&t.jsx("div",{className:"absolute inset-x-0 bottom-0 pointer-events-none",style:{top:`${I.fwdFrac*100}%`,background:"var(--sys-red)",opacity:.1}})]}),t.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:xe,height:Ge},"aria-hidden":"true",children:z.map((G,H)=>t.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${G.pos}%`,transform:H===0?"none":H===z.length-1?"translateX(-100%)":"translateX(-50%)"},children:G.label},H))})]}),t.jsx("div",{className:"pt-2 px-1 pb-2 shrink-0",children:M&&t.jsx(Ma,{allTypes:L,forwardedTotalByType:S,droppedTotalByType:F})})]})}const Ra=2,Aa=1;function Pa(e,n,o){const s=d=>(d==null?void 0:d.reduce((u,m)=>u+m.count,0))??0,r=s(n),a=s(o),c=r||(e==null?void 0:e.rx_count)||1,i=a||(e==null?void 0:e.dropped_count)||0;return c>0?i/(c+i)*100:0}function La(e,n,o){const s=r=>(r==null?void 0:r.reduce((a,c)=>a+c.count,0))??0;if(n!=null&&n.length&&o){const a=s(n)*100,c=n.length*o*1e3;return a/c*100}if(e){const r=(e.uptime_seconds||1)*1e3;return(e.total_airtime_ms||e.airtime_used_ms||0)/r*100}return 0}function kt(e,n,o){return jn(Math.max(n,Math.min(o,e)))}function $a(e,n,o,s,r){let a=Kt(e);n>20?a+=Te*2:n>12&&(a+=Te),o>8&&(a+=Te);const c=kt(a,0,Ra);let i=wn(e);o>8&&(i+=Te);const d=kt(i,0,Aa),u=ye(c),m=ye(d),j=s!==null?ye(s):null;let l="stable";return j!==null&&(u>j?l="increase":u{if(u!=="applying"){m("applying");try{const H=await Ls({tx_delay_factor:z,direct_tx_delay_factor:G});H!=null&&H.success?(m("success"),setTimeout(()=>m("idle"),2e3)):(m("error"),setTimeout(()=>m("idle"),2500))}catch{m("error"),setTimeout(()=>m("idle"),2500)}}},[u]);if(!c)return t.jsx(je,{children:t.jsx($s,{})});const x=10080*60,h=Math.floor(Date.now()/1e3)-x,y=Object.values((e==null?void 0:e.neighbors)??{}).filter(z=>z.zero_hop&&z.last_seen>=h&&bn(z).isRepeater).length,C=j.filter(z=>z.status==="active"||z.lastSeen>=h).length,T=Math.max(y,C),B=Pa(e,n,o),v=La(e,s,r),w=((W=(E=e==null?void 0:e.config)==null?void 0:E.delays)==null?void 0:W.tx_delay_factor)??null,b=((O=(I=e==null?void 0:e.config)==null?void 0:I.delays)==null?void 0:O.direct_tx_delay_factor)??null,p=$a(T,B,v,w),_=T!==1,k=Kt(T),A=[`${T} repeater${_?"s":""} heard in the last 7 days (base ×${k.toFixed(1)}).`];p.floodFactor===k&&B<=12&&v<=8?A.push("No modifiers applied — network looks healthy."):(B>20?A.push(`High duplicate rate (${B.toFixed(1)}%) suggests frequent collisions — window widened.`):B>12&&A.push(`Elevated duplicate rate (${B.toFixed(1)}%) — window widened one step.`),v>8&&A.push(`Channel is busy (${v.toFixed(1)}% TX util) — extra spacing added.`));const g=[`Direct uses one forwarder — ×${p.directFactor.toFixed(1)} backoff for channel contention.`];v>8&&g.push("Busy channel — small extra backoff.");const D=[`Flood ×${p.floodFactor.toFixed(1)} (${p.floodSlots} slot${p.floodSlots!==1?"s":""})`,...A,"",`Direct ×${p.directFactor.toFixed(1)}`,...g,"","Click to copy CLI commands"].join(` -`),P=w!==null?ye(w):null,R=b!==null?ye(b):null,L=P!==null&&p.floodSlots!==P,S=R!==null&&p.directSlots!==R,F=L||S,M=async()=>{const z=`set txdelay ${p.floodFactor.toFixed(1)} -set direct.txdelay ${p.directFactor.toFixed(1)}`;await Es(z),d(!0),setTimeout(()=>d(!1),1500)},$=()=>l(p.floodFactor,p.directFactor);return t.jsxs(je,{children:[t.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3 flex-wrap",children:[t.jsx(Nn,{className:"w-4 h-4 text-icon-card-title flex-shrink-0"}),t.jsx("span",{className:"type-micro",children:"DELAY DOCTOR"}),a&&t.jsx(ne,{color:"zinc",className:"hidden sm:inline-flex",children:a})]}),t.jsxs("button",{onClick:M,className:"flex gap-3 mb-2 sm:mb-3 w-full text-left hover:bg-subtle-fill radius-inner transition-base p-1 -m-1 group",title:D,children:[t.jsxs("div",{className:"flex-1 flex flex-col",children:[t.jsx("span",{className:"type-data-xl text-fg-primary",children:t.jsxs(Ye,{children:["×",p.floodFactor.toFixed(1)]})}),t.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Flood"})]}),t.jsxs("div",{className:"flex-1 flex flex-col",children:[t.jsx("span",{className:"type-data-xl text-sys-blue",children:t.jsxs(Ye,{children:["×",p.directFactor.toFixed(1)]})}),t.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Direct"})]}),t.jsx("div",{className:"flex items-center self-center opacity-0 group-hover:opacity-100 transition-opacity",children:i?t.jsx(at,{className:"w-4 h-4 text-sys-green"}):t.jsx(Fs,{className:"w-4 h-4 text-fg-muted"})})]}),t.jsx("div",{className:"flex-1 py-2",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"Dupe"}),t.jsxs("div",{className:`data-box data-box-fill data-box-left ${p.duplicateRate>8?"text-status-warning":""}`,children:[p.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:[p.txUtilization.toFixed(2),"%"]})]})]})}),t.jsx("div",{className:"pt-2 mt-auto",children:t.jsxs("div",{className:"flex items-end justify-between gap-2",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"data-box-label",children:"Current"}),t.jsx("div",{className:"flex gap-2",children:w!==null?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:["×",w.toFixed(2)]})}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("div",{className:"data-box data-box-fill data-box-left",style:{color:"var(--sys-blue)"},children:["×",(b==null?void 0:b.toFixed(2))??"—"]})})]}):t.jsx("span",{className:"text-sm text-fg-muted",children:"No config"})})]}),F&&t.jsxs("button",{onClick:$,disabled:u==="applying"||u==="success",className:`flex items-center gap-1.5 px-2.5 py-1.5 radius-inner type-micro font-medium transition-base - ${u==="success"?"bg-sys-green/15 text-sys-green":u==="error"?"bg-sys-red/15 text-sys-red":u==="applying"?"bg-subtle-fill text-fg-muted":"bg-sys-blue/10 text-sys-blue hover:bg-sys-blue/20"}`,title:`Apply ×${p.floodFactor.toFixed(1)} flood, ×${p.directFactor.toFixed(1)} direct`,children:[u==="success"?"Rx'd":u==="error"?"Failed":"Apply",u==="applying"?t.jsx(Le,{className:"w-3.5 h-3.5 animate-spin"}):u==="success"?t.jsx(at,{className:"w-3.5 h-3.5"}):t.jsxs("span",{className:"relative inline-flex items-end w-6 h-3.5",children:[t.jsx(Kn,{className:"w-3.5 h-3.5 absolute left-0 bottom-0"}),t.jsx(na,{className:"w-3 h-3 absolute right-0 bottom-0"})]})]})]})})]})}const cs=[{target:"RecentPackets",fn:"rssi",minStage:1},{target:"RecentPackets",fn:"snr",minStage:1}];pe(cs);const Ea=25;function Ia(){fe(cs);const e=we(),n=Is(),o=Hs(),s=ie(),r=Mn(),a=Je(x=>x.requestChannel),[c,i]=f.useState(!0),d=f.useCallback(x=>i(x),[]),u=f.useMemo(()=>[...e.length<=100?e:e.slice(-100)].sort((N,h)=>(h.timestamp??0)-(N.timestamp??0)),[e]),m=s==null?void 0:s.local_hash,j=s==null?void 0:s.neighbors,l=Cn();return t.jsxs(je,{noPadding:!0,className:"!overflow-visible",children:[t.jsx(It,{listHeader:!0,icon:t.jsx(zt,{}),title:"Recent Packets",actions:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Ht,{enabled:c,onChange:d,label:"Hide Dupes",size:"sm"}),o&&t.jsx(zs,{showLabel:!0}),t.jsxs($e,{color:"primary",outline:!0,href:"/packets",children:["View all",t.jsx(ut,{"data-slot":"icon"})]})]})}),t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-1",children:t.jsx(vn,{packets:u,allPackets:e,localHash:m,neighbors:j,resolveSource:l,getDecodedContent:r,onChannelClick:a,loading:n,maxPackets:Ea,showPagination:!1,flashNewest:!0,hideDupes:c,emptyMessage:"No packets received",footerAction:t.jsxs($e,{color:"primary",outline:!0,href:"/packets",children:["View all",t.jsx(ut,{"data-slot":"icon"})]})})})]})}const Ha={stable:"M5 12h14",up:"M5 15l7-7 7 7",down:"M19 9l-7 7-7-7"};function za({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:Ha[e]})})})}function Oa(){return t.jsx("div",{className:"mini-widget-loading",children:t.jsx("div",{className:"mini-widget-loading-spinner"})})}function Ga({message:e}){return t.jsx("div",{className:"mini-widget-error",children:t.jsx("span",{title:e,children:"No data"})})}function le({title:e,icon:n,value:o,unit:s,valueSize:r="md",status:a,subtitle:c,subtitleValue:i,trend:d,headerRight:u,children:m,isLoading:j=!1,error:l,className:x="",onClick:N,isLoaded:h}){const y=["mini-widget-value",r==="lg"&&"mini-widget-value-lg",r==="sm"&&"mini-widget-value-sm"].filter(Boolean).join(" "),C=["mini-widget",x].filter(Boolean).join(" ");return t.jsxs(je,{noPadding:!0,className:C,onClick:N,isLoaded:h,children:[t.jsxs("div",{className:"mini-widget-header",children:[n,t.jsx("span",{className:"mini-widget-title",children:e}),a&&a!=="unknown"&&t.jsx("div",{className:`mini-widget-status-dot ${a}`}),d&&t.jsx(za,{trend:d}),u&&t.jsx("span",{className:"ml-auto flex items-center",children:u})]}),j?t.jsx(Oa,{}):l?t.jsx(Ga,{message:l}):t.jsxs("div",{className:"mini-widget-content",children:[(o!==void 0||c||i)&&t.jsxs("div",{className:"mini-widget-value-row",children:[o!==void 0&&t.jsxs("div",{className:y,children:[typeof o=="number"?t.jsx(re,{value:o,className:"font-mono tabular-nums",priority:"medium",format:Number.isInteger(o)?void 0:{minimumFractionDigits:1,maximumFractionDigits:1}}):t.jsx(Ye,{children:o}),s&&t.jsx("span",{className:"mini-widget-unit",children:s})]}),(c||i)&&t.jsxs("span",{className:"mini-widget-badge-group",children:[c&&!i&&t.jsx("span",{className:"data-box mini-widget-subtitle-box",children:c}),c&&i&&t.jsx("span",{className:"mini-widget-subtitle truncate",children:c}),i&&t.jsx("span",{className:"data-box mini-widget-subtitle-box",children:i})]})]}),m]})]})}const Wa={DELTA_CRITICAL:10,SLOPE_CRITICAL:4,JITTER_CRITICAL:6,DELTA_WARNING:5,SLOPE_WARNING:2,JITTER_WARNING:4},ds={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 Ze(e,n){if(e.length===0)return null;const o=[...e].sort((c,i)=>c-i),s=n/100*(o.length-1),r=Math.floor(s),a=Math.ceil(s);return r===a?o[r]:o[r]+(o[a]-o[r])*(s-r)}function Mt(e){return Ze(e,50)}function qa(e){if(e.length<2)return 0;const n=e.reduce((r,a)=>r+a,0)/e.length,s=e.map(r=>Math.pow(r-n,2)).reduce((r,a)=>r+a,0)/e.length;return Math.sqrt(s)}function Xa(e){if(e.length<2)return 0;const n=e.length;let o=0,s=0,r=0,a=0;const c=e[0].timestamp;for(const d of e){const u=(d.timestamp-c)/3600,m=d.value;o+=u,s+=m,r+=u*m,a+=u*u}const i=n*a-o*o;return Math.abs(i)<1e-4?0:(n*r-o*s)/i}function Ua(e,n,o){const s=Wa;return e>=s.DELTA_CRITICAL?[2,`Noise floor ${e.toFixed(1)} dB above baseline`]:n>=s.SLOPE_CRITICAL?[2,`Noise floor rising ${n.toFixed(1)} dB/hour`]:o>=s.JITTER_CRITICAL?[2,`Noise floor unstable (±${o.toFixed(1)} dB)`]:e>=s.DELTA_WARNING?[1,`Noise floor ${e.toFixed(1)} dB above baseline`]:n>=s.SLOPE_WARNING?[1,`Noise floor rising ${n.toFixed(1)} dB/hour`]:o>=s.JITTER_WARNING?[1,`Noise floor variable (±${o.toFixed(1)} dB)`]:[0,null]}function Va(e){if(e.length===0)return{...ds,computedAt:Math.floor(Date.now()/1e3)};const n=Math.floor(Date.now()/1e3),o=e.filter(y=>Number.isFinite(y)),s=e.length>0?[e[e.length-1]]:[],r=e.slice(-4).filter(y=>Number.isFinite(y)),a=Mt(o),c=Ze(o,10),i=Ze(o,90),d=Mt(s),u=d!==null&&c!==null?d-c:0,m=r.map((y,C)=>({timestamp:n-(r.length-1-C)*3600,value:y})),j=Xa(m),l=qa(r),x=o.length>=12,[N,h]=x?Ua(u,j,l):[0,null];return{baselineMedian:a,baselineP10:c,baselineP90:i,currentMedian:d,currentSampleCount:s.length,delta:u,slope:j,jitter:l,penalty:N,penaltyReason:h,computedAt:n,isReliable:x}}const Ya={lbtStats:null,noiseFloor:null,sparklineNoiseFloor:[],noiseFloorWindowHistory:[],linkQuality:null,channelHealth:null,nfTrend:ds,radioConfig:null,trends:null,stats:null,recentPackets:[],quickNeighbors:[],isLoading:!0,error:null,refresh:async()=>{}},us=f.createContext(Ya);function Ja({children:e}){var R;const n=ie(),o=we(),s=Ot(),r=Os(),a=Ne(),c=ee[a],i=Math.max(1,c.minutes/60),d=n===null,[u,m]=f.useState(null),j=f.useCallback(async()=>{try{const L=await Gt(Math.ceil(i));if(L.success&&L.data){m(L.data.history);return}const S=await Wt(Math.ceil(i));S.success&&S.data&&S.data.count>0&&m(null)}catch{}},[i]);f.useEffect(()=>{j();const L=setInterval(j,6e4);return()=>clearInterval(L)},[j]);const l=f.useMemo(()=>Ft(o,i,u),[o,i,u]),x=(n==null?void 0:n.noise_floor_dbm)??null,N=f.useMemo(()=>Gs(x)?x:null,[x]),h=f.useMemo(()=>{var S;const L=(S=n==null?void 0:n.config)==null?void 0:S.radio;return L?{sf:L.spreading_factor??7,bwHz:L.bandwidth??125e3}:null},[(R=n==null?void 0:n.config)==null?void 0:R.radio]),y=Ws(i),C=qs(i),T=n==null?void 0:n.neighbors,B=f.useMemo(()=>Object.fromEntries(Object.entries(T??{}).filter(([S])=>!r.has(S))),[T,r]),v=f.useMemo(()=>s.filter(L=>!r.has(L.hash)),[s,r]),w=f.useMemo(()=>Va(y),[y]),b=f.useMemo(()=>Xs(v,B,h),[v,B,h]),p=f.useMemo(()=>Us(l,N,b),[l,N,b]),[_,k]=f.useState({noiseFloor:null,networkScore:null,channelHealth:null}),A=f.useRef(0);f.useEffect(()=>{const L=()=>{const F=Date.now();F-A.current>3e4&&(A.current=F,k({noiseFloor:N,networkScore:(b==null?void 0:b.networkScore)??null,channelHealth:(p==null?void 0:p.score)??null}))};L();const S=setInterval(L,5e3);return()=>clearInterval(S)},[N,b==null?void 0:b.networkScore,p==null?void 0:p.score]);const g=f.useMemo(()=>({noiseFloor:{current:N,previous:_.noiseFloor,trend:N!==null?Ie(N,_.noiseFloor,2,!0):"stable"},networkScore:{current:(b==null?void 0:b.networkScore)??0,previous:_.networkScore,trend:Ie((b==null?void 0:b.networkScore)??0,_.networkScore,3,!1)},channelHealth:{current:(p==null?void 0:p.score)??0,previous:_.channelHealth,trend:Ie((p==null?void 0:p.score)??0,_.channelHealth,3,!1)}}),[N,b==null?void 0:b.networkScore,p==null?void 0:p.score,_]),P={lbtStats:l,noiseFloor:N,sparklineNoiseFloor:y,noiseFloorWindowHistory:C,linkQuality:b,channelHealth:p,nfTrend:w,radioConfig:h,trends:g,stats:n,recentPackets:o,quickNeighbors:s,isLoading:d,error:null,refresh:async()=>{}};return t.jsx(us.Provider,{value:P,children:e})}function et(){const e=f.useContext(us);if(e===void 0)throw new Error("useLBTData must be used within an LBTDataProvider");return e}function Za(e){return e<100?"excellent":e<250?"good":e<500?"fair":e<1e3?"congested":"critical"}function Ka(e){return e===0?"No backoffs":"Retries"}function Qa(e,n){return e===0?void 0:`${n.toFixed(0)}%`}function eo(){const{lbtStats:e,isLoading:n,error:o}=et(),s=qt(),r=(e==null?void 0:e.avgBackoffMs)??0,a=(e==null?void 0:e.retryRate)??0,c=e?Za(r):"unknown",i=e==null?void 0:e.sparklineBackoff,d=f.useMemo(()=>!i||i.length<2?[]:i.map((u,m)=>({timestamp:Date.now()-(i.length-1-m)*36e5,count:u})),[i]);return t.jsx(le,{title:"LBT Backoff",icon:t.jsx(oa,{className:"mini-widget-icon"}),value:Math.round(r),unit:"ms",status:c,subtitle:e?Ka(r):void 0,subtitleValue:e?Qa(r,a):void 0,isLoading:n,error:o,onClick:()=>s("/packets"),children:t.jsx("div",{className:"mini-widget-sparkline w-full",children:t.jsx(ts,{data:d,width:9999,height:24,invertScale:!0,isLoading:n,className:"w-full"})})})}const ms=[{target:"LinkLeaders",fn:"path",minStage:1,when:xn},{target:"LinkLeaders",fn:"src_hash",minStage:1,when:gn}];pe(ms);function to(){fe(ms);const e=qt(),n=Ot(),o=we(),s=ie(),r=Ne(),c=ee[r].minutes*60,i=Vs(),d=f.useMemo(()=>{if(i===0)return o;const p=i-c;return o.filter(_=>_.timestamp>=p)},[o,c,i]),u=s===null,m=s!=null&&s.local_hash?ot(s.local_hash):"",j=(s==null?void 0:s.neighbors)??{},{neighborHashes:l,neighborNames:x}=f.useMemo(()=>{const p=new Set,_=new Map;for(const k of n){p.add(k.hash);const A=j[k.hash],g=(A==null?void 0:A.name)||(A==null?void 0:A.node_name)||k.prefix;_.set(k.hash,g)}return{neighborHashes:p,neighborNames:_}},[n,j]),N=f.useMemo(()=>{if(l.size===0||d.length===0||!m)return{champion:null,listener:null,loudest:null};const{scores:p}=Sn(d,l,m),_=[];for(const[D,P]of p)P.blendedScore!==0&&_.push({...P,name:x.get(D)??ot(D)});let k=null,A=null,g=null;for(const D of _)(!k||D.blendedScore>k.blendedScore)&&(k=D),(!A||D.listenerScore>A.listenerScore)&&(A=D),(!g||D.loudScore>g.loudScore)&&(g=D);return{champion:k,listener:A,loudest:g}},[d,l,m,x]),h=p=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["🏆 Champion: ",p.name]}),t.jsxs("div",{className:"text-fg-muted mb-1",children:["Blended Score: ",p.blendedScore,t.jsx("span",{className:"text-fg-muted/60 ml-1",children:"(Listener + Loud)"})]}),t.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1 space-y-0.5",children:[t.jsxs("div",{children:["Listener: ",p.listenerScore,"/100 (",p.listenerCount," shared paths)"]}),t.jsxs("div",{children:["Loud: ",p.loudScore,"/100 (",p.loudCount," packets relayed)"]})]})]}),y=p=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["👂 Best Listener: ",p.name]}),t.jsxs("div",{className:"text-fg-muted mb-1",children:["Score: ",p.listenerScore,"/100"]}),t.jsx("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:t.jsxs("div",{children:[p.listenerCount," packets where they heard your transmissions"]})})]}),C=p=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["📢 Loudest: ",p.name]}),t.jsxs("div",{className:"text-fg-muted mb-1",children:["Score: ",p.loudScore,"/100"]}),t.jsx("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:t.jsxs("div",{children:[p.loudCount," packets they relayed directly to you"]})})]}),{champion:T,listener:B,loudest:v}=N,b=T||B||v?t.jsxs("div",{className:"flex flex-col gap-0 sm:gap-0.5",children:[T&&t.jsx(me,{content:h(T),children:t.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[t.jsx(kn,{className:"w-2.5 h-2.5 sm:w-3 sm: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:T.name}),t.jsx("span",{className:"text-map-neighbor-color pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:T.blendedScore})]})}),B&&t.jsx(me,{content:y(B),children:t.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[t.jsx(as,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-fg-muted flex-shrink-0"}),t.jsx("span",{className:"text-fg-muted font-mono truncate flex-1 min-w-0",children:B.name}),t.jsx("span",{className:"text-fg-muted pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:B.listenerScore})]})}),v&&t.jsx(me,{content:C(v),children:t.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[t.jsx(Jn,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-fg-muted flex-shrink-0"}),t.jsx("span",{className:"text-fg-muted font-mono truncate flex-1 min-w-0",children:v.name}),t.jsx("span",{className:"text-fg-muted pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:v.loudScore})]})})]}):n.length===0?t.jsx("div",{className:"flex items-center justify-center text-xs sm:text-sm text-fg-muted mt-auto",children:"No direct neighbors"}):t.jsx("div",{className:"flex items-center justify-center text-xs sm:text-sm text-fg-muted mt-auto",children:"No routing data yet"});return t.jsx(le,{title:"Link Leaders",icon:t.jsx(ea,{className:"mini-widget-icon"}),isLoading:u,onClick:()=>e("/contacts"),children:b})}function so(e){return e<15?"excellent":e<30?"good":e<45?"fair":e<60?"congested":"critical"}function no(e){return e<15?"Clear channel":e<30?"Light traffic":e<45?"Moderate traffic":e<60?"Heavy traffic":e<75?"Congested":"Severe congestion"}function ao(){const{lbtStats:e,isLoading:n,error:o}=et(),s=e?Et(e):0,r=e?so(s):"unknown",a=(e==null?void 0:e.maxBackoffMs)??0,c=e?a>200?"Peak":no(s):void 0,i=e&&a>200?`${Math.round(a)}ms`:void 0,d=e==null?void 0:e.sparklineCollisionRisk,u=f.useMemo(()=>!d||d.length<2?[]:d.map((j,l)=>({timestamp:Date.now()-(d.length-1-l)*36e5,count:j})),[d]),m=Math.round(s*10)/10;return t.jsx(le,{title:"Collision Risk",icon:t.jsx(_n,{className:"mini-widget-icon"}),value:m,unit:"%",status:r,subtitle:c,subtitleValue:i,isLoading:n,error:o,children:t.jsx("div",{className:"mini-widget-sparkline w-full",children:t.jsx(ts,{data:u,width:9999,height:24,invertScale:!0,isLoading:n,className:"w-full"})})})}function oo(e){return e<30?"excellent":e<50?"good":e<70?"fair":e<90?"congested":"critical"}function ro(e){return e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}function io(){var h,y;const[e,n]=f.useState(!1),[o]=f.useState(0),{stats:s,lbtStats:r,isLoading:a}=et(),c=((y=(h=s==null?void 0:s.config)==null?void 0:h.duty_cycle)==null?void 0:y.enforcement_enabled)??!1,i=f.useMemo(()=>{if(!s)return null;if(!c){const w=s.airtime_used_ms??0,b=s.max_airtime_ms??1,p=b>0?w/b*100:0;return{usedMs:w,maxMs:b,remainingMs:Math.max(0,b-w),utilizationPercent:p}}const C=s.airtime_used_ms??0,T=s.max_airtime_ms??1,B=s.airtime_remaining_ms??0,v=s.utilization_percent??(T>0?C/T*100:0);return{usedMs:C,maxMs:T,remainingMs:B,utilizationPercent:v}},[s,c]),d=f.useMemo(()=>{if(!r||r.totalPacketsWithLBT===0)return 100;const C=r.totalPacketsWithLBT-r.packetsWithRetries,T=r.totalPacketsWithLBT;return C/T*100},[r]),u=(i==null?void 0:i.utilizationPercent)??0,m=oo(u),j=(i==null?void 0:i.remainingMs)??0,l=d<95?"1st Try":"Remaining",x=d<95?`${d.toFixed(0)}%`:ro(j),N=i?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(le,{title:"Duty Cycle",icon:t.jsx(zt,{className:"mini-widget-icon"}),value:u.toFixed(1),unit:"%",status:m,subtitle:l,subtitleValue:x,isLoading:a,children:N})}function lo(){return t.jsxs("div",{className:"mini-widget",children:[t.jsxs("div",{className:"mini-widget-header",children:[t.jsx(Me,{className:"w-4 h-4"}),t.jsx(Me,{className:"h-3 w-16"})]}),t.jsx(Me,{className:"h-7 w-12 mt-2"}),t.jsx(Me,{className:"h-3 w-20 mt-2"})]})}function co(){return t.jsx("div",{className:"widget-row",children:Array.from({length:5}).map((e,n)=>t.jsx(lo,{},n))})}const fs=[{target:"MeshHealth",fn:"type",minStage:1}];pe(fs);function uo({className:e="",isLoaded:n,leading:o}){fe(fs);const s=Xt(),r=n??s??!0;return t.jsxs("div",{className:`mesh-health-container relative ${e}`,children:[t.jsxs("div",{className:"mesh-health-header",children:[t.jsx(Ys,{className:"w-4 h-4 text-sys-blue"}),t.jsx("span",{className:"type-label text-fg-muted",children:"MESH HEALTH"})]}),r?t.jsx(Ja,{children:t.jsxs("div",{className:"widget-row",children:[o&&t.jsx("div",{className:"widget-leading",children:o}),t.jsx(eo,{}),t.jsx(ao,{}),t.jsx(io,{}),t.jsx(to,{})]})}):t.jsx(co,{})]})}const ps=[{target:"PublicChannel",fn:"decrypt",minStage:2,when:yn}];pe(ps);let hs="",xs="",Ct="";function mo(){const e=new Date,n=e.toDateString();if(n!==Ct){Ct=n,hs=n;const o=new Date(e);o.setDate(o.getDate()-1),xs=o.toDateString()}}function fo(e){mo();const n=new Date(e*1e3).toDateString();return n===hs?"Today":n===xs?"Yesterday":new Date(e*1e3).toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"})}function po(e,n,o){return`${e||""}|${n}|${o}`}function ho(e,n){const o=e.message,s=n.message;return o.timestamp===s.timestamp&&o.text===s.text&&o.senderName===s.senderName&&o.channelHash===s.channelHash&&o.channelName===s.channelName&&e.isChannelSelected===n.isChannelSelected&&e.onChannelClick===n.onChannelClick}const xo=f.memo(function({message:n,onChannelClick:o,isChannelSelected:s}){const r=n.channelName||n.channelHash.slice(0,6);return t.jsx("div",{style:{transform:"translateZ(0)",willChange:"transform"},children:t.jsx(Ln,{senderName:n.senderName||"Unknown",text:n.text,timestamp:n.timestamp,bubbleVariant:"subtle",nameAccessory:t.jsx(Qt,{channelName:r,active:s,onClick:()=>o==null?void 0:o(n.channelHash)})})})},ho);function go({open:e,onClose:n,messages:o,onLoadMore:s,hasMoreToLoad:r,isDecoding:a,initialChannel:c}){const i=f.useRef(null),d=f.useRef(!0),u=Ne(),m=Ut(),j=f.useRef(!1);f.useEffect(()=>{e?(j.current=!0,it.resume()):j.current&&it.pause()},[e]);const l=f.useMemo(()=>{const g=Date.now()/1e3,D=ee[u].minutes,P=g-D*60;return[...o].filter(R=>R.timestamp>=P).sort((R,L)=>R.timestamp-L.timestamp)},[o,u]),x=f.useCallback(()=>{const g=i.current;g&&(d.current=g.scrollTop>=-50)},[]),N=f.useMemo(()=>{const g=new Map;for(const D of l){const P=D.channelHash,R=g.get(P);R?R.count++:g.set(P,{name:D.channelName||D.channelHash.slice(0,6),hash:D.channelHash,count:1})}return Array.from(g.values()).sort((D,P)=>P.count-D.count)},[l]),h=N.length,[y,C]=f.useState(null),[T,B]=f.useState(!1);f.useEffect(()=>{e&&c&&C(c)},[e,c]);const v=f.useCallback(()=>{s(y,N)},[s,y,N]),w=f.useMemo(()=>y?l.filter(g=>g.channelHash===y):l,[l,y]),b=f.useMemo(()=>{const g=[];let D="";for(const P of w){const R=fo(P.timestamp);R!==D&&(g.push({type:"date",date:R}),D=R),g.push({type:"message",message:P})}return g},[w]);f.useLayoutEffect(()=>{const g=i.current;g&&d.current&&(g.scrollTop=0)},[w.length]);const p=19,_=N.slice(0,p),k=N.slice(p),A=k.length>0;return t.jsx(Vt,{open:e,onClose:n,size:"lg",motionPlus:!0,solid:!0,children:t.jsxs(Yt,{className:"p-0 flex flex-col h-[80vh] max-h-[700px] rounded-2xl",children:[t.jsx("div",{className:"flex-shrink-0 px-4 sm:px-5 py-3 sm:py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ss,{className:"size-5 text-icon-card-title flex-shrink-0"}),t.jsx("h2",{className:"type-micro",children:"Public Channels"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(es,{ranges:ee,selectedIndex:u,onSelect:m,size:"sm"}),t.jsx("button",{onClick:n,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),t.jsx("button",{onClick:n,className:"hidden sm:flex items-center justify-center p-2 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-subtle","aria-label":"Close",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}),t.jsx("div",{className:"flex-shrink-0 px-3 pb-2 relative z-10 isolate",style:{minHeight:h>0?void 0:0},children:h>0&&t.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.jsxs("button",{onClick:()=>C(null),className:J("px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",y===null?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:["All ",h]}),_.map(g=>t.jsx("button",{onClick:()=>C(g.hash),className:J("flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",y===g.hash?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:t.jsx("span",{className:"truncate max-w-[80px]",children:g.name})},g.hash)),A&&t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>B(!T),className:J("flex items-center gap-0.5 px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",T||k.some(g=>g.hash===y)?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:["+",k.length,t.jsx(tn,{className:J("size-3 transition-transform",T&&"rotate-180")})]}),T&&t.jsx("div",{className:J("absolute top-full left-0 mt-1 z-50","min-w-[140px] max-h-[200px] overflow-y-auto","p-1 rounded-lg","bg-elevated backdrop-blur-xl","ring-1 ring-edge-subtle shadow-xl"),children:k.map(g=>t.jsxs("button",{onClick:()=>{C(g.hash),B(!1)},className:J("w-full flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-all text-left",y===g.hash?"bg-sys-blue/20 text-sys-blue":"text-fg-secondary hover:bg-subtle-fill-strong"),children:[t.jsx($n,{className:"size-2.5 opacity-60 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:g.name}),t.jsxs("span",{className:"opacity-60 ml-auto",children:["(",g.count,")"]})]},g.hash))})]})]})}),t.jsx("div",{ref:i,onScroll:x,className:J("flex-1 overflow-y-auto overflow-x-hidden","mx-3 mb-3 radius-inner depth-stroke-inset","flex flex-col-reverse"),children:a&&w.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[300px] text-fg-muted px-4 py-4",children:[t.jsx(Le,{className:"size-12 mb-4 text-sys-indigo animate-spin"}),t.jsx("p",{className:"text-lg font-medium",children:"Loading messages..."})]}):w.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[300px] text-fg-muted px-4 py-4",children:[t.jsx(Fn,{className:"size-16 mb-4 opacity-20"}),t.jsx("p",{className:"text-lg font-medium",children:"No messages yet"}),t.jsx("p",{className:"text-sm mt-1 opacity-70",children:y?"No messages in this channel":"Public channel messages will appear here"})]}):t.jsxs("div",{className:"px-4 py-4",children:[r&&t.jsx("div",{className:"flex justify-center mb-4",children:t.jsx("button",{onClick:v,disabled:a,className:J("px-4 py-1.5 rounded-full","text-[11px] font-medium","ring-1 ring-inset",a?"bg-subtle-fill text-fg-muted ring-edge-subtle cursor-wait":"bg-sys-blue/10 text-sys-blue ring-sys-blue/20 hover:bg-sys-blue/20 hover:ring-sys-blue/30"),children:a?t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Le,{className:"size-3 animate-spin"}),"Loading..."]}):"Load older messages"})}),b.map((g,D)=>{if(g.type==="date")return t.jsx("div",{className:"flex justify-center my-4",children:t.jsx("span",{className:J("px-3.5 py-1.5 rounded-full","bg-subtle-fill backdrop-blur-sm","text-[11px] text-fg-muted/80 font-medium","ring-1 ring-edge-subtle"),children:g.date})},`date-${g.date}-${D}`);const P=`msg-${g.message.timestamp}-${g.message.senderName||"anon"}-${g.message.channelHash}`;return t.jsx("div",{children:t.jsx(xo,{message:g.message,onChannelClick:C,isChannelSelected:y===g.message.channelHash})},P)})]})}),t.jsx("div",{className:"flex-shrink-0 px-5 py-2 text-center",children:t.jsxs("p",{className:"text-[11px] text-fg-muted",children:[w.length," messages · ",h," ",h===1?"channel":"channels",a&&t.jsxs("span",{className:"ml-2 text-sys-indigo",children:[t.jsx(Le,{className:"inline size-3 animate-spin mr-1"}),"Decrypting..."]})]})})]})})}function yo(e){const n=[],o=new Set;for(const s of e.values()){const r=s.decoded;if(!r||!r.decrypted||r.macCorrupted||!r.text)continue;const a=po(r.senderName,r.channelHash,r.text);o.has(a)||(o.add(a),n.push({timestamp:s.timestamp,channelName:r.channelName,channelHash:r.channelHash,senderName:r.senderName,text:r.text,rssi:s.rssi,snr:s.snr}))}return n}function bo({isLoaded:e}){const n=Xt(),o=e??n??!0;fe(ps);const s=we(),[r,a]=f.useState(!1),[c,i]=f.useState(null),d=Ne(),u=f.useCallback(()=>{i(null),a(!0),Ce.getState().queueDecryption(s)},[s]),m=Je(_=>_.requestedHash),j=Je(_=>_.clearRequest);f.useEffect(()=>{m&&(i(m),a(!0),Ce.getState().queueDecryption(s),j())},[m,j,s]);const l=Js(),x=Zs(),N=Ks(),h=f.useMemo(()=>yo(l),[l]),y=f.useMemo(()=>{const _=Date.now()/1e3,k=ee[d].minutes,A=_-k*60;return h.filter(g=>g.timestamp>=A)},[h,d]),C=f.useMemo(()=>y.length===0?null:y.reduce((_,k)=>k.timestamp>_.timestamp?k:_),[y]),T=x.isDecoding,v=f.useMemo(()=>{const _=Date.now()/1e3,k=ee[d].minutes,A=_-k*60,g=new Set;let D=0;for(const P of s)(P.type??P.payload_type)===rt.GRP_TXT&&((P.timestamp??0){const _=Date.now()/1e3,k=ee[d].minutes,A=_-k*60;for(const g of s)if((g.type??g.payload_type)===rt.GRP_TXT&&!((g.timestamp??0){if(!T){if(_){const A=k.find(g=>g.hash===_);if(A){Ce.getState().queueChannelDecryption(s,A.name);return}}Ce.getState().queueDecryption(s)}},[s,T]);return o?t.jsxs(t.Fragment,{children:[t.jsx("div",{onClick:u,className:J("group cursor-pointer rounded-2xl transition-all duration-150","bg-surface/80 backdrop-blur-lg depth-raised","hover:bg-subtle-fill","px-3 py-2.5 sm:px-4 sm:py-3"),children:t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-shrink-0",children:[t.jsx(ss,{className:"size-4 text-icon-card-title flex-shrink-0"}),t.jsx("span",{className:"type-micro",children:"CHAT ACTIVITY"}),v>0&&t.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-subtle-fill ring-1 ring-inset ring-edge-subtle text-sm tabular-nums text-fg-secondary",children:v}),t.jsx(mt,{className:"size-4 text-fg-muted group-hover:text-sys-indigo transition-colors ml-auto sm:hidden"})]}),t.jsxs("div",{className:"flex items-center gap-2 sm:gap-1.5 min-w-0 overflow-hidden",children:[t.jsx(Ke,{mode:"wait",initial:!1,children:C?t.jsxs(ge.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex items-center gap-2 sm:gap-1.5 min-w-0",children:[C.channelName&&t.jsx("span",{className:"hidden sm:inline-flex",children:t.jsx(Qt,{channelName:C.channelName})}),t.jsx("div",{className:"hidden sm:flex w-[30px] h-[30px] clay-avatar",style:{"--avatar-color":Rn(He(C.senderName||"").cleanName)},children:He(C.senderName||"").emoji?t.jsx("span",{className:"text-base",children:He(C.senderName||"").emoji}):t.jsx("span",{className:"text-white text-xs font-bold tracking-tighter",children:An(C.senderName||"")})}),t.jsx("div",{className:"inline-flex items-center px-3 py-1.5 rounded-2xl rounded-tr-md bg-[#007AFF] shadow-sm min-w-0 flex-1 sm:flex-initial sm:max-w-xs sm:-ml-px",children:t.jsx("span",{className:"text-sm text-white truncate tracking-wide",children:Pn(C.text,{isOutgoing:!0})})}),t.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-subtle-fill ring-1 ring-inset ring-edge-subtle text-sm tabular-nums text-fg-secondary flex-shrink-0",children:en(C.timestamp)})]},`msg-${C.timestamp}-${C.senderName}-${C.channelHash}`):N?t.jsx(ge.span,{initial:{opacity:0},animate:{opacity:1},className:"text-sm text-fg-muted italic",children:"No messages yet"},"empty"):t.jsxs(ge.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,y:-16},transition:{duration:.15},className:"flex items-center gap-2 sm:gap-1.5",children:[t.jsx("div",{className:"hidden sm:block w-8 h-4 rounded bg-subtle-fill-strong animate-pulse"}),t.jsx("div",{className:"hidden sm:block w-[30px] h-[30px] rounded-full bg-subtle-fill-strong animate-pulse"}),t.jsx("div",{className:"h-8 w-32 sm:w-48 rounded-2xl bg-subtle-fill-strong animate-pulse"}),t.jsx("div",{className:"w-12 h-6 rounded-md bg-subtle-fill-strong animate-pulse"})]},"skeleton")}),t.jsx(mt,{className:"size-4 text-fg-muted group-hover:text-sys-indigo transition-colors flex-shrink-0 hidden sm:block ml-1"})]})]})}),t.jsx(go,{open:r,onClose:()=>a(!1),messages:h,onLoadMore:p,hasMoreToLoad:b,isDecoding:T,initialChannel:c})]}):t.jsx("div",{className:"h-14 rounded-xl bg-elevated/50 animate-pulse"})}const q=2,jo=2,De=5,Re=4,be=20,We=Qe(Y.cyan),qe=Qe(Y.amber),Xe=Qe(Y.red);function tt(e,n,o){const s=o.length;if(s===0)return null;let r=0,a=0;for(let w=0;wr&&(r=b);const p=o[w].newlyGuarded.length;p>a&&(a=p)}if(r===0&&a===0)return null;const c=Math.max(1,De-a),i=r>0?Math.max(1,Math.ceil(r/c)):1,d=e-Re*2,u=n-Re*2,m=(d-q*(be-1))/be,j=(u-q*(De-1))/De,l=Math.max(3,Math.min(m,j)),x=l+q,N=s,h=0,y=be*x-q,C=Re+(d-y)/2,T=De*x-q,B=Re+(u-T),v=Math.min(jo,l/3);return{quantum:i,tileSize:l,colStep:x,visibleCols:N,startIdx:h,offsetX:C,offsetY:B,gridH:T,r:v}}function wo(e,n,o,s,r){e.clearRect(0,0,o*(window.devicePixelRatio||1),s*(window.devicePixelRatio||1));const a=tt(o,s,n);if(a)for(let c=0;c0?(h=a.offsetY+a.gridH-d*a.colStep+q,y=d*a.colStep-q):N==="dropped"&&u>0?(h=a.offsetY+a.gridH-(d+u)*a.colStep+q,y=u*a.colStep-q):N==="guarded"&&m>0&&(h=a.offsetY+a.gridH-j*a.colStep+q,y=m*a.colStep-q),y>0&&(e.beginPath(),e.roundRect(l-1,h-1,a.tileSize+2,y+2,a.r+1),e.stroke()),e.restore()}}}function No(e,n,o,s,r){const a=tt(o,s,r);if(!a)return null;const c=Math.floor((e-a.offsetX+q/2)/a.colStep);if(c<0||c>=a.visibleCols)return null;const i=r[a.startIdx+c],d=Math.ceil(i.allowedDelta/a.quantum),u=Math.ceil(i.droppedDelta/a.quantum),m=i.newlyGuarded.length,j=d+u+m;if(j===0)return null;const l=a.offsetX+c*a.colStep;if(el+a.tileSize)return null;const x=a.offsetY+a.gridH,N=x-d*a.colStep+q,h=x-(d+u)*a.colStep+q,y=x-j*a.colStep+q;return m>0&&n>=y&&n0&&n>=h&&n0&&n>=N&&n<=x?{col:c,segment:"allowed"}:null}function Ue(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}const de=5;function vo(e){if(e<60)return`${Math.round(e)}s`;if(e<3600)return`${Math.floor(e/60)}m`;const n=Math.floor(e/3600),o=Math.floor(e%3600/60);return o>0?`${n}h ${o}m`:`${n}h`}function ko(e,n,o,s){const r=e.allowedDelta+e.droppedDelta;if(n==="allowed")return t.jsxs("div",{className:"min-w-[120px] space-y-1",children:[t.jsx("div",{className:"text-[10px] text-fg-muted tabular-nums",children:Ue(e.ts)}),t.jsxs("div",{className:"text-xs tabular-nums",children:[t.jsx("span",{className:"text-sys-cyan font-medium",children:e.allowedDelta}),t.jsx("span",{className:"text-fg-muted",children:" adverts allowed"})]}),e.trackedCount>0&&t.jsxs("div",{className:"text-[10px] text-fg-muted tabular-nums",children:[e.trackedCount," sources tracked"]}),r>0&&t.jsxs("div",{className:"text-[10px] text-fg-muted tabular-nums",children:[Math.round(e.allowedDelta/r*100),"% of traffic"]})]});if(n==="dropped"){const a=r>0?Math.round(e.droppedDelta/r*100):0,c=a-o;return t.jsxs("div",{className:"min-w-[140px] max-w-[240px] space-y-1",children:[t.jsx("div",{className:"text-[10px] text-fg-muted tabular-nums",children:Ue(e.ts)}),t.jsxs("div",{className:"text-xs tabular-nums",children:[t.jsx("span",{className:"text-sys-amber font-medium",children:e.droppedDelta}),t.jsx("span",{className:"text-fg-muted",children:" adverts dropped"})]}),r>0&&t.jsxs("div",{className:"text-[10px] tabular-nums",children:[t.jsxs("span",{className:a>50?"text-sys-amber":"text-fg-muted",children:[a,"% drop rate"]}),Math.abs(c)>=5&&t.jsxs("span",{className:c>0?"text-sys-amber":"text-sys-cyan",children:[" ","(",c>0?"+":"",c,"% vs avg)"]})]}),e.drops.length>0&&t.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:[e.drops.slice(0,de).map((i,d)=>t.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[t.jsx("span",{className:"font-mono truncate",children:i.name||i.pubkey.slice(0,8)}),t.jsx("span",{className:"text-fg-muted text-[10px] truncate flex-shrink-0 max-w-[100px]",children:i.reason})]},`${i.pubkey}-${d}`)),e.drops.length>de&&t.jsxs("div",{className:"text-[10px] text-fg-muted",children:["+",e.drops.length-de," more"]})]})]})}return t.jsxs("div",{className:"min-w-[140px] max-w-[220px] space-y-1",children:[t.jsx("div",{className:"text-[10px] text-fg-muted tabular-nums",children:Ue(e.ts)}),t.jsxs("div",{className:"text-xs text-sys-red font-medium",children:[e.newlyGuarded.length," newly guarded"]}),e.newlyGuarded.length>0&&t.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:[e.newlyGuarded.slice(0,de).map(a=>t.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[t.jsx("span",{className:"font-mono truncate",children:s(a.pubkey)}),t.jsx("span",{className:"text-fg-muted tabular-nums flex-shrink-0",children:vo(a.remaining)})]},a.pubkey)),e.newlyGuarded.length>de&&t.jsxs("div",{className:"text-[10px] text-fg-muted",children:["+",e.newlyGuarded.length-de," more"]})]})]})}function Mo(e){if(e.length<=be)return e;const n=Math.ceil(e.length/be),o=[];for(let s=0;sMo(n),[n]),s=f.useRef(null),r=f.useRef(null),{show:a,hide:c,updatePosition:i}=nn(),d=f.useRef(!1),u=f.useRef(null),m=ie(),j=an(),[l,x]=f.useState(!1),N=(g=(A=m==null?void 0:m.config)==null?void 0:A.repeater)==null?void 0:g.advert_rate_limit,h=(P=(D=m==null?void 0:m.config)==null?void 0:D.repeater)==null?void 0:P.advert_penalty_box,y=(L=(R=m==null?void 0:m.config)==null?void 0:R.repeater)==null?void 0:L.advert_adaptive,C=(e==null?void 0:e.stats.adverts_allowed)??0,T=(e==null?void 0:e.stats.adverts_dropped)??0,B=f.useMemo(()=>{const S=new Set;for(const F of o)for(const M of F.newlyGuarded)S.add(M.pubkey);return S.size},[o]),v=f.useMemo(()=>{const S=new Map;for(const M of(e==null?void 0:e.recent_drops)??[])M.name&&S.set(M.pubkey,M.name);const F=(m==null?void 0:m.neighbors)??{};for(const[M,$]of Object.entries(F))if(!S.has(M)){const E=$.name||$.node_name;E&&S.set(M,E)}return M=>S.get(M)||M.slice(0,8)},[e==null?void 0:e.recent_drops,m==null?void 0:m.neighbors]),w=f.useMemo(()=>{let S=0,F=0;for(const $ of o)S+=$.allowedDelta,F+=$.droppedDelta;const M=S+F;return M>0?Math.round(F/M*100):0},[o]),b="10m",p=f.useCallback(()=>{const S=s.current,F=r.current;if(!S||!F)return;const M=F.getBoundingClientRect(),$=window.devicePixelRatio||1,E=Math.floor(M.width),W=Math.floor(M.height);if(E===0||W===0)return;S.width=E*$,S.height=W*$,S.style.width=`${E}px`,S.style.height=`${W}px`;const I=S.getContext("2d");I&&(I.scale($,$),wo(I,o,E,W,u.current))},[o]);f.useEffect(()=>{p();const S=new ResizeObserver(()=>p());return r.current&&S.observe(r.current),()=>S.disconnect()},[p]);const _=f.useCallback(S=>{const F=r.current;if(!F||o.length===0)return;const M=F.getBoundingClientRect(),$=Math.floor(M.width),E=Math.floor(M.height),W=S.clientX-M.left,I=S.clientY-M.top,O=No(W,I,$,E,o);if(!O){u.current&&(u.current=null,p()),d.current&&(d.current=!1,c());return}const z=u.current;(!z||z.col!==O.col||z.segment!==O.segment)&&(u.current=O,p());const G=tt($,E,o);if(!G)return;const H=o[G.startIdx+O.col],U=ko(H,O.segment,w,v);d.current?i(S.clientX,S.clientY):d.current=!0,a(U,S.clientX,S.clientY)},[o,w,v,a,c,i,p]),k=f.useCallback(()=>{u.current&&(u.current=null,p()),d.current&&(d.current=!1,c())},[c,p]);return t.jsxs(je,{noPadding:!0,isLoaded:!0,className:"mini-widget overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"mini-widget-header",children:[t.jsx(En,{className:"mini-widget-icon"}),t.jsx("span",{className:"mini-widget-title",children:"Advert Decisions"}),t.jsx(ne,{color:"zinc",children:b})]}),t.jsx("div",{ref:r,className:"h-28 mx-2 overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",onMouseMove:_,onMouseLeave:k,children:o.length>0?t.jsx("canvas",{ref:s,className:"block w-full h-full"}):t.jsx("div",{className:"flex items-center justify-center w-full h-full text-xs text-fg-muted",children:"Waiting for data…"})}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-3 sm:gap-x-4 gap-y-1 px-3 py-2.5 type-data-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"shrink-0 w-3 h-3 rounded-xs bg-sys-cyan"}),t.jsx("span",{className:"text-fg-secondary uppercase tracking-wide whitespace-nowrap",children:"Allow"}),t.jsx("span",{className:"tabular-nums text-fg-muted shrink-0",children:t.jsx(re,{value:C,priority:"low"})})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"shrink-0 w-3 h-3 rounded-xs bg-sys-amber"}),t.jsx("span",{className:"text-fg-secondary uppercase tracking-wide whitespace-nowrap",children:"Drop"}),t.jsx("span",{className:"tabular-nums text-fg-muted shrink-0",children:t.jsx(re,{value:T,priority:"low"})})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"shrink-0 w-3 h-3 rounded-xs bg-sys-red"}),t.jsx("span",{className:"text-fg-secondary uppercase tracking-wide whitespace-nowrap",children:"In Jail"}),t.jsx("span",{className:"tabular-nums text-fg-muted shrink-0",children:B})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"shrink-0 w-3 h-3 rounded-xs bg-zinc-500/30"}),t.jsx("span",{className:"text-fg-secondary uppercase tracking-wide whitespace-nowrap",children:"Tracked"}),t.jsx("span",{className:"tabular-nums text-fg-muted shrink-0",children:(e==null?void 0:e.tracked_pubkeys)??0})]})]}),t.jsx("div",{className:"mt-auto px-2 pb-2",children:t.jsxs($e,{color:"primary",outline:!0,className:"w-full justify-center",onClick:()=>x(!0),children:[t.jsx(In,{"data-slot":"icon"}),"Adapt"]})}),t.jsx(Bn,{open:l,onClose:()=>x(!1),currentConfig:{tokenBucket:N,penaltyBox:h,adaptive:y},onApplied:async()=>{await j({force:!0}).catch(()=>{})}})]})}const To=f.memo(Co);function So(e){if(e<60)return`${Math.round(e)}s`;if(e<3600)return`${Math.floor(e/60)}m`;const n=Math.floor(e/3600),o=Math.floor(e%3600/60);return o>0?`${n}h ${o}m`:`${n}h`}function _o(){const e=ve(),n=ie();return{all:f.useMemo(()=>{if(!(e!=null&&e.active_penalties))return[];const s=new Map;for(const i of e.recent_drops??[])i.name&&s.set(i.pubkey,i.name);const r=(n==null?void 0:n.neighbors)??{};for(const[i,d]of Object.entries(r))if(!s.has(i)){const u=d.name||d.node_name;u&&s.set(i,u)}const a=new Map,c=new Map;for(const i of e.recent_drops??[])a.has(i.pubkey)||a.set(i.pubkey,i.reason),c.set(i.pubkey,(c.get(i.pubkey)??0)+1);return Object.entries(e.active_penalties).sort(([,i],[,d])=>d-i).map(([i,d])=>({pubkey:i,name:s.get(i)||i.slice(0,8),remaining:d,reason:a.get(i),dropCount:c.get(i)??0}))},[e,n==null?void 0:n.neighbors]),isLoading:!e,penaltyCount:e?Object.keys(e.active_penalties??{}).length:0}}function gs({offender:e,rank:n}){const o=n===0;return t.jsx(me,{content:t.jsxs("div",{className:"max-w-[260px]",children:[t.jsx("div",{className:"font-semibold mb-1",children:e.name}),t.jsx("div",{className:"text-fg-muted text-xs font-mono mb-1",children:e.pubkey}),t.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1 space-y-0.5 text-xs",children:[t.jsxs("div",{children:["Penalty: ",So(e.remaining)," remaining"]}),e.reason&&t.jsxs("div",{children:["Reason: ",e.reason]}),t.jsxs("div",{children:["Recent drops: ",e.dropCount]})]})]}),children:t.jsx("div",{className:"text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:t.jsx("span",{className:`font-mono truncate ${o?"font-semibold text-sys-red":"text-fg-muted"}`,children:e.name})})})}function Bo({open:e,onClose:n,offenders:o}){return t.jsxs(Vt,{open:e,onClose:n,size:"sm",children:[t.jsx(on,{icon:t.jsx(os,{size:20}),title:`Jail (${o.length})`,onClose:n}),t.jsx(Yt,{className:"flex flex-col gap-1 max-h-[60vh] overflow-y-auto",children:o.length===0?t.jsx("div",{className:"text-center text-sm text-fg-muted py-4",children:"No active penalties"}):o.map(s=>t.jsx(gs,{offender:s},s.pubkey))})]})}function Do(){const{all:e,isLoading:n,penaltyCount:o}=_o(),s=ve(),[r,a]=f.useState(!1),c=f.useCallback(()=>a(!0),[]),i=f.useCallback(()=>a(!1),[]),d=e.slice(0,3),u=(s==null?void 0:s.recent_drops)??[],m=o===0&&u.length>0&&!n,j=u.slice(0,3);return t.jsxs(t.Fragment,{children:[t.jsxs(le,{title:"Most Wanted",icon:t.jsx(os,{className:"mini-widget-icon"}),isLoading:n,isLoaded:!0,children:[d.length>0?t.jsx("div",{className:"flex flex-col gap-0 sm:gap-0.5",children:d.map((l,x)=>t.jsx(gs,{offender:l,rank:x},l.pubkey))}):m?t.jsx("div",{className:"flex flex-col gap-0 sm:gap-0.5",children:j.map((l,x)=>t.jsx(me,{content:t.jsxs("div",{className:"max-w-[260px]",children:[t.jsx("div",{className:"font-semibold mb-1",children:l.name||l.pubkey}),t.jsx("div",{className:"text-fg-muted text-xs font-mono mb-1",children:l.pubkey}),t.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1 text-xs",children:[t.jsxs("div",{children:["Reason: ",l.reason]}),t.jsxs("div",{children:[Math.round(l.seconds_ago),"s ago"]})]})]}),children:t.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[t.jsx("span",{className:`font-mono truncate flex-1 min-w-0 ${x===0?"font-semibold text-sys-amber":"text-fg-muted"}`,children:l.name||l.pubkey.slice(0,8)}),t.jsx("span",{className:`pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right truncate ${x===0?"text-sys-amber":"text-fg-muted"}`,children:l.reason.replace(/^Token bucket: /,"").replace(/^Penalty: /,"")})]})},l.pubkey))}):o===0&&!n?t.jsx("div",{className:"flex items-center justify-center text-xs text-fg-muted mt-auto",children:"No active penalties"}):null,o>0?t.jsxs("div",{className:"flex items-center mt-auto pt-0.5",children:[t.jsxs("span",{className:"text-[10px] text-fg-muted tabular-nums",children:[o," in jail"]}),o>3&&t.jsx($e,{plain:!0,className:"ml-auto text-[10px] text-sys-blue hover:underline",onClick:c,children:"Show All"})]}):m?t.jsx("div",{className:"flex items-center mt-auto pt-0.5",children:t.jsxs("span",{className:"text-[10px] text-sys-amber tabular-nums",children:[u.length," recent drop",u.length!==1?"s":""]})}):null]}),t.jsx(Bo,{open:r,onClose:i,offenders:e})]})}const Tt=[{key:"quiet",color:Y.green,label:"Quiet"},{key:"normal",color:Y.blue,label:"Normal"},{key:"busy",color:Y.amber,label:"Busy"},{key:"congested",color:Y.red,label:"Congested"}],St={quiet:"text-sys-green",normal:"text-sys-blue",busy:"text-sys-amber",congested:"text-sys-red"},_t=2,Ro=4;function Ao(e,n,o,s){const{quietMax:r,normalMax:a,busyMax:c,ewmaValue:i}=n;e.clearRect(0,0,o,s);const d=Math.max(c*2,i*1.3,c+.5),u=_t*3,m=o-u,j=[{start:0,end:r,color:Y.green},{start:r,end:a,color:Y.blue},{start:a,end:c,color:Y.amber},{start:c,end:d,color:Y.red}],l=[];let x=0;for(const k of j){const A=(k.end-k.start)/d*m;l.push({...k,px:x,pw:A}),x+=A+_t}const N=8,h=N,y=s-N-2;for(const k of l)e.fillStyle=k.color,e.globalAlpha=1,e.beginPath(),e.roundRect(k.px,h,k.pw,y,Ro),e.fill();function C(k){const A=Math.max(0,Math.min(k,d));for(const D of l)if(A<=D.end){const P=D.end>D.start?(A-D.start)/(D.end-D.start):0;return D.px+P*D.pw}const g=l[l.length-1];return g.px+g.pw}const T=C(i),B=4,v=4,w=h-1,b=h+y+1,p=lt[900],_=lt[200];e.fillStyle=p,e.beginPath(),e.moveTo(T-v,w-B),e.lineTo(T+v,w-B),e.lineTo(T,w),e.closePath(),e.fill(),e.fillStyle=_,e.beginPath(),e.moveTo(T-(v-1),w-B+.5),e.lineTo(T+(v-1),w-B+.5),e.lineTo(T,w-.5),e.closePath(),e.fill();for(const[k,A]of[[p,-1],[_,0],[p,1]])e.strokeStyle=k,e.lineWidth=1,e.beginPath(),e.moveTo(T+A,w),e.lineTo(T+A,b),e.stroke()}const Ae={stiffness:120,damping:20,mass:.8};function Po(){var g,D,P,R,L,S,F;const e=ve(),n=Jt(),o=Zt(),s=rn(),r=ie(),a=f.useRef(null),c=f.useRef(null),i=(D=(g=r==null?void 0:r.config)==null?void 0:g.repeater)==null?void 0:D.advert_adaptive,d=(e==null?void 0:e.adaptive.current_tier)??"normal",u=e==null?void 0:e.adaptive.pending_tier,m=!!u&&u!==d,j=((P=i==null?void 0:i.thresholds)==null?void 0:P.quiet_max)??.05,l=((R=i==null?void 0:i.thresholds)==null?void 0:R.normal_max)??.2,x=((L=i==null?void 0:i.thresholds)==null?void 0:L.busy_max)??.5,N=ue(s),h=Se(N,Ae),y=ue(j),C=ue(l),T=ue(x),B=Se(y,Ae),v=Se(C,Ae),w=Se(T,Ae);f.useEffect(()=>{N.set(s)},[s,N]),f.useEffect(()=>{y.set(j)},[j,y]),f.useEffect(()=>{C.set(l)},[l,C]),f.useEffect(()=>{T.set(x)},[x,T]);const b=f.useCallback(()=>{const M=a.current,$=c.current;if(!M||!$)return;const E=$.getBoundingClientRect(),W=window.devicePixelRatio||1,I=Math.floor(E.width),O=Math.floor(E.height);if(I===0||O===0)return;M.width=I*W,M.height=O*W,M.style.width=`${I}px`,M.style.height=`${O}px`;const z=M.getContext("2d");z&&(z.scale(W,W),Ao(z,{quietMax:B.get(),normalMax:v.get(),busyMax:w.get(),ewmaValue:h.get()},I,O))},[B,v,w,h]);f.useEffect(()=>{const M=[h.on("change",()=>b()),B.on("change",()=>b()),v.on("change",()=>b()),w.on("change",()=>b())];return()=>M.forEach($=>$())},[h,B,v,w,b]),f.useEffect(()=>{b();const M=new ResizeObserver(()=>b());return c.current&&M.observe(c.current),()=>M.disconnect()},[b]);const p=((S=Tt.find(M=>M.key===d))==null?void 0:S.label)??d,_=St[d]??"text-fg-muted",k=!e&&!o,A=o&&!n;return t.jsxs(le,{title:"Adaptive Tier",icon:t.jsx(ln,{className:"mini-widget-icon"}),isLoading:k,isLoaded:!0,error:A?"Adaptive tier data unavailable":null,headerRight:t.jsxs("span",{className:"text-[10px] text-fg-muted tabular-nums",children:[t.jsx("span",{className:"data-box data-box-compact",children:s.toFixed(2)}),t.jsx("span",{className:"ml-0.5 text-fg-muted/60",children:"adv/min"})]}),children:[t.jsx("div",{ref:c,className:"w-full h-8 sm:h-10 md:h-12",children:t.jsx("canvas",{ref:a,className:"block w-full h-full"})}),t.jsxs("div",{className:J("data-box data-box-fill text-center font-semibold uppercase tracking-wide mt-1",_),children:[p,m&&t.jsxs("span",{className:J("ml-1.5 text-[10px] font-normal animate-pulse",St[u]??"text-fg-muted"),children:["→ ",((F=Tt.find(M=>M.key===u))==null?void 0:F.label)??u]})]})]})}const Lo=f.memo(Po);function Bt(e){if(e<60)return`${e}s`;if(e<3600){const s=Math.floor(e/60),r=e%60;return r>0?`${s}m ${r}s`:`${s}m`}const n=Math.floor(e/3600),o=Math.floor(e%3600/60);return o>0?`${n}h ${o}m`:`${n}h`}function $o(){var l;const e=ve(),n=((e==null?void 0:e.stats.drop_rate)??0)*100,o=(e==null?void 0:e.stats.adverts_allowed)??0,s=(e==null?void 0:e.stats.adverts_dropped)??0,r=(e==null?void 0:e.tracked_pubkeys)??0,a=(e==null?void 0:e.effective_limits)??null,c=((l=e==null?void 0:e.metrics)==null?void 0:l.duplicate_ratio_ewma)??0,i=(e==null?void 0:e.stats.adverts_duplicate_reheard)??0,d=o+s,u=d>0?o/d*100:100,m=!e,j=d>0?s/d*100:0;return t.jsx(le,{title:"Drop Rate",icon:t.jsx(ns,{className:"mini-widget-icon"}),value:Math.round(n),unit:"%",isLoading:m,isLoaded:!0,headerRight:t.jsxs("span",{className:"text-[10px] text-fg-muted tabular-nums",children:["Tracked ",t.jsx("span",{className:"data-box data-box-compact ml-0.5",children:r})]}),children:d>0&&t.jsx(me,{content:t.jsxs("div",{className:"min-w-[140px] space-y-1",children:[t.jsx("div",{className:"text-xs text-fg-secondary font-medium",children:"Effective Limits"}),a?t.jsxs("div",{className:"space-y-0.5 text-[10px] tabular-nums",children:[t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("span",{className:"text-fg-muted",children:"Bucket"}),t.jsxs("span",{children:[a.bucket_capacity," tokens"]})]}),t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("span",{className:"text-fg-muted",children:"Refill"}),t.jsxs("span",{children:[a.refill_tokens," / ",Bt(a.refill_interval_seconds)]})]}),a.min_interval_seconds>0&&t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("span",{className:"text-fg-muted",children:"Min interval"}),t.jsx("span",{children:Bt(a.min_interval_seconds)})]})]}):t.jsx("div",{className:"text-[10px] text-fg-muted",children:"Limits not available"}),t.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1 space-y-0.5 text-[10px] tabular-nums",children:[t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("span",{className:"text-fg-muted",children:"Tracked"}),t.jsxs("span",{children:[r," pubkey",r!==1?"s":""]})]}),i>0&&t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("span",{className:"text-fg-muted",children:"Deduped"}),t.jsxs("span",{children:[i.toLocaleString()," (",Math.round(c*100),"%)"]})]})]})]}),children:t.jsxs("div",{className:"w-full mt-auto cursor-default",children:[t.jsxs("div",{className:"flex h-1.5 gap-0.5",children:[t.jsx("div",{className:"h-full rounded-full bg-sys-cyan transition-all duration-500",style:{width:`${u}%`}}),t.jsx("div",{className:"h-full rounded-full bg-sys-red transition-all duration-500",style:{width:`${j}%`}})]}),t.jsxs("div",{className:"flex justify-between mt-0.5",children:[t.jsx("span",{className:"type-data-xs text-sys-cyan/70 tabular-nums",children:o.toLocaleString()}),t.jsx("span",{className:"type-data-xs text-sys-red/70 tabular-nums",children:s.toLocaleString()})]})]})})})}const Fo="/assets/spam-can-JZXwgFOy.svg",Eo=1376,Ve=768,Io=[{x:0,w:280,stretch:!1},{x:280,w:4,stretch:!0},{x:284,w:808,stretch:!1},{x:1092,w:4,stretch:!0},{x:1096,w:280,stretch:!1}];function Ho(){return t.jsx("div",{className:"relative h-full w-full overflow-hidden rounded-[var(--radius-card)]",children:t.jsx("div",{className:"absolute inset-0 flex","data-spam-can":!0,children:Io.map(({x:e,w:n,stretch:o})=>t.jsx("svg",{viewBox:`${e} 0 ${n} ${Ve}`,preserveAspectRatio:"none",style:o?{height:"100%",flex:"1 1 0",minWidth:0}:{height:"100%",aspectRatio:`${n} / ${Ve}`,flexShrink:0},children:t.jsx("image",{href:Fo,width:Eo,height:Ve})},e))})})}const zo=f.memo(Ho);function Oo(){const e=Jt();return!Zt()||!e?null:t.jsxs("div",{className:"mesh-health-container relative",children:[t.jsxs("div",{className:"mesh-health-header",children:[t.jsx(Un,{className:"w-4 h-4 text-sys-blue"}),t.jsx("span",{className:"type-label text-fg-muted",children:"SPAMGUARD"})]}),t.jsxs("div",{className:"widget-row",children:[t.jsx("div",{className:"widget-leading",children:t.jsx(To,{})}),t.jsx(Lo,{}),t.jsx($o,{}),t.jsx(Do,{}),t.jsx(zo,{})]})]})}function Dr(){var g,D,P;const e=ie(),n=cn(),o=dn(),s=ga(),r=f.useRef(!1);o&&!r.current&&(r.current=!0);const a=r.current,c=Ne(),i=Ut(),d=un(),u=ee[c]??ee[4],m=d.isBackgroundLoading&&c>=5,[j,l]=f.useState([]),[x,N]=f.useState(0),[h,y]=f.useState(()=>localStorage.getItem("rx-crc-overlay")==="true"),C=f.useCallback(()=>{y(R=>{const L=!R;return localStorage.setItem("rx-crc-overlay",String(L)),L})},[]),[T,B]=f.useState(()=>localStorage.getItem("rx-analytics-view")==="true"),v=f.useCallback(R=>{B(R),localStorage.setItem("rx-analytics-view",String(R))},[]);f.useEffect(()=>{const R=u.minutes/60;Promise.all([Wt(R),Gt(R,5e4)]).then(([L,S])=>{var F,M;N((L.success&&((F=L.data)==null?void 0:F.count)!=null?L.data.count:S.success&&((M=S.data)==null?void 0:M.count)!=null?S.data.count:0)??0),l(S.success&&S.data?S.data.history:[])})},[u.minutes]);const w=f.useMemo(()=>{const R=O=>(O==null?void 0:O.reduce((z,G)=>z+G.count,0))??0,L=R(s==null?void 0:s.received),S=R(s==null?void 0:s.unique_received),F=R(s==null?void 0:s.forwarded),M=R(s==null?void 0:s.dropped),$=R(s==null?void 0:s.transmitted),E=((s==null?void 0:s.time_range_minutes)??u.minutes)/60,W=E>0?Math.round(L/E):0,I=E>0?Math.round(F/E):0;return{received:L,uniqueReceived:S,forwarded:F,dropped:M,transmitted:$,rxPerHour:W,fwdPerHour:I}},[s,u.minutes]),b=f.useMemo(()=>s?{totalBytes:s.totalReceivedBytes,kbPerHour:s.kbPerHour}:{totalBytes:0,kbPerHour:0},[s]),p=f.useMemo(()=>{if(!s)return[];const{receivedBytesBuckets:R,start_time:L,bucket_duration_seconds:S,bucket_count:F}=s,M=new Array(F).fill(0);for(const $ of j){let E=Math.floor(($.timestamp-L)/S);E<0&&(E=0),!(E>=F)&&M[E]++}return R.map(($,E)=>({start:$.start,end:$.end,bytesByType:{...$.countByType,...h&&M[E]>0?{[Q]:M[E]}:{}},totalBytes:$.totalCount}))},[s,j,h]),_=f.useMemo(()=>{if(!s)return[];const{receivedCountByType:R}=s,L=Object.keys(R).map(S=>parseInt(S,10)).filter(S=>(R[S]??0)>0).sort((S,F)=>(R[F]??0)-(R[S]??0));return h&&x>0&&L.unshift(Q),L},[s,x,h]),k=f.useMemo(()=>{if(!s)return{};const R={...s.receivedCountByType??{}};return h&&x>0&&(R[Q]=x),R},[s,x,h]),A=(e==null?void 0:e.node_name)??((g=e==null?void 0:e.config)==null?void 0:g.node_name)??"Unknown Node";return f.useEffect(()=>{A&&A!=="Unknown Node"&&(document.title=`pyMC: ${A}`)},[A]),n?t.jsxs(dt,{neomorphic:!0,className:"p-8 text-center",children:[t.jsx("p",{className:"type-subheading text-sys-red mb-2",children:"Failed to connect to backend"}),t.jsx("p",{className:"type-body text-fg-muted",children:n}),t.jsx("p",{className:"type-data-sm text-fg-muted mt-4",children:"Make sure the backend is running on port 8000"})]}):t.jsxs(mn,{children:[t.jsx(fn,{title:A,icon:t.jsx(Hn,{}),subtitle:t.jsx(Tn,{}),controls:t.jsx(es,{ranges:ee,selectedIndex:c,onSelect:i,isPending:m})}),t.jsxs(pn,{ready:a,children:[t.jsx(bo,{}),t.jsx(ft,{template:"hero-auto",children:t.jsxs(dt,{neomorphic:!0,children:[t.jsx(It,{icon:t.jsx(ns,{}),title:"PACKETS RECEIVED",badge:u.label,badgeColor:"zinc",titleExtra:t.jsx(Ht,{enabled:T,onChange:v,size:"sm",label:t.jsx("span",{className:"font-mono text-xs text-fg-muted uppercase tracking-wide",children:"Advanced"})}),actions:a?t.jsx("div",{className:"flex items-center gap-1.5",children:T?t.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"CRC errors — packets corrupted during radio transmission",children:[t.jsx(ct,{className:"w-3.5 h-3.5 text-sys-red"}),t.jsxs("span",{children:["CRC ",x.toLocaleString()]})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:C,className:"p-1 rounded hover:bg-zinc-500/20 active:bg-zinc-500/30 transition-colors touch-manipulation",title:h?"Hide CRC Errors":"Show CRC Errors","aria-label":h?"Hide CRC error overlay":"Show CRC error overlay","aria-pressed":h,children:t.jsx(ct,{className:`w-3.5 h-3.5 transition-colors ${h?"text-sys-red":"text-fg-muted"}`})}),t.jsxs("div",{className:"data-box",children:[b.kbPerHour," KB/hr"]})]})}):void 0}),t.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:T?t.jsx(Da,{forwardedBuckets:(s==null?void 0:s.forwardedBytesBuckets)??[],droppedBuckets:(s==null?void 0:s.droppedBytesBuckets)??[],forwardedActiveTypes:(s==null?void 0:s.forwardedActiveTypes)??[],droppedActiveTypes:(s==null?void 0:s.droppedActiveTypes)??[],forwardedCount:w.forwarded,droppedCount:w.dropped,crcCount:x,crcHistory:j,receivedCount:w.received,forwardedTotalByType:(s==null?void 0:s.forwardedTotalByType)??{},droppedTotalByType:(s==null?void 0:s.droppedTotalByType)??{},startTime:(s==null?void 0:s.start_time)??0,bucketDurationSeconds:(s==null?void 0:s.bucket_duration_seconds)??1,bucketCount:(s==null?void 0:s.bucket_count)??0,timeRangeMinutes:u.minutes}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-8",children:[t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("div",{className:"type-data-xl text-fg-primary",children:a?t.jsx(re,{value:w.received,className:"font-mono tabular-nums",priority:"high"}):t.jsx("span",{className:"opacity-30",children:"—"})}),t.jsx(ne,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"Total Rx"})]}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("div",{className:"type-data-xl text-fg-primary",children:a?t.jsx(re,{value:w.uniqueReceived,className:"font-mono tabular-nums",priority:"high"}):t.jsx("span",{className:"opacity-30",children:"—"})}),t.jsx(ne,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"Unique"})]})]}),t.jsx("div",{className:"mt-2 flex-1 min-h-0",children:t.jsx(ja,{buckets:p,activeTypes:_,totalByType:k,mode:"count"})})]})})]})}),t.jsx(uo,{leading:t.jsx(Fa,{stats:e,localHash:e==null?void 0:e.local_hash,receivedBuckets:s==null?void 0:s.received,droppedBuckets:s==null?void 0:s.dropped,forwardedBuckets:s==null?void 0:s.forwarded,bucketDurationSeconds:s==null?void 0:s.bucket_duration_seconds,timeRangeLabel:u.label})}),t.jsx(Oo,{}),t.jsx(Ia,{}),e&&t.jsx(ft,{template:"auto",children:t.jsx(Dn,{nodeName:A,publicKey:e.public_key,pathHashMode:(P=(D=e.config)==null?void 0:D.mesh)==null?void 0:P.path_hash_mode})})]})]})}export{Dr as default}; diff --git a/frontend/dist/assets/DataValue-9iNfucjq.js b/frontend/dist/assets/DataValue-B0xdrk88.js similarity index 87% rename from frontend/dist/assets/DataValue-9iNfucjq.js rename to frontend/dist/assets/DataValue-B0xdrk88.js index 5b101011..1d1adebf 100644 --- a/frontend/dist/assets/DataValue-9iNfucjq.js +++ b/frontend/dist/assets/DataValue-B0xdrk88.js @@ -1 +1 @@ -import{r as a,cY as d,j as o,cZ as N}from"./index-C2xvS0Jd.js";import{A as g}from"./index-QCPybZMd.js";const I=a.memo(function({value:t,format:e,prefix:r,suffix:s,className:n,priority:m="medium"}){const[u,p]=a.useState(!1),[f,l]=a.useState(t);a.useEffect(()=>d(()=>{p(!0),l(0)},m),[m]),a.useEffect(()=>{u&&l(t)},[u,t]);const A=`${r??""}${t.toLocaleString(void 0,e)}${s??""}`;return u?o.jsx(g,{className:`${n??""} overflow-hidden`,format:e,prefix:r,suffix:s,transition:N.numberTicker,children:f}):o.jsx("span",{className:n,children:A})}),x={",":"punc",".":"punc-period",":":"punc-colon","/":"punc-slash"},c=/([,\.:\/])/g;function j(i){return i.split(c).map((e,r)=>{const s=x[e];return s?o.jsx("span",{className:s,children:e},r):e})}const S=a.memo(function({children:t,className:e="",as:r="span"}){const s=a.useMemo(()=>{let n;return typeof t=="number"?n=t.toLocaleString():Array.isArray(t)?n=t.join(""):n=String(t??""),c.test(n)?(c.lastIndex=0,j(n)):n},[t]);return o.jsx(r,{className:`data-tight ${e}`.trim(),children:s})});export{I as A,S as D}; +import{r as a,cZ as d,j as o,c_ as N}from"./index-D33fcA3L.js";import{A as g}from"./index-5slIee7x.js";const I=a.memo(function({value:t,format:e,prefix:r,suffix:s,className:n,priority:m="medium"}){const[u,p]=a.useState(!1),[f,l]=a.useState(t);a.useEffect(()=>d(()=>{p(!0),l(0)},m),[m]),a.useEffect(()=>{u&&l(t)},[u,t]);const A=`${r??""}${t.toLocaleString(void 0,e)}${s??""}`;return u?o.jsx(g,{className:`${n??""} overflow-hidden`,format:e,prefix:r,suffix:s,transition:N.numberTicker,children:f}):o.jsx("span",{className:n,children:A})}),x={",":"punc",".":"punc-period",":":"punc-colon","/":"punc-slash"},c=/([,\.:\/])/g;function j(i){return i.split(c).map((e,r)=>{const s=x[e];return s?o.jsx("span",{className:s,children:e},r):e})}const S=a.memo(function({children:t,className:e="",as:r="span"}){const s=a.useMemo(()=>{let n;return typeof t=="number"?n=t.toLocaleString():Array.isArray(t)?n=t.join(""):n=String(t??""),c.test(n)?(c.lastIndex=0,j(n)):n},[t]);return o.jsx(r,{className:`data-tight ${e}`.trim(),children:s})});export{I as A,S as D}; diff --git a/frontend/dist/assets/Grid-kVOI-wJp.js b/frontend/dist/assets/Grid-DQYUnZsY.js similarity index 95% rename from frontend/dist/assets/Grid-kVOI-wJp.js rename to frontend/dist/assets/Grid-DQYUnZsY.js index 15966498..e54f4913 100644 --- a/frontend/dist/assets/Grid-kVOI-wJp.js +++ b/frontend/dist/assets/Grid-DQYUnZsY.js @@ -1 +1 @@ -import{r as b,j as c,c as d}from"./index-C2xvS0Jd.js";const g={hero:{mobile:12},"hero-tall":{mobile:12},"hero-auto":{mobile:12},panel:{mobile:12,md:6},feature:{mobile:12,md:6,lg:4},standard:{mobile:12,sm:6,lg:4,xl:3},compact:{mobile:6,lg:3},widget:{mobile:6,sm:4,md:3,lg:2},auto:{mobile:12}},p={hero:"bento-row-hero","hero-tall":"bento-row-hero-tall","hero-auto":"bento-row-hero-auto",panel:"bento-row-panel",feature:"bento-row-feature",standard:"bento-row-standard",compact:"bento-row-compact",widget:"bento-row-widget",auto:"bento-row-auto"};function w({template:o,children:r,className:e,gap:n}){const t=g[o],m=p[o],a=n==="none"?"gap-0":n==="sm"?"bento-gap-sm":n==="lg"?"bento-gap-lg":"bento-gap",i=b.Children.map(r,l=>!b.isValidElement(l)||l.type===u?l:c.jsx(u,{span:t.mobile,sm:t.sm,md:t.md,lg:t.lg,xl:t.xl,children:l}));return c.jsx("div",{className:d("bento-row",m,a,e),children:i})}function s(o,r=""){const e=r?`${r}:`:"";return o==="full"?`${e}col-span-full`:o==="auto"?`${e}col-auto`:o===1.5?`${e}bento-col-1-5`:`${e}bento-col-${o}`}function u({children:o,span:r,sm:e,md:n,lg:t,xl:m,ratio:a,className:i}){const l=d("bento-cell",s(r),e&&s(e,"sm"),n&&s(n,"md"),t&&s(t,"lg"),m&&s(m,"xl"),i);return c.jsx("div",{className:l,"data-ratio":a??void 0,style:a?{"--cell-ratio":a}:void 0,children:o})}export{u as C,w as R}; +import{r as b,j as c,c as d}from"./index-D33fcA3L.js";const g={hero:{mobile:12},"hero-tall":{mobile:12},"hero-auto":{mobile:12},panel:{mobile:12,md:6},feature:{mobile:12,md:6,lg:4},standard:{mobile:12,sm:6,lg:4,xl:3},compact:{mobile:6,lg:3},widget:{mobile:6,sm:4,md:3,lg:2},auto:{mobile:12}},p={hero:"bento-row-hero","hero-tall":"bento-row-hero-tall","hero-auto":"bento-row-hero-auto",panel:"bento-row-panel",feature:"bento-row-feature",standard:"bento-row-standard",compact:"bento-row-compact",widget:"bento-row-widget",auto:"bento-row-auto"};function w({template:o,children:r,className:e,gap:n}){const t=g[o],m=p[o],a=n==="none"?"gap-0":n==="sm"?"bento-gap-sm":n==="lg"?"bento-gap-lg":"bento-gap",i=b.Children.map(r,l=>!b.isValidElement(l)||l.type===u?l:c.jsx(u,{span:t.mobile,sm:t.sm,md:t.md,lg:t.lg,xl:t.xl,children:l}));return c.jsx("div",{className:d("bento-row",m,a,e),children:i})}function s(o,r=""){const e=r?`${r}:`:"";return o==="full"?`${e}col-span-full`:o==="auto"?`${e}col-auto`:o===1.5?`${e}bento-col-1-5`:`${e}bento-col-${o}`}function u({children:o,span:r,sm:e,md:n,lg:t,xl:m,ratio:a,className:i}){const l=d("bento-cell",s(r),e&&s(e,"sm"),n&&s(n,"md"),t&&s(t,"lg"),m&&s(m,"xl"),i);return c.jsx("div",{className:l,"data-ratio":a??void 0,style:a?{"--cell-ratio":a}:void 0,children:o})}export{u as C,w as R}; diff --git a/frontend/dist/assets/KeycapButton-BVIaMPId.js b/frontend/dist/assets/KeycapButton-xWUX1i8p.js similarity index 98% rename from frontend/dist/assets/KeycapButton-BVIaMPId.js rename to frontend/dist/assets/KeycapButton-xWUX1i8p.js index cee27393..fc00e571 100644 --- a/frontend/dist/assets/KeycapButton-BVIaMPId.js +++ b/frontend/dist/assets/KeycapButton-xWUX1i8p.js @@ -1 +1 @@ -import{r as l,j as t,Z as O}from"./index-C2xvS0Jd.js";import{b as F,c as x}from"./keycap-sfx-ByZp-njj.js";const R={a:"24,3 76,3 83,7 76,11 24,11 17,7",b:"88,22 93,27 93,71 88,76 83,71 83,27",c:"88,106 93,111 93,155 88,160 83,155 83,111",d:"24,171 76,171 83,175 76,179 24,179 17,175",e:"12,106 17,111 17,155 12,160 7,155 7,111",f:"12,22 17,27 17,71 12,76 7,71 7,27",g:"24,86 76,86 83,91 76,96 24,96 17,91"},w=Object.keys(R),N={0:"abcdef",1:"bc",2:"abdeg",3:"abcdg",4:"bcfg",5:"acdfg",6:"acdefg",7:"abc",8:"abcdefg",9:"abcdfg",A:"abcefg",B:"cdefg",C:"adef",D:"bcdeg",E:"adefg",F:"aefg",G:"acdef",H:"bcefg",I:"ef",J:"bcde",L:"def",M:"abcefg",N:"ceg",O:"abcdef",P:"abefg",Q:"abcfg",R:"eg",S:"acdfg",T:"defg",U:"bcdef",V:"cde",Y:"bcdfg",Z:"abdeg",a:"abcefg",b:"cdefg",c:"deg",d:"bcdeg",e:"adefg",f:"aefg",g:"abcdfg",h:"cefg",i:"c",j:"bcde",l:"def",m:"abcef",n:"ceg",o:"cdeg",p:"abefg",r:"eg",s:"acdfg",t:"defg",u:"cde",v:"cde",y:"bcdfg"," ":"",_:"d","-":"g","=":"dg","°":"abfg",'"':"bf","'":"f","(":"adef",")":"abcd","[":"adef","]":"abcd","!":"bc",".":"d"},C=6,D=56,L=2;function B(){return w.filter(()=>Math.random()>.45).join("")}function $(r,i){const n=Array.from(r).map(a=>N[a.toUpperCase()]??N[a]??""),d=Math.max(0,(i??0)-r.length);for(let a=0;a{if(a)return;const e=$(r,d),o=e.length,g=C+(o-1)*L;let y=0,b,E=!1;const k=()=>{if(!E){if(y++,y>=g){f(null);return}f(e.map((j,_)=>{const v=C+_*L;return y>=v?j:B()})),b=setTimeout(k,D)}};return k(),()=>{E=!0,clearTimeout(b)}},[r,d,a]);const c=(e,o)=>t.jsx("svg",{viewBox:"0 0 100 182",width:h,height:n,className:"seven-seg__char","aria-hidden":"true",children:w.map(g=>t.jsx("polygon",{points:R[g],fill:i,stroke:i,strokeWidth:4,strokeLinejoin:"round",opacity:e.includes(g)?1:M},g))},o),s=$(r,d),u=T??s;return t.jsxs("span",{className:`seven-seg${S?` ${S}`:""}`,children:[u.map((e,o)=>c(e,`${o}-${e}`)),t.jsx("span",{className:"sr-only",children:r})]})}const G={grey:"/assets/keycap.svg",red:"/assets/keycap-red.svg"},I=O[900],P="#FFDEB0";function Z({icon:r,variant:i="grey",onClick:n,onPress:d,sentDuration:a=2e3,title:S,disabled:h=!1,className:m,iconColor:M=I,iconActiveColor:T=P,indicators:f}){const c=!!d,[s,u]=l.useState("idle"),[e,o]=l.useState(!1),g=l.useRef(),y=c?s==="held":e,b=c&&(s==="sending"||s==="sent"),E=c?s==="held"||s==="sending":e;l.useEffect(()=>()=>clearTimeout(g.current),[]);const k=l.useCallback(()=>{h||b||(F(),c?u("held"):o(!0))},[h,b,c]),j=l.useCallback(async()=>{if(c){if(s!=="held")return;x(),u("sending");const p=await d();u(p?"sent":"idle"),p&&(g.current=setTimeout(()=>u("idle"),a))}else{if(!e)return;o(!1),x(),n==null||n()}},[c,s,d,a,e,n]),_=l.useCallback(()=>{c?s==="held"&&(x(),u("idle")):(e&&x(),o(!1))},[c,s,e]),v=t.jsx("button",{onMouseDown:k,onMouseUp:j,onMouseLeave:_,onTouchStart:k,onTouchEnd:j,onTouchCancel:_,disabled:h||b,className:`keycap-btn${i==="red"?" keycap-btn--red-cap":""}${E?" keycap-btn--pressed":""}${m&&!f?` ${m}`:""}`,title:S,children:t.jsxs("div",{className:"keycap-wrap",children:[t.jsx("img",{src:G[i],alt:"",className:"keycap-btn__img",draggable:!1}),t.jsx("span",{className:"keycap-icon-overlay",style:{color:y||s==="sending"?T:M},children:r})]})});return f!=null&&f.length?t.jsxs("div",{className:`keycap-group${m?` ${m}`:""}`,children:[v,t.jsx("div",{className:"indicator-key-pair",children:f.map(p=>{const A=p.trackPress?s:p.active?"active":"idle";return t.jsxs("div",{className:`indicator-key${A!=="idle"?` indicator-key--${A}`:""}`,children:[t.jsx("span",{className:"indicator-key__label",children:p.label}),t.jsx("span",{className:"indicator-key__led"})]},p.label)})})]}):v}export{Z as K,Y as S}; +import{r as l,j as t,Z as O}from"./index-D33fcA3L.js";import{b as F,c as x}from"./keycap-sfx-ByZp-njj.js";const R={a:"24,3 76,3 83,7 76,11 24,11 17,7",b:"88,22 93,27 93,71 88,76 83,71 83,27",c:"88,106 93,111 93,155 88,160 83,155 83,111",d:"24,171 76,171 83,175 76,179 24,179 17,175",e:"12,106 17,111 17,155 12,160 7,155 7,111",f:"12,22 17,27 17,71 12,76 7,71 7,27",g:"24,86 76,86 83,91 76,96 24,96 17,91"},w=Object.keys(R),N={0:"abcdef",1:"bc",2:"abdeg",3:"abcdg",4:"bcfg",5:"acdfg",6:"acdefg",7:"abc",8:"abcdefg",9:"abcdfg",A:"abcefg",B:"cdefg",C:"adef",D:"bcdeg",E:"adefg",F:"aefg",G:"acdef",H:"bcefg",I:"ef",J:"bcde",L:"def",M:"abcefg",N:"ceg",O:"abcdef",P:"abefg",Q:"abcfg",R:"eg",S:"acdfg",T:"defg",U:"bcdef",V:"cde",Y:"bcdfg",Z:"abdeg",a:"abcefg",b:"cdefg",c:"deg",d:"bcdeg",e:"adefg",f:"aefg",g:"abcdfg",h:"cefg",i:"c",j:"bcde",l:"def",m:"abcef",n:"ceg",o:"cdeg",p:"abefg",r:"eg",s:"acdfg",t:"defg",u:"cde",v:"cde",y:"bcdfg"," ":"",_:"d","-":"g","=":"dg","°":"abfg",'"':"bf","'":"f","(":"adef",")":"abcd","[":"adef","]":"abcd","!":"bc",".":"d"},C=6,D=56,L=2;function B(){return w.filter(()=>Math.random()>.45).join("")}function $(r,i){const n=Array.from(r).map(a=>N[a.toUpperCase()]??N[a]??""),d=Math.max(0,(i??0)-r.length);for(let a=0;a{if(a)return;const e=$(r,d),o=e.length,g=C+(o-1)*L;let y=0,b,E=!1;const k=()=>{if(!E){if(y++,y>=g){f(null);return}f(e.map((j,_)=>{const v=C+_*L;return y>=v?j:B()})),b=setTimeout(k,D)}};return k(),()=>{E=!0,clearTimeout(b)}},[r,d,a]);const c=(e,o)=>t.jsx("svg",{viewBox:"0 0 100 182",width:h,height:n,className:"seven-seg__char","aria-hidden":"true",children:w.map(g=>t.jsx("polygon",{points:R[g],fill:i,stroke:i,strokeWidth:4,strokeLinejoin:"round",opacity:e.includes(g)?1:M},g))},o),s=$(r,d),u=T??s;return t.jsxs("span",{className:`seven-seg${S?` ${S}`:""}`,children:[u.map((e,o)=>c(e,`${o}-${e}`)),t.jsx("span",{className:"sr-only",children:r})]})}const G={grey:"/assets/keycap.svg",red:"/assets/keycap-red.svg"},I=O[900],P="#FFDEB0";function Z({icon:r,variant:i="grey",onClick:n,onPress:d,sentDuration:a=2e3,title:S,disabled:h=!1,className:m,iconColor:M=I,iconActiveColor:T=P,indicators:f}){const c=!!d,[s,u]=l.useState("idle"),[e,o]=l.useState(!1),g=l.useRef(),y=c?s==="held":e,b=c&&(s==="sending"||s==="sent"),E=c?s==="held"||s==="sending":e;l.useEffect(()=>()=>clearTimeout(g.current),[]);const k=l.useCallback(()=>{h||b||(F(),c?u("held"):o(!0))},[h,b,c]),j=l.useCallback(async()=>{if(c){if(s!=="held")return;x(),u("sending");const p=await d();u(p?"sent":"idle"),p&&(g.current=setTimeout(()=>u("idle"),a))}else{if(!e)return;o(!1),x(),n==null||n()}},[c,s,d,a,e,n]),_=l.useCallback(()=>{c?s==="held"&&(x(),u("idle")):(e&&x(),o(!1))},[c,s,e]),v=t.jsx("button",{onMouseDown:k,onMouseUp:j,onMouseLeave:_,onTouchStart:k,onTouchEnd:j,onTouchCancel:_,disabled:h||b,className:`keycap-btn${i==="red"?" keycap-btn--red-cap":""}${E?" keycap-btn--pressed":""}${m&&!f?` ${m}`:""}`,title:S,children:t.jsxs("div",{className:"keycap-wrap",children:[t.jsx("img",{src:G[i],alt:"",className:"keycap-btn__img",draggable:!1}),t.jsx("span",{className:"keycap-icon-overlay",style:{color:y||s==="sending"?T:M},children:r})]})});return f!=null&&f.length?t.jsxs("div",{className:`keycap-group${m?` ${m}`:""}`,children:[v,t.jsx("div",{className:"indicator-key-pair",children:f.map(p=>{const A=p.trackPress?s:p.active?"active":"idle";return t.jsxs("div",{className:`indicator-key${A!=="idle"?` indicator-key--${A}`:""}`,children:[t.jsx("span",{className:"indicator-key__label",children:p.label}),t.jsx("span",{className:"indicator-key__led"})]},p.label)})})]}):v}export{Z as K,Y as S}; diff --git a/frontend/dist/assets/LightSparkline-Dtyxi9BD.js b/frontend/dist/assets/LightSparkline-r3FtGEtW.js similarity index 96% rename from frontend/dist/assets/LightSparkline-Dtyxi9BD.js rename to frontend/dist/assets/LightSparkline-r3FtGEtW.js index 3660902e..a78aed82 100644 --- a/frontend/dist/assets/LightSparkline-Dtyxi9BD.js +++ b/frontend/dist/assets/LightSparkline-r3FtGEtW.js @@ -1 +1 @@ -import{r as y,j as t}from"./index-C2xvS0Jd.js";const m="var(--sys-cyan)",k="var(--sys-blue)",v="var(--sys-indigo)",I="var(--sparkline-critical)",g="var(--fg-muted)";function C(d,o,e,s=2){if(d.length<2)return"";const r=d.map(n=>n.count),u=Math.max(...r,1),p=Math.min(...r),l=u-p||1,j=o-s*2,a=e-s*2,i=r.map((n,c)=>({x:s+c/(r.length-1)*j,y:s+a-(n-p)/l*a}));let x=`M ${i[0].x.toFixed(1)} ${i[0].y.toFixed(1)}`;for(let n=1;nC(o,e,s),[o,e,s]),x=!r&&o.length>=2,n=r??(x?`url(#${a})`:g),c=l.includes("w-");return p&&o.length<2?t.jsx("div",{className:`flex items-center justify-center ${l}`,style:c?{height:s}:{width:e,height:s},children:t.jsx("div",{className:"rounded animate-pulse bg-subtle-fill-hover",style:c?{width:"100%",height:s-6}:{width:e-8,height:s-6}})}):o.length<2?t.jsx("svg",{width:e,height:s,viewBox:`0 0 ${e} ${s}`,className:l,"aria-hidden":"true",children:t.jsx("line",{x1:4,y1:s/2,x2:e-4,y2:s/2,stroke:I,strokeWidth:1.5,strokeDasharray:"3,2"})}):t.jsxs("svg",{width:e,height:s,viewBox:`0 0 ${e} ${s}`,preserveAspectRatio:"none",className:l,"aria-hidden":"true",style:{maxWidth:"100%"},children:[x&&t.jsx("defs",{children:t.jsxs("linearGradient",{id:a,gradientUnits:"userSpaceOnUse",x1:0,y1:2,x2:0,y2:s-2,children:[t.jsx("stop",{offset:"0%",stopColor:u?v:m}),t.jsx("stop",{offset:"50%",stopColor:k}),t.jsx("stop",{offset:"100%",stopColor:u?m:v})]})}),t.jsx("path",{d:i,fill:"none",stroke:n,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})});export{L}; +import{r as y,j as t}from"./index-D33fcA3L.js";const m="var(--sys-cyan)",k="var(--sys-blue)",v="var(--sys-indigo)",I="var(--sparkline-critical)",g="var(--fg-muted)";function C(d,o,e,s=2){if(d.length<2)return"";const r=d.map(n=>n.count),u=Math.max(...r,1),p=Math.min(...r),l=u-p||1,j=o-s*2,a=e-s*2,i=r.map((n,c)=>({x:s+c/(r.length-1)*j,y:s+a-(n-p)/l*a}));let x=`M ${i[0].x.toFixed(1)} ${i[0].y.toFixed(1)}`;for(let n=1;nC(o,e,s),[o,e,s]),x=!r&&o.length>=2,n=r??(x?`url(#${a})`:g),c=l.includes("w-");return p&&o.length<2?t.jsx("div",{className:`flex items-center justify-center ${l}`,style:c?{height:s}:{width:e,height:s},children:t.jsx("div",{className:"rounded animate-pulse bg-subtle-fill-hover",style:c?{width:"100%",height:s-6}:{width:e-8,height:s-6}})}):o.length<2?t.jsx("svg",{width:e,height:s,viewBox:`0 0 ${e} ${s}`,className:l,"aria-hidden":"true",children:t.jsx("line",{x1:4,y1:s/2,x2:e-4,y2:s/2,stroke:I,strokeWidth:1.5,strokeDasharray:"3,2"})}):t.jsxs("svg",{width:e,height:s,viewBox:`0 0 ${e} ${s}`,preserveAspectRatio:"none",className:l,"aria-hidden":"true",style:{maxWidth:"100%"},children:[x&&t.jsx("defs",{children:t.jsxs("linearGradient",{id:a,gradientUnits:"userSpaceOnUse",x1:0,y1:2,x2:0,y2:s-2,children:[t.jsx("stop",{offset:"0%",stopColor:u?v:m}),t.jsx("stop",{offset:"50%",stopColor:k}),t.jsx("stop",{offset:"100%",stopColor:u?m:v})]})}),t.jsx("path",{d:i,fill:"none",stroke:n,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})});export{L}; diff --git a/frontend/dist/assets/Login-BbzCGlZ1.js b/frontend/dist/assets/Login-roDFdIby.js similarity index 99% rename from frontend/dist/assets/Login-BbzCGlZ1.js rename to frontend/dist/assets/Login-roDFdIby.js index 01069a1a..cdca4e47 100644 --- a/frontend/dist/assets/Login-BbzCGlZ1.js +++ b/frontend/dist/assets/Login-roDFdIby.js @@ -1 +1 @@ -import{r as s,j as e,u as _,g as Z,i as B,s as E,l as I,m as r,a as T,b as u,A,c as f,I as j,C as W,d as z,B as F,Z as D}from"./index-C2xvS0Jd.js";function U({width:i,height:n,className:d="",fill:a="currentColor"}){return e.jsxs("svg",{viewBox:"0 0 134 15",width:i,height:n,className:d,role:"img","aria-label":"MeshCore",style:{fillRule:"evenodd",clipRule:"evenodd"},children:[e.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"}),e.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"}),e.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"}),e.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"}),e.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"}),e.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"}),e.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"}),e.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"})]})}const q=s.memo(U),H="/assets/WCM_Waves-RN-_ocPH.gif",K="/assets/pyMC-logo-CaIkLXHc.svg",l={container:{hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:T.normal,delayChildren:.1}}},item:{hidden:{opacity:0,y:12},visible:{opacity:1,y:0,transition:u.smooth}},footer:{hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{...u.gentle,delay:.4}}},error:{hidden:{opacity:0,height:0,marginTop:0},visible:{opacity:1,height:"auto",marginTop:24,transition:u.snappy},exit:{opacity:0,height:0,marginTop:0,transition:{duration:.15}}}},b=f("block type-badge text-fg-secondary"),X=s.memo(function({className:n}){return e.jsxs("svg",{className:f("animate-spin",n),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.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"})]})}),p=s.memo(function({href:n,children:d}){return e.jsx(r.a,{href:n,target:"_blank",rel:"noopener noreferrer",whileHover:{scale:1.05},whileTap:{scale:.98},className:"inline-flex items-center gap-1.5 opacity-60 hover:opacity-100 transition-opacity",children:d})}),v=()=>e.jsx("span",{className:"text-white/20 text-xs","aria-hidden":"true",children:"•"}),Y=s.memo(function(){return e.jsx("div",{className:"fixed inset-0 -z-10",style:{backgroundColor:D[950]},"aria-hidden":"true"})}),O=s.memo(function(){return e.jsxs(r.footer,{variants:l.footer,initial:"hidden",animate:"visible",className:"fixed bottom-0 inset-x-0 px-4 py-6",children:[e.jsx("p",{className:"text-center type-badge text-white/40 mb-3",children:"Powered By"}),e.jsx("div",{className:"mx-auto max-w-xs",children:e.jsxs("div",{className:"flex items-center justify-center gap-4",children:[e.jsx(p,{href:"https://github.com/rightup/pyMC_Repeater",children:e.jsx("img",{src:K,alt:"pyMC",className:"h-14"})}),e.jsx(v,{}),e.jsx(p,{href:"https://meshcore.co.uk",children:e.jsx(q,{height:12,className:"text-white"})}),e.jsx(v,{}),e.jsxs(p,{href:"https://wcmesh.com",children:[e.jsx("div",{className:"size-14 overflow-hidden radius-badge border border-white/10 -translate-y-1",children:e.jsx("img",{src:H,alt:"",className:"size-full object-cover"})}),e.jsx("span",{className:"font-mono text-sm font-semibold tracking-tight text-white",children:"WCM"})]})]})})]})}),V={session_expired:"Your session has expired. Please sign in again.",no_token:"Authentication required. Please sign in.",token_expired_away:"Your session expired while you were away."};function J(){const i=_(),[n,d]=s.useState("admin"),[a,N]=s.useState(""),[C,w]=s.useState(Z),[L,g]=s.useState(!1),[o,h]=s.useState(null),[y]=s.useState(()=>{try{const t=sessionStorage.getItem("auth_redirect_reason");return sessionStorage.removeItem("auth_redirect_reason"),t?V[t]??null:null}catch{return null}}),c=n.length>0&&a.length>0&&!L;s.useEffect(()=>{B()&&i("/",{replace:!0})},[i]);const m=s.useCallback(()=>h(null),[]),M=s.useCallback(t=>{d(t.target.value),o&&m()},[o,m]),k=s.useCallback(t=>{N(t.target.value),o&&m()},[o,m]),S=s.useCallback(t=>{w(t),E(t)},[]),R=s.useCallback(async t=>{if(t.preventDefault(),!c)return;g(!0),h(null);const x=await I(n,a,C);g(!1),x.success?window.location.href="/":h(x.error??"Login failed")},[c,n,a,C]),P=s.useCallback(t=>{t.key==="Enter"&&c&&t.target.tagName==="INPUT"&&(t.preventDefault(),t.currentTarget.requestSubmit())},[c]);return e.jsxs(e.Fragment,{children:[e.jsx(Y,{}),e.jsx("main",{className:"flex min-h-svh items-center justify-center px-4 py-6 sm:px-6 lg:px-8 -mt-6",children:e.jsxs(r.div,{variants:l.container,initial:"hidden",animate:"visible",className:"w-full max-w-sm space-y-10",children:[e.jsx(r.div,{variants:l.item,className:"flex justify-center",children:e.jsx(A,{})}),y&&!o&&e.jsx(r.div,{variants:l.item,className:"rounded-md bg-sys-amber/10 px-3 py-2.5 text-center",children:e.jsx("p",{className:"text-sm text-sys-amber",children:y})}),e.jsxs(r.form,{variants:l.item,onSubmit:R,onKeyDown:P,className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"username",className:b,children:"Username"}),e.jsx("div",{className:"mt-2",children:e.jsx(j,{id:"username",name:"username",type:"text",value:n,onChange:M,required:!0,autoComplete:"username",className:"font-mono text-sm font-semibold"})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:b,children:"Password"}),e.jsx("div",{className:"mt-2",children:e.jsx(j,{id:"password",name:"password",type:"password",value:a,onChange:k,required:!0,autoComplete:"current-password",autoFocus:!0,className:"font-mono text-sm font-semibold"})})]}),e.jsx("div",{className:"-mt-2",children:e.jsx(W,{checked:C,onChange:S,label:e.jsx("span",{className:"type-badge text-fg-secondary",children:"Remember me"}),size:"sm"})}),e.jsx(z,{mode:"wait",children:o&&e.jsx(r.div,{variants:l.error,initial:"hidden",animate:"visible",exit:"exit",role:"alert",className:"rounded-md bg-sys-red/10 p-3 overflow-hidden",children:e.jsx("p",{className:"text-sm text-sys-red text-center",children:o})},"error")}),e.jsx(r.div,{whileTap:c?{scale:.98}:void 0,children:e.jsx(F,{type:"submit",disabled:!c,className:"w-full py-3 radius-pill font-mono text-sm font-semibold uppercase tracking-wide text-white bg-sys-indigo hover:bg-sys-blue shadow-sm transition-colors",children:L?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"size-4"}),"Signing in…"]}):"Sign in"})})]}),e.jsxs(r.p,{variants:l.item,className:"text-center text-sm/6 text-fg-muted",children:["A ",e.jsx("span",{className:"text-sys-blue",children:"@RightUp"})," X"," ",e.jsx("span",{className:"text-sys-blue",children:"@Treehouse⚡"})," Collab"]})]})}),e.jsx(O,{})]})}export{J as default}; +import{r as s,j as e,u as _,g as Z,i as B,s as E,l as I,m as r,a as T,b as u,A,c as f,I as j,C as W,d as z,B as F,Z as D}from"./index-D33fcA3L.js";function U({width:i,height:n,className:d="",fill:a="currentColor"}){return e.jsxs("svg",{viewBox:"0 0 134 15",width:i,height:n,className:d,role:"img","aria-label":"MeshCore",style:{fillRule:"evenodd",clipRule:"evenodd"},children:[e.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"}),e.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"}),e.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"}),e.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"}),e.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"}),e.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"}),e.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"}),e.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"})]})}const q=s.memo(U),H="/assets/WCM_Waves-RN-_ocPH.gif",K="/assets/pyMC-logo-CaIkLXHc.svg",l={container:{hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:T.normal,delayChildren:.1}}},item:{hidden:{opacity:0,y:12},visible:{opacity:1,y:0,transition:u.smooth}},footer:{hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{...u.gentle,delay:.4}}},error:{hidden:{opacity:0,height:0,marginTop:0},visible:{opacity:1,height:"auto",marginTop:24,transition:u.snappy},exit:{opacity:0,height:0,marginTop:0,transition:{duration:.15}}}},b=f("block type-badge text-fg-secondary"),X=s.memo(function({className:n}){return e.jsxs("svg",{className:f("animate-spin",n),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.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"})]})}),p=s.memo(function({href:n,children:d}){return e.jsx(r.a,{href:n,target:"_blank",rel:"noopener noreferrer",whileHover:{scale:1.05},whileTap:{scale:.98},className:"inline-flex items-center gap-1.5 opacity-60 hover:opacity-100 transition-opacity",children:d})}),v=()=>e.jsx("span",{className:"text-white/20 text-xs","aria-hidden":"true",children:"•"}),Y=s.memo(function(){return e.jsx("div",{className:"fixed inset-0 -z-10",style:{backgroundColor:D[950]},"aria-hidden":"true"})}),O=s.memo(function(){return e.jsxs(r.footer,{variants:l.footer,initial:"hidden",animate:"visible",className:"fixed bottom-0 inset-x-0 px-4 py-6",children:[e.jsx("p",{className:"text-center type-badge text-white/40 mb-3",children:"Powered By"}),e.jsx("div",{className:"mx-auto max-w-xs",children:e.jsxs("div",{className:"flex items-center justify-center gap-4",children:[e.jsx(p,{href:"https://github.com/rightup/pyMC_Repeater",children:e.jsx("img",{src:K,alt:"pyMC",className:"h-14"})}),e.jsx(v,{}),e.jsx(p,{href:"https://meshcore.co.uk",children:e.jsx(q,{height:12,className:"text-white"})}),e.jsx(v,{}),e.jsxs(p,{href:"https://wcmesh.com",children:[e.jsx("div",{className:"size-14 overflow-hidden radius-badge border border-white/10 -translate-y-1",children:e.jsx("img",{src:H,alt:"",className:"size-full object-cover"})}),e.jsx("span",{className:"font-mono text-sm font-semibold tracking-tight text-white",children:"WCM"})]})]})})]})}),V={session_expired:"Your session has expired. Please sign in again.",no_token:"Authentication required. Please sign in.",token_expired_away:"Your session expired while you were away."};function J(){const i=_(),[n,d]=s.useState("admin"),[a,N]=s.useState(""),[C,w]=s.useState(Z),[L,g]=s.useState(!1),[o,h]=s.useState(null),[y]=s.useState(()=>{try{const t=sessionStorage.getItem("auth_redirect_reason");return sessionStorage.removeItem("auth_redirect_reason"),t?V[t]??null:null}catch{return null}}),c=n.length>0&&a.length>0&&!L;s.useEffect(()=>{B()&&i("/",{replace:!0})},[i]);const m=s.useCallback(()=>h(null),[]),M=s.useCallback(t=>{d(t.target.value),o&&m()},[o,m]),k=s.useCallback(t=>{N(t.target.value),o&&m()},[o,m]),S=s.useCallback(t=>{w(t),E(t)},[]),R=s.useCallback(async t=>{if(t.preventDefault(),!c)return;g(!0),h(null);const x=await I(n,a,C);g(!1),x.success?window.location.href="/":h(x.error??"Login failed")},[c,n,a,C]),P=s.useCallback(t=>{t.key==="Enter"&&c&&t.target.tagName==="INPUT"&&(t.preventDefault(),t.currentTarget.requestSubmit())},[c]);return e.jsxs(e.Fragment,{children:[e.jsx(Y,{}),e.jsx("main",{className:"flex min-h-svh items-center justify-center px-4 py-6 sm:px-6 lg:px-8 -mt-6",children:e.jsxs(r.div,{variants:l.container,initial:"hidden",animate:"visible",className:"w-full max-w-sm space-y-10",children:[e.jsx(r.div,{variants:l.item,className:"flex justify-center",children:e.jsx(A,{})}),y&&!o&&e.jsx(r.div,{variants:l.item,className:"rounded-md bg-sys-amber/10 px-3 py-2.5 text-center",children:e.jsx("p",{className:"text-sm text-sys-amber",children:y})}),e.jsxs(r.form,{variants:l.item,onSubmit:R,onKeyDown:P,className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"username",className:b,children:"Username"}),e.jsx("div",{className:"mt-2",children:e.jsx(j,{id:"username",name:"username",type:"text",value:n,onChange:M,required:!0,autoComplete:"username",className:"font-mono text-sm font-semibold"})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:b,children:"Password"}),e.jsx("div",{className:"mt-2",children:e.jsx(j,{id:"password",name:"password",type:"password",value:a,onChange:k,required:!0,autoComplete:"current-password",autoFocus:!0,className:"font-mono text-sm font-semibold"})})]}),e.jsx("div",{className:"-mt-2",children:e.jsx(W,{checked:C,onChange:S,label:e.jsx("span",{className:"type-badge text-fg-secondary",children:"Remember me"}),size:"sm"})}),e.jsx(z,{mode:"wait",children:o&&e.jsx(r.div,{variants:l.error,initial:"hidden",animate:"visible",exit:"exit",role:"alert",className:"rounded-md bg-sys-red/10 p-3 overflow-hidden",children:e.jsx("p",{className:"text-sm text-sys-red text-center",children:o})},"error")}),e.jsx(r.div,{whileTap:c?{scale:.98}:void 0,children:e.jsx(F,{type:"submit",disabled:!c,className:"w-full py-3 radius-pill font-mono text-sm font-semibold uppercase tracking-wide text-white bg-sys-indigo hover:bg-sys-blue shadow-sm transition-colors",children:L?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"size-4"}),"Signing in…"]}):"Sign in"})})]}),e.jsxs(r.p,{variants:l.item,className:"text-center text-sm/6 text-fg-muted",children:["A ",e.jsx("span",{className:"text-sys-blue",children:"@RightUp"})," X"," ",e.jsx("span",{className:"text-sys-blue",children:"@Treehouse⚡"})," Collab"]})]})}),e.jsx(O,{})]})}export{J as default}; diff --git a/frontend/dist/assets/Logs-DyZ7duPG.js b/frontend/dist/assets/Logs-Dy7jDjKn.js similarity index 92% rename from frontend/dist/assets/Logs-DyZ7duPG.js rename to frontend/dist/assets/Logs-Dy7jDjKn.js index 60345528..a2bc5295 100644 --- a/frontend/dist/assets/Logs-DyZ7duPG.js +++ b/frontend/dist/assets/Logs-Dy7jDjKn.js @@ -1 +1 @@ -import{dY as h,dZ as f,a5 as j,d_ as L,d$ as v,r as l,e0 as N,j as e,e1 as m,a7 as y,B as w,c as i,e2 as b,dN as C,m as S,e3 as E}from"./index-C2xvS0Jd.js";import{P,a as R,B as k,C as B}from"./PageLayout-Cg7r5tdt.js";import{C as I,a as T}from"./circle-stop-DHdw14LD.js";const D=l.memo(function({log:a}){return e.jsx(S.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:"easeOut"},className:"p-3 bg-subtle-fill/80 radius-inner depth-stroke-raised hover:bg-subtle-fill-strong transition-base",children:e.jsxs("div",{className:"flex items-baseline gap-3",children:[e.jsx("span",{className:i("type-data-sm w-14 shrink-0",E(a.level)),children:a.level}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"type-data-sm text-fg-primary break-words whitespace-pre-wrap",children:a.message}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-1",children:new Date(a.timestamp).toLocaleString()})]})]})})});function M({showDebug:s,onToggle:a}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:i("type-data-sm",s?"text-sys-orange":"text-sys-cyan"),children:s?"DEBUG":"INFO"}),e.jsx(C,{enabled:s,onChange:a,size:"sm"})]})}function O(){const s=h(),a=f(),o=j(),r=L(),g=v(),[c,x]=l.useState(!1),u=l.useCallback(()=>{x(t=>!t)},[]),d=c?s:s.filter(t=>t.level!=="DEBUG"),n=l.useRef(r);return n.current=r,l.useEffect(()=>{if(!o)return;n.current();const t=setInterval(()=>n.current(),N.logs);return()=>clearInterval(t)},[o]),e.jsxs(P,{children:[e.jsx(R,{title:"System Logs",icon:e.jsx(m,{}),controls:e.jsx(M,{showDebug:c,onToggle:u})}),e.jsx(k,{ready:!0,children:e.jsxs(B,{neomorphic:!0,noPadding:!0,children:[e.jsx(y,{listHeader:!0,icon:e.jsx(m,{className:"icon-sm"}),title:"Log Entries",actions:e.jsx(w,{plain:!0,color:o?"danger":"primary",onClick:()=>g(!o),title:o?"Pause":"Resume",className:i(!o&&"animate-pulse-slow"),children:o?e.jsx(I,{"data-slot":"icon",className:"!w-5 !h-5"}):e.jsx(T,{"data-slot":"icon",className:"!w-5 !h-5"})})}),e.jsx("div",{className:"space-y-2 max-h-[calc(100dvh-226px)] sm:max-h-[calc(100dvh-234px)] lg:max-h-[calc(100vh-194px)] overflow-y-auto p-4",children:a&&s.length===0?e.jsx(b,{count:10}):d.length===0?e.jsx("div",{className:"text-center py-12 text-fg-muted",children:s.length===0?"No logs available":"No logs match selected filters"}):d.map((t,p)=>e.jsx(D,{log:t},`${t.timestamp}-${p}`))})]})})]})}export{O as default}; +import{dY as h,dZ as f,a5 as j,d_ as L,d$ as v,r as l,e0 as N,j as e,e1 as m,a7 as y,B as w,c as i,e2 as b,dN as C,m as S,e3 as E}from"./index-D33fcA3L.js";import{P,a as R,B as k,C as B}from"./PageLayout-CRN-E5xi.js";import{C as I,a as T}from"./circle-stop-Dh0g22OE.js";const D=l.memo(function({log:a}){return e.jsx(S.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:"easeOut"},className:"p-3 bg-subtle-fill/80 radius-inner depth-stroke-raised hover:bg-subtle-fill-strong transition-base",children:e.jsxs("div",{className:"flex items-baseline gap-3",children:[e.jsx("span",{className:i("type-data-sm w-14 shrink-0",E(a.level)),children:a.level}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"type-data-sm text-fg-primary break-words whitespace-pre-wrap",children:a.message}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-1",children:new Date(a.timestamp).toLocaleString()})]})]})})});function M({showDebug:s,onToggle:a}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:i("type-data-sm",s?"text-sys-orange":"text-sys-cyan"),children:s?"DEBUG":"INFO"}),e.jsx(C,{enabled:s,onChange:a,size:"sm"})]})}function O(){const s=h(),a=f(),o=j(),r=L(),g=v(),[c,x]=l.useState(!1),u=l.useCallback(()=>{x(t=>!t)},[]),d=c?s:s.filter(t=>t.level!=="DEBUG"),n=l.useRef(r);return n.current=r,l.useEffect(()=>{if(!o)return;n.current();const t=setInterval(()=>n.current(),N.logs);return()=>clearInterval(t)},[o]),e.jsxs(P,{children:[e.jsx(R,{title:"System Logs",icon:e.jsx(m,{}),controls:e.jsx(M,{showDebug:c,onToggle:u})}),e.jsx(k,{ready:!0,children:e.jsxs(B,{neomorphic:!0,noPadding:!0,children:[e.jsx(y,{listHeader:!0,icon:e.jsx(m,{className:"icon-sm"}),title:"Log Entries",actions:e.jsx(w,{plain:!0,color:o?"danger":"primary",onClick:()=>g(!o),title:o?"Pause":"Resume",className:i(!o&&"animate-pulse-slow"),children:o?e.jsx(I,{"data-slot":"icon",className:"!w-5 !h-5"}):e.jsx(T,{"data-slot":"icon",className:"!w-5 !h-5"})})}),e.jsx("div",{className:"space-y-2 max-h-[calc(100dvh-226px)] sm:max-h-[calc(100dvh-234px)] lg:max-h-[calc(100vh-194px)] overflow-y-auto p-4",children:a&&s.length===0?e.jsx(b,{count:10}):d.length===0?e.jsx("div",{className:"text-center py-12 text-fg-muted",children:s.length===0?"No logs available":"No logs match selected filters"}):d.map((t,p)=>e.jsx(D,{log:t},`${t.timestamp}-${p}`))})]})})]})}export{O as default}; diff --git a/frontend/dist/assets/MeshGraph-D_cqlL51.js b/frontend/dist/assets/MeshGraph-DJIb7g1_.js similarity index 99% rename from frontend/dist/assets/MeshGraph-D_cqlL51.js rename to frontend/dist/assets/MeshGraph-DJIb7g1_.js index 00e02610..e4974a45 100644 --- a/frontend/dist/assets/MeshGraph-D_cqlL51.js +++ b/frontend/dist/assets/MeshGraph-DJIb7g1_.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/webgl-device-QoBMYpnS-Crxmw1Do.js","assets/index-C2xvS0Jd.js","assets/max-BBb5g8bL.js","assets/consumer-registry-DJyYnY6J.js","assets/variants-cyDnzhWy.js","assets/git-branch-BhoB5t-Q.js","assets/clock-DU0z3qMB.js","assets/database-cyku2KnA.js","assets/badge-colors-Dl76Mz8m.js","assets/meshcore-tx-constants-DgpFTAmf.js","assets/target-BpFOYbOg.js","assets/layers-BICmdhXR.js","assets/search-DPGHPI2q.js","assets/settings-2-OYYe3udS.js","assets/rotate-ccw-Sqgw9a-1.js","assets/chevron-right-C9GG0xWI.js","assets/network-D80fXCJJ.js","assets/index-7uzBcJ1E.css"])))=>i.map(i=>d[i]); -var cL=Object.defineProperty;var uL=(i,e,t)=>e in i?cL(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var b=(i,e,t)=>uL(i,typeof e!="symbol"?e+"":e,t);import{e as rp,r as U,_ as m0,bu as un,cu as mg,dp as dL,dq as hL,j as f,aC as fL,aD as g0,bM as Vl,c as oh,bY as pL,dr as mL,m as ma,a0 as ey,a2 as gg,ds as PS,dt as jh,du as NS,ao as hd,dv as gL,dw as _L,d as Jc,dx as yL,aQ as bL,dy as vL,dz as xL,dA as wL,dB as SL,dC as EL,dD as CL,dE as TL,a6 as kL,cP as AL,dF as IL,O as Ge,Z as Xt,dG as _0,V as Oi,ap as be,dH as LL,dI as RL,aa as _g,dJ as fd,dK as y0,dL as PL,aE as Pc,dM as NL,b2 as DL,dN as ML,dO as OL,B as ty,c3 as BL,a1 as FL,a3 as zL,dP as UL}from"./index-C2xvS0Jd.js";import{m as b0,t as yg,a as $L,b as jL,e as Rn,u as HL,G as VL,c as GL,E as WL}from"./max-BBb5g8bL.js";import{u as YL,r as qL,f as v0,g as XL,e as KL}from"./consumer-registry-DJyYnY6J.js";import{s as ZL,M as DS,a as x0,b as iy}from"./variants-cyDnzhWy.js";import{G as Wp}from"./git-branch-BhoB5t-Q.js";import{C as QL}from"./clock-DU0z3qMB.js";import{D as JL}from"./database-cyku2KnA.js";import{N as eR,a as tR}from"./badge-colors-Dl76Mz8m.js";import{e as iR,f as w0,g as nR}from"./meshcore-tx-constants-DgpFTAmf.js";import{E as sR,T as rR}from"./target-BpFOYbOg.js";import{L as S0}from"./layers-BICmdhXR.js";import{S as E0}from"./search-DPGHPI2q.js";import{S as C0}from"./settings-2-OYYe3udS.js";import{R as T0}from"./rotate-ccw-Sqgw9a-1.js";import{C as Yp}from"./chevron-right-C9GG0xWI.js";import{N as MS}from"./network-D80fXCJJ.js";/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/webgl-device-QoBMYpnS-CdQYT9sr.js","assets/index-D33fcA3L.js","assets/max-CkBnBUwN.js","assets/consumer-registry-DXaeZxMm.js","assets/variants-ByRhxIcL.js","assets/git-branch-Ryinnbc1.js","assets/clock-D_m2QiHa.js","assets/database-Bm4-qoOy.js","assets/badge-colors-Dl76Mz8m.js","assets/meshcore-tx-constants-DgpFTAmf.js","assets/target-B3CHoIpd.js","assets/layers-DguV5fdN.js","assets/search-DN8guzpX.js","assets/settings-2-C5Lvk9-M.js","assets/rotate-ccw-B3SnN1wY.js","assets/chevron-right-D4kUPDBw.js","assets/network-Btok3jeo.js","assets/index-7uzBcJ1E.css"])))=>i.map(i=>d[i]); +var cL=Object.defineProperty;var uL=(i,e,t)=>e in i?cL(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var b=(i,e,t)=>uL(i,typeof e!="symbol"?e+"":e,t);import{e as rp,r as U,_ as m0,bv as un,cv as mg,dq as dL,dr as hL,j as f,aC as fL,aD as g0,bN as Vl,c as oh,bZ as pL,ds as mL,m as ma,a0 as ey,a2 as gg,dt as PS,du as jh,dv as NS,ao as hd,dw as gL,dx as _L,d as Jc,dy as yL,aR as bL,dz as vL,dA as xL,dB as wL,dC as SL,dD as EL,dE as CL,dF as TL,a6 as kL,cQ as AL,dG as IL,O as Ge,Z as Xt,dH as _0,V as Oi,ap as be,dI as LL,dJ as RL,aa as _g,dK as fd,aE as y0,dL as PL,aF as Pc,dM as NL,b3 as DL,dN as ML,dO as OL,B as ty,c4 as BL,a1 as FL,a3 as zL,dP as UL}from"./index-D33fcA3L.js";import{m as b0,t as yg,a as $L,b as jL,e as Rn,u as HL,G as VL,c as GL,E as WL}from"./max-CkBnBUwN.js";import{u as YL,r as qL,f as v0,g as XL,e as KL}from"./consumer-registry-DXaeZxMm.js";import{s as ZL,M as DS,a as x0,b as iy}from"./variants-ByRhxIcL.js";import{G as Wp}from"./git-branch-Ryinnbc1.js";import{C as QL}from"./clock-D_m2QiHa.js";import{D as JL}from"./database-Bm4-qoOy.js";import{N as eR,a as tR}from"./badge-colors-Dl76Mz8m.js";import{e as iR,f as w0,g as nR}from"./meshcore-tx-constants-DgpFTAmf.js";import{E as sR,T as rR}from"./target-B3CHoIpd.js";import{L as S0}from"./layers-DguV5fdN.js";import{S as E0}from"./search-DN8guzpX.js";import{S as C0}from"./settings-2-C5Lvk9-M.js";import{R as T0}from"./rotate-ccw-B3SnN1wY.js";import{C as Yp}from"./chevron-right-D4kUPDBw.js";import{N as MS}from"./network-Btok3jeo.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -29,7 +29,7 @@ ${r}${o}${i.type.toUpperCase()}: ${i.message}

Compilation error in ${r}



 ${o}
-
`,l.style.top="10px",l.style.left="10px",l.style.position="absolute",l.style.zIndex="9999",l.style.width="100%",l.style.textAlign="left",document.body.appendChild(l),(n=document.getElementsByClassName("luma-compiler-log-error")[0])==null||n.scrollIntoView(),l.onclick=()=>{const c=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(c)}}};$(w2,"defaultProps",{...yn.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let MN=w2;function ON(i){return BN(i.source)||i.id||fy(`unnamed ${i.stage}-shader`)}function BN(i,e="unnamed"){const t=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(i);return t?t[1]:e}const E2=class C2 extends yn{constructor(e,t){super(e,t,C2.defaultProps),$(this,"shaderLayout"),$(this,"bufferLayout"),$(this,"linkStatus","pending"),$(this,"hash",""),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}get[Symbol.toStringTag](){return"RenderPipeline"}};$(E2,"defaultProps",{...yn.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}});let Zh=E2;const T2=class k2 extends yn{constructor(e,t){super(e,t,k2.defaultProps),$(this,"hash",""),$(this,"shaderLayout"),this.shaderLayout=t.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};$(T2,"defaultProps",{...yn.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let Q0=T2;function FN(i){return jN[i]}function zN(i){const[e,t]=$N[i],n=e==="i32"||e==="u32",s=e!=="u32",r=UN[e]*t;return{primitiveType:e,components:t,byteLength:r,integer:n,signed:s}}const UN={f32:4,f16:2,i32:4,u32:4},$N={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},jN={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}};function A2(i,e){const t={};for(const n of i.attributes){const s=HN(i,e,n.name);s&&(t[n.name]=s)}return t}function Nte(i,e,t=16){const n=A2(i,e),s=new Array(t).fill(null);for(const r of Object.values(n))s[r.location]=r;return s}function HN(i,e,t){const n=VN(i,t),s=GN(e,t);if(!n)return null;const r=zN(n.type),o=cN(r),a=(s==null?void 0:s.vertexFormat)||o,l=my(a);return{attributeName:(s==null?void 0:s.attributeName)||n.name,bufferName:(s==null?void 0:s.bufferName)||n.name,location:n.location,shaderType:n.type,primitiveType:r.primitiveType,shaderComponents:r.components,vertexFormat:a,bufferDataType:l.type,bufferComponents:l.components,normalized:l.normalized,integer:r.integer,stepMode:(s==null?void 0:s.stepMode)||n.stepMode||"vertex",byteOffset:(s==null?void 0:s.byteOffset)||0,byteStride:(s==null?void 0:s.byteStride)||0}}function VN(i,e){const t=i.attributes.find(n=>n.name===e);return t||le.warn(`shader layout attribute "${e}" not present in shader`),t||null}function GN(i,e){WN(i);let t=YN(i,e);return t||(t=qN(i,e),t)?t:(le.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function WN(i){for(const e of i)(e.attributes&&e.format||!e.attributes&&!e.format)&&le.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function YN(i,e){for(const t of i)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function qN(i,e){var t;for(const n of i){let s=n.byteStride;if(typeof n.byteStride!="number")for(const o of n.attributes||[]){const a=my(o.format);s+=a.byteLength}const r=(t=n.attributes)==null?void 0:t.find(o=>o.attribute===e);if(r)return{attributeName:r.attribute,bufferName:n.name,stepMode:n.stepMode,vertexFormat:r.format,byteOffset:r.byteOffset,byteStride:s}}return null}let wd;function I2(i){return(!wd||wd.byteLengthr.type==="uniform"&&r.name===(e==null?void 0:e.name));if(!n)throw new Error(e==null?void 0:e.name);const s=n;for(const r of s.uniforms||[])this.bindingLayout[r.name]=r}}setUniforms(e){for(const[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){QN(this.uniforms[e],t)||(this.uniforms[e]=JN(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}let ai=class{constructor(e){$(this,"uniformBlocks",new Map),$(this,"uniformBufferLayouts",new Map),$(this,"uniformBuffers",new Map);for(const[t,n]of Object.entries(e)){const s=t,r=new ZN(n.uniformTypes??{},n.uniformSizes??{});this.uniformBufferLayouts.set(s,r);const o=new eD({name:t});o.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(s,o)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){var t;for(const[n,s]of Object.entries(e))(t=this.uniformBlocks.get(n))==null||t.setUniforms(s);this.updateUniformBuffers()}getUniformBufferByteLength(e){var t;return((t=this.uniformBufferLayouts.get(e))==null?void 0:t.byteLength)||0}getUniformBufferData(e){var t,n;const s=((t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms())||{};return(n=this.uniformBufferLayouts.get(e))==null?void 0:n.getData(s)}createUniformBuffer(e,t,n){n&&this.setUniforms(n);const s=this.getUniformBufferByteLength(t),r=e.createBuffer({usage:me.UNIFORM|me.COPY_DST,byteLength:s}),o=this.getUniformBufferData(t);return r.write(o),r}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){const n=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:me.UNIFORM|me.COPY_DST,byteLength:n});this.uniformBuffers.set(t,s)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const n=this.updateUniformBuffer(t);e||(e=n)}return e&&le.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){var t;const n=this.uniformBlocks.get(e);let s=this.uniformBuffers.get(e),r=!1;if(s&&n!=null&&n.needsRedraw){r||(r=n.needsRedraw);const o=this.getUniformBufferData(e);s=this.uniformBuffers.get(e),s==null||s.write(o);const a=(t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms();le.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}return r}};var Oo;(function(i){i[i.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",i[i.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",i[i.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i[i.ZERO=0]="ZERO",i[i.ONE=1]="ONE",i[i.SRC_COLOR=768]="SRC_COLOR",i[i.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",i[i.SRC_ALPHA=770]="SRC_ALPHA",i[i.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",i[i.DST_ALPHA=772]="DST_ALPHA",i[i.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",i[i.DST_COLOR=774]="DST_COLOR",i[i.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",i[i.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",i[i.CONSTANT_COLOR=32769]="CONSTANT_COLOR",i[i.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",i[i.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",i[i.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",i[i.FUNC_ADD=32774]="FUNC_ADD",i[i.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",i[i.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",i[i.BLEND_EQUATION=32777]="BLEND_EQUATION",i[i.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",i[i.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",i[i.BLEND_DST_RGB=32968]="BLEND_DST_RGB",i[i.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",i[i.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",i[i.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",i[i.BLEND_COLOR=32773]="BLEND_COLOR",i[i.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",i[i.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",i[i.LINE_WIDTH=2849]="LINE_WIDTH",i[i.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",i[i.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",i[i.CULL_FACE_MODE=2885]="CULL_FACE_MODE",i[i.FRONT_FACE=2886]="FRONT_FACE",i[i.DEPTH_RANGE=2928]="DEPTH_RANGE",i[i.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",i[i.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",i[i.DEPTH_FUNC=2932]="DEPTH_FUNC",i[i.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",i[i.STENCIL_FUNC=2962]="STENCIL_FUNC",i[i.STENCIL_FAIL=2964]="STENCIL_FAIL",i[i.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",i[i.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",i[i.STENCIL_REF=2967]="STENCIL_REF",i[i.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",i[i.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",i[i.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",i[i.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",i[i.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",i[i.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",i[i.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",i[i.VIEWPORT=2978]="VIEWPORT",i[i.SCISSOR_BOX=3088]="SCISSOR_BOX",i[i.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",i[i.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",i[i.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",i[i.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",i[i.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",i[i.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",i[i.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",i[i.RED_BITS=3410]="RED_BITS",i[i.GREEN_BITS=3411]="GREEN_BITS",i[i.BLUE_BITS=3412]="BLUE_BITS",i[i.ALPHA_BITS=3413]="ALPHA_BITS",i[i.DEPTH_BITS=3414]="DEPTH_BITS",i[i.STENCIL_BITS=3415]="STENCIL_BITS",i[i.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",i[i.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",i[i.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",i[i.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",i[i.SAMPLES=32937]="SAMPLES",i[i.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",i[i.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",i[i.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",i[i.VENDOR=7936]="VENDOR",i[i.RENDERER=7937]="RENDERER",i[i.VERSION=7938]="VERSION",i[i.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",i[i.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",i[i.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",i[i.STATIC_DRAW=35044]="STATIC_DRAW",i[i.STREAM_DRAW=35040]="STREAM_DRAW",i[i.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.BUFFER_SIZE=34660]="BUFFER_SIZE",i[i.BUFFER_USAGE=34661]="BUFFER_USAGE",i[i.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",i[i.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",i[i.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",i[i.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",i[i.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",i[i.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",i[i.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",i[i.CULL_FACE=2884]="CULL_FACE",i[i.FRONT=1028]="FRONT",i[i.BACK=1029]="BACK",i[i.FRONT_AND_BACK=1032]="FRONT_AND_BACK",i[i.BLEND=3042]="BLEND",i[i.DEPTH_TEST=2929]="DEPTH_TEST",i[i.DITHER=3024]="DITHER",i[i.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",i[i.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",i[i.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",i[i.SCISSOR_TEST=3089]="SCISSOR_TEST",i[i.STENCIL_TEST=2960]="STENCIL_TEST",i[i.NO_ERROR=0]="NO_ERROR",i[i.INVALID_ENUM=1280]="INVALID_ENUM",i[i.INVALID_VALUE=1281]="INVALID_VALUE",i[i.INVALID_OPERATION=1282]="INVALID_OPERATION",i[i.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",i[i.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",i[i.CW=2304]="CW",i[i.CCW=2305]="CCW",i[i.DONT_CARE=4352]="DONT_CARE",i[i.FASTEST=4353]="FASTEST",i[i.NICEST=4354]="NICEST",i[i.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",i[i.BYTE=5120]="BYTE",i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.SHORT=5122]="SHORT",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.INT=5124]="INT",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.FLOAT=5126]="FLOAT",i[i.DOUBLE=5130]="DOUBLE",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.ALPHA=6406]="ALPHA",i[i.RGB=6407]="RGB",i[i.RGBA=6408]="RGBA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",i[i.VERTEX_SHADER=35633]="VERTEX_SHADER",i[i.COMPILE_STATUS=35713]="COMPILE_STATUS",i[i.DELETE_STATUS=35712]="DELETE_STATUS",i[i.LINK_STATUS=35714]="LINK_STATUS",i[i.VALIDATE_STATUS=35715]="VALIDATE_STATUS",i[i.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",i[i.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",i[i.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",i[i.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",i[i.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",i[i.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",i[i.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",i[i.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",i[i.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",i[i.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",i[i.SHADER_TYPE=35663]="SHADER_TYPE",i[i.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",i[i.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",i[i.NEVER=512]="NEVER",i[i.LESS=513]="LESS",i[i.EQUAL=514]="EQUAL",i[i.LEQUAL=515]="LEQUAL",i[i.GREATER=516]="GREATER",i[i.NOTEQUAL=517]="NOTEQUAL",i[i.GEQUAL=518]="GEQUAL",i[i.ALWAYS=519]="ALWAYS",i[i.KEEP=7680]="KEEP",i[i.REPLACE=7681]="REPLACE",i[i.INCR=7682]="INCR",i[i.DECR=7683]="DECR",i[i.INVERT=5386]="INVERT",i[i.INCR_WRAP=34055]="INCR_WRAP",i[i.DECR_WRAP=34056]="DECR_WRAP",i[i.NEAREST=9728]="NEAREST",i[i.LINEAR=9729]="LINEAR",i[i.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",i[i.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",i[i.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",i[i.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",i[i.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",i[i.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",i[i.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",i[i.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE=5890]="TEXTURE",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i[i.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",i[i.TEXTURE0=33984]="TEXTURE0",i[i.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",i[i.REPEAT=10497]="REPEAT",i[i.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i[i.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",i[i.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",i[i.FLOAT_VEC2=35664]="FLOAT_VEC2",i[i.FLOAT_VEC3=35665]="FLOAT_VEC3",i[i.FLOAT_VEC4=35666]="FLOAT_VEC4",i[i.INT_VEC2=35667]="INT_VEC2",i[i.INT_VEC3=35668]="INT_VEC3",i[i.INT_VEC4=35669]="INT_VEC4",i[i.BOOL=35670]="BOOL",i[i.BOOL_VEC2=35671]="BOOL_VEC2",i[i.BOOL_VEC3=35672]="BOOL_VEC3",i[i.BOOL_VEC4=35673]="BOOL_VEC4",i[i.FLOAT_MAT2=35674]="FLOAT_MAT2",i[i.FLOAT_MAT3=35675]="FLOAT_MAT3",i[i.FLOAT_MAT4=35676]="FLOAT_MAT4",i[i.SAMPLER_2D=35678]="SAMPLER_2D",i[i.SAMPLER_CUBE=35680]="SAMPLER_CUBE",i[i.LOW_FLOAT=36336]="LOW_FLOAT",i[i.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",i[i.HIGH_FLOAT=36338]="HIGH_FLOAT",i[i.LOW_INT=36339]="LOW_INT",i[i.MEDIUM_INT=36340]="MEDIUM_INT",i[i.HIGH_INT=36341]="HIGH_INT",i[i.FRAMEBUFFER=36160]="FRAMEBUFFER",i[i.RENDERBUFFER=36161]="RENDERBUFFER",i[i.RGBA4=32854]="RGBA4",i[i.RGB5_A1=32855]="RGB5_A1",i[i.RGB565=36194]="RGB565",i[i.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",i[i.STENCIL_INDEX=6401]="STENCIL_INDEX",i[i.STENCIL_INDEX8=36168]="STENCIL_INDEX8",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i[i.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",i[i.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",i[i.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",i[i.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",i[i.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",i[i.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",i[i.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",i[i.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",i[i.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",i[i.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",i[i.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",i[i.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",i[i.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",i[i.NONE=0]="NONE",i[i.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",i[i.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",i[i.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",i[i.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",i[i.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",i[i.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",i[i.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",i[i.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",i[i.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",i[i.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",i[i.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",i[i.READ_BUFFER=3074]="READ_BUFFER",i[i.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",i[i.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",i[i.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",i[i.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",i[i.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",i[i.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",i[i.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",i[i.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",i[i.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",i[i.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",i[i.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",i[i.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",i[i.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",i[i.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",i[i.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",i[i.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",i[i.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",i[i.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",i[i.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",i[i.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",i[i.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",i[i.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",i[i.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",i[i.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",i[i.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",i[i.RED=6403]="RED",i[i.RGB8=32849]="RGB8",i[i.RGBA8=32856]="RGBA8",i[i.RGB10_A2=32857]="RGB10_A2",i[i.TEXTURE_3D=32879]="TEXTURE_3D",i[i.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",i[i.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",i[i.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",i[i.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",i[i.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",i[i.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",i[i.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",i[i.SRGB=35904]="SRGB",i[i.SRGB8=35905]="SRGB8",i[i.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",i[i.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",i[i.RGBA32F=34836]="RGBA32F",i[i.RGB32F=34837]="RGB32F",i[i.RGBA16F=34842]="RGBA16F",i[i.RGB16F=34843]="RGB16F",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",i[i.R11F_G11F_B10F=35898]="R11F_G11F_B10F",i[i.RGB9_E5=35901]="RGB9_E5",i[i.RGBA32UI=36208]="RGBA32UI",i[i.RGB32UI=36209]="RGB32UI",i[i.RGBA16UI=36214]="RGBA16UI",i[i.RGB16UI=36215]="RGB16UI",i[i.RGBA8UI=36220]="RGBA8UI",i[i.RGB8UI=36221]="RGB8UI",i[i.RGBA32I=36226]="RGBA32I",i[i.RGB32I=36227]="RGB32I",i[i.RGBA16I=36232]="RGBA16I",i[i.RGB16I=36233]="RGB16I",i[i.RGBA8I=36238]="RGBA8I",i[i.RGB8I=36239]="RGB8I",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.R8=33321]="R8",i[i.RG8=33323]="RG8",i[i.R16F=33325]="R16F",i[i.R32F=33326]="R32F",i[i.RG16F=33327]="RG16F",i[i.RG32F=33328]="RG32F",i[i.R8I=33329]="R8I",i[i.R8UI=33330]="R8UI",i[i.R16I=33331]="R16I",i[i.R16UI=33332]="R16UI",i[i.R32I=33333]="R32I",i[i.R32UI=33334]="R32UI",i[i.RG8I=33335]="RG8I",i[i.RG8UI=33336]="RG8UI",i[i.RG16I=33337]="RG16I",i[i.RG16UI=33338]="RG16UI",i[i.RG32I=33339]="RG32I",i[i.RG32UI=33340]="RG32UI",i[i.R8_SNORM=36756]="R8_SNORM",i[i.RG8_SNORM=36757]="RG8_SNORM",i[i.RGB8_SNORM=36758]="RGB8_SNORM",i[i.RGBA8_SNORM=36759]="RGBA8_SNORM",i[i.RGB10_A2UI=36975]="RGB10_A2UI",i[i.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",i[i.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.HALF_FLOAT=5131]="HALF_FLOAT",i[i.RG=33319]="RG",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",i[i.CURRENT_QUERY=34917]="CURRENT_QUERY",i[i.QUERY_RESULT=34918]="QUERY_RESULT",i[i.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",i[i.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",i[i.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",i[i.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",i[i.DRAW_BUFFER0=34853]="DRAW_BUFFER0",i[i.DRAW_BUFFER1=34854]="DRAW_BUFFER1",i[i.DRAW_BUFFER2=34855]="DRAW_BUFFER2",i[i.DRAW_BUFFER3=34856]="DRAW_BUFFER3",i[i.DRAW_BUFFER4=34857]="DRAW_BUFFER4",i[i.DRAW_BUFFER5=34858]="DRAW_BUFFER5",i[i.DRAW_BUFFER6=34859]="DRAW_BUFFER6",i[i.DRAW_BUFFER7=34860]="DRAW_BUFFER7",i[i.DRAW_BUFFER8=34861]="DRAW_BUFFER8",i[i.DRAW_BUFFER9=34862]="DRAW_BUFFER9",i[i.DRAW_BUFFER10=34863]="DRAW_BUFFER10",i[i.DRAW_BUFFER11=34864]="DRAW_BUFFER11",i[i.DRAW_BUFFER12=34865]="DRAW_BUFFER12",i[i.DRAW_BUFFER13=34866]="DRAW_BUFFER13",i[i.DRAW_BUFFER14=34867]="DRAW_BUFFER14",i[i.DRAW_BUFFER15=34868]="DRAW_BUFFER15",i[i.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",i[i.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",i[i.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",i[i.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",i[i.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",i[i.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",i[i.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",i[i.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",i[i.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",i[i.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",i[i.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",i[i.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",i[i.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",i[i.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",i[i.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",i[i.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",i[i.SAMPLER_3D=35679]="SAMPLER_3D",i[i.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",i[i.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",i[i.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",i[i.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",i[i.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",i[i.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",i[i.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",i[i.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",i[i.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",i[i.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",i[i.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",i[i.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",i[i.MAX_SAMPLES=36183]="MAX_SAMPLES",i[i.SAMPLER_BINDING=35097]="SAMPLER_BINDING",i[i.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",i[i.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",i[i.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",i[i.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",i[i.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",i[i.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",i[i.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",i[i.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",i[i.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",i[i.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",i[i.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",i[i.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",i[i.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",i[i.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",i[i.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",i[i.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",i[i.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",i[i.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",i[i.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",i[i.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",i[i.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",i[i.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",i[i.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",i[i.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",i[i.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",i[i.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",i[i.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",i[i.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",i[i.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",i[i.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",i[i.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",i[i.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",i[i.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",i[i.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",i[i.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",i[i.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",i[i.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",i[i.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",i[i.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",i[i.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",i[i.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i[i.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",i[i.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",i[i.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",i[i.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",i[i.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",i[i.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",i[i.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",i[i.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",i[i.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",i[i.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",i[i.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",i[i.UNIFORM_TYPE=35383]="UNIFORM_TYPE",i[i.UNIFORM_SIZE=35384]="UNIFORM_SIZE",i[i.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",i[i.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",i[i.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",i[i.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",i[i.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",i[i.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",i[i.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",i[i.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",i[i.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",i[i.OBJECT_TYPE=37138]="OBJECT_TYPE",i[i.SYNC_CONDITION=37139]="SYNC_CONDITION",i[i.SYNC_STATUS=37140]="SYNC_STATUS",i[i.SYNC_FLAGS=37141]="SYNC_FLAGS",i[i.SYNC_FENCE=37142]="SYNC_FENCE",i[i.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",i[i.UNSIGNALED=37144]="UNSIGNALED",i[i.SIGNALED=37145]="SIGNALED",i[i.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",i[i.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",i[i.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",i[i.WAIT_FAILED=37149]="WAIT_FAILED",i[i.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",i[i.COLOR=6144]="COLOR",i[i.DEPTH=6145]="DEPTH",i[i.STENCIL=6146]="STENCIL",i[i.MIN=32775]="MIN",i[i.MAX=32776]="MAX",i[i.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",i[i.STREAM_READ=35041]="STREAM_READ",i[i.STREAM_COPY=35042]="STREAM_COPY",i[i.STATIC_READ=35045]="STATIC_READ",i[i.STATIC_COPY=35046]="STATIC_COPY",i[i.DYNAMIC_READ=35049]="DYNAMIC_READ",i[i.DYNAMIC_COPY=35050]="DYNAMIC_COPY",i[i.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",i[i.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",i[i.INVALID_INDEX=4294967295]="INVALID_INDEX",i[i.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",i[i.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",i[i.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",i[i.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",i[i.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",i[i.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",i[i.R16_EXT=33322]="R16_EXT",i[i.RG16_EXT=33324]="RG16_EXT",i[i.RGB16_EXT=32852]="RGB16_EXT",i[i.RGBA16_EXT=32859]="RGBA16_EXT",i[i.R16_SNORM_EXT=36760]="R16_SNORM_EXT",i[i.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",i[i.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",i[i.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",i[i.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",i[i.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",i[i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",i[i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",i[i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",i[i.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",i[i.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",i[i.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",i[i.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",i[i.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",i[i.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",i[i.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",i[i.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",i[i.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",i[i.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",i[i.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",i[i.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",i[i.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",i[i.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",i[i.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",i[i.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",i[i.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",i[i.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",i[i.LINE_WEBGL=6913]="LINE_WEBGL",i[i.FILL_WEBGL=6914]="FILL_WEBGL",i[i.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",i[i.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",i[i.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",i[i.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",i[i.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",i[i.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",i[i.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",i[i.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",i[i.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",i[i.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",i[i.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",i[i.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",i[i.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",i[i.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",i[i.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",i[i.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",i[i.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",i[i.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",i[i.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",i[i.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",i[i.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",i[i.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",i[i.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",i[i.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Oo||(Oo={}));const tD={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},iD=i=>({drawBuffersWEBGL(e){return i.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),nD=i=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return i.createVertexArray()},deleteVertexArrayOES(e){return i.deleteVertexArray(e)},isVertexArrayOES(e){return i.isVertexArray(e)},bindVertexArrayOES(e){return i.bindVertexArray(e)}}),sD=i=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return i.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return i.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return i.vertexAttribDivisor(...e)}});function rD(i=!0){const e=HTMLCanvasElement.prototype;if(!i&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,n){if(t==="webgl"||t==="experimental-webgl"){const s=this.originalGetContext("webgl2",n);return s instanceof HTMLElement&&oD(s),s}return this.originalGetContext(t,n)}}function oD(i){i.getExtension("EXT_color_buffer_float");const e={...tD,WEBGL_disjoint_timer_query:i.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:iD(i),OES_vertex_array_object:nD(i),ANGLE_instanced_arrays:sD(i)},t=i.getExtension;i.getExtension=function(s){return t.call(i,s)||(s in e?e[s]:null)};const n=i.getSupportedExtensions;i.getSupportedExtensions=function(){const s=n.apply(i)||[];return s==null?void 0:s.concat(Object.keys(e))}}async function L2(i,e){const t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");const n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",i),new Promise((s,r)=>{n.onload=s,n.onerror=o=>r(new Error(`Unable to load script '${i}': ${o}`)),t.appendChild(n)})}const aD=1;let fi=null,J0=!1;const _y={debugSpectorJS:le.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function lD(i){if(!globalThis.SPECTOR)try{await L2(i.debugSpectorJSUrl||_y.debugSpectorJSUrl)}catch(e){le.warn(String(e))}}function Ote(i){var e;if(i={..._y,...i},!i.debugSpectorJS)return null;if(!fi&&globalThis.SPECTOR&&!((e=globalThis.luma)!=null&&e.spector)){le.probe(aD,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:t}=globalThis.SPECTOR;fi=new t,globalThis.luma&&(globalThis.luma.spector=fi)}if(!fi)return null;if(J0||(J0=!0,fi.spyCanvases(),fi==null||fi.onCaptureStarted.add(t=>le.info("Spector capture started:",t)()),fi==null||fi.onCapture.add(t=>{le.info("Spector capture complete:",t)(),fi==null||fi.getResultUI(),fi==null||fi.resultView.display(),fi==null||fi.resultView.addCapture(t)})),i.gl){const t=i.gl,n=t.device;fi==null||fi.startCapture(i.gl,500),t.device=n,new Promise(s=>setTimeout(s,2e3)).then(s=>{le.info("Spector capture stopped after 2 seconds")(),fi==null||fi.stopCapture()})}return fi}const cD="https://unpkg.com/webgl-debug@2.0.1/index.js";function R2(i){return i.luma=i.luma||{},i.luma}async function uD(){Vu()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await L2(cD))}function Bte(i,e={}){return e.debugWebGL||e.traceWebGL?hD(i,e):dD(i)}function dD(i){const e=R2(i);return e.realContext?e.realContext:i}function hD(i,e){if(!globalThis.WebGLDebugUtils)return le.warn("webgl-debug not loaded")(),i;const t=R2(i);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...Oo,...i});const n=globalThis.WebGLDebugUtils.makeDebugContext(i,fD.bind(null,e),pD.bind(null,e));for(const o in Oo)!(o in n)&&typeof Oo[o]=="number"&&(n[o]=Oo[o]);class s{}Object.setPrototypeOf(n,Object.getPrototypeOf(i)),Object.setPrototypeOf(s,n);const r=Object.create(s);return t.realContext=i,t.debugContext=r,r.debug=!0,r}function ex(i,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(i,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${i}(${t})`}function fD(i,e,t,n){n=Array.from(n).map(a=>a===void 0?"undefined":a);const s=globalThis.WebGLDebugUtils.glEnumToString(e),r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,n),o=`${s} in gl.${t}(${r})`;le.error(o)();debugger}function pD(i,e,t){let n="";le.level>=1&&(n=ex(e,t),i.traceWebGL&&le.log(1,n)());for(const s of t)if(s===void 0){n=n||ex(e,t);debugger}}const Sd=1;class mD extends CN{constructor(){super(),$(this,"type","webgl"),Cg.defaultProps={...Cg.defaultProps,..._y}}enforceWebGL2(e){rD(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&le.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){const{WebGLDevice:n}=await m0(async()=>{const{WebGLDevice:r}=await import("./webgl-device-QoBMYpnS-Crxmw1Do.js");return{WebGLDevice:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]));if(e instanceof n)return e;if((e==null?void 0:e.device)instanceof n)return e.device;if(!gD(e))throw new Error("Invalid WebGL2RenderingContext");const s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){const{WebGLDevice:t}=await m0(async()=>{const{WebGLDevice:n}=await import("./webgl-device-QoBMYpnS-Crxmw1Do.js");return{WebGLDevice:n}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]));le.groupCollapsed(Sd,"WebGLDevice created")();try{const n=[];(e.debugWebGL||e.debug)&&n.push(uD()),e.debugSpectorJS&&n.push(lD(e));const s=await Promise.allSettled(n);for(const a of s)a.status==="rejected"&&le.error(`Failed to initialize debug libraries ${a.reason}`)();const r=new t(e),o=`${r._reused?"Reusing":"Created"} device with WebGL2 ${r.props.debug?"debug ":""}context: ${r.info.vendor}, ${r.info.renderer} for canvas: ${r.canvasContext.id}`;return le.probe(Sd,o)(),le.table(Sd,r.info)(),r}finally{le.groupEnd(Sd)()}}}function gD(i){return typeof WebGL2RenderingContext<"u"&&i instanceof WebGL2RenderingContext?!0:!!(i&&Number.isFinite(i._version))}const _D=new mD,yD="#b3b3b3",bD=void 0,Ag=void 0,vD=1,xD=4,wD="#666666",SD=.1,ED=1,CD=1,P2="#222222",fe={enableSimulation:!0,spaceSize:8192,pointSizeScale:1,linkWidthScale:1,linkArrowsSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,linkArrows:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",hoveredLinkCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",hoveredLinkColor:void 0,hoveredLinkWidthIncrease:5,focusedPointRingColor:"white",focusedPointIndex:void 0,simulation:{decay:5e3,gravity:.25,center:0,repulsion:1,repulsionTheta:1.15,linkSpring:1,linkDistance:10,linkDistRandomVariationRange:[1,1.2],repulsionFromMouse:2,friction:.85,cluster:.1},showFPSMonitor:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||2,scalePointsOnZoom:!1,scaleLinksOnZoom:!1,enableZoom:!0,enableSimulationDuringZoom:!1,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,pointSamplingDistance:150,attribution:"",rescalePositions:void 0,enableRightClickRepulsion:!1},TD=.7,kD=.95,AD=3;/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:N2,setPrototypeOf:tx,isFrozen:ID,getPrototypeOf:LD,getOwnPropertyDescriptor:RD}=Object;let{freeze:fn,seal:gs,create:D2}=Object,{apply:Ig,construct:Lg}=typeof Reflect<"u"&&Reflect;fn||(fn=function(i){return i});gs||(gs=function(i){return i});Ig||(Ig=function(i,e,t){return i.apply(e,t)});Lg||(Lg=function(i,e){return new i(...e)});const Ed=pn(Array.prototype.forEach),PD=pn(Array.prototype.lastIndexOf),ix=pn(Array.prototype.pop),lc=pn(Array.prototype.push),ND=pn(Array.prototype.splice),hh=pn(String.prototype.toLowerCase),nm=pn(String.prototype.toString),nx=pn(String.prototype.match),cc=pn(String.prototype.replace),DD=pn(String.prototype.indexOf),MD=pn(String.prototype.trim),Ms=pn(Object.prototype.hasOwnProperty),rn=pn(RegExp.prototype.test),uc=OD(TypeError);function pn(i){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s2&&arguments[2]!==void 0?arguments[2]:hh;tx&&tx(i,null);let n=e.length;for(;n--;){let s=e[n];if(typeof s=="string"){const r=t(s);r!==s&&(ID(e)||(e[n]=r),s=r)}i[s]=!0}return i}function BD(i){for(let e=0;e/gm),jD=gs(/\$\{[\w\W]*/gm),HD=gs(/^data-[\-\w.\u00B7-\uFFFF]+$/),VD=gs(/^aria-[\-\w]+$/),M2=gs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),GD=gs(/^(?:\w+script|data):/i),WD=gs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),O2=gs(/^html$/i),YD=gs(/^[a-z][.\w]*(-[.\w]+)+$/i);var lx=Object.freeze({__proto__:null,ARIA_ATTR:VD,ATTR_WHITESPACE:WD,CUSTOM_ELEMENT:YD,DATA_ATTR:HD,DOCTYPE_NAME:O2,ERB_EXPR:$D,IS_ALLOWED_URI:M2,IS_SCRIPT_OR_DATA:GD,MUSTACHE_EXPR:UD,TMPLIT_EXPR:jD});const hc={element:1,text:3,progressingInstruction:7,comment:8,document:9},qD=function(){return typeof window>"u"?null:window},XD=function(i,e){if(typeof i!="object"||typeof i.createPolicy!="function")return null;let t=null;const n="data-tt-policy-suffix";e&&e.hasAttribute(n)&&(t=e.getAttribute(n));const s="dompurify"+(t?"#"+t:"");try{return i.createPolicy(s,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},cx=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function B2(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qD();const e=L=>B2(L);if(e.version="3.2.6",e.removed=[],!i||!i.document||i.document.nodeType!==hc.document||!i.Element)return e.isSupported=!1,e;let{document:t}=i;const n=t,s=n.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:d,DOMParser:h,trustedTypes:p}=i,m=l.prototype,y=dc(m,"cloneNode"),g=dc(m,"remove"),_=dc(m,"nextSibling"),S=dc(m,"childNodes"),E=dc(m,"parentNode");if(typeof o=="function"){const L=t.createElement("template");L.content&&L.content.ownerDocument&&(t=L.content.ownerDocument)}let x,T="";const{implementation:I,createNodeIterator:B,createDocumentFragment:H,getElementsByTagName:Q}=t,{importNode:re}=n;let D=cx();e.isSupported=typeof N2=="function"&&typeof E=="function"&&I&&I.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:de,ERB_EXPR:se,TMPLIT_EXPR:R,DATA_ATTR:ee,ARIA_ATTR:F,IS_SCRIPT_OR_DATA:q,ATTR_WHITESPACE:te,CUSTOM_ELEMENT:Z}=lx;let{IS_ALLOWED_URI:ae}=lx,J=null;const Se=rt({},[...sx,...sm,...rm,...om,...rx]);let xe=null;const et=rt({},[...ox,...am,...ax,...Cd]);let he=Object.seal(D2(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),yt=null,Xe=null,dt=!0,ie=!0,Ce=!1,Pe=!0,X=!1,We=!0,He=!1,bt=!1,Vt=!1,pe=!1,it=!1,si=!1,yi=!0,Zs=!1;const Zn="user-content-";let wo=!0,On=!1,di={},tn=null;const bi=rt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Qn=null;const Ss=rt({},["audio","video","img","source","image","track"]);let Qs=null;const Bn=rt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Es="http://www.w3.org/1998/Math/MathML",nn="http://www.w3.org/2000/svg",Ti="http://www.w3.org/1999/xhtml";let Qt=Ti,$i=!1,vn=null;const So=rt({},[Es,nn,Ti],nm);let Mr=rt({},["mi","mo","mn","ms","mtext"]),ji=rt({},["annotation-xml"]);const Or=rt({},["title","style","font","a","script"]);let Cs=null;const Js=["application/xhtml+xml","text/html"],ic="text/html";let Jt=null,At=null;const Jn=t.createElement("form"),Ut=function(L){return L instanceof RegExp||L instanceof Function},Ts=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(At&&At===L)){if((!L||typeof L!="object")&&(L={}),L=Gr(L),Cs=Js.indexOf(L.PARSER_MEDIA_TYPE)===-1?ic:L.PARSER_MEDIA_TYPE,Jt=Cs==="application/xhtml+xml"?nm:hh,J=Ms(L,"ALLOWED_TAGS")?rt({},L.ALLOWED_TAGS,Jt):Se,xe=Ms(L,"ALLOWED_ATTR")?rt({},L.ALLOWED_ATTR,Jt):et,vn=Ms(L,"ALLOWED_NAMESPACES")?rt({},L.ALLOWED_NAMESPACES,nm):So,Qs=Ms(L,"ADD_URI_SAFE_ATTR")?rt(Gr(Bn),L.ADD_URI_SAFE_ATTR,Jt):Bn,Qn=Ms(L,"ADD_DATA_URI_TAGS")?rt(Gr(Ss),L.ADD_DATA_URI_TAGS,Jt):Ss,tn=Ms(L,"FORBID_CONTENTS")?rt({},L.FORBID_CONTENTS,Jt):bi,yt=Ms(L,"FORBID_TAGS")?rt({},L.FORBID_TAGS,Jt):Gr({}),Xe=Ms(L,"FORBID_ATTR")?rt({},L.FORBID_ATTR,Jt):Gr({}),di=Ms(L,"USE_PROFILES")?L.USE_PROFILES:!1,dt=L.ALLOW_ARIA_ATTR!==!1,ie=L.ALLOW_DATA_ATTR!==!1,Ce=L.ALLOW_UNKNOWN_PROTOCOLS||!1,Pe=L.ALLOW_SELF_CLOSE_IN_ATTR!==!1,X=L.SAFE_FOR_TEMPLATES||!1,We=L.SAFE_FOR_XML!==!1,He=L.WHOLE_DOCUMENT||!1,pe=L.RETURN_DOM||!1,it=L.RETURN_DOM_FRAGMENT||!1,si=L.RETURN_TRUSTED_TYPE||!1,Vt=L.FORCE_BODY||!1,yi=L.SANITIZE_DOM!==!1,Zs=L.SANITIZE_NAMED_PROPS||!1,wo=L.KEEP_CONTENT!==!1,On=L.IN_PLACE||!1,ae=L.ALLOWED_URI_REGEXP||M2,Qt=L.NAMESPACE||Ti,Mr=L.MATHML_TEXT_INTEGRATION_POINTS||Mr,ji=L.HTML_INTEGRATION_POINTS||ji,he=L.CUSTOM_ELEMENT_HANDLING||{},L.CUSTOM_ELEMENT_HANDLING&&Ut(L.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(he.tagNameCheck=L.CUSTOM_ELEMENT_HANDLING.tagNameCheck),L.CUSTOM_ELEMENT_HANDLING&&Ut(L.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(he.attributeNameCheck=L.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),L.CUSTOM_ELEMENT_HANDLING&&typeof L.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(he.allowCustomizedBuiltInElements=L.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),X&&(ie=!1),it&&(pe=!0),di&&(J=rt({},rx),xe=[],di.html===!0&&(rt(J,sx),rt(xe,ox)),di.svg===!0&&(rt(J,sm),rt(xe,am),rt(xe,Cd)),di.svgFilters===!0&&(rt(J,rm),rt(xe,am),rt(xe,Cd)),di.mathMl===!0&&(rt(J,om),rt(xe,ax),rt(xe,Cd))),L.ADD_TAGS&&(J===Se&&(J=Gr(J)),rt(J,L.ADD_TAGS,Jt)),L.ADD_ATTR&&(xe===et&&(xe=Gr(xe)),rt(xe,L.ADD_ATTR,Jt)),L.ADD_URI_SAFE_ATTR&&rt(Qs,L.ADD_URI_SAFE_ATTR,Jt),L.FORBID_CONTENTS&&(tn===bi&&(tn=Gr(tn)),rt(tn,L.FORBID_CONTENTS,Jt)),wo&&(J["#text"]=!0),He&&rt(J,["html","head","body"]),J.table&&(rt(J,["tbody"]),delete yt.tbody),L.TRUSTED_TYPES_POLICY){if(typeof L.TRUSTED_TYPES_POLICY.createHTML!="function")throw uc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof L.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw uc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=L.TRUSTED_TYPES_POLICY,T=x.createHTML("")}else x===void 0&&(x=XD(p,s)),x!==null&&typeof T=="string"&&(T=x.createHTML(""));fn&&fn(L),At=L}},er=rt({},[...sm,...rm,...FD]),Br=rt({},[...om,...zD]),Eo=function(L){let V=E(L);(!V||!V.tagName)&&(V={namespaceURI:Qt,tagName:"template"});const C=hh(L.tagName),G=hh(V.tagName);return vn[L.namespaceURI]?L.namespaceURI===nn?V.namespaceURI===Ti?C==="svg":V.namespaceURI===Es?C==="svg"&&(G==="annotation-xml"||Mr[G]):!!er[C]:L.namespaceURI===Es?V.namespaceURI===Ti?C==="math":V.namespaceURI===nn?C==="math"&&ji[G]:!!Br[C]:L.namespaceURI===Ti?V.namespaceURI===nn&&!ji[G]||V.namespaceURI===Es&&!Mr[G]?!1:!Br[C]&&(Or[C]||!er[C]):!!(Cs==="application/xhtml+xml"&&vn[L.namespaceURI]):!1},es=function(L){lc(e.removed,{element:L});try{E(L).removeChild(L)}catch{g(L)}},hi=function(L,V){try{lc(e.removed,{attribute:V.getAttributeNode(L),from:V})}catch{lc(e.removed,{attribute:null,from:V})}if(V.removeAttribute(L),L==="is")if(pe||it)try{es(V)}catch{}else try{V.setAttribute(L,"")}catch{}},xn=function(L){let V=null,C=null;if(Vt)L=""+L;else{const Te=nx(L,/^[\r\n\t ]+/);C=Te&&Te[0]}Cs==="application/xhtml+xml"&&Qt===Ti&&(L=''+L+"");const G=x?x.createHTML(L):L;if(Qt===Ti)try{V=new h().parseFromString(G,Cs)}catch{}if(!V||!V.documentElement){V=I.createDocument(Qt,"template",null);try{V.documentElement.innerHTML=$i?T:G}catch{}}const ne=V.body||V.documentElement;return L&&C&&ne.insertBefore(t.createTextNode(C),ne.childNodes[0]||null),Qt===Ti?Q.call(V,He?"html":"body")[0]:He?V.documentElement:ne},ks=function(L){return B.call(L.ownerDocument||L,L,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ct=function(L){return L instanceof d&&(typeof L.nodeName!="string"||typeof L.textContent!="string"||typeof L.removeChild!="function"||!(L.attributes instanceof u)||typeof L.removeAttribute!="function"||typeof L.setAttribute!="function"||typeof L.namespaceURI!="string"||typeof L.insertBefore!="function"||typeof L.hasChildNodes!="function")},Fr=function(L){return typeof a=="function"&&L instanceof a};function nt(L,V,C){Ed(L,G=>{G.call(e,V,C,At)})}const wn=function(L){let V=null;if(nt(D.beforeSanitizeElements,L,null),ct(L))return es(L),!0;const C=Jt(L.nodeName);if(nt(D.uponSanitizeElement,L,{tagName:C,allowedTags:J}),We&&L.hasChildNodes()&&!Fr(L.firstElementChild)&&rn(/<[/\w!]/g,L.innerHTML)&&rn(/<[/\w!]/g,L.textContent)||L.nodeType===hc.progressingInstruction||We&&L.nodeType===hc.comment&&rn(/<[/\w]/g,L.data))return es(L),!0;if(!J[C]||yt[C]){if(!yt[C]&&tr(C)&&(he.tagNameCheck instanceof RegExp&&rn(he.tagNameCheck,C)||he.tagNameCheck instanceof Function&&he.tagNameCheck(C)))return!1;if(wo&&!tn[C]){const G=E(L)||L.parentNode,ne=S(L)||L.childNodes;if(ne&&G){const Te=ne.length;for(let It=Te-1;It>=0;--It){const st=y(ne[It],!0);st.__removalCount=(L.__removalCount||0)+1,G.insertBefore(st,_(L))}}}return es(L),!0}return L instanceof l&&!Eo(L)||(C==="noscript"||C==="noembed"||C==="noframes")&&rn(/<\/no(script|embed|frames)/i,L.innerHTML)?(es(L),!0):(X&&L.nodeType===hc.text&&(V=L.textContent,Ed([de,se,R],G=>{V=cc(V,G," ")}),L.textContent!==V&&(lc(e.removed,{element:L.cloneNode()}),L.textContent=V)),nt(D.afterSanitizeElements,L,null),!1)},zr=function(L,V,C){if(yi&&(V==="id"||V==="name")&&(C in t||C in Jn))return!1;if(!(ie&&!Xe[V]&&rn(ee,V))&&!(dt&&rn(F,V))){if(!xe[V]||Xe[V]){if(!(tr(L)&&(he.tagNameCheck instanceof RegExp&&rn(he.tagNameCheck,L)||he.tagNameCheck instanceof Function&&he.tagNameCheck(L))&&(he.attributeNameCheck instanceof RegExp&&rn(he.attributeNameCheck,V)||he.attributeNameCheck instanceof Function&&he.attributeNameCheck(V))||V==="is"&&he.allowCustomizedBuiltInElements&&(he.tagNameCheck instanceof RegExp&&rn(he.tagNameCheck,C)||he.tagNameCheck instanceof Function&&he.tagNameCheck(C))))return!1}else if(!Qs[V]&&!rn(ae,cc(C,te,""))&&!((V==="src"||V==="xlink:href"||V==="href")&&L!=="script"&&DD(C,"data:")===0&&Qn[L])&&!(Ce&&!rn(q,cc(C,te,"")))&&C)return!1}return!0},tr=function(L){return L!=="annotation-xml"&&nx(L,Z)},Fn=function(L){nt(D.beforeSanitizeAttributes,L,null);const{attributes:V}=L;if(!V||ct(L))return;const C={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe,forceKeepAttr:void 0};let G=V.length;for(;G--;){const ne=V[G],{name:Te,namespaceURI:It,value:st}=ne,Je=Jt(Te),vi=st;let ht=Te==="value"?vi:MD(vi);if(C.attrName=Je,C.attrValue=ht,C.keepAttr=!0,C.forceKeepAttr=void 0,nt(D.uponSanitizeAttribute,L,C),ht=C.attrValue,Zs&&(Je==="id"||Je==="name")&&(hi(Te,L),ht=Zn+ht),We&&rn(/((--!?|])>)|<\/(style|title)/i,ht)){hi(Te,L);continue}if(C.forceKeepAttr)continue;if(!C.keepAttr){hi(Te,L);continue}if(!Pe&&rn(/\/>/i,ht)){hi(Te,L);continue}X&&Ed([de,se,R],Lt=>{ht=cc(ht,Lt," ")});const ir=Jt(L.nodeName);if(!zr(ir,Je,ht)){hi(Te,L);continue}if(x&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!It)switch(p.getAttributeType(ir,Je)){case"TrustedHTML":{ht=x.createHTML(ht);break}case"TrustedScriptURL":{ht=x.createScriptURL(ht);break}}if(ht!==vi)try{It?L.setAttributeNS(It,Te,ht):L.setAttribute(Te,ht),ct(L)?es(L):ix(e.removed)}catch{hi(Te,L)}}nt(D.afterSanitizeAttributes,L,null)},sn=function L(V){let C=null;const G=ks(V);for(nt(D.beforeSanitizeShadowDOM,V,null);C=G.nextNode();)nt(D.uponSanitizeShadowNode,C,null),wn(C),Fn(C),C.content instanceof r&&L(C.content);nt(D.afterSanitizeShadowDOM,V,null)};return e.sanitize=function(L){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,G=null,ne=null,Te=null;if($i=!L,$i&&(L=""),typeof L!="string"&&!Fr(L))if(typeof L.toString=="function"){if(L=L.toString(),typeof L!="string")throw uc("dirty is not a string, aborting")}else throw uc("toString is not a function");if(!e.isSupported)return L;if(bt||Ts(V),e.removed=[],typeof L=="string"&&(On=!1),On){if(L.nodeName){const Je=Jt(L.nodeName);if(!J[Je]||yt[Je])throw uc("root node is forbidden and cannot be sanitized in-place")}}else if(L instanceof a)C=xn(""),G=C.ownerDocument.importNode(L,!0),G.nodeType===hc.element&&G.nodeName==="BODY"||G.nodeName==="HTML"?C=G:C.appendChild(G);else{if(!pe&&!X&&!He&&L.indexOf("<")===-1)return x&&si?x.createHTML(L):L;if(C=xn(L),!C)return pe?null:si?T:""}C&&Vt&&es(C.firstChild);const It=ks(On?L:C);for(;ne=It.nextNode();)wn(ne),Fn(ne),ne.content instanceof r&&sn(ne.content);if(On)return L;if(pe){if(it)for(Te=H.call(C.ownerDocument);C.firstChild;)Te.appendChild(C.firstChild);else Te=C;return(xe.shadowroot||xe.shadowrootmode)&&(Te=re.call(n,Te,!0)),Te}let st=He?C.outerHTML:C.innerHTML;return He&&J["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&rn(O2,C.ownerDocument.doctype.name)&&(st=" +`,l.style.top="10px",l.style.left="10px",l.style.position="absolute",l.style.zIndex="9999",l.style.width="100%",l.style.textAlign="left",document.body.appendChild(l),(n=document.getElementsByClassName("luma-compiler-log-error")[0])==null||n.scrollIntoView(),l.onclick=()=>{const c=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(c)}}};$(w2,"defaultProps",{...yn.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let MN=w2;function ON(i){return BN(i.source)||i.id||fy(`unnamed ${i.stage}-shader`)}function BN(i,e="unnamed"){const t=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(i);return t?t[1]:e}const E2=class C2 extends yn{constructor(e,t){super(e,t,C2.defaultProps),$(this,"shaderLayout"),$(this,"bufferLayout"),$(this,"linkStatus","pending"),$(this,"hash",""),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}get[Symbol.toStringTag](){return"RenderPipeline"}};$(E2,"defaultProps",{...yn.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}});let Zh=E2;const T2=class k2 extends yn{constructor(e,t){super(e,t,k2.defaultProps),$(this,"hash",""),$(this,"shaderLayout"),this.shaderLayout=t.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};$(T2,"defaultProps",{...yn.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let Q0=T2;function FN(i){return jN[i]}function zN(i){const[e,t]=$N[i],n=e==="i32"||e==="u32",s=e!=="u32",r=UN[e]*t;return{primitiveType:e,components:t,byteLength:r,integer:n,signed:s}}const UN={f32:4,f16:2,i32:4,u32:4},$N={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},jN={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}};function A2(i,e){const t={};for(const n of i.attributes){const s=HN(i,e,n.name);s&&(t[n.name]=s)}return t}function Nte(i,e,t=16){const n=A2(i,e),s=new Array(t).fill(null);for(const r of Object.values(n))s[r.location]=r;return s}function HN(i,e,t){const n=VN(i,t),s=GN(e,t);if(!n)return null;const r=zN(n.type),o=cN(r),a=(s==null?void 0:s.vertexFormat)||o,l=my(a);return{attributeName:(s==null?void 0:s.attributeName)||n.name,bufferName:(s==null?void 0:s.bufferName)||n.name,location:n.location,shaderType:n.type,primitiveType:r.primitiveType,shaderComponents:r.components,vertexFormat:a,bufferDataType:l.type,bufferComponents:l.components,normalized:l.normalized,integer:r.integer,stepMode:(s==null?void 0:s.stepMode)||n.stepMode||"vertex",byteOffset:(s==null?void 0:s.byteOffset)||0,byteStride:(s==null?void 0:s.byteStride)||0}}function VN(i,e){const t=i.attributes.find(n=>n.name===e);return t||le.warn(`shader layout attribute "${e}" not present in shader`),t||null}function GN(i,e){WN(i);let t=YN(i,e);return t||(t=qN(i,e),t)?t:(le.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function WN(i){for(const e of i)(e.attributes&&e.format||!e.attributes&&!e.format)&&le.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function YN(i,e){for(const t of i)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function qN(i,e){var t;for(const n of i){let s=n.byteStride;if(typeof n.byteStride!="number")for(const o of n.attributes||[]){const a=my(o.format);s+=a.byteLength}const r=(t=n.attributes)==null?void 0:t.find(o=>o.attribute===e);if(r)return{attributeName:r.attribute,bufferName:n.name,stepMode:n.stepMode,vertexFormat:r.format,byteOffset:r.byteOffset,byteStride:s}}return null}let wd;function I2(i){return(!wd||wd.byteLengthr.type==="uniform"&&r.name===(e==null?void 0:e.name));if(!n)throw new Error(e==null?void 0:e.name);const s=n;for(const r of s.uniforms||[])this.bindingLayout[r.name]=r}}setUniforms(e){for(const[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){QN(this.uniforms[e],t)||(this.uniforms[e]=JN(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}let ai=class{constructor(e){$(this,"uniformBlocks",new Map),$(this,"uniformBufferLayouts",new Map),$(this,"uniformBuffers",new Map);for(const[t,n]of Object.entries(e)){const s=t,r=new ZN(n.uniformTypes??{},n.uniformSizes??{});this.uniformBufferLayouts.set(s,r);const o=new eD({name:t});o.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(s,o)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){var t;for(const[n,s]of Object.entries(e))(t=this.uniformBlocks.get(n))==null||t.setUniforms(s);this.updateUniformBuffers()}getUniformBufferByteLength(e){var t;return((t=this.uniformBufferLayouts.get(e))==null?void 0:t.byteLength)||0}getUniformBufferData(e){var t,n;const s=((t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms())||{};return(n=this.uniformBufferLayouts.get(e))==null?void 0:n.getData(s)}createUniformBuffer(e,t,n){n&&this.setUniforms(n);const s=this.getUniformBufferByteLength(t),r=e.createBuffer({usage:me.UNIFORM|me.COPY_DST,byteLength:s}),o=this.getUniformBufferData(t);return r.write(o),r}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){const n=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:me.UNIFORM|me.COPY_DST,byteLength:n});this.uniformBuffers.set(t,s)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const n=this.updateUniformBuffer(t);e||(e=n)}return e&&le.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){var t;const n=this.uniformBlocks.get(e);let s=this.uniformBuffers.get(e),r=!1;if(s&&n!=null&&n.needsRedraw){r||(r=n.needsRedraw);const o=this.getUniformBufferData(e);s=this.uniformBuffers.get(e),s==null||s.write(o);const a=(t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms();le.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}return r}};var Oo;(function(i){i[i.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",i[i.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",i[i.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i[i.ZERO=0]="ZERO",i[i.ONE=1]="ONE",i[i.SRC_COLOR=768]="SRC_COLOR",i[i.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",i[i.SRC_ALPHA=770]="SRC_ALPHA",i[i.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",i[i.DST_ALPHA=772]="DST_ALPHA",i[i.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",i[i.DST_COLOR=774]="DST_COLOR",i[i.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",i[i.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",i[i.CONSTANT_COLOR=32769]="CONSTANT_COLOR",i[i.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",i[i.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",i[i.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",i[i.FUNC_ADD=32774]="FUNC_ADD",i[i.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",i[i.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",i[i.BLEND_EQUATION=32777]="BLEND_EQUATION",i[i.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",i[i.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",i[i.BLEND_DST_RGB=32968]="BLEND_DST_RGB",i[i.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",i[i.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",i[i.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",i[i.BLEND_COLOR=32773]="BLEND_COLOR",i[i.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",i[i.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",i[i.LINE_WIDTH=2849]="LINE_WIDTH",i[i.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",i[i.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",i[i.CULL_FACE_MODE=2885]="CULL_FACE_MODE",i[i.FRONT_FACE=2886]="FRONT_FACE",i[i.DEPTH_RANGE=2928]="DEPTH_RANGE",i[i.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",i[i.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",i[i.DEPTH_FUNC=2932]="DEPTH_FUNC",i[i.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",i[i.STENCIL_FUNC=2962]="STENCIL_FUNC",i[i.STENCIL_FAIL=2964]="STENCIL_FAIL",i[i.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",i[i.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",i[i.STENCIL_REF=2967]="STENCIL_REF",i[i.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",i[i.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",i[i.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",i[i.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",i[i.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",i[i.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",i[i.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",i[i.VIEWPORT=2978]="VIEWPORT",i[i.SCISSOR_BOX=3088]="SCISSOR_BOX",i[i.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",i[i.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",i[i.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",i[i.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",i[i.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",i[i.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",i[i.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",i[i.RED_BITS=3410]="RED_BITS",i[i.GREEN_BITS=3411]="GREEN_BITS",i[i.BLUE_BITS=3412]="BLUE_BITS",i[i.ALPHA_BITS=3413]="ALPHA_BITS",i[i.DEPTH_BITS=3414]="DEPTH_BITS",i[i.STENCIL_BITS=3415]="STENCIL_BITS",i[i.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",i[i.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",i[i.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",i[i.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",i[i.SAMPLES=32937]="SAMPLES",i[i.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",i[i.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",i[i.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",i[i.VENDOR=7936]="VENDOR",i[i.RENDERER=7937]="RENDERER",i[i.VERSION=7938]="VERSION",i[i.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",i[i.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",i[i.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",i[i.STATIC_DRAW=35044]="STATIC_DRAW",i[i.STREAM_DRAW=35040]="STREAM_DRAW",i[i.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.BUFFER_SIZE=34660]="BUFFER_SIZE",i[i.BUFFER_USAGE=34661]="BUFFER_USAGE",i[i.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",i[i.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",i[i.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",i[i.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",i[i.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",i[i.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",i[i.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",i[i.CULL_FACE=2884]="CULL_FACE",i[i.FRONT=1028]="FRONT",i[i.BACK=1029]="BACK",i[i.FRONT_AND_BACK=1032]="FRONT_AND_BACK",i[i.BLEND=3042]="BLEND",i[i.DEPTH_TEST=2929]="DEPTH_TEST",i[i.DITHER=3024]="DITHER",i[i.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",i[i.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",i[i.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",i[i.SCISSOR_TEST=3089]="SCISSOR_TEST",i[i.STENCIL_TEST=2960]="STENCIL_TEST",i[i.NO_ERROR=0]="NO_ERROR",i[i.INVALID_ENUM=1280]="INVALID_ENUM",i[i.INVALID_VALUE=1281]="INVALID_VALUE",i[i.INVALID_OPERATION=1282]="INVALID_OPERATION",i[i.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",i[i.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",i[i.CW=2304]="CW",i[i.CCW=2305]="CCW",i[i.DONT_CARE=4352]="DONT_CARE",i[i.FASTEST=4353]="FASTEST",i[i.NICEST=4354]="NICEST",i[i.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",i[i.BYTE=5120]="BYTE",i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.SHORT=5122]="SHORT",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.INT=5124]="INT",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.FLOAT=5126]="FLOAT",i[i.DOUBLE=5130]="DOUBLE",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.ALPHA=6406]="ALPHA",i[i.RGB=6407]="RGB",i[i.RGBA=6408]="RGBA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",i[i.VERTEX_SHADER=35633]="VERTEX_SHADER",i[i.COMPILE_STATUS=35713]="COMPILE_STATUS",i[i.DELETE_STATUS=35712]="DELETE_STATUS",i[i.LINK_STATUS=35714]="LINK_STATUS",i[i.VALIDATE_STATUS=35715]="VALIDATE_STATUS",i[i.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",i[i.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",i[i.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",i[i.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",i[i.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",i[i.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",i[i.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",i[i.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",i[i.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",i[i.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",i[i.SHADER_TYPE=35663]="SHADER_TYPE",i[i.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",i[i.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",i[i.NEVER=512]="NEVER",i[i.LESS=513]="LESS",i[i.EQUAL=514]="EQUAL",i[i.LEQUAL=515]="LEQUAL",i[i.GREATER=516]="GREATER",i[i.NOTEQUAL=517]="NOTEQUAL",i[i.GEQUAL=518]="GEQUAL",i[i.ALWAYS=519]="ALWAYS",i[i.KEEP=7680]="KEEP",i[i.REPLACE=7681]="REPLACE",i[i.INCR=7682]="INCR",i[i.DECR=7683]="DECR",i[i.INVERT=5386]="INVERT",i[i.INCR_WRAP=34055]="INCR_WRAP",i[i.DECR_WRAP=34056]="DECR_WRAP",i[i.NEAREST=9728]="NEAREST",i[i.LINEAR=9729]="LINEAR",i[i.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",i[i.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",i[i.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",i[i.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",i[i.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",i[i.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",i[i.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",i[i.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE=5890]="TEXTURE",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i[i.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",i[i.TEXTURE0=33984]="TEXTURE0",i[i.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",i[i.REPEAT=10497]="REPEAT",i[i.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i[i.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",i[i.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",i[i.FLOAT_VEC2=35664]="FLOAT_VEC2",i[i.FLOAT_VEC3=35665]="FLOAT_VEC3",i[i.FLOAT_VEC4=35666]="FLOAT_VEC4",i[i.INT_VEC2=35667]="INT_VEC2",i[i.INT_VEC3=35668]="INT_VEC3",i[i.INT_VEC4=35669]="INT_VEC4",i[i.BOOL=35670]="BOOL",i[i.BOOL_VEC2=35671]="BOOL_VEC2",i[i.BOOL_VEC3=35672]="BOOL_VEC3",i[i.BOOL_VEC4=35673]="BOOL_VEC4",i[i.FLOAT_MAT2=35674]="FLOAT_MAT2",i[i.FLOAT_MAT3=35675]="FLOAT_MAT3",i[i.FLOAT_MAT4=35676]="FLOAT_MAT4",i[i.SAMPLER_2D=35678]="SAMPLER_2D",i[i.SAMPLER_CUBE=35680]="SAMPLER_CUBE",i[i.LOW_FLOAT=36336]="LOW_FLOAT",i[i.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",i[i.HIGH_FLOAT=36338]="HIGH_FLOAT",i[i.LOW_INT=36339]="LOW_INT",i[i.MEDIUM_INT=36340]="MEDIUM_INT",i[i.HIGH_INT=36341]="HIGH_INT",i[i.FRAMEBUFFER=36160]="FRAMEBUFFER",i[i.RENDERBUFFER=36161]="RENDERBUFFER",i[i.RGBA4=32854]="RGBA4",i[i.RGB5_A1=32855]="RGB5_A1",i[i.RGB565=36194]="RGB565",i[i.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",i[i.STENCIL_INDEX=6401]="STENCIL_INDEX",i[i.STENCIL_INDEX8=36168]="STENCIL_INDEX8",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i[i.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",i[i.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",i[i.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",i[i.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",i[i.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",i[i.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",i[i.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",i[i.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",i[i.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",i[i.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",i[i.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",i[i.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",i[i.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",i[i.NONE=0]="NONE",i[i.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",i[i.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",i[i.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",i[i.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",i[i.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",i[i.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",i[i.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",i[i.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",i[i.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",i[i.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",i[i.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",i[i.READ_BUFFER=3074]="READ_BUFFER",i[i.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",i[i.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",i[i.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",i[i.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",i[i.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",i[i.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",i[i.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",i[i.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",i[i.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",i[i.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",i[i.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",i[i.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",i[i.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",i[i.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",i[i.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",i[i.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",i[i.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",i[i.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",i[i.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",i[i.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",i[i.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",i[i.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",i[i.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",i[i.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",i[i.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",i[i.RED=6403]="RED",i[i.RGB8=32849]="RGB8",i[i.RGBA8=32856]="RGBA8",i[i.RGB10_A2=32857]="RGB10_A2",i[i.TEXTURE_3D=32879]="TEXTURE_3D",i[i.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",i[i.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",i[i.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",i[i.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",i[i.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",i[i.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",i[i.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",i[i.SRGB=35904]="SRGB",i[i.SRGB8=35905]="SRGB8",i[i.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",i[i.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",i[i.RGBA32F=34836]="RGBA32F",i[i.RGB32F=34837]="RGB32F",i[i.RGBA16F=34842]="RGBA16F",i[i.RGB16F=34843]="RGB16F",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",i[i.R11F_G11F_B10F=35898]="R11F_G11F_B10F",i[i.RGB9_E5=35901]="RGB9_E5",i[i.RGBA32UI=36208]="RGBA32UI",i[i.RGB32UI=36209]="RGB32UI",i[i.RGBA16UI=36214]="RGBA16UI",i[i.RGB16UI=36215]="RGB16UI",i[i.RGBA8UI=36220]="RGBA8UI",i[i.RGB8UI=36221]="RGB8UI",i[i.RGBA32I=36226]="RGBA32I",i[i.RGB32I=36227]="RGB32I",i[i.RGBA16I=36232]="RGBA16I",i[i.RGB16I=36233]="RGB16I",i[i.RGBA8I=36238]="RGBA8I",i[i.RGB8I=36239]="RGB8I",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.R8=33321]="R8",i[i.RG8=33323]="RG8",i[i.R16F=33325]="R16F",i[i.R32F=33326]="R32F",i[i.RG16F=33327]="RG16F",i[i.RG32F=33328]="RG32F",i[i.R8I=33329]="R8I",i[i.R8UI=33330]="R8UI",i[i.R16I=33331]="R16I",i[i.R16UI=33332]="R16UI",i[i.R32I=33333]="R32I",i[i.R32UI=33334]="R32UI",i[i.RG8I=33335]="RG8I",i[i.RG8UI=33336]="RG8UI",i[i.RG16I=33337]="RG16I",i[i.RG16UI=33338]="RG16UI",i[i.RG32I=33339]="RG32I",i[i.RG32UI=33340]="RG32UI",i[i.R8_SNORM=36756]="R8_SNORM",i[i.RG8_SNORM=36757]="RG8_SNORM",i[i.RGB8_SNORM=36758]="RGB8_SNORM",i[i.RGBA8_SNORM=36759]="RGBA8_SNORM",i[i.RGB10_A2UI=36975]="RGB10_A2UI",i[i.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",i[i.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.HALF_FLOAT=5131]="HALF_FLOAT",i[i.RG=33319]="RG",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",i[i.CURRENT_QUERY=34917]="CURRENT_QUERY",i[i.QUERY_RESULT=34918]="QUERY_RESULT",i[i.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",i[i.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",i[i.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",i[i.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",i[i.DRAW_BUFFER0=34853]="DRAW_BUFFER0",i[i.DRAW_BUFFER1=34854]="DRAW_BUFFER1",i[i.DRAW_BUFFER2=34855]="DRAW_BUFFER2",i[i.DRAW_BUFFER3=34856]="DRAW_BUFFER3",i[i.DRAW_BUFFER4=34857]="DRAW_BUFFER4",i[i.DRAW_BUFFER5=34858]="DRAW_BUFFER5",i[i.DRAW_BUFFER6=34859]="DRAW_BUFFER6",i[i.DRAW_BUFFER7=34860]="DRAW_BUFFER7",i[i.DRAW_BUFFER8=34861]="DRAW_BUFFER8",i[i.DRAW_BUFFER9=34862]="DRAW_BUFFER9",i[i.DRAW_BUFFER10=34863]="DRAW_BUFFER10",i[i.DRAW_BUFFER11=34864]="DRAW_BUFFER11",i[i.DRAW_BUFFER12=34865]="DRAW_BUFFER12",i[i.DRAW_BUFFER13=34866]="DRAW_BUFFER13",i[i.DRAW_BUFFER14=34867]="DRAW_BUFFER14",i[i.DRAW_BUFFER15=34868]="DRAW_BUFFER15",i[i.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",i[i.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",i[i.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",i[i.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",i[i.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",i[i.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",i[i.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",i[i.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",i[i.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",i[i.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",i[i.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",i[i.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",i[i.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",i[i.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",i[i.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",i[i.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",i[i.SAMPLER_3D=35679]="SAMPLER_3D",i[i.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",i[i.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",i[i.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",i[i.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",i[i.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",i[i.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",i[i.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",i[i.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",i[i.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",i[i.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",i[i.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",i[i.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",i[i.MAX_SAMPLES=36183]="MAX_SAMPLES",i[i.SAMPLER_BINDING=35097]="SAMPLER_BINDING",i[i.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",i[i.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",i[i.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",i[i.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",i[i.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",i[i.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",i[i.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",i[i.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",i[i.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",i[i.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",i[i.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",i[i.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",i[i.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",i[i.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",i[i.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",i[i.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",i[i.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",i[i.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",i[i.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",i[i.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",i[i.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",i[i.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",i[i.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",i[i.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",i[i.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",i[i.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",i[i.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",i[i.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",i[i.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",i[i.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",i[i.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",i[i.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",i[i.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",i[i.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",i[i.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",i[i.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",i[i.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",i[i.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",i[i.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",i[i.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",i[i.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i[i.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",i[i.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",i[i.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",i[i.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",i[i.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",i[i.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",i[i.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",i[i.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",i[i.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",i[i.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",i[i.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",i[i.UNIFORM_TYPE=35383]="UNIFORM_TYPE",i[i.UNIFORM_SIZE=35384]="UNIFORM_SIZE",i[i.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",i[i.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",i[i.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",i[i.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",i[i.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",i[i.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",i[i.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",i[i.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",i[i.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",i[i.OBJECT_TYPE=37138]="OBJECT_TYPE",i[i.SYNC_CONDITION=37139]="SYNC_CONDITION",i[i.SYNC_STATUS=37140]="SYNC_STATUS",i[i.SYNC_FLAGS=37141]="SYNC_FLAGS",i[i.SYNC_FENCE=37142]="SYNC_FENCE",i[i.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",i[i.UNSIGNALED=37144]="UNSIGNALED",i[i.SIGNALED=37145]="SIGNALED",i[i.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",i[i.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",i[i.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",i[i.WAIT_FAILED=37149]="WAIT_FAILED",i[i.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",i[i.COLOR=6144]="COLOR",i[i.DEPTH=6145]="DEPTH",i[i.STENCIL=6146]="STENCIL",i[i.MIN=32775]="MIN",i[i.MAX=32776]="MAX",i[i.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",i[i.STREAM_READ=35041]="STREAM_READ",i[i.STREAM_COPY=35042]="STREAM_COPY",i[i.STATIC_READ=35045]="STATIC_READ",i[i.STATIC_COPY=35046]="STATIC_COPY",i[i.DYNAMIC_READ=35049]="DYNAMIC_READ",i[i.DYNAMIC_COPY=35050]="DYNAMIC_COPY",i[i.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",i[i.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",i[i.INVALID_INDEX=4294967295]="INVALID_INDEX",i[i.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",i[i.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",i[i.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",i[i.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",i[i.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",i[i.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",i[i.R16_EXT=33322]="R16_EXT",i[i.RG16_EXT=33324]="RG16_EXT",i[i.RGB16_EXT=32852]="RGB16_EXT",i[i.RGBA16_EXT=32859]="RGBA16_EXT",i[i.R16_SNORM_EXT=36760]="R16_SNORM_EXT",i[i.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",i[i.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",i[i.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",i[i.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",i[i.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",i[i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",i[i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",i[i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",i[i.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",i[i.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",i[i.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",i[i.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",i[i.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",i[i.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",i[i.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",i[i.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",i[i.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",i[i.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",i[i.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",i[i.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",i[i.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",i[i.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",i[i.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",i[i.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",i[i.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",i[i.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",i[i.LINE_WEBGL=6913]="LINE_WEBGL",i[i.FILL_WEBGL=6914]="FILL_WEBGL",i[i.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",i[i.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",i[i.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",i[i.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",i[i.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",i[i.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",i[i.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",i[i.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",i[i.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",i[i.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",i[i.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",i[i.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",i[i.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",i[i.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",i[i.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",i[i.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",i[i.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",i[i.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",i[i.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",i[i.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",i[i.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",i[i.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",i[i.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",i[i.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Oo||(Oo={}));const tD={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},iD=i=>({drawBuffersWEBGL(e){return i.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),nD=i=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return i.createVertexArray()},deleteVertexArrayOES(e){return i.deleteVertexArray(e)},isVertexArrayOES(e){return i.isVertexArray(e)},bindVertexArrayOES(e){return i.bindVertexArray(e)}}),sD=i=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return i.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return i.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return i.vertexAttribDivisor(...e)}});function rD(i=!0){const e=HTMLCanvasElement.prototype;if(!i&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,n){if(t==="webgl"||t==="experimental-webgl"){const s=this.originalGetContext("webgl2",n);return s instanceof HTMLElement&&oD(s),s}return this.originalGetContext(t,n)}}function oD(i){i.getExtension("EXT_color_buffer_float");const e={...tD,WEBGL_disjoint_timer_query:i.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:iD(i),OES_vertex_array_object:nD(i),ANGLE_instanced_arrays:sD(i)},t=i.getExtension;i.getExtension=function(s){return t.call(i,s)||(s in e?e[s]:null)};const n=i.getSupportedExtensions;i.getSupportedExtensions=function(){const s=n.apply(i)||[];return s==null?void 0:s.concat(Object.keys(e))}}async function L2(i,e){const t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");const n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",i),new Promise((s,r)=>{n.onload=s,n.onerror=o=>r(new Error(`Unable to load script '${i}': ${o}`)),t.appendChild(n)})}const aD=1;let fi=null,J0=!1;const _y={debugSpectorJS:le.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function lD(i){if(!globalThis.SPECTOR)try{await L2(i.debugSpectorJSUrl||_y.debugSpectorJSUrl)}catch(e){le.warn(String(e))}}function Ote(i){var e;if(i={..._y,...i},!i.debugSpectorJS)return null;if(!fi&&globalThis.SPECTOR&&!((e=globalThis.luma)!=null&&e.spector)){le.probe(aD,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:t}=globalThis.SPECTOR;fi=new t,globalThis.luma&&(globalThis.luma.spector=fi)}if(!fi)return null;if(J0||(J0=!0,fi.spyCanvases(),fi==null||fi.onCaptureStarted.add(t=>le.info("Spector capture started:",t)()),fi==null||fi.onCapture.add(t=>{le.info("Spector capture complete:",t)(),fi==null||fi.getResultUI(),fi==null||fi.resultView.display(),fi==null||fi.resultView.addCapture(t)})),i.gl){const t=i.gl,n=t.device;fi==null||fi.startCapture(i.gl,500),t.device=n,new Promise(s=>setTimeout(s,2e3)).then(s=>{le.info("Spector capture stopped after 2 seconds")(),fi==null||fi.stopCapture()})}return fi}const cD="https://unpkg.com/webgl-debug@2.0.1/index.js";function R2(i){return i.luma=i.luma||{},i.luma}async function uD(){Vu()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await L2(cD))}function Bte(i,e={}){return e.debugWebGL||e.traceWebGL?hD(i,e):dD(i)}function dD(i){const e=R2(i);return e.realContext?e.realContext:i}function hD(i,e){if(!globalThis.WebGLDebugUtils)return le.warn("webgl-debug not loaded")(),i;const t=R2(i);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...Oo,...i});const n=globalThis.WebGLDebugUtils.makeDebugContext(i,fD.bind(null,e),pD.bind(null,e));for(const o in Oo)!(o in n)&&typeof Oo[o]=="number"&&(n[o]=Oo[o]);class s{}Object.setPrototypeOf(n,Object.getPrototypeOf(i)),Object.setPrototypeOf(s,n);const r=Object.create(s);return t.realContext=i,t.debugContext=r,r.debug=!0,r}function ex(i,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(i,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${i}(${t})`}function fD(i,e,t,n){n=Array.from(n).map(a=>a===void 0?"undefined":a);const s=globalThis.WebGLDebugUtils.glEnumToString(e),r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,n),o=`${s} in gl.${t}(${r})`;le.error(o)();debugger}function pD(i,e,t){let n="";le.level>=1&&(n=ex(e,t),i.traceWebGL&&le.log(1,n)());for(const s of t)if(s===void 0){n=n||ex(e,t);debugger}}const Sd=1;class mD extends CN{constructor(){super(),$(this,"type","webgl"),Cg.defaultProps={...Cg.defaultProps,..._y}}enforceWebGL2(e){rD(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&le.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){const{WebGLDevice:n}=await m0(async()=>{const{WebGLDevice:r}=await import("./webgl-device-QoBMYpnS-CdQYT9sr.js");return{WebGLDevice:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]));if(e instanceof n)return e;if((e==null?void 0:e.device)instanceof n)return e.device;if(!gD(e))throw new Error("Invalid WebGL2RenderingContext");const s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){const{WebGLDevice:t}=await m0(async()=>{const{WebGLDevice:n}=await import("./webgl-device-QoBMYpnS-CdQYT9sr.js");return{WebGLDevice:n}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]));le.groupCollapsed(Sd,"WebGLDevice created")();try{const n=[];(e.debugWebGL||e.debug)&&n.push(uD()),e.debugSpectorJS&&n.push(lD(e));const s=await Promise.allSettled(n);for(const a of s)a.status==="rejected"&&le.error(`Failed to initialize debug libraries ${a.reason}`)();const r=new t(e),o=`${r._reused?"Reusing":"Created"} device with WebGL2 ${r.props.debug?"debug ":""}context: ${r.info.vendor}, ${r.info.renderer} for canvas: ${r.canvasContext.id}`;return le.probe(Sd,o)(),le.table(Sd,r.info)(),r}finally{le.groupEnd(Sd)()}}}function gD(i){return typeof WebGL2RenderingContext<"u"&&i instanceof WebGL2RenderingContext?!0:!!(i&&Number.isFinite(i._version))}const _D=new mD,yD="#b3b3b3",bD=void 0,Ag=void 0,vD=1,xD=4,wD="#666666",SD=.1,ED=1,CD=1,P2="#222222",fe={enableSimulation:!0,spaceSize:8192,pointSizeScale:1,linkWidthScale:1,linkArrowsSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,linkArrows:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",hoveredLinkCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",hoveredLinkColor:void 0,hoveredLinkWidthIncrease:5,focusedPointRingColor:"white",focusedPointIndex:void 0,simulation:{decay:5e3,gravity:.25,center:0,repulsion:1,repulsionTheta:1.15,linkSpring:1,linkDistance:10,linkDistRandomVariationRange:[1,1.2],repulsionFromMouse:2,friction:.85,cluster:.1},showFPSMonitor:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||2,scalePointsOnZoom:!1,scaleLinksOnZoom:!1,enableZoom:!0,enableSimulationDuringZoom:!1,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,pointSamplingDistance:150,attribution:"",rescalePositions:void 0,enableRightClickRepulsion:!1},TD=.7,kD=.95,AD=3;/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:N2,setPrototypeOf:tx,isFrozen:ID,getPrototypeOf:LD,getOwnPropertyDescriptor:RD}=Object;let{freeze:fn,seal:gs,create:D2}=Object,{apply:Ig,construct:Lg}=typeof Reflect<"u"&&Reflect;fn||(fn=function(i){return i});gs||(gs=function(i){return i});Ig||(Ig=function(i,e,t){return i.apply(e,t)});Lg||(Lg=function(i,e){return new i(...e)});const Ed=pn(Array.prototype.forEach),PD=pn(Array.prototype.lastIndexOf),ix=pn(Array.prototype.pop),lc=pn(Array.prototype.push),ND=pn(Array.prototype.splice),hh=pn(String.prototype.toLowerCase),nm=pn(String.prototype.toString),nx=pn(String.prototype.match),cc=pn(String.prototype.replace),DD=pn(String.prototype.indexOf),MD=pn(String.prototype.trim),Ms=pn(Object.prototype.hasOwnProperty),rn=pn(RegExp.prototype.test),uc=OD(TypeError);function pn(i){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s2&&arguments[2]!==void 0?arguments[2]:hh;tx&&tx(i,null);let n=e.length;for(;n--;){let s=e[n];if(typeof s=="string"){const r=t(s);r!==s&&(ID(e)||(e[n]=r),s=r)}i[s]=!0}return i}function BD(i){for(let e=0;e/gm),jD=gs(/\$\{[\w\W]*/gm),HD=gs(/^data-[\-\w.\u00B7-\uFFFF]+$/),VD=gs(/^aria-[\-\w]+$/),M2=gs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),GD=gs(/^(?:\w+script|data):/i),WD=gs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),O2=gs(/^html$/i),YD=gs(/^[a-z][.\w]*(-[.\w]+)+$/i);var lx=Object.freeze({__proto__:null,ARIA_ATTR:VD,ATTR_WHITESPACE:WD,CUSTOM_ELEMENT:YD,DATA_ATTR:HD,DOCTYPE_NAME:O2,ERB_EXPR:$D,IS_ALLOWED_URI:M2,IS_SCRIPT_OR_DATA:GD,MUSTACHE_EXPR:UD,TMPLIT_EXPR:jD});const hc={element:1,text:3,progressingInstruction:7,comment:8,document:9},qD=function(){return typeof window>"u"?null:window},XD=function(i,e){if(typeof i!="object"||typeof i.createPolicy!="function")return null;let t=null;const n="data-tt-policy-suffix";e&&e.hasAttribute(n)&&(t=e.getAttribute(n));const s="dompurify"+(t?"#"+t:"");try{return i.createPolicy(s,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},cx=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function B2(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qD();const e=L=>B2(L);if(e.version="3.2.6",e.removed=[],!i||!i.document||i.document.nodeType!==hc.document||!i.Element)return e.isSupported=!1,e;let{document:t}=i;const n=t,s=n.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:d,DOMParser:h,trustedTypes:p}=i,m=l.prototype,y=dc(m,"cloneNode"),g=dc(m,"remove"),_=dc(m,"nextSibling"),S=dc(m,"childNodes"),E=dc(m,"parentNode");if(typeof o=="function"){const L=t.createElement("template");L.content&&L.content.ownerDocument&&(t=L.content.ownerDocument)}let x,T="";const{implementation:I,createNodeIterator:B,createDocumentFragment:H,getElementsByTagName:Q}=t,{importNode:re}=n;let D=cx();e.isSupported=typeof N2=="function"&&typeof E=="function"&&I&&I.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:de,ERB_EXPR:se,TMPLIT_EXPR:R,DATA_ATTR:ee,ARIA_ATTR:F,IS_SCRIPT_OR_DATA:q,ATTR_WHITESPACE:te,CUSTOM_ELEMENT:Z}=lx;let{IS_ALLOWED_URI:ae}=lx,J=null;const Se=rt({},[...sx,...sm,...rm,...om,...rx]);let xe=null;const et=rt({},[...ox,...am,...ax,...Cd]);let he=Object.seal(D2(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),yt=null,Xe=null,dt=!0,ie=!0,Ce=!1,Pe=!0,X=!1,We=!0,He=!1,bt=!1,Vt=!1,pe=!1,it=!1,si=!1,yi=!0,Zs=!1;const Zn="user-content-";let wo=!0,On=!1,di={},tn=null;const bi=rt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Qn=null;const Ss=rt({},["audio","video","img","source","image","track"]);let Qs=null;const Bn=rt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Es="http://www.w3.org/1998/Math/MathML",nn="http://www.w3.org/2000/svg",Ti="http://www.w3.org/1999/xhtml";let Qt=Ti,$i=!1,vn=null;const So=rt({},[Es,nn,Ti],nm);let Mr=rt({},["mi","mo","mn","ms","mtext"]),ji=rt({},["annotation-xml"]);const Or=rt({},["title","style","font","a","script"]);let Cs=null;const Js=["application/xhtml+xml","text/html"],ic="text/html";let Jt=null,At=null;const Jn=t.createElement("form"),Ut=function(L){return L instanceof RegExp||L instanceof Function},Ts=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(At&&At===L)){if((!L||typeof L!="object")&&(L={}),L=Gr(L),Cs=Js.indexOf(L.PARSER_MEDIA_TYPE)===-1?ic:L.PARSER_MEDIA_TYPE,Jt=Cs==="application/xhtml+xml"?nm:hh,J=Ms(L,"ALLOWED_TAGS")?rt({},L.ALLOWED_TAGS,Jt):Se,xe=Ms(L,"ALLOWED_ATTR")?rt({},L.ALLOWED_ATTR,Jt):et,vn=Ms(L,"ALLOWED_NAMESPACES")?rt({},L.ALLOWED_NAMESPACES,nm):So,Qs=Ms(L,"ADD_URI_SAFE_ATTR")?rt(Gr(Bn),L.ADD_URI_SAFE_ATTR,Jt):Bn,Qn=Ms(L,"ADD_DATA_URI_TAGS")?rt(Gr(Ss),L.ADD_DATA_URI_TAGS,Jt):Ss,tn=Ms(L,"FORBID_CONTENTS")?rt({},L.FORBID_CONTENTS,Jt):bi,yt=Ms(L,"FORBID_TAGS")?rt({},L.FORBID_TAGS,Jt):Gr({}),Xe=Ms(L,"FORBID_ATTR")?rt({},L.FORBID_ATTR,Jt):Gr({}),di=Ms(L,"USE_PROFILES")?L.USE_PROFILES:!1,dt=L.ALLOW_ARIA_ATTR!==!1,ie=L.ALLOW_DATA_ATTR!==!1,Ce=L.ALLOW_UNKNOWN_PROTOCOLS||!1,Pe=L.ALLOW_SELF_CLOSE_IN_ATTR!==!1,X=L.SAFE_FOR_TEMPLATES||!1,We=L.SAFE_FOR_XML!==!1,He=L.WHOLE_DOCUMENT||!1,pe=L.RETURN_DOM||!1,it=L.RETURN_DOM_FRAGMENT||!1,si=L.RETURN_TRUSTED_TYPE||!1,Vt=L.FORCE_BODY||!1,yi=L.SANITIZE_DOM!==!1,Zs=L.SANITIZE_NAMED_PROPS||!1,wo=L.KEEP_CONTENT!==!1,On=L.IN_PLACE||!1,ae=L.ALLOWED_URI_REGEXP||M2,Qt=L.NAMESPACE||Ti,Mr=L.MATHML_TEXT_INTEGRATION_POINTS||Mr,ji=L.HTML_INTEGRATION_POINTS||ji,he=L.CUSTOM_ELEMENT_HANDLING||{},L.CUSTOM_ELEMENT_HANDLING&&Ut(L.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(he.tagNameCheck=L.CUSTOM_ELEMENT_HANDLING.tagNameCheck),L.CUSTOM_ELEMENT_HANDLING&&Ut(L.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(he.attributeNameCheck=L.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),L.CUSTOM_ELEMENT_HANDLING&&typeof L.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(he.allowCustomizedBuiltInElements=L.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),X&&(ie=!1),it&&(pe=!0),di&&(J=rt({},rx),xe=[],di.html===!0&&(rt(J,sx),rt(xe,ox)),di.svg===!0&&(rt(J,sm),rt(xe,am),rt(xe,Cd)),di.svgFilters===!0&&(rt(J,rm),rt(xe,am),rt(xe,Cd)),di.mathMl===!0&&(rt(J,om),rt(xe,ax),rt(xe,Cd))),L.ADD_TAGS&&(J===Se&&(J=Gr(J)),rt(J,L.ADD_TAGS,Jt)),L.ADD_ATTR&&(xe===et&&(xe=Gr(xe)),rt(xe,L.ADD_ATTR,Jt)),L.ADD_URI_SAFE_ATTR&&rt(Qs,L.ADD_URI_SAFE_ATTR,Jt),L.FORBID_CONTENTS&&(tn===bi&&(tn=Gr(tn)),rt(tn,L.FORBID_CONTENTS,Jt)),wo&&(J["#text"]=!0),He&&rt(J,["html","head","body"]),J.table&&(rt(J,["tbody"]),delete yt.tbody),L.TRUSTED_TYPES_POLICY){if(typeof L.TRUSTED_TYPES_POLICY.createHTML!="function")throw uc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof L.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw uc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=L.TRUSTED_TYPES_POLICY,T=x.createHTML("")}else x===void 0&&(x=XD(p,s)),x!==null&&typeof T=="string"&&(T=x.createHTML(""));fn&&fn(L),At=L}},er=rt({},[...sm,...rm,...FD]),Br=rt({},[...om,...zD]),Eo=function(L){let V=E(L);(!V||!V.tagName)&&(V={namespaceURI:Qt,tagName:"template"});const C=hh(L.tagName),G=hh(V.tagName);return vn[L.namespaceURI]?L.namespaceURI===nn?V.namespaceURI===Ti?C==="svg":V.namespaceURI===Es?C==="svg"&&(G==="annotation-xml"||Mr[G]):!!er[C]:L.namespaceURI===Es?V.namespaceURI===Ti?C==="math":V.namespaceURI===nn?C==="math"&&ji[G]:!!Br[C]:L.namespaceURI===Ti?V.namespaceURI===nn&&!ji[G]||V.namespaceURI===Es&&!Mr[G]?!1:!Br[C]&&(Or[C]||!er[C]):!!(Cs==="application/xhtml+xml"&&vn[L.namespaceURI]):!1},es=function(L){lc(e.removed,{element:L});try{E(L).removeChild(L)}catch{g(L)}},hi=function(L,V){try{lc(e.removed,{attribute:V.getAttributeNode(L),from:V})}catch{lc(e.removed,{attribute:null,from:V})}if(V.removeAttribute(L),L==="is")if(pe||it)try{es(V)}catch{}else try{V.setAttribute(L,"")}catch{}},xn=function(L){let V=null,C=null;if(Vt)L=""+L;else{const Te=nx(L,/^[\r\n\t ]+/);C=Te&&Te[0]}Cs==="application/xhtml+xml"&&Qt===Ti&&(L=''+L+"");const G=x?x.createHTML(L):L;if(Qt===Ti)try{V=new h().parseFromString(G,Cs)}catch{}if(!V||!V.documentElement){V=I.createDocument(Qt,"template",null);try{V.documentElement.innerHTML=$i?T:G}catch{}}const ne=V.body||V.documentElement;return L&&C&&ne.insertBefore(t.createTextNode(C),ne.childNodes[0]||null),Qt===Ti?Q.call(V,He?"html":"body")[0]:He?V.documentElement:ne},ks=function(L){return B.call(L.ownerDocument||L,L,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ct=function(L){return L instanceof d&&(typeof L.nodeName!="string"||typeof L.textContent!="string"||typeof L.removeChild!="function"||!(L.attributes instanceof u)||typeof L.removeAttribute!="function"||typeof L.setAttribute!="function"||typeof L.namespaceURI!="string"||typeof L.insertBefore!="function"||typeof L.hasChildNodes!="function")},Fr=function(L){return typeof a=="function"&&L instanceof a};function nt(L,V,C){Ed(L,G=>{G.call(e,V,C,At)})}const wn=function(L){let V=null;if(nt(D.beforeSanitizeElements,L,null),ct(L))return es(L),!0;const C=Jt(L.nodeName);if(nt(D.uponSanitizeElement,L,{tagName:C,allowedTags:J}),We&&L.hasChildNodes()&&!Fr(L.firstElementChild)&&rn(/<[/\w!]/g,L.innerHTML)&&rn(/<[/\w!]/g,L.textContent)||L.nodeType===hc.progressingInstruction||We&&L.nodeType===hc.comment&&rn(/<[/\w]/g,L.data))return es(L),!0;if(!J[C]||yt[C]){if(!yt[C]&&tr(C)&&(he.tagNameCheck instanceof RegExp&&rn(he.tagNameCheck,C)||he.tagNameCheck instanceof Function&&he.tagNameCheck(C)))return!1;if(wo&&!tn[C]){const G=E(L)||L.parentNode,ne=S(L)||L.childNodes;if(ne&&G){const Te=ne.length;for(let It=Te-1;It>=0;--It){const st=y(ne[It],!0);st.__removalCount=(L.__removalCount||0)+1,G.insertBefore(st,_(L))}}}return es(L),!0}return L instanceof l&&!Eo(L)||(C==="noscript"||C==="noembed"||C==="noframes")&&rn(/<\/no(script|embed|frames)/i,L.innerHTML)?(es(L),!0):(X&&L.nodeType===hc.text&&(V=L.textContent,Ed([de,se,R],G=>{V=cc(V,G," ")}),L.textContent!==V&&(lc(e.removed,{element:L.cloneNode()}),L.textContent=V)),nt(D.afterSanitizeElements,L,null),!1)},zr=function(L,V,C){if(yi&&(V==="id"||V==="name")&&(C in t||C in Jn))return!1;if(!(ie&&!Xe[V]&&rn(ee,V))&&!(dt&&rn(F,V))){if(!xe[V]||Xe[V]){if(!(tr(L)&&(he.tagNameCheck instanceof RegExp&&rn(he.tagNameCheck,L)||he.tagNameCheck instanceof Function&&he.tagNameCheck(L))&&(he.attributeNameCheck instanceof RegExp&&rn(he.attributeNameCheck,V)||he.attributeNameCheck instanceof Function&&he.attributeNameCheck(V))||V==="is"&&he.allowCustomizedBuiltInElements&&(he.tagNameCheck instanceof RegExp&&rn(he.tagNameCheck,C)||he.tagNameCheck instanceof Function&&he.tagNameCheck(C))))return!1}else if(!Qs[V]&&!rn(ae,cc(C,te,""))&&!((V==="src"||V==="xlink:href"||V==="href")&&L!=="script"&&DD(C,"data:")===0&&Qn[L])&&!(Ce&&!rn(q,cc(C,te,"")))&&C)return!1}return!0},tr=function(L){return L!=="annotation-xml"&&nx(L,Z)},Fn=function(L){nt(D.beforeSanitizeAttributes,L,null);const{attributes:V}=L;if(!V||ct(L))return;const C={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe,forceKeepAttr:void 0};let G=V.length;for(;G--;){const ne=V[G],{name:Te,namespaceURI:It,value:st}=ne,Je=Jt(Te),vi=st;let ht=Te==="value"?vi:MD(vi);if(C.attrName=Je,C.attrValue=ht,C.keepAttr=!0,C.forceKeepAttr=void 0,nt(D.uponSanitizeAttribute,L,C),ht=C.attrValue,Zs&&(Je==="id"||Je==="name")&&(hi(Te,L),ht=Zn+ht),We&&rn(/((--!?|])>)|<\/(style|title)/i,ht)){hi(Te,L);continue}if(C.forceKeepAttr)continue;if(!C.keepAttr){hi(Te,L);continue}if(!Pe&&rn(/\/>/i,ht)){hi(Te,L);continue}X&&Ed([de,se,R],Lt=>{ht=cc(ht,Lt," ")});const ir=Jt(L.nodeName);if(!zr(ir,Je,ht)){hi(Te,L);continue}if(x&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!It)switch(p.getAttributeType(ir,Je)){case"TrustedHTML":{ht=x.createHTML(ht);break}case"TrustedScriptURL":{ht=x.createScriptURL(ht);break}}if(ht!==vi)try{It?L.setAttributeNS(It,Te,ht):L.setAttribute(Te,ht),ct(L)?es(L):ix(e.removed)}catch{hi(Te,L)}}nt(D.afterSanitizeAttributes,L,null)},sn=function L(V){let C=null;const G=ks(V);for(nt(D.beforeSanitizeShadowDOM,V,null);C=G.nextNode();)nt(D.uponSanitizeShadowNode,C,null),wn(C),Fn(C),C.content instanceof r&&L(C.content);nt(D.afterSanitizeShadowDOM,V,null)};return e.sanitize=function(L){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,G=null,ne=null,Te=null;if($i=!L,$i&&(L=""),typeof L!="string"&&!Fr(L))if(typeof L.toString=="function"){if(L=L.toString(),typeof L!="string")throw uc("dirty is not a string, aborting")}else throw uc("toString is not a function");if(!e.isSupported)return L;if(bt||Ts(V),e.removed=[],typeof L=="string"&&(On=!1),On){if(L.nodeName){const Je=Jt(L.nodeName);if(!J[Je]||yt[Je])throw uc("root node is forbidden and cannot be sanitized in-place")}}else if(L instanceof a)C=xn(""),G=C.ownerDocument.importNode(L,!0),G.nodeType===hc.element&&G.nodeName==="BODY"||G.nodeName==="HTML"?C=G:C.appendChild(G);else{if(!pe&&!X&&!He&&L.indexOf("<")===-1)return x&&si?x.createHTML(L):L;if(C=xn(L),!C)return pe?null:si?T:""}C&&Vt&&es(C.firstChild);const It=ks(On?L:C);for(;ne=It.nextNode();)wn(ne),Fn(ne),ne.content instanceof r&&sn(ne.content);if(On)return L;if(pe){if(it)for(Te=H.call(C.ownerDocument);C.firstChild;)Te.appendChild(C.firstChild);else Te=C;return(xe.shadowroot||xe.shadowrootmode)&&(Te=re.call(n,Te,!0)),Te}let st=He?C.outerHTML:C.innerHTML;return He&&J["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&rn(O2,C.ownerDocument.doctype.name)&&(st=" `+st),X&&Ed([de,se,R],Je=>{st=cc(st,Je," ")}),x&&si?x.createHTML(st):st},e.setConfig=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ts(L),bt=!0},e.clearConfig=function(){At=null,bt=!1},e.isValidAttribute=function(L,V,C){At||Ts({});const G=Jt(L),ne=Jt(V);return zr(G,ne,C)},e.addHook=function(L,V){typeof V=="function"&&lc(D[L],V)},e.removeHook=function(L,V){if(V!==void 0){const C=PD(D[L],V);return C===-1?void 0:ND(D[L],C,1)[0]}return ix(D[L])},e.removeHooks=function(L){D[L]=[]},e.removeAllHooks=function(){D=cx()},e}var KD=B2();const ZD=i=>typeof i=="function",F2=i=>Array.isArray(i),QD=i=>i instanceof Object,JD=i=>i instanceof Object?i.constructor.name!=="Function"&&i.constructor.name!=="Object":!1,ux=i=>QD(i)&&!F2(i)&&!ZD(i)&&!JD(i);function Bo(i){let e;if(F2(i))e=i;else{const t=jo(i),n=t==null?void 0:t.rgb();e=[(n==null?void 0:n.r)||0,(n==null?void 0:n.g)||0,(n==null?void 0:n.b)||0,(t==null?void 0:t.opacity)??1]}return[e[0]/255,e[1]/255,e[2]/255,e[3]]}function eM(i,e,t){return .2126*i+.7152*e+.0722*t}function jn(i,e,t=0,n=0,s,r){return i.readPixelsToArrayWebGL(e,{sourceX:t,sourceY:n,sourceWidth:s,sourceHeight:r})}function tM(i,e,t){return Math.min(Math.max(i,e),t)}function ss(i){return i!=null&&!Number.isNaN(i)}function iM(i,e){return KD.sanitize(i,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br"],ALLOWED_ATTR:["href","target","class","id","style"],ALLOW_DATA_ATTR:!1,...e})}class nM{constructor(){this.enableSimulation=fe.enableSimulation,this.backgroundColor=P2,this.spaceSize=fe.spaceSize,this.pointColor=yD,this.pointDefaultColor=void 0,this.pointGreyoutOpacity=bD,this.pointGreyoutColor=Ag,this.pointSize=xD,this.pointDefaultSize=void 0,this.pointOpacity=vD,this.pointSizeScale=fe.pointSizeScale,this.hoveredPointCursor=fe.hoveredPointCursor,this.hoveredLinkCursor=fe.hoveredLinkCursor,this.renderHoveredPointRing=fe.renderHoveredPointRing,this.hoveredPointRingColor=fe.hoveredPointRingColor,this.focusedPointRingColor=fe.focusedPointRingColor,this.focusedPointIndex=fe.focusedPointIndex,this.linkColor=wD,this.linkDefaultColor=void 0,this.linkOpacity=ED,this.linkGreyoutOpacity=SD,this.linkWidth=CD,this.linkDefaultWidth=void 0,this.linkWidthScale=fe.linkWidthScale,this.hoveredLinkColor=fe.hoveredLinkColor,this.hoveredLinkWidthIncrease=fe.hoveredLinkWidthIncrease,this.renderLinks=fe.renderLinks,this.curvedLinks=fe.curvedLinks,this.curvedLinkSegments=fe.curvedLinkSegments,this.curvedLinkWeight=fe.curvedLinkWeight,this.curvedLinkControlPointDistance=fe.curvedLinkControlPointDistance,this.linkArrows=fe.linkArrows,this.linkDefaultArrows=void 0,this.linkArrowsSizeScale=fe.linkArrowsSizeScale,this.scaleLinksOnZoom=fe.scaleLinksOnZoom,this.linkVisibilityDistanceRange=fe.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=fe.linkVisibilityMinTransparency,this.simulationDecay=fe.simulation.decay,this.simulationGravity=fe.simulation.gravity,this.simulationCenter=fe.simulation.center,this.simulationRepulsion=fe.simulation.repulsion,this.simulationRepulsionTheta=fe.simulation.repulsionTheta,this.simulationLinkSpring=fe.simulation.linkSpring,this.simulationLinkDistance=fe.simulation.linkDistance,this.simulationLinkDistRandomVariationRange=fe.simulation.linkDistRandomVariationRange,this.simulationRepulsionFromMouse=fe.simulation.repulsionFromMouse,this.enableRightClickRepulsion=fe.enableRightClickRepulsion,this.simulationFriction=fe.simulation.friction,this.simulationCluster=fe.simulation.cluster,this.onSimulationStart=void 0,this.onSimulationTick=void 0,this.onSimulationEnd=void 0,this.onSimulationPause=void 0,this.onSimulationRestart=void 0,this.onSimulationUnpause=void 0,this.onClick=void 0,this.onPointClick=void 0,this.onLinkClick=void 0,this.onBackgroundClick=void 0,this.onMouseMove=void 0,this.onPointMouseOver=void 0,this.onPointMouseOut=void 0,this.onLinkMouseOver=void 0,this.onLinkMouseOut=void 0,this.onZoomStart=void 0,this.onZoom=void 0,this.onZoomEnd=void 0,this.onDragStart=void 0,this.onDrag=void 0,this.onDragEnd=void 0,this.showFPSMonitor=fe.showFPSMonitor,this.pixelRatio=fe.pixelRatio,this.scalePointsOnZoom=fe.scalePointsOnZoom,this.initialZoomLevel=void 0,this.enableZoom=fe.enableZoom,this.enableSimulationDuringZoom=fe.enableSimulationDuringZoom,this.enableDrag=fe.enableDrag,this.fitViewOnInit=fe.fitViewOnInit,this.fitViewDelay=fe.fitViewDelay,this.fitViewPadding=fe.fitViewPadding,this.fitViewDuration=fe.fitViewDuration,this.fitViewByPointsInRect=void 0,this.fitViewByPointIndices=void 0,this.randomSeed=void 0,this.pointSamplingDistance=fe.pointSamplingDistance,this.attribution=fe.attribution,this.rescalePositions=fe.rescalePositions}init(e){Object.keys(e).forEach(t=>{this.deepMergeConfig(this.getConfig(),e,t)})}deepMergeConfig(e,t,n){ux(e[n])&&ux(t[n])?Object.keys(t[n]).forEach(s=>{this.deepMergeConfig(e[n],t[n],s)}):e[n]=t[n]}getConfig(){return this}}function yy(i,e){if(!i)throw new Error(e||"shadertools: assertion failed.")}const lm={number:{type:"number",validate(i,e){return Number.isFinite(i)&&typeof e=="object"&&(e.max===void 0||i<=e.max)&&(e.min===void 0||i>=e.min)}},array:{type:"array",validate(i,e){return Array.isArray(i)||ArrayBuffer.isView(i)}}};function sM(i){const e={};for(const[t,n]of Object.entries(i))e[t]=rM(n);return e}function rM(i){let e=dx(i);if(e!=="object")return{value:i,...lm[e],type:e};if(typeof i=="object")return i?i.type!==void 0?{...i,...lm[i.type],type:i.type}:i.value===void 0?{type:"object",value:i}:(e=dx(i.value),{...i,...lm[e],type:e}):{type:"object",value:null};throw new Error("props")}function dx(i){return Array.isArray(i)||ArrayBuffer.isView(i)?"array":typeof i}const oM=`#ifdef MODULE_LOGDEPTH logdepth_adjustPosition(gl_Position); #endif diff --git a/frontend/dist/assets/Mqtt-DF6wnkuy.js b/frontend/dist/assets/Mqtt-C8Anxpfs.js similarity index 95% rename from frontend/dist/assets/Mqtt-DF6wnkuy.js rename to frontend/dist/assets/Mqtt-C8Anxpfs.js index 904adc9a..fecd41a5 100644 --- a/frontend/dist/assets/Mqtt-DF6wnkuy.js +++ b/frontend/dist/assets/Mqtt-C8Anxpfs.js @@ -1,4 +1,4 @@ -import{e as Se,fm as N,fn as Ke,r as d,j as e,I as K,B as te,c as C,f2 as Fe,f3 as ze,aE as be,f4 as Ve,a8 as pe,V as I,a0 as ne,bM as xe,fo as ye,dn as Ce,fp as Le,fq as me,bH as We,fr as $e,aa as le,a7 as Pe,fs as O,ft as Ye,fu as Ze,fv as Me,fw as Je,fx as Xe,fy as _e,a2 as je,fz as qe,cK as ke,fA as Qe,bY as et}from"./index-C2xvS0Jd.js";import{C as Q,P as tt,a as st,B as at}from"./PageLayout-Cg7r5tdt.js";import{L as Re,a as fe}from"./listbox-DnHpTyQt.js";import{S as nt}from"./settings-2-OYYe3udS.js";import{P as re}from"./plus-CH14Vv92.js";import{M as rt}from"./map-pin-CQk00ph2.js";import{C as lt}from"./check-check-UEaQfqci.js";import{Z as se}from"./zap-v3FkQoQ-.js";import{S as Te}from"./search-DPGHPI2q.js";import{C as de}from"./chevron-right-C9GG0xWI.js";import{H as ot}from"./hash-DjqT3oXN.js";import{u as it,C as ct}from"./chevron-up-CTCjpmk_.js";import{F as dt}from"./funnel-DGVJFdsh.js";import{a as ut,C as mt}from"./circle-stop-DHdw14LD.js";import{T as ht}from"./trash-2-Def3YmfN.js";import{M as pt}from"./message-square-BE66c4_-.js";import{C as xt}from"./cpu-CUBKtjSm.js";import{R as ue,C as ge}from"./Grid-kVOI-wJp.js";import{W as ft}from"./wifi-Bc9OxL0c.js";import{W as gt}from"./wifi-off-omfJv-eS.js";import{D as Ne}from"./database-cyku2KnA.js";import{C as Nt}from"./clock-DU0z3qMB.js";import"./element-movement-CSQuYFsD.js";import"./use-text-value-CU5Ho7TY.js";import"./frozen-Cx4cJH6f.js";/** +import{e as Se,fm as N,fn as Ke,r as d,j as e,I as K,B as te,c as C,f2 as Fe,f3 as ze,aF as be,f4 as Ve,a8 as pe,V as I,a0 as ne,bN as xe,fo as ye,dp as Ce,fp as Le,fq as me,bI as We,fr as $e,aa as le,a7 as Pe,fs as O,ft as Ze,fu as Ye,fv as Me,fw as Je,fx as Xe,fy as _e,a2 as je,fz as qe,cL as ke,fA as Qe,bZ as et}from"./index-D33fcA3L.js";import{C as Q,P as tt,a as st,B as at}from"./PageLayout-CRN-E5xi.js";import{L as Re,a as fe}from"./listbox-DkfYDEqr.js";import{S as nt}from"./settings-2-C5Lvk9-M.js";import{P as re}from"./plus-C0dCjBh9.js";import{M as rt}from"./map-pin-B_Rx-xpd.js";import{C as lt}from"./check-check-C-QgFmon.js";import{Z as se}from"./zap-C-Mue2DZ.js";import{S as Te}from"./search-DN8guzpX.js";import{C as de}from"./chevron-right-D4kUPDBw.js";import{H as ot}from"./hash-Ba9bZo8v.js";import{u as it,C as ct}from"./chevron-up-DyOgmQ5-.js";import{F as dt}from"./funnel-BBIwSMOb.js";import{a as ut,C as mt}from"./circle-stop-Dh0g22OE.js";import{T as ht}from"./trash-2-CUY4NG5t.js";import{M as pt}from"./message-square-DFs8_yFI.js";import{C as xt}from"./cpu--k4RdYyx.js";import{R as ue,C as ge}from"./Grid-DQYUnZsY.js";import{W as ft}from"./wifi-D716s0ef.js";import{W as gt}from"./wifi-off-BQtV63nI.js";import{D as Ne}from"./database-Bm4-qoOy.js";import{C as Nt}from"./clock-D_m2QiHa.js";import"./element-movement-BL6huHzq.js";import"./use-text-value-iYUkduzo.js";import"./frozen-C10EXZ59.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -15,5 +15,5 @@ import{e as Se,fm as N,fn as Ke,r as d,j as e,I as K,B as te,c as C,f2 as Fe,f3 * See the LICENSE file in the root directory of this source tree. */const yt=[["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=Se("unplug",yt),Ct=[["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"]],Ae=new Map;for(const[s,t,r,l,i,a]of Ct)Ae.set(s,{code:s,city:t,...r?{state:r}:{},country:l,countryCode:i,continent:a});const At={city:"Unknown",country:"Unknown",countryCode:"??",continent:"Unknown"};function ee(s){return Ae.get(s.toUpperCase())??{code:s.toUpperCase(),...At}}function jt(s){const t=Ae.get(s.toUpperCase());return t?t.state?`${t.city}, ${t.state}`:t.city:s.toUpperCase()}function vt(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 Ut=[{name:"West Coast Mesh",emoji:"🏄",continent:"North America",frequencyMHz:"927.875",codes:["SBP","SBA","OXR","LAX","SNA","ONT","PSP","SAN","TIJ"]}];function Et(s){const t=s.toUpperCase();return t.length!==2||t==="??"?"🏳️":String.fromCodePoint(...[...t].map(r=>127462+r.charCodeAt(0)-65))}const wt={"North America":"🌎","Latin America":"🌎",Europe:"🌍",Africa:"🌍","Middle East":"🌍","Asia Pacific":"🌏",Oceania:"🌏",Unknown:"🏳️"};function Lt(s){return wt[s]??"🏳️"}function Pt(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 q({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 Mt={connected:"green",connecting:"amber",error:"red",disconnected:"zinc"},Ue=[{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 kt(){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(Ue.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"}),Ue.map(({topic:m,label:A,description:b})=>{const E=x.includes(m);return e.jsxs("button",{onClick:()=>P(m),disabled:!U,title:`${E?"Unsubscribe from":"Subscribe to"} ${m} ${b}`,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 Ee({ch:s,selected:t,streaming:r,onToggle:l}){const i=ee(s.iata),a=jt(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 Rt=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=ye(),U=Ce(),v=Le(),[L,P]=d.useState(""),[M,m]=d.useState(()=>new Set),A=d.useRef(new Set),b=d.useMemo(()=>Pt(t),[t]),E=d.useMemo(()=>{const c=new Map;for(const w of b)c.set(w.iata.toUpperCase(),w);return c},[b]),j=d.useMemo(()=>b.map(c=>c.iata),[b]),F=d.useMemo(()=>{if(!L)return b;const c=L.toLowerCase();return b.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)})},[b,L]),z=d.useMemo(()=>vt(F.map(c=>c.iata)),[F]),Y=d.useMemo(()=>{const c=[...v.values()],w=new Set(b.map(g=>g.iata.toUpperCase()));return Ut.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,b]);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 S=[...c].filter(B=>ee(B).continent===H.continent);S.length>0&&S.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 b.length===0?e.jsxs("div",{className:"flex items-center gap-2 py-1.5 text-fg-muted type-data-xs",children:[e.jsx(rt,{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:b.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(lt,{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((S,B)=>S+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((S,B)=>S+B.codes.length,0),H=c.countries.flatMap(S=>S.codes),Z=H.length>0&&H.every(S=>h.has(S)),ie=H.some(S=>h.has(S));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:[Lt(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:S=>{S.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(S=>S.continent===c.continent).map(S=>{const B=`${w}/_curated/${S.name}`,D=M.has(B),W=S.resolvedCodes.length>0&&S.resolvedCodes.every($=>h.has($)),X=S.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:[S.emoji," ",S.name]}),e.jsx("span",{className:"text-[10px] text-fg-muted/40 tabular-nums",children:S.resolvedCodes.length}),S.frequencyMHz&&e.jsxs("span",{className:"text-[9px] text-fg-muted/30 font-mono",children:[S.frequencyMHz," MHz"]})]}),e.jsx("button",{onClick:$=>{$.stopPropagation(),oe(S.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 ${S.name} channels`:`Select all ${S.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:S.resolvedCodes.map($=>{const _=E.get($);return _?e.jsx(Ee,{ch:_,selected:h.has(_.iata),streaming:y,onToggle:i},$):null})})]},S.name)}),c.countries.map(({country:S,countryCode:B,codes:D})=>{const W=`${w}/${S}`,X=M.has(W),$=c.countries.length>1||D.length>6,_=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:[Et(B)," ",S]}),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",_?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:_?`Deselect all ${S} channels`:`Select all ${S} channels`,children:_?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(Ee,{ch:he,selected:h.has(he.iata),streaming:y,onToggle:i},J):null})})]},S)})]})]},w)})})]})});function Tt(){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),b=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(q,{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(fe,{value:"wss",children:"wss://"}),e.jsx(fe,{value:"mqtt",children:"mqtt://"})]})}),e.jsx(q,{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(q,{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(nt,{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(q,{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(q,{label:"Basepath",className:"w-24 shrink-0",children:e.jsx(K,{size:"sm",value:l,onChange:o=>b(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(q,{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(q,{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:Mt[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(kt,{})}),f&&e.jsx("div",{className:"border-t border-edge-subtle/20 pt-4",children:e.jsx(Rt,{})})]})}function Oe(s){let t=s.messageCount;for(const r of s.children.values())t+=Oe(r);return t}const Bt=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(b=>!b)},[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,b)=>b.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(ot,{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 Dt({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(Bt,{node:i,depth:0,onSelect:s,selectedTopic:t},i.segment))})}const Ot={advert:"indigo",trace:"cyan",grp_txt:"green",ack:"zinc",path:"amber",txt_msg:"blue"},It=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:Ot[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(ct,{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?Gt(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 Gt(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 Ht({topicFilter:s}){const t=N(h=>h.messages),r=N(h=>h.paused),l=N(h=>h.setPaused),i=N(h=>h.clearMessages),a=Ce(),x=ye(),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 b=d.useMemo(()=>s?t.filter(h=>h.topic.startsWith(s)):t,[t,s]),E=it({count:b.length,getScrollElement:()=>p.current,estimateSize:()=>52,overscan:20});d.useEffect(()=>{U&&b.length>0&&!r&&E.scrollToIndex(b.length-1,{align:"end"})},[b.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(dt,{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(ut,{"data-slot":"icon",className:"!w-4 !h-4"}):e.jsx(mt,{"data-slot":"icon",className:"!w-4 !h-4"})}),e.jsx(te,{plain:!0,onClick:i,title:"Clear messages",children:e.jsx(ht,{"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(pt,{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:b.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(It,{msg:b[h.index]})},h.key))})})]})}const Kt=/^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)Kt.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 Ft(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 zt=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 Vt(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 Wt=[25,50,100,250];function $t({topicFilter:s=""}){const t=Le(),r=ye(),[l,i]=d.useState(""),[a,x]=d.useState(null),[p,U]=d.useState(50),[v,L]=d.useState(50),P=d.useMemo(()=>Vt(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(()=>Ft(m),[m]),b=d.useMemo(()=>m.map(n=>({obs:n,parsed:Ie(n.firmwareVersion)})),[m]),E=d.useMemo(()=>{if(!l)return m;const n=l.toLowerCase();return b.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,b,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(ve,{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(ve,{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(xt,{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:Wt.map(n=>e.jsxs(fe,{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(ge,{span:12,sm:6,lg:4,xl:3,children:e.jsx(zt,{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 Yt={connected:"green",connecting:"amber",loading:"blue",error:"red",disconnected:"zinc"},Zt=[{tier:"3d",label:"3 Day"},{tier:"7d",label:"7 Day"},{tier:"14d",label:"14 Day"}],we=["24h","3d","7d","14d"];function Jt(){const s=O(u=>u.url),t=O(u=>u.port),r=O(u=>u.username),l=O(u=>u.password),i=Ye(),a=Ze(),x=Me(),p=Je(),U=Xe(),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),b=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=we.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=>b(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(je,{"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:Yt[i]??"zinc",children:i}),(h||f)&&x>0&&e.jsxs("span",{className:"type-data-xs text-fg-muted tabular-nums",children:[e.jsx(Ne,{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(je,{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(Ne,{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:Zt.map(({tier:u,label:o})=>{const c=we.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 Xt(){try{if(localStorage.getItem(Ge)==="http")return"http"}catch{}return"mqtt"}function _t(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 js(){const[s,t]=d.useState(""),[r,l]=d.useState(Xt),i=N(j=>j.status),a=Ce(),x=N(j=>j.stopMqttMode),p=Qe(),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),_t(j)},[]),m=a.active||i==="connected"||p,A=r==="http",b=A?"External Database":"MQTT Subscription",E=A?e.jsx(me,{}):e.jsx(ke,{});return e.jsxs(tt,{children:[e.jsxs("div",{className:"relative",style:{isolation:"isolate"},children:[e.jsx(st,{title:b,icon:E,subtitle:A?e.jsxs("div",{className:"flex items-start gap-2 max-w-2xl",children:[e.jsx(Ne,{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(et,{className:"w-3.5 h-3.5 text-sys-amber shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs leading-relaxed text-fg-muted",children:"Use an external MQTT broker to feed packets into pymc_console. Limited to live sessions only — does not overwrite pyMC_Repeater database or interfere with its operation. Hard refresh or clearing session cache will clear MQTT data. 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(at,{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(Jt,{})})}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{template:"auto",children:e.jsx(Q,{compact:!0,children:e.jsx(Tt,{})})}),e.jsxs(ue,{template:"hero-tall",children:[e.jsx(ge,{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(Dt,{onTopicSelect:P,selectedTopic:s})})]})}),e.jsx(ge,{span:12,md:8,children:e.jsx(Q,{noPadding:!0,children:e.jsx(Ht,{topicFilter:s})})})]}),i==="connected"&&e.jsx($t,{topicFilter:s})]})]})]})}export{js as default}; +${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 Rt=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=ye(),U=Ce(),v=Le(),[L,P]=d.useState(""),[M,m]=d.useState(()=>new Set),A=d.useRef(new Set),b=d.useMemo(()=>Pt(t),[t]),E=d.useMemo(()=>{const c=new Map;for(const w of b)c.set(w.iata.toUpperCase(),w);return c},[b]),j=d.useMemo(()=>b.map(c=>c.iata),[b]),F=d.useMemo(()=>{if(!L)return b;const c=L.toLowerCase();return b.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)})},[b,L]),z=d.useMemo(()=>vt(F.map(c=>c.iata)),[F]),Z=d.useMemo(()=>{const c=[...v.values()],w=new Set(b.map(g=>g.iata.toUpperCase()));return Ut.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 Y=H.iata.toUpperCase();w.has(Y)&&T.add(Y)}}return{...g,resolvedCodes:[...T].sort()}}).filter(g=>g.resolvedCodes.length>0)},[v,b]);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(Z);u.current=Z,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 Y=!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),Y=!0;break}}if(Y)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 S=[...c].filter(B=>ee(B).continent===H.continent);S.length>0&&S.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 b.length===0?e.jsxs("div",{className:"flex items-center gap-2 py-1.5 text-fg-muted type-data-xs",children:[e.jsx(rt,{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:b.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(lt,{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((S,B)=>S+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((S,B)=>S+B.codes.length,0),H=c.countries.flatMap(S=>S.codes),Y=H.length>0&&H.every(S=>h.has(S)),ie=H.some(S=>h.has(S));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:[Lt(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:S=>{S.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",Y?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:Y?`Deselect all ${c.continent} channels`:`Select all ${c.continent} channels`,children:Y?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:[Z.filter(S=>S.continent===c.continent).map(S=>{const B=`${w}/_curated/${S.name}`,D=M.has(B),W=S.resolvedCodes.length>0&&S.resolvedCodes.every($=>h.has($)),X=S.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:[S.emoji," ",S.name]}),e.jsx("span",{className:"text-[10px] text-fg-muted/40 tabular-nums",children:S.resolvedCodes.length}),S.frequencyMHz&&e.jsxs("span",{className:"text-[9px] text-fg-muted/30 font-mono",children:[S.frequencyMHz," MHz"]})]}),e.jsx("button",{onClick:$=>{$.stopPropagation(),oe(S.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 ${S.name} channels`:`Select all ${S.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:S.resolvedCodes.map($=>{const _=E.get($);return _?e.jsx(Ee,{ch:_,selected:h.has(_.iata),streaming:y,onToggle:i},$):null})})]},S.name)}),c.countries.map(({country:S,countryCode:B,codes:D})=>{const W=`${w}/${S}`,X=M.has(W),$=c.countries.length>1||D.length>6,_=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:[Et(B)," ",S]}),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",_?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:_?`Deselect all ${S} channels`:`Select all ${S} channels`,children:_?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(Ee,{ch:he,selected:h.has(he.iata),streaming:y,onToggle:i},J):null})})]},S)})]})]},w)})})]})});function Tt(){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),b=N(o=>o.setBasepath),E=N(o=>o.setProtocol),j=N(o=>o.setEncryption),F=N(o=>o.setValidateCertificate),z=N(o=>o.setUsername),Z=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(q,{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(fe,{value:"wss",children:"wss://"}),e.jsx(fe,{value:"mqtt",children:"mqtt://"})]})}),e.jsx(q,{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(q,{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(nt,{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(q,{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(q,{label:"Basepath",className:"w-24 shrink-0",children:e.jsx(K,{size:"sm",value:l,onChange:o=>b(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(q,{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(q,{label:"Password",className:"flex-1 min-w-0",children:e.jsx(K,{size:"sm",type:"password",value:U,onChange:o=>Z(o.target.value),placeholder:"optional",disabled:R})})]})]})})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(I,{color:Mt[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(kt,{})}),f&&e.jsx("div",{className:"border-t border-edge-subtle/20 pt-4",children:e.jsx(Rt,{})})]})}function Oe(s){let t=s.messageCount;for(const r of s.children.values())t+=Oe(r);return t}const Bt=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(b=>!b)},[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,b)=>b.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(ot,{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 Dt({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(Bt,{node:i,depth:0,onSelect:s,selectedTopic:t},i.segment))})}const Ot={advert:"indigo",trace:"cyan",grp_txt:"green",ack:"zinc",path:"amber",txt_msg:"blue"},It=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:Ot[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(ct,{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?Gt(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 Gt(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 Ht({topicFilter:s}){const t=N(h=>h.messages),r=N(h=>h.paused),l=N(h=>h.setPaused),i=N(h=>h.clearMessages),a=Ce(),x=ye(),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 b=d.useMemo(()=>s?t.filter(h=>h.topic.startsWith(s)):t,[t,s]),E=it({count:b.length,getScrollElement:()=>p.current,estimateSize:()=>52,overscan:20});d.useEffect(()=>{U&&b.length>0&&!r&&E.scrollToIndex(b.length-1,{align:"end"})},[b.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(dt,{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"]})]}),Z=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(ut,{"data-slot":"icon",className:"!w-4 !h-4"}):e.jsx(mt,{"data-slot":"icon",className:"!w-4 !h-4"})}),e.jsx(te,{plain:!0,onClick:i,title:"Clear messages",children:e.jsx(ht,{"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(pt,{className:"icon-sm"}),title:"Messages",listHeader:!0,titleExtra:z,actions:Z}),e.jsx("div",{ref:p,onScroll:j,className:"flex-1 overflow-y-auto min-h-0",children:b.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(It,{msg:b[h.index]})},h.key))})})]})}const Kt=/^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)Kt.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 Ft(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 zt=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 Vt(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 Wt=[25,50,100,250];function $t({topicFilter:s=""}){const t=Le(),r=ye(),[l,i]=d.useState(""),[a,x]=d.useState(null),[p,U]=d.useState(50),[v,L]=d.useState(50),P=d.useMemo(()=>Vt(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(()=>Ft(m),[m]),b=d.useMemo(()=>m.map(n=>({obs:n,parsed:Ie(n.firmwareVersion)})),[m]),E=d.useMemo(()=>{if(!l)return m;const n=l.toLowerCase();return b.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,b,l]),j=d.useMemo(()=>E.slice(0,v),[E,v]),F=E.length>v,z=d.useCallback(n=>{U(n),L(n)},[]),Z=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(ve,{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(ve,{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(xt,{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=>Z(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:Wt.map(n=>e.jsxs(fe,{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(ge,{span:12,sm:6,lg:4,xl:3,children:e.jsx(zt,{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 Zt={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"}],we=["24h","3d","7d","14d"];function Jt(){const s=O(u=>u.url),t=O(u=>u.port),r=O(u=>u.username),l=O(u=>u.password),i=Ze(),a=Ye(),x=Me(),p=Je(),U=Xe(),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),b=O(u=>u.setPassword),E=O(u=>u.connect),j=O(u=>u.disconnect),F=O(u=>u.startPolling),z=O(u=>u.stopPolling),Z=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=we.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=>b(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(je,{"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:Zt[i]??"zinc",children:i}),(h||f)&&x>0&&e.jsxs("span",{className:"type-data-xs text-fg-muted tabular-nums",children:[e.jsx(Ne,{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(je,{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(Ne,{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=we.indexOf(u)<=V,w=qe.has(u);return e.jsx("button",{onClick:()=>!c&&!w&&void Z(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 Xt(){try{if(localStorage.getItem(Ge)==="http")return"http"}catch{}return"mqtt"}function _t(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 js(){const[s,t]=d.useState(""),[r,l]=d.useState(Xt),i=N(j=>j.status),a=Ce(),x=N(j=>j.stopMqttMode),p=Qe(),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),_t(j)},[]),m=a.active||i==="connected"||p,A=r==="http",b=A?"External Database":"MQTT Subscription",E=A?e.jsx(me,{}):e.jsx(ke,{});return e.jsxs(tt,{children:[e.jsxs("div",{className:"relative",style:{isolation:"isolate"},children:[e.jsx(st,{title:b,icon:E,subtitle:A?e.jsxs("div",{className:"flex items-start gap-2 max-w-2xl",children:[e.jsx(Ne,{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(et,{className:"w-3.5 h-3.5 text-sys-amber shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs leading-relaxed text-fg-muted",children:"Use an external MQTT broker to feed packets into pymc_console. Limited to live sessions only — does not overwrite pyMC_Repeater database or interfere with its operation. Hard refresh or clearing session cache will clear MQTT data. 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(at,{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(Jt,{})})}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{template:"auto",children:e.jsx(Q,{compact:!0,children:e.jsx(Tt,{})})}),e.jsxs(ue,{template:"hero-tall",children:[e.jsx(ge,{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(Dt,{onTopicSelect:P,selectedTopic:s})})]})}),e.jsx(ge,{span:12,md:8,children:e.jsx(Q,{noPadding:!0,children:e.jsx(Ht,{topicFilter:s})})})]}),i==="connected"&&e.jsx($t,{topicFilter:s})]})]})]})}export{js as default}; diff --git a/frontend/dist/assets/MqttModeBadge-DOXwpg3i.js b/frontend/dist/assets/MqttModeBadge-BtcQeS2v.js similarity index 60% rename from frontend/dist/assets/MqttModeBadge-DOXwpg3i.js rename to frontend/dist/assets/MqttModeBadge-BtcQeS2v.js index c10755bd..34c4c4cf 100644 --- a/frontend/dist/assets/MqttModeBadge-DOXwpg3i.js +++ b/frontend/dist/assets/MqttModeBadge-BtcQeS2v.js @@ -1,6 +1,6 @@ -import{aX as Le,bi as ve,d0 as qe,d1 as xe,aZ as Qe,aY as Z,r as l,b0 as Ve,b1 as ee,b5 as U,b4 as z,aT as I,b8 as Q,d2 as se,d3 as _e,bd as Ye,be as He,bj as Ke,bf as re,bk as We,bg as me,d4 as je,d5 as V,d6 as A,d7 as G,d8 as he,d9 as Pe,bh as le,bu as C,da as ye,db as ge,bl as we,bs as Xe,bm as Te,bn as Ee,bo as J,bp as Ze,bq as Ue,bt as Fe,dc as ze,dd as Oe,bv as Je,de as et,df as tt,bw as ke,dg as nt,dh as at,di as ot,aU as st,dj as rt,bC as lt,dk as ut,dl as it,dm as Ne,bE as ct,bG as ce,e as dt,j as x,c as M,d as pt,m as ft,cZ as bt,dn as vt,u as mt,V as ht,aa as Ie}from"./index-C2xvS0Jd.js";import{C as yt}from"./chevron-right-C9GG0xWI.js";import{F as gt,y as xt,R as Pt,T as $t,w as St,A as Ct}from"./map-pin-CQk00ph2.js";var wt=Object.defineProperty,kt=(e,n,t)=>n in e?wt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Be=(e,n,t)=>(kt(e,typeof n!="symbol"?n+"":n,t),t),P=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(P||{}),It=(e=>(e[e.OpenPopover=0]="OpenPopover",e[e.ClosePopover=1]="ClosePopover",e[e.SetButton=2]="SetButton",e[e.SetButtonId=3]="SetButtonId",e[e.SetPanel=4]="SetPanel",e[e.SetPanelId=5]="SetPanelId",e))(It||{});let Bt={0:e=>e.popoverState===0?e:{...e,popoverState:0,__demoMode:!1},1(e){return e.popoverState===1?e:{...e,popoverState:1,__demoMode:!1}},2(e,n){return e.button===n.button?e:{...e,button:n.button}},3(e,n){return e.buttonId===n.buttonId?e:{...e,buttonId:n.buttonId}},4(e,n){return e.panel===n.panel?e:{...e,panel:n.panel}},5(e,n){return e.panelId===n.panelId?e:{...e,panelId:n.panelId}}};class $e extends Le{constructor(n){super(n),Be(this,"actions",{close:()=>this.send({type:1}),refocusableClose:t=>{this.actions.close();let f=t?ve(t)?t:"current"in t&&ve(t.current)?t.current:this.state.button:this.state.button;f==null||f.focus()},open:()=>this.send({type:0}),setButtonId:t=>this.send({type:3,buttonId:t}),setButton:t=>this.send({type:2,button:t}),setPanelId:t=>this.send({type:5,panelId:t}),setPanel:t=>this.send({type:4,panel:t})}),Be(this,"selectors",{isPortalled:t=>{var f;if(!t.button||!t.panel)return!1;let m=(f=qe(t.button))!=null?f:document;for(let $ of m.querySelectorAll("body > *"))if(Number($==null?void 0:$.contains(t.button))^Number($==null?void 0:$.contains(t.panel)))return!0;let i=xe(m),r=i.indexOf(t.button),a=(r+i.length-1)%i.length,S=(r+1)%i.length,y=i[a],s=i[S];return!t.panel.contains(y)&&!t.panel.contains(s)}});{let t=this.state.id,f=Qe.get(null);this.on(0,()=>f.actions.push(t)),this.on(1,()=>f.actions.pop(t))}}static new({id:n,__demoMode:t=!1}){return new $e({id:n,__demoMode:t,popoverState:t?0:1,buttons:{current:[]},button:null,buttonId:null,panel:null,panelId:null,beforePanelSentinel:{current:null},afterPanelSentinel:{current:null},afterButtonSentinel:{current:null}})}reduce(n,t){return Z(t.type,Bt,n,t)}}const Me=l.createContext(null);function de(e){let n=l.useContext(Me);if(n===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,de),t}return n}function _t({id:e,__demoMode:n=!1}){let t=l.useMemo(()=>$e.new({id:e,__demoMode:n}),[]);return Ve(()=>t.dispose()),t}let Se=l.createContext(null);Se.displayName="PopoverGroupContext";function De(){return l.useContext(Se)}let pe=l.createContext(null);pe.displayName="PopoverPanelContext";function jt(){return l.useContext(pe)}let Tt="div";function Et(e,n){var t;let f=l.useId(),{__demoMode:m=!1,...i}=e,r=_t({id:f,__demoMode:m}),a=l.useRef(null),S=z(n,et(u=>{a.current=u})),[y,s,$,w,B]=U(r,l.useCallback(u=>[u.popoverState,u.button,u.panel,u.buttonId,u.panelId],[])),k=tt((t=a.current)!=null?t:s),b=ke(w),p=ke(B),v=l.useMemo(()=>({buttonId:b,panelId:p,close:r.actions.close}),[b,p,r]),g=De(),c=g==null?void 0:g.registerPopover,_=I(()=>{var u,j;let E=se((u=a.current)!=null?u:s);return(j=g==null?void 0:g.isFocusWithinPopoverGroup())!=null?j:E&&((s==null?void 0:s.contains(E))||($==null?void 0:$.contains(E)))});l.useEffect(()=>c==null?void 0:c(v),[c,v]);let[te,ne]=nt(),L=at(s),D=ot({mainTreeNode:L,portals:te,defaultContainers:[{get current(){return r.state.button}},{get current(){return r.state.panel}}]});st(k,"focus",u=>{var j,E,O,W,N,X;u.target!==window&&rt(u.target)&&r.state.popoverState===P.Open&&(_()||r.state.button&&r.state.panel&&(D.contains(u.target)||(E=(j=r.state.beforePanelSentinel.current)==null?void 0:j.contains)!=null&&E.call(j,u.target)||(W=(O=r.state.afterPanelSentinel.current)==null?void 0:O.contains)!=null&&W.call(O,u.target)||(X=(N=r.state.afterButtonSentinel.current)==null?void 0:N.contains)!=null&&X.call(N,u.target)||r.actions.close()))},!0);let Y=y===P.Open;lt(Y,D.resolveContainers,(u,j)=>{r.actions.close(),ut(j,it.Loose)||(u.preventDefault(),s==null||s.focus())});let ae=re({open:y===P.Open,close:r.actions.refocusableClose}),oe=U(r,l.useCallback(u=>Z(u.popoverState,{[P.Open]:J.Open,[P.Closed]:J.Closed}),[])),H={ref:S},K=le();return C.createElement(Ne,{node:L},C.createElement(Ct,null,C.createElement(pe.Provider,{value:null},C.createElement(Me.Provider,{value:r},C.createElement(Oe,{value:r.actions.refocusableClose},C.createElement(ct,{value:oe},C.createElement(ne,null,K({ourProps:H,theirProps:i,slot:ae,defaultTag:Tt,name:"Popover"}))))))))}let Ft="button";function Ot(e,n){let t=l.useId(),{id:f=`headlessui-popover-button-${t}`,disabled:m=!1,autoFocus:i=!1,...r}=e,a=de("Popover.Button"),[S,y,s,$,w,B,k]=U(a,l.useCallback(o=>[o.popoverState,a.selectors.isPortalled(o),o.button,o.buttonId,o.panel,o.panelId,o.afterButtonSentinel],[])),b=l.useRef(null),p=`headlessui-focus-sentinel-${l.useId()}`,v=De(),g=v==null?void 0:v.closeOthers,c=jt()!==null;l.useEffect(()=>{if(!c)return a.actions.setButtonId(f),()=>a.actions.setButtonId(null)},[c,f,a]);let[_]=l.useState(()=>Symbol()),te=z(b,n,gt(),I(o=>{if(!c){if(o)a.state.buttons.current.push(_);else{let d=a.state.buttons.current.indexOf(_);d!==-1&&a.state.buttons.current.splice(d,1)}a.state.buttons.current.length>1&&console.warn("You are already using a but only 1 is supported."),o&&a.actions.setButton(o)}})),ne=z(b,n),L=I(o=>{var d,T,F;if(c){if(a.state.popoverState===P.Closed)return;switch(o.key){case Q.Space:case Q.Enter:o.preventDefault(),(T=(d=o.target).click)==null||T.call(d),a.actions.close(),(F=a.state.button)==null||F.focus();break}}else switch(o.key){case Q.Space:case Q.Enter:o.preventDefault(),o.stopPropagation(),a.state.popoverState===P.Closed?(g==null||g(a.state.buttonId),a.actions.open()):a.actions.close();break;case Q.Escape:if(a.state.popoverState!==P.Open)return g==null?void 0:g(a.state.buttonId);if(!b.current)return;let R=se(b.current);if(R&&!b.current.contains(R))return;o.preventDefault(),o.stopPropagation(),a.actions.close();break}}),D=I(o=>{c||o.key===Q.Space&&o.preventDefault()}),Y=I(o=>{var d,T;_e(o.currentTarget)||m||(c?(a.actions.close(),(d=a.state.button)==null||d.focus()):(o.preventDefault(),o.stopPropagation(),a.state.popoverState===P.Closed?(g==null||g(a.state.buttonId),a.actions.open()):a.actions.close(),(T=a.state.button)==null||T.focus()))}),ae=I(o=>{o.preventDefault(),o.stopPropagation()}),{isFocusVisible:oe,focusProps:H}=Ye({autoFocus:i}),{isHovered:K,hoverProps:u}=He({isDisabled:m}),{pressed:j,pressProps:E}=Ke({disabled:m}),O=S===P.Open,W=re({open:O,active:j||O,disabled:m,hover:K,focus:oe,autofocus:i}),N=We(e,s),X=c?me({ref:ne,type:N,onKeyDown:L,onClick:Y,disabled:m||void 0,autoFocus:i},H,u,E):me({ref:te,id:$,type:N,"aria-expanded":S===P.Open,"aria-controls":w?B:void 0,disabled:m||void 0,autoFocus:i,onKeyDown:L,onKeyUp:D,onClick:Y,onMouseDown:ae},H,u,E),ue=je(),fe=I(()=>{if(!ve(a.state.panel))return;let o=a.state.panel;function d(){Z(ue.current,{[A.Forwards]:()=>V(o,G.First),[A.Backwards]:()=>V(o,G.Last)})===he.Error&&V(xe(Pe(a.state.button)).filter(T=>T.dataset.headlessuiFocusGuard!=="true"),Z(ue.current,{[A.Forwards]:G.Next,[A.Backwards]:G.Previous}),{relativeTo:a.state.button})}d()}),h=le();return C.createElement(C.Fragment,null,h({ourProps:X,theirProps:r,slot:W,defaultTag:Ft,name:"Popover.Button"}),O&&!c&&y&&C.createElement(ye,{id:p,ref:k,features:ge.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:fe}))}let Nt="div",Mt=ce.RenderStrategy|ce.Static;function Re(e,n){let t=l.useId(),{id:f=`headlessui-popover-backdrop-${t}`,transition:m=!1,...i}=e,r=de("Popover.Backdrop"),a=U(r,l.useCallback(v=>v.popoverState,[])),[S,y]=l.useState(null),s=z(n,y),$=Te(),[w,B]=Ee(m,S,$!==null?($&J.Open)===J.Open:a===P.Open),k=I(v=>{if(_e(v.currentTarget))return v.preventDefault();r.actions.close()}),b=re({open:a===P.Open}),p={ref:s,id:f,"aria-hidden":!0,onClick:k,...Fe(B)};return le()({ourProps:p,theirProps:i,slot:b,defaultTag:Nt,features:Mt,visible:w,name:"Popover.Backdrop"})}let Dt="div",Rt=ce.RenderStrategy|ce.Static;function At(e,n){let t=l.useId(),{id:f=`headlessui-popover-panel-${t}`,focus:m=!1,anchor:i,portal:r=!1,modal:a=!1,transition:S=!1,...y}=e,s=de("Popover.Panel"),$=U(s,s.selectors.isPortalled),[w,B,k,b,p]=U(s,l.useCallback(h=>[h.popoverState,h.button,h.__demoMode,h.beforePanelSentinel,h.afterPanelSentinel],[])),v=`headlessui-focus-sentinel-before-${t}`,g=`headlessui-focus-sentinel-after-${t}`,c=l.useRef(null),_=xt(i),[te,ne]=Pt(_),L=$t();_&&(r=!0);let[D,Y]=l.useState(null),ae=z(c,n,_?te:null,s.actions.setPanel,Y),oe=we(B),H=we(c.current);Xe(()=>(s.actions.setPanelId(f),()=>s.actions.setPanelId(null)),[f,s]);let K=Te(),[u,j]=Ee(S,D,K!==null?(K&J.Open)===J.Open:w===P.Open);Ze(u,B,s.actions.close),Ue(k?!1:a&&u,H);let E=I(h=>{var o;switch(h.key){case Q.Escape:if(s.state.popoverState!==P.Open||!c.current)return;let d=se(c.current);if(d&&!c.current.contains(d))return;h.preventDefault(),h.stopPropagation(),s.actions.close(),(o=s.state.button)==null||o.focus();break}});l.useEffect(()=>{var h;e.static||w===P.Closed&&((h=e.unmount)==null||h)&&s.actions.setPanel(null)},[w,e.unmount,e.static,s]),l.useEffect(()=>{if(k||!m||w!==P.Open||!c.current)return;let h=se(c.current);c.current.contains(h)||V(c.current,G.First)},[k,m,c.current,w]);let O=re({open:w===P.Open,close:s.actions.refocusableClose}),W=me(_?L():{},{ref:ae,id:f,onKeyDown:E,onBlur:m&&w===P.Open?h=>{var o,d,T,F,R;let q=h.relatedTarget;q&&c.current&&((o=c.current)!=null&&o.contains(q)||(s.actions.close(),((T=(d=b.current)==null?void 0:d.contains)!=null&&T.call(d,q)||(R=(F=p.current)==null?void 0:F.contains)!=null&&R.call(F,q))&&q.focus({preventScroll:!0})))}:void 0,tabIndex:-1,style:{...y.style,...ne,"--button-width":St(u,B,!0).width},...Fe(j)}),N=je(),X=I(()=>{let h=c.current;if(!h)return;function o(){Z(N.current,{[A.Forwards]:()=>{var d;V(h,G.First)===he.Error&&((d=s.state.afterPanelSentinel.current)==null||d.focus())},[A.Backwards]:()=>{var d;(d=s.state.button)==null||d.focus({preventScroll:!0})}})}o()}),ue=I(()=>{let h=c.current;if(!h)return;function o(){Z(N.current,{[A.Forwards]:()=>{var d;if(!s.state.button)return;let T=(d=Pe(s.state.button))!=null?d:document.body,F=xe(T),R=F.indexOf(s.state.button),q=F.slice(0,R+1),ie=[...F.slice(R+1),...q];for(let be of ie.slice())if(be.dataset.headlessuiFocusGuard==="true"||D!=null&&D.contains(be)){let Ce=ie.indexOf(be);Ce!==-1&&ie.splice(Ce,1)}V(ie,G.First,{sorted:!1})},[A.Backwards]:()=>{var d;V(h,G.Previous)===he.Error&&((d=s.state.button)==null||d.focus())}})}o()}),fe=le();return C.createElement(ze,null,C.createElement(pe.Provider,{value:f},C.createElement(Oe,{value:s.actions.refocusableClose},C.createElement(Je,{enabled:r?e.static||u:!1,ownerDocument:oe},u&&$&&C.createElement(ye,{id:v,ref:b,features:ge.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:X}),fe({ourProps:W,theirProps:y,slot:O,defaultTag:Dt,features:Rt,visible:u,name:"Popover.Panel"}),u&&$&&C.createElement(ye,{id:g,ref:p,features:ge.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:ue})))))}let Gt="div";function Lt(e,n){let t=l.useRef(null),f=z(t,n),[m,i]=l.useState([]),r=I(b=>{i(p=>{let v=p.indexOf(b);if(v!==-1){let g=p.slice();return g.splice(v,1),g}return p})}),a=I(b=>(i(p=>[...p,b]),()=>r(b))),S=I(()=>{var b;let p=Pe(t.current);if(!p)return!1;let v=se(t.current);return(b=t.current)!=null&&b.contains(v)?!0:m.some(g=>{var c,_;return((c=p.getElementById(g.buttonId.current))==null?void 0:c.contains(v))||((_=p.getElementById(g.panelId.current))==null?void 0:_.contains(v))})}),y=I(b=>{for(let p of m)p.buttonId.current!==b&&p.close()}),s=l.useMemo(()=>({registerPopover:a,unregisterPopover:r,isFocusWithinPopoverGroup:S,closeOthers:y}),[a,r,S,y]),$=re({}),w=e,B={ref:f},k=le();return C.createElement(Ne,null,C.createElement(Se.Provider,{value:s},k({ourProps:B,theirProps:w,slot:$,defaultTag:Gt,name:"Popover.Group"})))}let qt=ee(Et),Ae=ee(Ot),Qt=ee(Re),Vt=ee(Re),Ge=ee(At),Yt=ee(Lt),Ht=Object.assign(qt,{Button:Ae,Backdrop:Vt,Overlay:Qt,Panel:Ge,Group:Yt});/** +import{aY as Le,bj as ve,d1 as qe,d2 as ge,a_ as Ve,aZ as Z,r as l,b1 as He,b2 as ee,b6 as U,b5 as z,aU as I,b9 as V,d3 as se,d4 as _e,be as Qe,bf as Ye,bk as Ke,bg as re,bl as We,bh as me,d5 as je,d6 as H,d7 as A,d8 as G,d9 as he,da as Pe,bi as le,bv as C,db as ye,dc as xe,bm as we,bt as Xe,bn as Fe,bo as Oe,bp as J,bq as Ze,br as Ue,bu as Te,dd as ze,de as Ee,bw as Je,df as et,dg as tt,bx as ke,dh as nt,di as at,dj as ot,aV as st,dk as rt,bD as lt,dl as ut,dm as it,dn as Ne,bF as ct,bH as ce,e as dt,j as g,c as M,d as pt,m as ft,c_ as bt,dp as vt,u as mt,V as ht,aa as Ie}from"./index-D33fcA3L.js";import{C as yt}from"./chevron-right-D4kUPDBw.js";import{F as xt,y as gt,R as Pt,T as $t,w as St,A as Ct}from"./map-pin-B_Rx-xpd.js";var wt=Object.defineProperty,kt=(e,n,t)=>n in e?wt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Be=(e,n,t)=>(kt(e,typeof n!="symbol"?n+"":n,t),t),P=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(P||{}),It=(e=>(e[e.OpenPopover=0]="OpenPopover",e[e.ClosePopover=1]="ClosePopover",e[e.SetButton=2]="SetButton",e[e.SetButtonId=3]="SetButtonId",e[e.SetPanel=4]="SetPanel",e[e.SetPanelId=5]="SetPanelId",e))(It||{});let Bt={0:e=>e.popoverState===0?e:{...e,popoverState:0,__demoMode:!1},1(e){return e.popoverState===1?e:{...e,popoverState:1,__demoMode:!1}},2(e,n){return e.button===n.button?e:{...e,button:n.button}},3(e,n){return e.buttonId===n.buttonId?e:{...e,buttonId:n.buttonId}},4(e,n){return e.panel===n.panel?e:{...e,panel:n.panel}},5(e,n){return e.panelId===n.panelId?e:{...e,panelId:n.panelId}}};class $e extends Le{constructor(n){super(n),Be(this,"actions",{close:()=>this.send({type:1}),refocusableClose:t=>{this.actions.close();let f=t?ve(t)?t:"current"in t&&ve(t.current)?t.current:this.state.button:this.state.button;f==null||f.focus()},open:()=>this.send({type:0}),setButtonId:t=>this.send({type:3,buttonId:t}),setButton:t=>this.send({type:2,button:t}),setPanelId:t=>this.send({type:5,panelId:t}),setPanel:t=>this.send({type:4,panel:t})}),Be(this,"selectors",{isPortalled:t=>{var f;if(!t.button||!t.panel)return!1;let m=(f=qe(t.button))!=null?f:document;for(let $ of m.querySelectorAll("body > *"))if(Number($==null?void 0:$.contains(t.button))^Number($==null?void 0:$.contains(t.panel)))return!0;let i=ge(m),r=i.indexOf(t.button),a=(r+i.length-1)%i.length,S=(r+1)%i.length,y=i[a],s=i[S];return!t.panel.contains(y)&&!t.panel.contains(s)}});{let t=this.state.id,f=Ve.get(null);this.on(0,()=>f.actions.push(t)),this.on(1,()=>f.actions.pop(t))}}static new({id:n,__demoMode:t=!1}){return new $e({id:n,__demoMode:t,popoverState:t?0:1,buttons:{current:[]},button:null,buttonId:null,panel:null,panelId:null,beforePanelSentinel:{current:null},afterPanelSentinel:{current:null},afterButtonSentinel:{current:null}})}reduce(n,t){return Z(t.type,Bt,n,t)}}const Me=l.createContext(null);function de(e){let n=l.useContext(Me);if(n===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,de),t}return n}function _t({id:e,__demoMode:n=!1}){let t=l.useMemo(()=>$e.new({id:e,__demoMode:n}),[]);return He(()=>t.dispose()),t}let Se=l.createContext(null);Se.displayName="PopoverGroupContext";function De(){return l.useContext(Se)}let pe=l.createContext(null);pe.displayName="PopoverPanelContext";function jt(){return l.useContext(pe)}let Ft="div";function Ot(e,n){var t;let f=l.useId(),{__demoMode:m=!1,...i}=e,r=_t({id:f,__demoMode:m}),a=l.useRef(null),S=z(n,et(u=>{a.current=u})),[y,s,$,w,B]=U(r,l.useCallback(u=>[u.popoverState,u.button,u.panel,u.buttonId,u.panelId],[])),k=tt((t=a.current)!=null?t:s),b=ke(w),p=ke(B),v=l.useMemo(()=>({buttonId:b,panelId:p,close:r.actions.close}),[b,p,r]),x=De(),c=x==null?void 0:x.registerPopover,_=I(()=>{var u,j;let O=se((u=a.current)!=null?u:s);return(j=x==null?void 0:x.isFocusWithinPopoverGroup())!=null?j:O&&((s==null?void 0:s.contains(O))||($==null?void 0:$.contains(O)))});l.useEffect(()=>c==null?void 0:c(v),[c,v]);let[te,ne]=nt(),L=at(s),D=ot({mainTreeNode:L,portals:te,defaultContainers:[{get current(){return r.state.button}},{get current(){return r.state.panel}}]});st(k,"focus",u=>{var j,O,E,W,N,X;u.target!==window&&rt(u.target)&&r.state.popoverState===P.Open&&(_()||r.state.button&&r.state.panel&&(D.contains(u.target)||(O=(j=r.state.beforePanelSentinel.current)==null?void 0:j.contains)!=null&&O.call(j,u.target)||(W=(E=r.state.afterPanelSentinel.current)==null?void 0:E.contains)!=null&&W.call(E,u.target)||(X=(N=r.state.afterButtonSentinel.current)==null?void 0:N.contains)!=null&&X.call(N,u.target)||r.actions.close()))},!0);let Q=y===P.Open;lt(Q,D.resolveContainers,(u,j)=>{r.actions.close(),ut(j,it.Loose)||(u.preventDefault(),s==null||s.focus())});let ae=re({open:y===P.Open,close:r.actions.refocusableClose}),oe=U(r,l.useCallback(u=>Z(u.popoverState,{[P.Open]:J.Open,[P.Closed]:J.Closed}),[])),Y={ref:S},K=le();return C.createElement(Ne,{node:L},C.createElement(Ct,null,C.createElement(pe.Provider,{value:null},C.createElement(Me.Provider,{value:r},C.createElement(Ee,{value:r.actions.refocusableClose},C.createElement(ct,{value:oe},C.createElement(ne,null,K({ourProps:Y,theirProps:i,slot:ae,defaultTag:Ft,name:"Popover"}))))))))}let Tt="button";function Et(e,n){let t=l.useId(),{id:f=`headlessui-popover-button-${t}`,disabled:m=!1,autoFocus:i=!1,...r}=e,a=de("Popover.Button"),[S,y,s,$,w,B,k]=U(a,l.useCallback(o=>[o.popoverState,a.selectors.isPortalled(o),o.button,o.buttonId,o.panel,o.panelId,o.afterButtonSentinel],[])),b=l.useRef(null),p=`headlessui-focus-sentinel-${l.useId()}`,v=De(),x=v==null?void 0:v.closeOthers,c=jt()!==null;l.useEffect(()=>{if(!c)return a.actions.setButtonId(f),()=>a.actions.setButtonId(null)},[c,f,a]);let[_]=l.useState(()=>Symbol()),te=z(b,n,xt(),I(o=>{if(!c){if(o)a.state.buttons.current.push(_);else{let d=a.state.buttons.current.indexOf(_);d!==-1&&a.state.buttons.current.splice(d,1)}a.state.buttons.current.length>1&&console.warn("You are already using a but only 1 is supported."),o&&a.actions.setButton(o)}})),ne=z(b,n),L=I(o=>{var d,F,T;if(c){if(a.state.popoverState===P.Closed)return;switch(o.key){case V.Space:case V.Enter:o.preventDefault(),(F=(d=o.target).click)==null||F.call(d),a.actions.close(),(T=a.state.button)==null||T.focus();break}}else switch(o.key){case V.Space:case V.Enter:o.preventDefault(),o.stopPropagation(),a.state.popoverState===P.Closed?(x==null||x(a.state.buttonId),a.actions.open()):a.actions.close();break;case V.Escape:if(a.state.popoverState!==P.Open)return x==null?void 0:x(a.state.buttonId);if(!b.current)return;let R=se(b.current);if(R&&!b.current.contains(R))return;o.preventDefault(),o.stopPropagation(),a.actions.close();break}}),D=I(o=>{c||o.key===V.Space&&o.preventDefault()}),Q=I(o=>{var d,F;_e(o.currentTarget)||m||(c?(a.actions.close(),(d=a.state.button)==null||d.focus()):(o.preventDefault(),o.stopPropagation(),a.state.popoverState===P.Closed?(x==null||x(a.state.buttonId),a.actions.open()):a.actions.close(),(F=a.state.button)==null||F.focus()))}),ae=I(o=>{o.preventDefault(),o.stopPropagation()}),{isFocusVisible:oe,focusProps:Y}=Qe({autoFocus:i}),{isHovered:K,hoverProps:u}=Ye({isDisabled:m}),{pressed:j,pressProps:O}=Ke({disabled:m}),E=S===P.Open,W=re({open:E,active:j||E,disabled:m,hover:K,focus:oe,autofocus:i}),N=We(e,s),X=c?me({ref:ne,type:N,onKeyDown:L,onClick:Q,disabled:m||void 0,autoFocus:i},Y,u,O):me({ref:te,id:$,type:N,"aria-expanded":S===P.Open,"aria-controls":w?B:void 0,disabled:m||void 0,autoFocus:i,onKeyDown:L,onKeyUp:D,onClick:Q,onMouseDown:ae},Y,u,O),ue=je(),fe=I(()=>{if(!ve(a.state.panel))return;let o=a.state.panel;function d(){Z(ue.current,{[A.Forwards]:()=>H(o,G.First),[A.Backwards]:()=>H(o,G.Last)})===he.Error&&H(ge(Pe(a.state.button)).filter(F=>F.dataset.headlessuiFocusGuard!=="true"),Z(ue.current,{[A.Forwards]:G.Next,[A.Backwards]:G.Previous}),{relativeTo:a.state.button})}d()}),h=le();return C.createElement(C.Fragment,null,h({ourProps:X,theirProps:r,slot:W,defaultTag:Tt,name:"Popover.Button"}),E&&!c&&y&&C.createElement(ye,{id:p,ref:k,features:xe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:fe}))}let Nt="div",Mt=ce.RenderStrategy|ce.Static;function Re(e,n){let t=l.useId(),{id:f=`headlessui-popover-backdrop-${t}`,transition:m=!1,...i}=e,r=de("Popover.Backdrop"),a=U(r,l.useCallback(v=>v.popoverState,[])),[S,y]=l.useState(null),s=z(n,y),$=Fe(),[w,B]=Oe(m,S,$!==null?($&J.Open)===J.Open:a===P.Open),k=I(v=>{if(_e(v.currentTarget))return v.preventDefault();r.actions.close()}),b=re({open:a===P.Open}),p={ref:s,id:f,"aria-hidden":!0,onClick:k,...Te(B)};return le()({ourProps:p,theirProps:i,slot:b,defaultTag:Nt,features:Mt,visible:w,name:"Popover.Backdrop"})}let Dt="div",Rt=ce.RenderStrategy|ce.Static;function At(e,n){let t=l.useId(),{id:f=`headlessui-popover-panel-${t}`,focus:m=!1,anchor:i,portal:r=!1,modal:a=!1,transition:S=!1,...y}=e,s=de("Popover.Panel"),$=U(s,s.selectors.isPortalled),[w,B,k,b,p]=U(s,l.useCallback(h=>[h.popoverState,h.button,h.__demoMode,h.beforePanelSentinel,h.afterPanelSentinel],[])),v=`headlessui-focus-sentinel-before-${t}`,x=`headlessui-focus-sentinel-after-${t}`,c=l.useRef(null),_=gt(i),[te,ne]=Pt(_),L=$t();_&&(r=!0);let[D,Q]=l.useState(null),ae=z(c,n,_?te:null,s.actions.setPanel,Q),oe=we(B),Y=we(c.current);Xe(()=>(s.actions.setPanelId(f),()=>s.actions.setPanelId(null)),[f,s]);let K=Fe(),[u,j]=Oe(S,D,K!==null?(K&J.Open)===J.Open:w===P.Open);Ze(u,B,s.actions.close),Ue(k?!1:a&&u,Y);let O=I(h=>{var o;switch(h.key){case V.Escape:if(s.state.popoverState!==P.Open||!c.current)return;let d=se(c.current);if(d&&!c.current.contains(d))return;h.preventDefault(),h.stopPropagation(),s.actions.close(),(o=s.state.button)==null||o.focus();break}});l.useEffect(()=>{var h;e.static||w===P.Closed&&((h=e.unmount)==null||h)&&s.actions.setPanel(null)},[w,e.unmount,e.static,s]),l.useEffect(()=>{if(k||!m||w!==P.Open||!c.current)return;let h=se(c.current);c.current.contains(h)||H(c.current,G.First)},[k,m,c.current,w]);let E=re({open:w===P.Open,close:s.actions.refocusableClose}),W=me(_?L():{},{ref:ae,id:f,onKeyDown:O,onBlur:m&&w===P.Open?h=>{var o,d,F,T,R;let q=h.relatedTarget;q&&c.current&&((o=c.current)!=null&&o.contains(q)||(s.actions.close(),((F=(d=b.current)==null?void 0:d.contains)!=null&&F.call(d,q)||(R=(T=p.current)==null?void 0:T.contains)!=null&&R.call(T,q))&&q.focus({preventScroll:!0})))}:void 0,tabIndex:-1,style:{...y.style,...ne,"--button-width":St(u,B,!0).width},...Te(j)}),N=je(),X=I(()=>{let h=c.current;if(!h)return;function o(){Z(N.current,{[A.Forwards]:()=>{var d;H(h,G.First)===he.Error&&((d=s.state.afterPanelSentinel.current)==null||d.focus())},[A.Backwards]:()=>{var d;(d=s.state.button)==null||d.focus({preventScroll:!0})}})}o()}),ue=I(()=>{let h=c.current;if(!h)return;function o(){Z(N.current,{[A.Forwards]:()=>{var d;if(!s.state.button)return;let F=(d=Pe(s.state.button))!=null?d:document.body,T=ge(F),R=T.indexOf(s.state.button),q=T.slice(0,R+1),ie=[...T.slice(R+1),...q];for(let be of ie.slice())if(be.dataset.headlessuiFocusGuard==="true"||D!=null&&D.contains(be)){let Ce=ie.indexOf(be);Ce!==-1&&ie.splice(Ce,1)}H(ie,G.First,{sorted:!1})},[A.Backwards]:()=>{var d;H(h,G.Previous)===he.Error&&((d=s.state.button)==null||d.focus())}})}o()}),fe=le();return C.createElement(ze,null,C.createElement(pe.Provider,{value:f},C.createElement(Ee,{value:s.actions.refocusableClose},C.createElement(Je,{enabled:r?e.static||u:!1,ownerDocument:oe},u&&$&&C.createElement(ye,{id:v,ref:b,features:xe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:X}),fe({ourProps:W,theirProps:y,slot:E,defaultTag:Dt,features:Rt,visible:u,name:"Popover.Panel"}),u&&$&&C.createElement(ye,{id:x,ref:p,features:xe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:ue})))))}let Gt="div";function Lt(e,n){let t=l.useRef(null),f=z(t,n),[m,i]=l.useState([]),r=I(b=>{i(p=>{let v=p.indexOf(b);if(v!==-1){let x=p.slice();return x.splice(v,1),x}return p})}),a=I(b=>(i(p=>[...p,b]),()=>r(b))),S=I(()=>{var b;let p=Pe(t.current);if(!p)return!1;let v=se(t.current);return(b=t.current)!=null&&b.contains(v)?!0:m.some(x=>{var c,_;return((c=p.getElementById(x.buttonId.current))==null?void 0:c.contains(v))||((_=p.getElementById(x.panelId.current))==null?void 0:_.contains(v))})}),y=I(b=>{for(let p of m)p.buttonId.current!==b&&p.close()}),s=l.useMemo(()=>({registerPopover:a,unregisterPopover:r,isFocusWithinPopoverGroup:S,closeOthers:y}),[a,r,S,y]),$=re({}),w=e,B={ref:f},k=le();return C.createElement(Ne,null,C.createElement(Se.Provider,{value:s},k({ourProps:B,theirProps:w,slot:$,defaultTag:Gt,name:"Popover.Group"})))}let qt=ee(Ot),Ae=ee(Et),Vt=ee(Re),Ht=ee(Re),Ge=ee(At),Qt=ee(Lt),Yt=Object.assign(qt,{Button:Ae,Backdrop:Ht,Overlay:Vt,Panel:Ge,Group:Qt});/** * @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 Kt=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Wt=dt("chevron-left",Kt);function Xt({ranges:e,selectedIndex:n,onSelect:t,isPending:f,size:m="default"}){var B;const i=l.useRef(null),r=n>0,a=n{var v;const p=k==="left"?6:-6;(v=i.current)==null||v.animate([{opacity:1,transform:"translateX(0)"},{opacity:0,transform:`translateX(${p}px)`}],{duration:80,easing:"ease-out"}),setTimeout(()=>{var g;b(),(g=i.current)==null||g.animate([{opacity:0,transform:`translateX(${-p}px)`},{opacity:1,transform:"translateX(0)"}],{duration:80,easing:"ease-out"})},80)},$=()=>r&&s("left",()=>t(n-1)),w=()=>a&&s("right",()=>t(n+1));return x.jsx(Ht,{className:"relative inline-flex",children:({open:k,close:b})=>x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:M("inline-flex items-center rounded-full bg-surface/80 backdrop-blur-lg depth-raised",y?"gap-0.5 p-0.5":"gap-0.5 p-1",f&&"opacity-70"),children:[x.jsx("button",{type:"button",onClick:$,disabled:!r,"aria-label":"Previous",className:M("flex items-center justify-center rounded-full transition-all duration-100","text-fg-muted hover:text-fg-primary active:scale-90","disabled:opacity-25 disabled:pointer-events-none",y?"w-5 h-5":"w-6 h-6"),children:x.jsx(Wt,{className:y?"w-3 h-3":"w-3.5 h-3.5"})}),x.jsx(Ae,{className:M("rounded-full cursor-pointer transition-all","bg-surface shadow-[inset_0_0_0_1.5px_var(--sys-blue)]",y?"px-2.5 py-1":"px-3 py-1.5"),children:x.jsx("span",{ref:i,className:M("block font-semibold text-fg-primary tabular-nums select-none",y?"min-w-[1.5rem] text-[11px]":"min-w-[2rem] text-xs","text-center"),children:S})}),x.jsx("button",{type:"button",onClick:w,disabled:!a,"aria-label":"Next",className:M("flex items-center justify-center rounded-full transition-all duration-100","text-fg-muted hover:text-fg-primary active:scale-90","disabled:opacity-25 disabled:pointer-events-none",y?"w-5 h-5":"w-6 h-6"),children:x.jsx(yt,{className:y?"w-3 h-3":"w-3.5 h-3.5"})})]}),x.jsx(pt,{children:k&&x.jsx(Ge,{static:!0,anchor:"bottom",className:"z-50 mt-2",children:x.jsx(ft.div,{initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:bt.dropdown,className:M("surface-elevated radius-inset p-1","shadow-[var(--neo-outer)]"),children:x.jsx("div",{className:"grid grid-cols-4 gap-0.5",children:e.map((p,v)=>x.jsx("button",{type:"button",onClick:()=>{v!==n&&t(v),b()},className:M("px-2.5 py-1.5 radius-control text-xs font-medium transition-colors",v===n?"shadow-[inset_0_0_0_1.5px_var(--sys-blue)] text-fg-primary":"text-fg-secondary hover:bg-overlay-soft"),children:p.label},p.label))})})})})]})})}const Jt=l.memo(Xt),en=l.memo(function({variant:n="inline",showChannel:t=!0,className:f}){const{active:m,iatas:i}=vt(),r=mt();if(!m)return null;const a=t&&i.length>0?i.length<=3?i.join(", "):`${i.slice(0,2).join(", ")} +${i.length-2}`:null,S=a?`MQTT · ${a}`:"MQTT";return n==="pill"?x.jsx("span",{onClick:()=>r("/mqtt"),className:M("cursor-pointer",f),children:x.jsxs(ht,{color:"cyan",children:[x.jsx(Ie,{className:"w-3 h-3 mr-1"}),S]})}):x.jsxs("span",{className:M("inline-flex items-center gap-1 text-sys-cyan type-data-xs cursor-pointer","hover:text-sys-cyan/80 transition-colors",f),onClick:()=>r("/mqtt"),title:"MQTT mode active — click to manage",children:[x.jsx(Ie,{className:"w-3 h-3"}),x.jsx("span",{className:"font-medium",children:S})]})});export{Wt as C,en as M,Jt as T}; + */const Kt=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Wt=dt("chevron-left",Kt);function Xt({ranges:e,selectedIndex:n,onSelect:t,isPending:f,size:m="default"}){var B;const i=l.useRef(null),r=n>0,a=n{var v;const p=k==="left"?6:-6;(v=i.current)==null||v.animate([{opacity:1,transform:"translateX(0)"},{opacity:0,transform:`translateX(${p}px)`}],{duration:80,easing:"ease-out"}),setTimeout(()=>{var x;b(),(x=i.current)==null||x.animate([{opacity:0,transform:`translateX(${-p}px)`},{opacity:1,transform:"translateX(0)"}],{duration:80,easing:"ease-out"})},80)},$=()=>r&&s("left",()=>t(n-1)),w=()=>a&&s("right",()=>t(n+1));return g.jsx(Yt,{className:"relative inline-flex",children:({open:k,close:b})=>g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:M("inline-flex items-center rounded-full bg-surface/80 backdrop-blur-lg depth-raised",y?"gap-0.5 p-0.5":"gap-0.5 p-1",f&&"opacity-70"),children:[g.jsx("button",{type:"button",onClick:$,disabled:!r,"aria-label":"Previous",className:M("flex items-center justify-center rounded-full transition-all duration-100","text-fg-muted hover:text-fg-primary active:scale-90","disabled:opacity-25 disabled:pointer-events-none",y?"w-5 h-5":"w-6 h-6"),children:g.jsx(Wt,{className:y?"w-3 h-3":"w-3.5 h-3.5"})}),g.jsx(Ae,{className:M("rounded-full cursor-pointer transition-all","bg-surface shadow-[inset_0_0_0_1.5px_var(--sys-blue)]",y?"px-2.5 py-1":"px-3 py-1.5"),children:g.jsx("span",{ref:i,className:M("block font-semibold text-fg-primary tabular-nums select-none",y?"min-w-[1.5rem] text-[11px]":"min-w-[2rem] text-xs","text-center"),children:S})}),g.jsx("button",{type:"button",onClick:w,disabled:!a,"aria-label":"Next",className:M("flex items-center justify-center rounded-full transition-all duration-100","text-fg-muted hover:text-fg-primary active:scale-90","disabled:opacity-25 disabled:pointer-events-none",y?"w-5 h-5":"w-6 h-6"),children:g.jsx(yt,{className:y?"w-3 h-3":"w-3.5 h-3.5"})})]}),g.jsx(pt,{children:k&&g.jsx(Ge,{static:!0,anchor:"bottom",className:"z-50 mt-2",children:g.jsx(ft.div,{initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:bt.dropdown,className:M("surface-elevated radius-inset p-1","shadow-[var(--neo-outer)]"),children:g.jsx("div",{className:"grid grid-cols-4 gap-0.5",children:e.map((p,v)=>g.jsx("button",{type:"button",onClick:()=>{v!==n&&t(v),b()},className:M("px-2.5 py-1.5 radius-control text-xs font-medium transition-colors",v===n?"shadow-[inset_0_0_0_1.5px_var(--sys-blue)] text-fg-primary":"text-fg-secondary hover:bg-overlay-soft"),children:p.label},p.label))})})})})]})})}const Jt=l.memo(Xt),en=l.memo(function({variant:n="inline",showChannel:t=!0,className:f}){const{active:m,iatas:i}=vt(),r=mt();if(!m)return null;const a=t&&i.length>0?i.length<=3?i.join(", "):`${i.slice(0,2).join(", ")} +${i.length-2}`:null,S=a?`MQTT · ${a}`:"MQTT";return n==="pill"?g.jsx("span",{onClick:()=>r("/mqtt"),className:M("cursor-pointer",f),children:g.jsxs(ht,{color:"cyan",children:[g.jsx(Ie,{className:"w-3 h-3 mr-1"}),S]})}):g.jsxs("span",{className:M("inline-flex items-center gap-1 text-sys-cyan type-data-xs cursor-pointer","hover:text-sys-cyan/80 transition-colors",f),onClick:()=>r("/mqtt"),title:"MQTT mode active — click to manage",children:[g.jsx(Ie,{className:"w-3 h-3"}),g.jsx("span",{className:"font-medium",children:S})]})});export{Wt as C,en as M,Jt as T}; diff --git a/frontend/dist/assets/PacketList-BlTe2eo4.js b/frontend/dist/assets/PacketList-CbRsdi2q.js similarity index 95% rename from frontend/dist/assets/PacketList-BlTe2eo4.js rename to frontend/dist/assets/PacketList-CbRsdi2q.js index 78597764..da753c20 100644 --- a/frontend/dist/assets/PacketList-BlTe2eo4.js +++ b/frontend/dist/assets/PacketList-CbRsdi2q.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-CmQJ8_VP.js","assets/index-C2xvS0Jd.js","assets/BasemapLayer-DQCsZLc0.js","assets/car-D35Wwv-5.js","assets/useMapViewStore-DnPjO7Qt.js","assets/index-QCPybZMd.js","assets/index-wtt5rE5a.js","assets/index-7uzBcJ1E.css","assets/maplibre-gl-B1CfjdFi.css"])))=>i.map(i=>d[i]); -import{e as Se,bN as nt,bO as Ps,q as rt,n as lt,j as e,c as H,B as ns,t as it,r as m,a1 as rs,V as B,ao as je,bP as ct,bQ as Bs,bR as Ms,bS as Ls,aa as oe,bT as Rs,bU as Hs,bV as Fs,bW as me,bX as Xe,bY as Ze,_ as ot,bZ as dt,b_ as xt,b$ as mt,c0 as ht,c1 as ut,c2 as pt,m as ce,ax as le,a3 as ft,a0 as gt,c3 as J,c4 as yt,c5 as ie,c6 as jt,c7 as bt,c8 as hs,c9 as Nt,ca as vt,cb as wt,cc as kt,cd as Ct,ce as _t,cf as Je,cg as St,at as Tt,a6 as Ds,ch as Pt,ci as Bt,cj as Mt,ck as Lt,aC as As,aD as Es,d as We,cl as Rt,aE as Ht,cm as Ft,cn as ls,co as Dt}from"./index-C2xvS0Jd.js";import{C as At,u as Et}from"./chevron-up-CTCjpmk_.js";import{p as zt,e as zs,g as It,b as $t}from"./primitives-Ctn6pdEU.js";import{u as Ut,r as Ot,a as Vt,b as Gt,c as Qt,d as qt,i as Wt}from"./consumer-registry-DJyYnY6J.js";import{D as Pe,R as Ie,P as Be,g as Kt}from"./badge-colors-Dl76Mz8m.js";import{g as Is,e as Ce,a as $s}from"./chat-utils-DnJ-lYj3.js";import{S as $e,i as Ue,a as Yt,g as us}from"./SignalIndicator-DO8Lkax5.js";import{A as Xt}from"./arrow-up-C0VG8Et4.js";import{A as he}from"./arrow-right-DySc3ssS.js";import{A as Us}from"./arrow-down-4OY_dsXk.js";import{C as is}from"./chevron-right-C9GG0xWI.js";import{d as Zt}from"./payload-detail-BAEvS7Pl.js";import{M as Oe}from"./map-pin-CQk00ph2.js";import{C as Jt}from"./circle-question-mark-CF3fGjhH.js";import{L as ea}from"./layers-BICmdhXR.js";import{H as Os}from"./hash-DjqT3oXN.js";import{C as de}from"./clock-DU0z3qMB.js";import{L as cs,R as sa}from"./route-Awj5QSAO.js";import{A as ta}from"./activity-BFfde9uG.js";import{D as aa}from"./database-cyku2KnA.js";import{H as na,D as es,u as ra}from"./useMapViewStore-DnPjO7Qt.js";import{S as ve}from"./shield-DvZvtyKV.js";import{C as Vs}from"./MqttModeBadge-DOXwpg3i.js";import{Z as ps}from"./zap-v3FkQoQ-.js";/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-DYyUo4Xc.js","assets/index-D33fcA3L.js","assets/BasemapLayer-DhvtWc_h.js","assets/car-CeuvJE3C.js","assets/useMapViewStore-Ey8vE9rr.js","assets/index-5slIee7x.js","assets/index-DuiHY5wq.js","assets/index-7uzBcJ1E.css","assets/maplibre-gl-B1CfjdFi.css"])))=>i.map(i=>d[i]); +import{e as Se,bO as nt,bP as Ps,q as rt,n as lt,j as e,c as H,B as ns,t as it,r as m,a1 as rs,V as B,ao as je,bQ as ct,bR as Bs,bS as Ms,bT as Ls,aa as oe,bU as Rs,bV as Hs,bW as Fs,bX as me,bY as Xe,bZ as Ze,_ as ot,b_ as dt,b$ as xt,c0 as mt,c1 as ht,c2 as ut,c3 as pt,m as ce,ax as le,a3 as ft,a0 as gt,c4 as J,c5 as yt,c6 as ie,c7 as jt,c8 as bt,c9 as hs,ca as Nt,cb as vt,cc as wt,cd as kt,ce as Ct,cf as _t,cg as Je,ch as St,at as Tt,a6 as Ds,ci as Pt,cj as Bt,ck as Mt,cl as Lt,aC as As,aD as zs,d as We,cm as Rt,aF as Ht,cn as Ft,co as ls,cp as Dt}from"./index-D33fcA3L.js";import{C as At,u as zt}from"./chevron-up-DyOgmQ5-.js";import{p as Et,e as Es,g as It,b as $t}from"./primitives-C8YoaXqf.js";import{u as Ut,r as Ot,a as Vt,b as Gt,c as Qt,d as qt,i as Wt}from"./consumer-registry-DXaeZxMm.js";import{D as Pe,R as Ie,P as Be,g as Kt}from"./badge-colors-Dl76Mz8m.js";import{g as Is,e as Ce,a as $s}from"./chat-utils-DIy1-SG1.js";import{S as $e,i as Ue,a as Yt,g as us}from"./SignalIndicator-DmWlnzMv.js";import{A as Xt}from"./arrow-up-C4DdHKHn.js";import{A as he}from"./arrow-right-aT_K-Mjc.js";import{A as Us}from"./arrow-down-BI9NpupK.js";import{C as is}from"./chevron-right-D4kUPDBw.js";import{d as Zt}from"./payload-detail-DbnSd5NL.js";import{M as Oe}from"./map-pin-B_Rx-xpd.js";import{C as Jt}from"./circle-question-mark-CO80vHQp.js";import{L as ea}from"./layers-DguV5fdN.js";import{H as Os}from"./hash-Ba9bZo8v.js";import{C as de}from"./clock-D_m2QiHa.js";import{L as cs,R as sa}from"./route-5o9tQENO.js";import{A as ta}from"./activity-D6ySIfuC.js";import{D as aa}from"./database-Bm4-qoOy.js";import{H as na,D as es,u as ra}from"./useMapViewStore-Ey8vE9rr.js";import{S as ve}from"./shield-Ceq641wy.js";import{C as Vs}from"./MqttModeBadge-BtcQeS2v.js";import{Z as ps}from"./zap-C-Mue2DZ.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -29,7 +29,7 @@ import{e as Se,bN as nt,bO as Ps,q as rt,n as lt,j as e,c as H,B as ns,t as it,r * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ha=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],we=Se("user",ha);function ua(s){s.values.forEach(a=>a.stop())}function ss(s,a){[...a].reverse().forEach(n=>{const i=s.getVariant(n);i&&Ps(s,i),s.variantChildren&&s.variantChildren.forEach(l=>{ss(l,a)})})}function pa(s,a){if(Array.isArray(a))return ss(s,a);if(typeof a=="string")return ss(s,[a]);Ps(s,a)}function fa(){const s=new Set,a={subscribe(t){return s.add(t),()=>void s.delete(t)},start(t,n){const i=[];return s.forEach(l=>{i.push(nt(l,t,{transitionOverride:n}))}),Promise.all(i)},set(t){return s.forEach(n=>{pa(n,t)})},stop(){s.forEach(t=>{ua(t)})},mount(){return()=>{a.stop()}}};return a}function ga(){const s=rt(fa);return lt(s.mount,[]),s}function ya({"aria-label":s="Page navigation",className:a,...t}){return e.jsx("nav",{"aria-label":s,...t,className:H("flex gap-x-2",a)})}function ja({onClick:s,disabled:a=!1,className:t,children:n="Previous"}){return e.jsx("span",{className:H("grow basis-0",t),children:e.jsxs(ns,{plain:!0,onClick:s,disabled:a,"aria-label":"Previous page",className:H("gap-1",a&&"invisible"),children:[e.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M2.75 8H13.25M2.75 8L5.25 5.5M2.75 8L5.25 10.5",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})}),n]})})}function ba({onClick:s,disabled:a=!1,className:t,children:n="Next"}){return e.jsx("span",{className:H("flex grow basis-0 justify-end",t),children:e.jsxs(ns,{plain:!0,onClick:s,disabled:a,"aria-label":"Next page",className:H("gap-1",a&&"invisible"),children:[n,e.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M13.25 8L2.75 8M13.25 8L10.75 10.5M13.25 8L10.75 5.5",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})})]})})}function Na({className:s,...a}){return e.jsx("span",{...a,className:H("hidden items-baseline gap-x-2 sm:flex",s)})}function va({page:s,current:a=!1,onClick:t,className:n,children:i}){return e.jsx(ns,{plain:!a,outline:a,onClick:()=>t==null?void 0:t(s),"aria-label":`Page ${s}`,"aria-current":a?"page":void 0,className:H("min-w-[2.25rem] before:absolute before:-inset-px before:rounded-lg",a&&"before:bg-subtle-fill",n),children:i??s})}function wa({className:s,...a}){return e.jsx("span",{"aria-hidden":"true",...a,className:H("w-[2.25rem] select-none text-center text-sm text-fg-muted",s),children:"…"})}function ka(s,a,t=1){if(a<=7)return Array.from({length:a},(x,g)=>g+1);const n=Math.max(s-t,1),i=Math.min(s+t,a),l=n>2,r=iy+1),"gap",a]}if(l&&!r){const x=3+2*t;return[1,"gap",...Array.from({length:x},(u,y)=>a-x+y+1)]}return[1,"gap",...Array.from({length:i-n+1},(x,g)=>n+g),"gap",a]}const ur=it(s=>({requestedHash:null,requestChannel:a=>s({requestedHash:a}),clearRequest:()=>s({requestedHash:null})}));function Ca(s){if(s.length===0)return[];const a=[];let t=0;for(;t{const r=l===s.length-1,c=n!==null&&ct(i.toUpperCase(),n);return e.jsxs("span",{className:"flex items-center flex-shrink-0",children:[c?e.jsx("span",{className:"px-1 py-0.5 rounded bg-sys-amber/20 text-sys-amber text-[9px] font-medium",children:"You"}):e.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill-hover text-fg-secondary",children:i.toUpperCase()}),!r&&e.jsx(is,{className:"w-2.5 h-2.5 text-fg-muted mx-0.5 flex-shrink-0"})]},`${i}-${l}`)})})}const qs=m.memo(Ba);function Ws({channelName:s,onClick:a,active:t,compact:n,className:i}){const l=s.startsWith("#")?s:`#${s}`,r=H("inline-flex items-center flex-shrink-0","font-medium",n?"px-1.5 h-4 leading-4 rounded text-[10px]":"px-2 h-5 leading-5 rounded text-xs",t?"bg-sys-blue/20 text-sys-blue":"bg-sys-blue/10 text-sys-blue",a&&!t&&"hover:bg-sys-blue/20 cursor-pointer",i);return a?e.jsx("button",{type:"button",onClick:a,className:r,children:l}):e.jsx("span",{className:r,children:l})}function Ks({packet:s}){return s._remoteSource?e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge("teal"),children:"HTTP"}):s._mqttSource&&!s._remoteSource?e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge("purple"),children:"MQTT"}):null}function ge(s){return{"--data-box-accent":me[s]}}function Ys(s){const a=s.payload_type_name||Hs(s.payload_type??s.type),t=s.route_type_name||Fs(s.route_type??s.route),n=Be[a]??"zinc",i=Ie[t]??"zinc";return{payloadType:a,routeType:t,payloadColor:n,routeColor:i}}function Ve(s){if(!s)return[];if(Array.isArray(s))return s;try{const a=JSON.parse(s);return Array.isArray(a)?a:[]}catch{return[]}}function Xs(s,a){if(a){const t=a(s);return{name:t.name,isCompanion:t.isCompanion,isRepeater:t.isRepeater}}return{name:null,isCompanion:!1,isRepeater:!1}}function Ma({packet:s,onClick:a,localHash:t,neighbors:n,resolveSource:i,isFlashing:l=!1,isTraceHighlighted:r,onTraceHover:c,traceTag:x,onViewTraceReport:g,dupeGroupPosition:u,isDupeGroupHovered:y=!1,onDupeGroupHover:k,dupeCount:b,getDecodedContent:d,onChannelClick:C}){const M=b?!1:Bs(s.is_duplicate),o=u!==void 0,{payloadType:N,routeType:f,payloadColor:_,routeColor:v}=Ys(s),p=s.packet_origin==="tx_local",I=N==="TRACE",V=Ve(s.original_path),q=Ve(s.forwarded_path),Y=q.length>0?q:V,E=s.src_hash?je(s.src_hash):null,{name:X,isRepeater:F}=Xs(s,i);let D=null,W=null,Z=null,O=null;if(N==="GRP_TXT"&&d){const z=d(s);z!=null&&z.decrypted&&(W=z.senderName,Z=z.channelName,O=z.channelHash,z.text&&(D=z.text))}else if(N==="TXT_MSG"&&s.raw_packet)try{const z=Ms.fromHex(s.raw_packet);if(z.success&&z.packet){const L=Ls(z.packet.payload);L&&!L.encrypted&&(D=L.text)}}catch{}const T=W||(F?null:X),$=!!T,ee=!$&&F&&!!X,ne=!$&&!ee&&N==="GRP_TXT"&&!D,P=s.payload_length??s.length??0;s.lbt_attempts;const h=m.useCallback(()=>{I&&x&&g?g(x):a(s)},[I,x,g,a,s]),se=m.useCallback(()=>{I&&x&&c&&c(x),o&&k&&s.packet_hash&&k(s.packet_hash)},[I,x,c,o,k,s.packet_hash]),te=m.useCallback(()=>{c&&c(null),k&&k(null)},[c,k]),R=me[_]||me.zinc,U=y,G=()=>{const z={pointerEvents:"none"};return u==="first"?{...z,borderTop:`2px solid ${R}`,borderLeft:`2px solid ${R}`,borderRight:`2px solid ${R}`,borderBottom:"none",borderRadius:"8px 8px 0 0",inset:"-2px -2px 0 -2px"}:u==="middle"?{...z,borderTop:"none",borderLeft:`2px solid ${R}`,borderRight:`2px solid ${R}`,borderBottom:"none",borderRadius:0,inset:"0 -2px"}:u==="last"?{...z,borderTop:"none",borderLeft:`2px solid ${R}`,borderRight:`2px solid ${R}`,borderBottom:`2px solid ${R}`,borderRadius:"0 0 8px 8px",inset:"0 -2px -2px -2px"}:{...z,border:`2px solid ${R}`,borderRadius:"8px",inset:"-2px"}};return e.jsxs("div",{onClick:h,onMouseEnter:se,onMouseLeave:te,className:H("group relative cursor-pointer","hover:bg-subtle-fill",M&&!y&&"opacity-40",l&&"flash-row",p&&"bg-sys-indigo/5",r&&"bg-sys-teal/10"),children:[e.jsx("div",{className:H("absolute pointer-events-none transition-opacity duration-75",o?U?"opacity-100":"opacity-0":"opacity-0 group-hover:opacity-100"),style:G()}),e.jsxs("div",{className:"relative flex items-center gap-2 min-[600px]:gap-3 px-2 py-2 min-[600px]:px-3 min-[600px]:py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{className:"relative flex-shrink-0",children:$?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Is(Ce(T).cleanName)},children:Ce(T).emoji?e.jsx("span",{className:"text-base leading-none",children:Ce(T).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:$s(T)})}):ee?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(oe,{className:"size-5 text-sys-blue"})}):ne?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:e.jsx(Gs,{className:"size-4 text-fg-muted"})}):e.jsx(Qs,{packet:s,variant:"avatar",size:"sm"})}),e.jsx("div",{className:"min-w-0",children:$?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:T}),E&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:E})]}):ee?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:X}),E&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:E})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-bold text-[13px] text-fg-primary font-sans truncate",children:E||"—"}),X&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate max-w-[70px]",children:X})]})})]}),e.jsxs("div",{className:"flex-1 flex items-center gap-1 min-[600px]:gap-1.5 min-[900px]:gap-2 min-w-0",children:[e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge(_),children:N}),p&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge("indigo"),children:"LOCAL"}),e.jsx(Ks,{packet:s}),b&&b>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",b]}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge(v),children:f}),e.jsxs("span",{className:"hidden min-[520px]:inline type-data-xs text-fg-muted flex-shrink-0",children:[P,"B"]}),e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:D||Z?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate block flex items-center gap-1",children:[Z&&e.jsx(Ws,{channelName:Z,compact:!0,onClick:C&&O?z=>{z.stopPropagation(),C(O)}:void 0}),D&&e.jsx("span",{className:"italic truncate",children:D})]}):e.jsx(qs,{path:Y,localHash:t})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("span",{className:"data-box data-box-compact",children:Rs(s.timestamp)}),e.jsx($e,{rssi:s.rssi,snr:s.snr,compact:!0,showValues:!0,validated:Ue(s)})]})]})]})}function La({packet:s,onClick:a,localHash:t,neighbors:n,resolveSource:i,isFlashing:l=!1,isTraceHighlighted:r,traceTag:c,onViewTraceReport:x,dupeGroupPosition:g,isDupeGroupHovered:u=!1,onDupeGroupHover:y,dupeCount:k,getDecodedContent:b,onChannelClick:d}){const{payloadType:C,routeType:M,payloadColor:o,routeColor:N}=Ys(s),f=s.packet_origin==="tx_local",_=C==="TRACE",v=k?!1:Bs(s.is_duplicate),p=Ve(s.original_path),I=Ve(s.forwarded_path),V=I.length>0?I:p,q=s._hopCount??V.length,Y=s.src_hash?je(s.src_hash):null,{name:E,isRepeater:X}=Xs(s,i);let F=null,D=null,W=null,Z=null;if(C==="GRP_TXT"&&b){const R=b(s);R!=null&&R.decrypted&&(D=R.senderName,W=R.channelName,Z=R.channelHash,R.text&&(F=R.text))}else if(C==="TXT_MSG"&&s.raw_packet)try{const R=Ms.fromHex(s.raw_packet);if(R.success&&R.packet){const U=Ls(R.packet.payload);U&&!U.encrypted&&(F=U.text)}}catch{}const O=D||(X?null:E),T=!!O,$=!T&&X&&!!E,ee=!T&&!$&&C==="GRP_TXT"&&!F,ne=s.payload_length??s.length??0,P=s.lbt_attempts??0,h=()=>{_&&c&&x?x(c):a(s)},se=me[o]||me.zinc,te=()=>{if(!g)return{opacity:0};const R=u?1:.4,U=u?"3px":"2px";return g==="first"?{backgroundColor:se,opacity:R,width:U,top:"6px",bottom:0,borderRadius:"0 9999px 0 0"}:g==="middle"?{backgroundColor:se,opacity:R,width:U,top:0,bottom:0,borderRadius:0}:g==="last"?{backgroundColor:se,opacity:R,width:U,top:0,bottom:"6px",borderRadius:"0 0 9999px 0"}:{backgroundColor:se,opacity:R,width:U,top:"6px",bottom:"6px",borderRadius:"9999px"}};return e.jsxs("div",{onClick:h,className:H("relative pl-3 pr-2.5 py-2 cursor-pointer","active:bg-subtle-fill-hover",v&&"opacity-40",l&&"flash-row",f&&"bg-sys-indigo/5",r&&"bg-sys-teal/10"),children:[e.jsx("div",{className:"absolute left-0 transition-all",style:te()}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"relative flex-shrink-0 mt-0.5",children:T?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Is(Ce(O).cleanName)},children:Ce(O).emoji?e.jsx("span",{className:"text-base leading-none",children:Ce(O).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:$s(O)})}):$?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(oe,{className:"size-5 text-sys-blue"})}):ee?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:e.jsx(Gs,{className:"size-4 text-fg-muted"})}):e.jsx(Qs,{packet:s,variant:"avatar",size:"sm"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[T?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:O}):$?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:E}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-[14px] text-fg-primary tracking-tight flex-shrink-0",children:Y||"—"}),E&&e.jsx("span",{className:"text-[12px] text-fg-muted truncate min-w-0",children:E})]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge(o),children:C}),f&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge("indigo"),children:"LOCAL"}),e.jsx(Ks,{packet:s}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge(N),children:M}),k&&k>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",k]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("span",{className:"type-data-xs text-fg-muted w-[28px] text-right",children:s.rssi}),e.jsx($e,{rssi:s.rssi,compact:!0,showValues:!1,validated:Ue(s)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 type-data-xs text-fg-muted",children:[e.jsx("span",{className:"data-box data-box-compact flex-shrink-0",children:Rs(s.timestamp)}),ne>0&&e.jsxs("span",{children:[ne,"B"]}),P>0&&e.jsxs("span",{className:P>1?"text-sys-amber/60":void 0,children:["LBT:",P]}),s.snr!=null&&e.jsxs("span",{children:[s.snr.toFixed(0),"dB"]}),F||W?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate flex items-center gap-1 min-w-0",children:[W&&e.jsx(Ws,{channelName:W,compact:!0,onClick:d&&Z?R=>{R.stopPropagation(),d(Z)}:void 0}),F&&e.jsx("span",{className:"italic truncate",children:F})]}):q>0?e.jsx(qs,{path:V,localHash:t}):null]})]})]})]})}const Ra=m.memo(Ma),Ha=m.memo(La);function Fa(s,a,t,n,i=!1){const l=s.toUpperCase(),r=[],c=t&&Xe(l,t);c&&r.push(t);for(const b of Object.keys(a))Xe(l,b)&&r.push(b);if(i&&c&&t&&r.length===1)return{matches:r,probability:1,bestMatch:t};if(i&&c&&r.length>1){const b=r.filter(d=>d!==t);if(b.length===1)return{matches:r,probability:1,bestMatch:b[0]}}const x=r.length>0?1/r.length:0,g=[...r].sort();let u=null,y=-1;if(g.length===1)u=g[0];else if(g.length>1&&n){for(const b of g){const d=n.get(b),C=d?typeof d=="number"?d:d.combinedScore:0;C>y&&(y=C,u=b)}u||(u=g[0])}else g.length>0&&(u=g[0]);let k=x;if(r.length>1&&n&&y>0){let b=0;for(const d of r){const C=n.get(d);b+=C?typeof C=="number"?C:C.combinedScore:0}b>0&&(k=Math.min(.95,y/b))}return{matches:r,probability:k,bestMatch:u}}function Da(s,a,t,n){const l=(t-s)*Math.PI/180,r=(n-a)*Math.PI/180,c=Math.sin(l/2)*Math.sin(l/2)+Math.cos(s*Math.PI/180)*Math.cos(t*Math.PI/180)*Math.sin(r/2)*Math.sin(r/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}function Aa(s){return s<100?1:s<500?.9:s<1e3?.7:s<5e3?.5:s<1e4?.3:.1}const Ea=m.lazy(()=>ot(()=>import("./PathMapMapLibre-CmQJ8_VP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])));function za(s,a,t,n,i=!1,l,r,c){const x=dt(a);let g;r&&(g=xt(r,s,{position:c,isLastHop:i}).confidence);const{matches:u,probability:y}=Fa(s,x,n,l,i),k=u.length,b=[],d=s.toUpperCase(),C=t&&t.latitude!==void 0&&t.longitude!==void 0&&(t.latitude!==0||t.longitude!==0);for(const o of u){if(n&&Xe(d,n)&&o===n&&C&&t){b.push({hash:o,name:t.name||"Local Node",latitude:t.latitude,longitude:t.longitude,probability:i?1:y,isLocal:!0});continue}const N=x[o];N!=null&&N.latitude&&(N!=null&&N.longitude)&&!(N.latitude===0&&N.longitude===0)&&b.push({hash:o,name:N.node_name||N.name||"Unknown",latitude:N.latitude,longitude:N.longitude,probability:y,isLocal:!1,isDirectNeighbor:N.zero_hop===!0})}const M=b.length;if(M===1)b[0].probability=g??1;else if(M>1)if(g!==void 0&&g>0){const o=b[0];o.probability=g;const N=1-g,f=M-1;b.slice(1).forEach(_=>{_.probability=N/f})}else{let o=0;const N=b.map(f=>{if(f.isLocal)return{candidate:f,score:1};const _=l==null?void 0:l.get(f.hash);let v=.5;if(C&&t){const I=Da(t.latitude,t.longitude,f.latitude,f.longitude);v=Aa(I)}let p;return _?p=v*.3+_.hopConsistencyScore*.3+_.frequencyScore*.4:(p=v,f.isDirectNeighbor&&(p=Math.max(p,.8))),o+=p,{candidate:f,score:p}});if(o>0)N.forEach(({candidate:f,score:_})=>{f.probability=Math.min(.95,_/o)});else{const f=1/M;b.forEach(_=>_.probability=f)}}return{candidates:b,totalMatches:k}}function Ia(s,a,t,n,i,l){if(!s||s.length===0)return{hops:[],overallConfidence:0,hasValidPath:!1};const r=s.length-1,c=s.map((u,y)=>{const k=y===r,b=s.length-y,{candidates:d,totalMatches:C}=za(u,a,t,n,k,i,l,b),M=d.length>0?Math.max(...d.map(o=>o.probability)):0;return{prefix:u,candidates:d,confidence:M,totalMatches:C}}),x=c.reduce((u,y)=>y.confidence===0?0:u*y.confidence,1),g=c.some(u=>u.candidates.length>0);return{hops:c,overallConfidence:x,hasValidPath:g}}function $a(s){return`${(s*100).toFixed(0)}%`}function Ua(s){return s>=1?"text-sys-green":s>=.5?"text-sys-indigo":s>=.25?"text-signal-poor":s>0?"text-sys-red":"text-fg-muted"}function Oa(s,a,t){let n;return a===0?n=t.muted:s>=1?n=t.success:s>=.5?n=t.secondary:s>=.25?n=t.poor:s>0?n=t.danger:n=t.muted,{color:n}}class Va extends m.Component{constructor(a){super(a),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?e.jsxs("div",{className:"h-[200px] flex items-center justify-center text-fg-muted",children:[e.jsx(Ze,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function Ge({path:s,neighbors:a,localNode:t,localHash:n,srcHash:i,dstHash:l,neighborAffinity:r,prefixLookup:c,hubNodes:x,traceSnr:g,advertiserSource:u}){const[y,k]=m.useState(null),b=m.useMemo(()=>{if(!u)return null;const f=u.nodeType==="wardrive";return{prefix:u.prefix||"??",candidates:[{hash:u.publicKey||u.prefix||"source",name:u.name,latitude:u.latitude,longitude:u.longitude,probability:1,isLocal:!1,isWardrive:f}],confidence:1,totalMatches:1,isSource:!0}},[u]),d=m.useMemo(()=>{if(u||!i)return null;const f=je(i),_=a[i];if((_==null?void 0:_.latitude)&&(_==null?void 0:_.longitude)&&!(_.latitude===0&&_.longitude===0))return{prefix:f,candidates:[{hash:i,name:_.node_name||_.name||"Source",latitude:_.latitude,longitude:_.longitude,probability:1,isLocal:!1,isDirectNeighbor:_.zero_hop===!0}],confidence:1,totalMatches:1,isSource:!0};const p=(_==null?void 0:_.node_name)||(_==null?void 0:_.name)||i.slice(0,8);return{prefix:f,candidates:[{hash:i,name:p,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[u,i,a]),C=m.useMemo(()=>{const f=l!=null&&l.startsWith("0x")?l.slice(2):l;if((!f||f==="00"||f==="0000000000000000")&&t&&n){const q=je(n),Y=t.latitude!==0||t.longitude!==0;return{prefix:q,candidates:[{hash:n,name:t.name||"Local Node",latitude:Y?t.latitude:0,longitude:Y?t.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}if(!l)return null;const v=je(l);if(n&&l===n&&t){const q=t.latitude!==0||t.longitude!==0;return{prefix:v,candidates:[{hash:l,name:t.name||"Local Node",latitude:q?t.latitude:0,longitude:q?t.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const p=a[l];if((p==null?void 0:p.latitude)&&(p==null?void 0:p.longitude)&&!(p.latitude===0&&p.longitude===0))return{prefix:v,candidates:[{hash:l,name:p.node_name||p.name||"Destination",latitude:p.latitude,longitude:p.longitude,probability:1,isLocal:!1,isDirectNeighbor:p.zero_hop===!0}],confidence:1,totalMatches:1,isDestination:!0};const V=(p==null?void 0:p.node_name)||(p==null?void 0:p.name)||l.slice(0,8);return{prefix:v,candidates:[{hash:l,name:V,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[l,a,t,n]),M=m.useMemo(()=>Ia(s,a,t,n,r,c),[s,a,t,n,r,c]),o=m.useMemo(()=>{const f=[];b?f.push(b):d&&f.push(d),f.push(...M.hops),C&&f.push(C);const _=f.reduce((p,I)=>I.confidence===0?0:p*I.confidence,1),v=f.some(p=>p.candidates.some(I=>I.latitude!==0||I.longitude!==0));return{hops:f,overallConfidence:_,hasValidPath:v}},[b,d,M,C]),N=m.useMemo(()=>{const f=getComputedStyle(document.documentElement);return{success:f.getPropertyValue("--sys-green").trim()||"#39D98A",secondary:f.getPropertyValue("--sys-indigo").trim()||"#F9D26F",poor:f.getPropertyValue("--signal-poor").trim()||"#FF8A5C",danger:f.getPropertyValue("--sys-red").trim()||"#FF5C7A",muted:f.getPropertyValue("--text-muted").trim()||"#767688"}},[]);return o.hasValidPath?e.jsxs("div",{className:"h-full flex flex-col space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-muted",children:"Path Confidence:"}),e.jsx("span",{className:Ua(o.overallConfidence),children:$a(o.overallConfidence)}),e.jsx("button",{className:"text-fg-muted hover:text-fg-secondary transition-colors",title:"Confidence is calculated based on how many known nodes match each path prefix. Multiple matches reduce confidence due to collision probability.",children:e.jsx(Jt,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-green"}),e.jsx("span",{className:"text-fg-muted",children:"Exact"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-indigo"}),e.jsx("span",{className:"text-fg-muted",children:"Multi"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-fg-muted"}),e.jsx("span",{className:"text-fg-muted",children:"Unknown"})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(Va,{children:e.jsx(m.Suspense,{fallback:e.jsx("div",{className:"h-full bg-elevated flex items-center justify-center text-fg-muted text-sm",children:"Loading map..."}),children:e.jsx(Ea,{resolvedPath:o,localNode:t,hubNodes:x,hoveredHopIndex:y,onHoverHop:k,traceSnr:g})})})}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:o.hops.map((f,_)=>{var q,Y,E;const v=f.isSource===!0,p=f.isDestination===!0,I=y===_;let V;return v?V=`Source: ${((q=f.candidates[0])==null?void 0:q.name)||"Unknown"}`:p?V=`Destination: ${((Y=f.candidates[0])==null?void 0:Y.name)||"Unknown"}`:f.totalMatches===0?V="No matching nodes found":f.totalMatches===1?V=`Exact match: ${((E=f.candidates[0])==null?void 0:E.name)||"Unknown"}`:V=`${f.totalMatches} possible matches (${(f.confidence*100).toFixed(0)}% confidence)`,e.jsxs("div",{className:H("flex items-center gap-1 px-1.5 py-0.5 rounded type-data-xs cursor-pointer transition-all",I?"bg-sys-blue/20 ring-1 ring-sys-blue/50":"bg-elevated hover:bg-subtle",v&&"border border-sys-green/30",p&&"border border-sys-blue/30"),title:V,onMouseEnter:()=>k(_),onMouseLeave:()=>k(null),children:[v&&e.jsx("span",{className:"text-sys-green text-[8px] mr-0.5",children:"SRC"}),p&&e.jsx("span",{className:"text-sys-blue text-[8px] mr-0.5",children:"DST"}),e.jsx("span",{style:Oa(f.confidence,f.totalMatches,N),children:f.prefix}),!v&&!p&&f.totalMatches>1&&e.jsxs("span",{className:"text-fg-muted",children:["×",f.totalMatches]}),!v&&!p&&f.totalMatches===0&&e.jsx("span",{className:"text-fg-muted",children:"?"})]},_)})})]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-xs py-4",children:[e.jsx(Oe,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]})}const Ke=16;function Qe(s){return s.match(/.{1,2}/g)||[]}function ye(s){return s!==null&&s.startsWith("payload:")}const _e={hexRestOpacity:15,cardRestBg:"color-mix(in srgb, var(--elevated) 60%, var(--body))",cardRestShadow:` + */const ha=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],we=Se("user",ha);function ua(s){s.values.forEach(a=>a.stop())}function ss(s,a){[...a].reverse().forEach(n=>{const i=s.getVariant(n);i&&Ps(s,i),s.variantChildren&&s.variantChildren.forEach(l=>{ss(l,a)})})}function pa(s,a){if(Array.isArray(a))return ss(s,a);if(typeof a=="string")return ss(s,[a]);Ps(s,a)}function fa(){const s=new Set,a={subscribe(t){return s.add(t),()=>void s.delete(t)},start(t,n){const i=[];return s.forEach(l=>{i.push(nt(l,t,{transitionOverride:n}))}),Promise.all(i)},set(t){return s.forEach(n=>{pa(n,t)})},stop(){s.forEach(t=>{ua(t)})},mount(){return()=>{a.stop()}}};return a}function ga(){const s=rt(fa);return lt(s.mount,[]),s}function ya({"aria-label":s="Page navigation",className:a,...t}){return e.jsx("nav",{"aria-label":s,...t,className:H("flex gap-x-2",a)})}function ja({onClick:s,disabled:a=!1,className:t,children:n="Previous"}){return e.jsx("span",{className:H("grow basis-0",t),children:e.jsxs(ns,{plain:!0,onClick:s,disabled:a,"aria-label":"Previous page",className:H("gap-1",a&&"invisible"),children:[e.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M2.75 8H13.25M2.75 8L5.25 5.5M2.75 8L5.25 10.5",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})}),n]})})}function ba({onClick:s,disabled:a=!1,className:t,children:n="Next"}){return e.jsx("span",{className:H("flex grow basis-0 justify-end",t),children:e.jsxs(ns,{plain:!0,onClick:s,disabled:a,"aria-label":"Next page",className:H("gap-1",a&&"invisible"),children:[n,e.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M13.25 8L2.75 8M13.25 8L10.75 10.5M13.25 8L10.75 5.5",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})})]})})}function Na({className:s,...a}){return e.jsx("span",{...a,className:H("hidden items-baseline gap-x-2 sm:flex",s)})}function va({page:s,current:a=!1,onClick:t,className:n,children:i}){return e.jsx(ns,{plain:!a,outline:a,onClick:()=>t==null?void 0:t(s),"aria-label":`Page ${s}`,"aria-current":a?"page":void 0,className:H("min-w-[2.25rem] before:absolute before:-inset-px before:rounded-lg",a&&"before:bg-subtle-fill",n),children:i??s})}function wa({className:s,...a}){return e.jsx("span",{"aria-hidden":"true",...a,className:H("w-[2.25rem] select-none text-center text-sm text-fg-muted",s),children:"…"})}function ka(s,a,t=1){if(a<=7)return Array.from({length:a},(x,g)=>g+1);const n=Math.max(s-t,1),i=Math.min(s+t,a),l=n>2,r=iy+1),"gap",a]}if(l&&!r){const x=3+2*t;return[1,"gap",...Array.from({length:x},(u,y)=>a-x+y+1)]}return[1,"gap",...Array.from({length:i-n+1},(x,g)=>n+g),"gap",a]}const ur=it(s=>({requestedHash:null,requestChannel:a=>s({requestedHash:a}),clearRequest:()=>s({requestedHash:null})}));function Ca(s){if(s.length===0)return[];const a=[];let t=0;for(;t{const r=l===s.length-1,c=n!==null&&ct(i.toUpperCase(),n);return e.jsxs("span",{className:"flex items-center flex-shrink-0",children:[c?e.jsx("span",{className:"px-1 py-0.5 rounded bg-sys-amber/20 text-sys-amber text-[9px] font-medium",children:"You"}):e.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill-hover text-fg-secondary",children:i.toUpperCase()}),!r&&e.jsx(is,{className:"w-2.5 h-2.5 text-fg-muted mx-0.5 flex-shrink-0"})]},`${i}-${l}`)})})}const qs=m.memo(Ba);function Ws({channelName:s,onClick:a,active:t,compact:n,className:i}){const l=s.startsWith("#")?s:`#${s}`,r=H("inline-flex items-center flex-shrink-0","font-medium",n?"px-1.5 h-4 leading-4 rounded text-[10px]":"px-2 h-5 leading-5 rounded text-xs",t?"bg-sys-blue/20 text-sys-blue":"bg-sys-blue/10 text-sys-blue",a&&!t&&"hover:bg-sys-blue/20 cursor-pointer",i);return a?e.jsx("button",{type:"button",onClick:a,className:r,children:l}):e.jsx("span",{className:r,children:l})}function Ks({packet:s}){return s._remoteSource?e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge("teal"),children:"HTTP"}):s._mqttSource&&!s._remoteSource?e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge("purple"),children:"MQTT"}):null}function ge(s){return{"--data-box-accent":me[s]}}function Ys(s){const a=s.payload_type_name||Hs(s.payload_type??s.type),t=s.route_type_name||Fs(s.route_type??s.route),n=Be[a]??"zinc",i=Ie[t]??"zinc";return{payloadType:a,routeType:t,payloadColor:n,routeColor:i}}function Ve(s){if(!s)return[];if(Array.isArray(s))return s;try{const a=JSON.parse(s);return Array.isArray(a)?a:[]}catch{return[]}}function Xs(s,a){if(a){const t=a(s);return{name:t.name,isCompanion:t.isCompanion,isRepeater:t.isRepeater}}return{name:null,isCompanion:!1,isRepeater:!1}}function Ma({packet:s,onClick:a,localHash:t,neighbors:n,resolveSource:i,isFlashing:l=!1,isTraceHighlighted:r,onTraceHover:c,traceTag:x,onViewTraceReport:g,dupeGroupPosition:u,isDupeGroupHovered:y=!1,onDupeGroupHover:k,dupeCount:b,getDecodedContent:d,onChannelClick:C}){const M=b?!1:Bs(s.is_duplicate),o=u!==void 0,{payloadType:N,routeType:f,payloadColor:_,routeColor:v}=Ys(s),p=s.packet_origin==="tx_local",I=N==="TRACE",V=Ve(s.original_path),q=Ve(s.forwarded_path),Y=q.length>0?q:V,z=s.src_hash?je(s.src_hash):null,{name:X,isRepeater:F}=Xs(s,i);let D=null,W=null,Z=null,O=null;if(N==="GRP_TXT"&&d){const E=d(s);E!=null&&E.decrypted&&(W=E.senderName,Z=E.channelName,O=E.channelHash,E.text&&(D=E.text))}else if(N==="TXT_MSG"&&s.raw_packet)try{const E=Ms.fromHex(s.raw_packet);if(E.success&&E.packet){const L=Ls(E.packet.payload);L&&!L.encrypted&&(D=L.text)}}catch{}const T=W||(F?null:X),$=!!T,ee=!$&&F&&!!X,ne=!$&&!ee&&N==="GRP_TXT"&&!D,P=s.payload_length??s.length??0;s.lbt_attempts;const h=m.useCallback(()=>{I&&x&&g?g(x):a(s)},[I,x,g,a,s]),se=m.useCallback(()=>{I&&x&&c&&c(x),o&&k&&s.packet_hash&&k(s.packet_hash)},[I,x,c,o,k,s.packet_hash]),te=m.useCallback(()=>{c&&c(null),k&&k(null)},[c,k]),R=me[_]||me.zinc,U=y,G=()=>{const E={pointerEvents:"none"};return u==="first"?{...E,borderTop:`2px solid ${R}`,borderLeft:`2px solid ${R}`,borderRight:`2px solid ${R}`,borderBottom:"none",borderRadius:"8px 8px 0 0",inset:"-2px -2px 0 -2px"}:u==="middle"?{...E,borderTop:"none",borderLeft:`2px solid ${R}`,borderRight:`2px solid ${R}`,borderBottom:"none",borderRadius:0,inset:"0 -2px"}:u==="last"?{...E,borderTop:"none",borderLeft:`2px solid ${R}`,borderRight:`2px solid ${R}`,borderBottom:`2px solid ${R}`,borderRadius:"0 0 8px 8px",inset:"0 -2px -2px -2px"}:{...E,border:`2px solid ${R}`,borderRadius:"8px",inset:"-2px"}};return e.jsxs("div",{onClick:h,onMouseEnter:se,onMouseLeave:te,className:H("group relative cursor-pointer","hover:bg-subtle-fill",M&&!y&&"opacity-40",l&&"flash-row",p&&"bg-sys-indigo/5",r&&"bg-sys-teal/10"),children:[e.jsx("div",{className:H("absolute pointer-events-none transition-opacity duration-75",o?U?"opacity-100":"opacity-0":"opacity-0 group-hover:opacity-100"),style:G()}),e.jsxs("div",{className:"relative flex items-center gap-2 min-[600px]:gap-3 px-2 py-2 min-[600px]:px-3 min-[600px]:py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{className:"relative flex-shrink-0",children:$?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Is(Ce(T).cleanName)},children:Ce(T).emoji?e.jsx("span",{className:"text-base leading-none",children:Ce(T).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:$s(T)})}):ee?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(oe,{className:"size-5 text-sys-blue"})}):ne?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:e.jsx(Gs,{className:"size-4 text-fg-muted"})}):e.jsx(Qs,{packet:s,variant:"avatar",size:"sm"})}),e.jsx("div",{className:"min-w-0",children:$?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:T}),z&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:z})]}):ee?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:X}),z&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:z})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-bold text-[13px] text-fg-primary font-sans truncate",children:z||"—"}),X&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate max-w-[70px]",children:X})]})})]}),e.jsxs("div",{className:"flex-1 flex items-center gap-1 min-[600px]:gap-1.5 min-[900px]:gap-2 min-w-0",children:[e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge(_),children:N}),p&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge("indigo"),children:"LOCAL"}),e.jsx(Ks,{packet:s}),b&&b>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",b]}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge(v),children:f}),e.jsxs("span",{className:"hidden min-[520px]:inline type-data-xs text-fg-muted flex-shrink-0",children:[P,"B"]}),e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:D||Z?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate block flex items-center gap-1",children:[Z&&e.jsx(Ws,{channelName:Z,compact:!0,onClick:C&&O?E=>{E.stopPropagation(),C(O)}:void 0}),D&&e.jsx("span",{className:"italic truncate",children:D})]}):e.jsx(qs,{path:Y,localHash:t})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("span",{className:"data-box data-box-compact",children:Rs(s.timestamp)}),e.jsx($e,{rssi:s.rssi,snr:s.snr,compact:!0,showValues:!0,validated:Ue(s)})]})]})]})}function La({packet:s,onClick:a,localHash:t,neighbors:n,resolveSource:i,isFlashing:l=!1,isTraceHighlighted:r,traceTag:c,onViewTraceReport:x,dupeGroupPosition:g,isDupeGroupHovered:u=!1,onDupeGroupHover:y,dupeCount:k,getDecodedContent:b,onChannelClick:d}){const{payloadType:C,routeType:M,payloadColor:o,routeColor:N}=Ys(s),f=s.packet_origin==="tx_local",_=C==="TRACE",v=k?!1:Bs(s.is_duplicate),p=Ve(s.original_path),I=Ve(s.forwarded_path),V=I.length>0?I:p,q=s._hopCount??V.length,Y=s.src_hash?je(s.src_hash):null,{name:z,isRepeater:X}=Xs(s,i);let F=null,D=null,W=null,Z=null;if(C==="GRP_TXT"&&b){const R=b(s);R!=null&&R.decrypted&&(D=R.senderName,W=R.channelName,Z=R.channelHash,R.text&&(F=R.text))}else if(C==="TXT_MSG"&&s.raw_packet)try{const R=Ms.fromHex(s.raw_packet);if(R.success&&R.packet){const U=Ls(R.packet.payload);U&&!U.encrypted&&(F=U.text)}}catch{}const O=D||(X?null:z),T=!!O,$=!T&&X&&!!z,ee=!T&&!$&&C==="GRP_TXT"&&!F,ne=s.payload_length??s.length??0,P=s.lbt_attempts??0,h=()=>{_&&c&&x?x(c):a(s)},se=me[o]||me.zinc,te=()=>{if(!g)return{opacity:0};const R=u?1:.4,U=u?"3px":"2px";return g==="first"?{backgroundColor:se,opacity:R,width:U,top:"6px",bottom:0,borderRadius:"0 9999px 0 0"}:g==="middle"?{backgroundColor:se,opacity:R,width:U,top:0,bottom:0,borderRadius:0}:g==="last"?{backgroundColor:se,opacity:R,width:U,top:0,bottom:"6px",borderRadius:"0 0 9999px 0"}:{backgroundColor:se,opacity:R,width:U,top:"6px",bottom:"6px",borderRadius:"9999px"}};return e.jsxs("div",{onClick:h,className:H("relative pl-3 pr-2.5 py-2 cursor-pointer","active:bg-subtle-fill-hover",v&&"opacity-40",l&&"flash-row",f&&"bg-sys-indigo/5",r&&"bg-sys-teal/10"),children:[e.jsx("div",{className:"absolute left-0 transition-all",style:te()}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"relative flex-shrink-0 mt-0.5",children:T?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Is(Ce(O).cleanName)},children:Ce(O).emoji?e.jsx("span",{className:"text-base leading-none",children:Ce(O).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:$s(O)})}):$?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(oe,{className:"size-5 text-sys-blue"})}):ee?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:e.jsx(Gs,{className:"size-4 text-fg-muted"})}):e.jsx(Qs,{packet:s,variant:"avatar",size:"sm"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[T?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:O}):$?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:z}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-[14px] text-fg-primary tracking-tight flex-shrink-0",children:Y||"—"}),z&&e.jsx("span",{className:"text-[12px] text-fg-muted truncate min-w-0",children:z})]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge(o),children:C}),f&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge("indigo"),children:"LOCAL"}),e.jsx(Ks,{packet:s}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge(N),children:M}),k&&k>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",k]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("span",{className:"type-data-xs text-fg-muted w-[28px] text-right",children:s.rssi}),e.jsx($e,{rssi:s.rssi,compact:!0,showValues:!1,validated:Ue(s)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 type-data-xs text-fg-muted",children:[e.jsx("span",{className:"data-box data-box-compact flex-shrink-0",children:Rs(s.timestamp)}),ne>0&&e.jsxs("span",{children:[ne,"B"]}),P>0&&e.jsxs("span",{className:P>1?"text-sys-amber/60":void 0,children:["LBT:",P]}),s.snr!=null&&e.jsxs("span",{children:[s.snr.toFixed(0),"dB"]}),F||W?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate flex items-center gap-1 min-w-0",children:[W&&e.jsx(Ws,{channelName:W,compact:!0,onClick:d&&Z?R=>{R.stopPropagation(),d(Z)}:void 0}),F&&e.jsx("span",{className:"italic truncate",children:F})]}):q>0?e.jsx(qs,{path:V,localHash:t}):null]})]})]})]})}const Ra=m.memo(Ma),Ha=m.memo(La);function Fa(s,a,t,n,i=!1){const l=s.toUpperCase(),r=[],c=t&&Xe(l,t);c&&r.push(t);for(const b of Object.keys(a))Xe(l,b)&&r.push(b);if(i&&c&&t&&r.length===1)return{matches:r,probability:1,bestMatch:t};if(i&&c&&r.length>1){const b=r.filter(d=>d!==t);if(b.length===1)return{matches:r,probability:1,bestMatch:b[0]}}const x=r.length>0?1/r.length:0,g=[...r].sort();let u=null,y=-1;if(g.length===1)u=g[0];else if(g.length>1&&n){for(const b of g){const d=n.get(b),C=d?typeof d=="number"?d:d.combinedScore:0;C>y&&(y=C,u=b)}u||(u=g[0])}else g.length>0&&(u=g[0]);let k=x;if(r.length>1&&n&&y>0){let b=0;for(const d of r){const C=n.get(d);b+=C?typeof C=="number"?C:C.combinedScore:0}b>0&&(k=Math.min(.95,y/b))}return{matches:r,probability:k,bestMatch:u}}function Da(s,a,t,n){const l=(t-s)*Math.PI/180,r=(n-a)*Math.PI/180,c=Math.sin(l/2)*Math.sin(l/2)+Math.cos(s*Math.PI/180)*Math.cos(t*Math.PI/180)*Math.sin(r/2)*Math.sin(r/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}function Aa(s){return s<100?1:s<500?.9:s<1e3?.7:s<5e3?.5:s<1e4?.3:.1}const za=m.lazy(()=>ot(()=>import("./PathMapMapLibre-DYyUo4Xc.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])));function Ea(s,a,t,n,i=!1,l,r,c){const x=dt(a);let g;r&&(g=xt(r,s,{position:c,isLastHop:i}).confidence);const{matches:u,probability:y}=Fa(s,x,n,l,i),k=u.length,b=[],d=s.toUpperCase(),C=t&&t.latitude!==void 0&&t.longitude!==void 0&&(t.latitude!==0||t.longitude!==0);for(const o of u){if(n&&Xe(d,n)&&o===n&&C&&t){b.push({hash:o,name:t.name||"Local Node",latitude:t.latitude,longitude:t.longitude,probability:i?1:y,isLocal:!0});continue}const N=x[o];N!=null&&N.latitude&&(N!=null&&N.longitude)&&!(N.latitude===0&&N.longitude===0)&&b.push({hash:o,name:N.node_name||N.name||"Unknown",latitude:N.latitude,longitude:N.longitude,probability:y,isLocal:!1,isDirectNeighbor:N.zero_hop===!0})}const M=b.length;if(M===1)b[0].probability=g??1;else if(M>1)if(g!==void 0&&g>0){const o=b[0];o.probability=g;const N=1-g,f=M-1;b.slice(1).forEach(_=>{_.probability=N/f})}else{let o=0;const N=b.map(f=>{if(f.isLocal)return{candidate:f,score:1};const _=l==null?void 0:l.get(f.hash);let v=.5;if(C&&t){const I=Da(t.latitude,t.longitude,f.latitude,f.longitude);v=Aa(I)}let p;return _?p=v*.3+_.hopConsistencyScore*.3+_.frequencyScore*.4:(p=v,f.isDirectNeighbor&&(p=Math.max(p,.8))),o+=p,{candidate:f,score:p}});if(o>0)N.forEach(({candidate:f,score:_})=>{f.probability=Math.min(.95,_/o)});else{const f=1/M;b.forEach(_=>_.probability=f)}}return{candidates:b,totalMatches:k}}function Ia(s,a,t,n,i,l){if(!s||s.length===0)return{hops:[],overallConfidence:0,hasValidPath:!1};const r=s.length-1,c=s.map((u,y)=>{const k=y===r,b=s.length-y,{candidates:d,totalMatches:C}=Ea(u,a,t,n,k,i,l,b),M=d.length>0?Math.max(...d.map(o=>o.probability)):0;return{prefix:u,candidates:d,confidence:M,totalMatches:C}}),x=c.reduce((u,y)=>y.confidence===0?0:u*y.confidence,1),g=c.some(u=>u.candidates.length>0);return{hops:c,overallConfidence:x,hasValidPath:g}}function $a(s){return`${(s*100).toFixed(0)}%`}function Ua(s){return s>=1?"text-sys-green":s>=.5?"text-sys-indigo":s>=.25?"text-signal-poor":s>0?"text-sys-red":"text-fg-muted"}function Oa(s,a,t){let n;return a===0?n=t.muted:s>=1?n=t.success:s>=.5?n=t.secondary:s>=.25?n=t.poor:s>0?n=t.danger:n=t.muted,{color:n}}class Va extends m.Component{constructor(a){super(a),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?e.jsxs("div",{className:"h-[200px] flex items-center justify-center text-fg-muted",children:[e.jsx(Ze,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function Ge({path:s,neighbors:a,localNode:t,localHash:n,srcHash:i,dstHash:l,neighborAffinity:r,prefixLookup:c,hubNodes:x,traceSnr:g,advertiserSource:u}){const[y,k]=m.useState(null),b=m.useMemo(()=>{if(!u)return null;const f=u.nodeType==="wardrive";return{prefix:u.prefix||"??",candidates:[{hash:u.publicKey||u.prefix||"source",name:u.name,latitude:u.latitude,longitude:u.longitude,probability:1,isLocal:!1,isWardrive:f}],confidence:1,totalMatches:1,isSource:!0}},[u]),d=m.useMemo(()=>{if(u||!i)return null;const f=je(i),_=a[i];if((_==null?void 0:_.latitude)&&(_==null?void 0:_.longitude)&&!(_.latitude===0&&_.longitude===0))return{prefix:f,candidates:[{hash:i,name:_.node_name||_.name||"Source",latitude:_.latitude,longitude:_.longitude,probability:1,isLocal:!1,isDirectNeighbor:_.zero_hop===!0}],confidence:1,totalMatches:1,isSource:!0};const p=(_==null?void 0:_.node_name)||(_==null?void 0:_.name)||i.slice(0,8);return{prefix:f,candidates:[{hash:i,name:p,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[u,i,a]),C=m.useMemo(()=>{const f=l!=null&&l.startsWith("0x")?l.slice(2):l;if((!f||f==="00"||f==="0000000000000000")&&t&&n){const q=je(n),Y=t.latitude!==0||t.longitude!==0;return{prefix:q,candidates:[{hash:n,name:t.name||"Local Node",latitude:Y?t.latitude:0,longitude:Y?t.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}if(!l)return null;const v=je(l);if(n&&l===n&&t){const q=t.latitude!==0||t.longitude!==0;return{prefix:v,candidates:[{hash:l,name:t.name||"Local Node",latitude:q?t.latitude:0,longitude:q?t.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const p=a[l];if((p==null?void 0:p.latitude)&&(p==null?void 0:p.longitude)&&!(p.latitude===0&&p.longitude===0))return{prefix:v,candidates:[{hash:l,name:p.node_name||p.name||"Destination",latitude:p.latitude,longitude:p.longitude,probability:1,isLocal:!1,isDirectNeighbor:p.zero_hop===!0}],confidence:1,totalMatches:1,isDestination:!0};const V=(p==null?void 0:p.node_name)||(p==null?void 0:p.name)||l.slice(0,8);return{prefix:v,candidates:[{hash:l,name:V,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[l,a,t,n]),M=m.useMemo(()=>Ia(s,a,t,n,r,c),[s,a,t,n,r,c]),o=m.useMemo(()=>{const f=[];b?f.push(b):d&&f.push(d),f.push(...M.hops),C&&f.push(C);const _=f.reduce((p,I)=>I.confidence===0?0:p*I.confidence,1),v=f.some(p=>p.candidates.some(I=>I.latitude!==0||I.longitude!==0));return{hops:f,overallConfidence:_,hasValidPath:v}},[b,d,M,C]),N=m.useMemo(()=>{const f=getComputedStyle(document.documentElement);return{success:f.getPropertyValue("--sys-green").trim()||"#39D98A",secondary:f.getPropertyValue("--sys-indigo").trim()||"#F9D26F",poor:f.getPropertyValue("--signal-poor").trim()||"#FF8A5C",danger:f.getPropertyValue("--sys-red").trim()||"#FF5C7A",muted:f.getPropertyValue("--text-muted").trim()||"#767688"}},[]);return o.hasValidPath?e.jsxs("div",{className:"h-full flex flex-col space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-muted",children:"Path Confidence:"}),e.jsx("span",{className:Ua(o.overallConfidence),children:$a(o.overallConfidence)}),e.jsx("button",{className:"text-fg-muted hover:text-fg-secondary transition-colors",title:"Confidence is calculated based on how many known nodes match each path prefix. Multiple matches reduce confidence due to collision probability.",children:e.jsx(Jt,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-green"}),e.jsx("span",{className:"text-fg-muted",children:"Exact"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-indigo"}),e.jsx("span",{className:"text-fg-muted",children:"Multi"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-fg-muted"}),e.jsx("span",{className:"text-fg-muted",children:"Unknown"})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(Va,{children:e.jsx(m.Suspense,{fallback:e.jsx("div",{className:"h-full bg-elevated flex items-center justify-center text-fg-muted text-sm",children:"Loading map..."}),children:e.jsx(za,{resolvedPath:o,localNode:t,hubNodes:x,hoveredHopIndex:y,onHoverHop:k,traceSnr:g})})})}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:o.hops.map((f,_)=>{var q,Y,z;const v=f.isSource===!0,p=f.isDestination===!0,I=y===_;let V;return v?V=`Source: ${((q=f.candidates[0])==null?void 0:q.name)||"Unknown"}`:p?V=`Destination: ${((Y=f.candidates[0])==null?void 0:Y.name)||"Unknown"}`:f.totalMatches===0?V="No matching nodes found":f.totalMatches===1?V=`Exact match: ${((z=f.candidates[0])==null?void 0:z.name)||"Unknown"}`:V=`${f.totalMatches} possible matches (${(f.confidence*100).toFixed(0)}% confidence)`,e.jsxs("div",{className:H("flex items-center gap-1 px-1.5 py-0.5 rounded type-data-xs cursor-pointer transition-all",I?"bg-sys-blue/20 ring-1 ring-sys-blue/50":"bg-elevated hover:bg-subtle",v&&"border border-sys-green/30",p&&"border border-sys-blue/30"),title:V,onMouseEnter:()=>k(_),onMouseLeave:()=>k(null),children:[v&&e.jsx("span",{className:"text-sys-green text-[8px] mr-0.5",children:"SRC"}),p&&e.jsx("span",{className:"text-sys-blue text-[8px] mr-0.5",children:"DST"}),e.jsx("span",{style:Oa(f.confidence,f.totalMatches,N),children:f.prefix}),!v&&!p&&f.totalMatches>1&&e.jsxs("span",{className:"text-fg-muted",children:["×",f.totalMatches]}),!v&&!p&&f.totalMatches===0&&e.jsx("span",{className:"text-fg-muted",children:"?"})]},_)})})]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-xs py-4",children:[e.jsx(Oe,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]})}const Ke=16;function Qe(s){return s.match(/.{1,2}/g)||[]}function ye(s){return s!==null&&s.startsWith("payload:")}const _e={hexRestOpacity:15,cardRestBg:"color-mix(in srgb, var(--elevated) 60%, var(--body))",cardRestShadow:` var(--depth-stroke-tl), var(--depth-stroke-br) `,selectionBorderWidth:2},ts={type:"tween",duration:.25,ease:[.25,.1,.25,1]};function Ga(s,a){return s?`inset 0 0 0 ${_e.selectionBorderWidth}px ${me[a]}`:_e.cardRestShadow}function Qa(s,a){return s?a:`color-mix(in srgb, ${a} ${_e.hexRestOpacity}%, transparent)`}function qa({segments:s,selectedSegment:a,onSegmentClick:t}){const[n,i]=m.useState(null),[l,r]=m.useState(null),c=s.some(u=>u.id!==void 0)&&t,x=[];for(const u of s){const y=Qe(u.hex);for(const k of y)x.push({byte:k.toUpperCase(),color:u.color,id:u.id})}const g=[];for(let u=0;u{const k=u.length{const o=M===u.length-1,N=k&&o,f=me[d],p=(C?n===C:l===d)||!!(C&&a===C);return e.jsx("span",{className:`w-[1.75rem] text-xs text-center py-0.5 font-mono select-text ${c?"cursor-pointer":""}`,style:{backgroundColor:Qa(p,f),color:p?"rgba(255,255,255,0.95)":f,transition:p?"none":"background-color 0.15s ease-out, color 0.15s ease-out",touchAction:"manipulation",...N?{borderRadius:"0 0.375rem 0.375rem 0"}:{}},onMouseEnter:()=>{C?i(C):r(d)},onMouseLeave:()=>{i(null),r(null)},onClick:()=>C&&(t==null?void 0:t(C)),onTouchStart:()=>{C?i(C):r(d)},onTouchEnd:()=>{i(null),r(null)},children:b},M)})},y)})})}function Wa({rawHex:s,hexSegments:a,selectedSegment:t,onSegmentClick:n}){const[i,l]=m.useState(!1),r=m.useCallback(async()=>{await ft(s.toUpperCase()),l(!0),setTimeout(()=>l(!1),2e3)},[s]);return e.jsxs("div",{className:"bg-inset radius-inner p-6 relative depth-stroke-inset",children:[e.jsx(qa,{segments:a,selectedSegment:t,onSegmentClick:n}),e.jsx("button",{onClick:r,className:"absolute bottom-3 right-3 flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg bg-subtle-fill-hover hover:bg-subtle-fill-strong text-fg-muted hover:text-fg-secondary transition-all text-xs font-sans",title:"Copy raw packet hex",children:i?e.jsxs(e.Fragment,{children:[e.jsx(gt,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{className:"text-sys-green",children:"Copied"})]}):e.jsxs(e.Fragment,{children:[e.jsx(rs,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Copy"})]})})]})}function Ka(s,a){const t=[];let n=0;const i=a.slice(0,64);t.push({id:"payload:publicKey",title:"Public Key",color:"pink",hex:i,startByte:n,endByte:n+31,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:s.publicKey.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 public key (32 bytes)"})]})}),n+=32;const l=a.slice(64,72);t.push({id:"payload:timestamp",title:"Timestamp",color:"orange",hex:l,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:l.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[s.timestamp," (",ie(s.timestamp),")"]})]})}),n+=4;const r=a.slice(72,200);t.push({id:"payload:signature",title:"Signature",color:"teal",hex:r,startByte:n,endByte:n+63,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:s.signature.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 signature (64 bytes)"})]})}),n+=64;const c=a.slice(200,202);if(t.push({id:"payload:flags",title:"Flags",color:"blue",hex:c,startByte:n,endByte:n,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(J,{size:"standard",copy:!0,children:["0x",s.flags.toString(16).padStart(2,"0").toUpperCase()]}),e.jsx("p",{className:"text-xs text-fg-primary mt-1",children:s.flagsDescription}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Node Type: ",s.nodeType]})]})}),n+=1,s.latitude!==void 0){const x=a.slice(n*2,n*2+8);t.push({id:"payload:latitude",title:"Latitude",color:"green",hex:x,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:x.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[s.latitude.toFixed(6),"°"]})]})}),n+=4}if(s.longitude!==void 0){const x=a.slice(n*2,n*2+8);t.push({id:"payload:longitude",title:"Longitude",color:"indigo",hex:x,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:x.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[s.longitude.toFixed(6),"°"]})]})}),n+=4}if(s.name){const x=a.slice(n*2),g=x.length/2;t.push({id:"payload:name",title:"Name",color:"amber",hex:x,startByte:n,endByte:n+g-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:x.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:['"',s.name,'"']})]})})}return t}function Ya(s,a){return[{id:"payload:crc",title:"CRC",color:"green",hex:a.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(J,{size:"standard",copy:!0,children:["0x",s.crc]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"CRC32 of acknowledged packet"})]})}]}function Xa(s,a){const t=[];t.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:a.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(J,{size:"standard",copy:!0,children:["0x",s.channelHash]}),s.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",s.channelName]})]})}),s.macHex&&t.push({id:"payload:mac",title:"MAC",color:"indigo",hex:a.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:s.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=a.slice(6);return n&&t.push({id:"payload:ciphertext",title:s.decrypted?"Message":"Ciphertext",color:s.decrypted?"green":"zinc",hex:n,startByte:3,endByte:3+n.length/2-1,decoded:s.decrypted?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-fg-primary",children:['"',s.text,'"']}),s.senderName&&e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["From: ",s.senderName]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:n.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"AES-128-ECB encrypted"})]})}),t}function Za(s,a){const t=[];t.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:a.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(J,{size:"standard",copy:!0,children:["0x",s.channelHash]}),s.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",s.channelName]})]})}),s.macHex&&t.push({id:"payload:mac",title:"MAC",color:"indigo",hex:a.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:s.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=a.slice(6);return n&&t.push({id:"payload:ciphertext",title:s.decrypted?"Decrypted Data":"Encrypted Data",color:s.decrypted?"green":"zinc",hex:n,startByte:3,endByte:3+n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:(s.decryptedHex||n).toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[s.dataLength," bytes",s.decrypted?"":" (AES-128-ECB encrypted)"]})]})}),t}function Ja(s,a){const t=[],n=parseInt(a.slice(0,2),16),i=isNaN(n)?{hashSize:1,hopCount:s.pathLength}:jt(n),l=i.hopCount*i.hashSize;if(t.push({id:"payload:pathLength",title:"Path Length",color:"blue",hex:a.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",children:i.hopCount}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[i.hopCount," hop",i.hopCount!==1?"s":"",i.hashSize>1&&` × ${i.hashSize}B hashes`]})]})}),s.path.length>0){const r=a.slice(2,2+l*2);t.push({id:"payload:path",title:"Path Hops",color:"amber",hex:r,startByte:1,endByte:l,decoded:e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:s.path.map((c,x)=>e.jsxs("span",{className:"flex items-center gap-1",children:[x>0&&e.jsx(he,{className:"w-3 h-3 text-fg-muted"}),e.jsx(B,{color:"amber",className:"font-mono",children:c})]},x))})})})}if(s.extraType!=null){const r=1+l;t.push({id:"payload:extraType",title:"Extra Type",color:"indigo",hex:a.slice(r*2,r*2+2),startByte:r,endByte:r,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",children:s.extraTypeName??`0x${s.extraType.toString(16).padStart(2,"0")}`}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Bundled payload type"})]})})}if(s.extraData){const r=1+l+1,c=a.slice(r*2);c&&t.push({id:"payload:extraData",title:"Extra Data",color:"indigo",hex:c,startByte:r,endByte:r+c.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:c.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[c.length/2," bytes"]})]})})}return t}function en(s,a){const t=[];t.push({id:"payload:crc",title:"Trace Tag",color:"blue",hex:a.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(J,{size:"standard",copy:!0,children:["0x",s.traceTag]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique trace request identifier"})]})}),t.push({id:"payload:mac",title:"Auth Code",color:"indigo",hex:a.slice(8,16),startByte:4,endByte:7,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:s.authCode}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Authentication/verification code"})]})});const n=1<<(s.flags&3);t.push({id:"payload:flags",title:"Flags",color:"amber",hex:a.slice(16,18),startByte:8,endByte:8,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(J,{size:"standard",copy:!0,children:["0x",s.flags.toString(16).toUpperCase().padStart(2,"0")]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:s.flags===0?"No flags set (1B hashes)":`Bits 0-1: ${n}B per hash • ${s.flags.toString(2).padStart(8,"0")}b`})]})});const i=a.slice(18);return i&&t.push({id:"payload:path",title:"Target Path",color:"indigo",hex:i,startByte:9,endByte:9+i.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:s.pathHashes.map((l,r)=>{const c=s.snrValues[r],x=c!==void 0?Kt(c):"zinc";return e.jsxs("span",{className:"flex items-center gap-1",children:[r>0&&e.jsx(he,{className:"w-3 h-3 text-fg-muted"}),e.jsx(B,{color:"indigo",className:"font-mono",children:l}),c!==void 0&&e.jsxs(B,{color:x,className:"font-mono",children:[c>=0?"+":"",Number.isInteger(c)?c:c.toFixed(1),"dB"]})]},r)})}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[s.pathHashes.length," target ",s.pathHashes.length===1?"hop":"hops",n>1&&` × ${n}B hashes`,s.snrValues.length>0&&` • ${s.snrValues.length} SNR ${s.snrValues.length===1?"value":"values"} collected`,s.isComplete&&" • ✓ Complete"]})]})}),t}function sn(s,a){const t=[];t.push({id:"payload:msgId",title:"Message ID",color:"blue",hex:a.slice(0,4),startByte:0,endByte:1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:s.messageId.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique message identifier"})]})}),t.push({id:"payload:partNum",title:"Part Number",color:"amber",hex:a.slice(4,6),startByte:2,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:s.partNumber}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"0-indexed part number"})]})}),t.push({id:"payload:totalParts",title:"Total Parts",color:"orange",hex:a.slice(6,8),startByte:3,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:s.totalParts}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["Part ",s.partNumber+1," of ",s.totalParts]})]})});const n=a.slice(8);return n&&t.push({id:"payload:partData",title:"Part Data",color:"cyan",hex:n,startByte:4,endByte:4+n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:n.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[n.length/2," bytes"]})]})}),t}function tn(s,a){switch(s.type){case"advert":return Ka(s,a);case"ack":return Ya(s,a);case"grp_txt":return Xa(s,a);case"grp_data":return Za(s,a);case"path":return Ja(s,a);case"trace":return en(s,a);case"multipart":return sn(s,a);default:return[{id:"payload:ciphertext",title:"Raw Data",color:"zinc",hex:a,startByte:0,endByte:a.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:a.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[a.length/2," bytes"]})]})}]}}function an(s){return s.map(a=>({id:a.id,hex:a.hex,color:a.color}))}function nn({bits:s,field:a,value:t,binary:n}){const i=()=>{if(a==="Payload Type"){const l=Be[t]||"zinc";return e.jsx(B,{color:l,children:t})}if(a==="Route Type"){const l=Ie[t]||"zinc";return e.jsx(B,{color:l,children:t})}return e.jsx("span",{className:"text-sm text-fg-primary",children:t})};return e.jsxs("tr",{children:[e.jsx("td",{className:"py-1.5 text-xs text-fg-muted tabular-nums",children:s}),e.jsx("td",{className:"py-1.5 text-sm text-fg-secondary",children:a}),e.jsx("td",{className:"py-1.5",children:i()}),e.jsx("td",{className:"py-1.5 type-data-xs text-sys-cyan",children:n})]})}function js({id:s,title:a,color:t,hexBytes:n,startByte:i,endByte:l,isSelected:r,children:c}){const x=n?Qe(n):[];return e.jsxs(ce.div,{layout:"position",layoutId:s,transition:ts,className:"w-full min-w-0 overflow-hidden radius-inner p-4 sm:p-5 space-y-4",style:{backgroundColor:_e.cardRestBg,boxShadow:Ga(r,t)},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 min-w-0",children:[e.jsx(B,{color:t,children:a}),x.length>0&&x.length<=16&&x.map((g,u)=>e.jsx(B,{color:t,className:"font-mono",children:g.toUpperCase()},u))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",i,"-",l]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden",children:c})]})}function rn({advert:s,timestamp:a}){const t=a?ie(a):ie(s.timestamp);return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-indigo/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-indigo) 0%, var(--sys-blue) 100%)"},children:e.jsx(oe,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:s.name||"Unknown Node"}),e.jsx("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:s.nodeType})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[s.latitude!==void 0&&s.longitude!==void 0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oe,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-mono",children:[s.latitude.toFixed(5),"°, ",s.longitude.toFixed(5),"°"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:t})]})]})]})})}function ln({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown";return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-teal/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-teal) 0%, var(--sys-cyan) 100%)"},children:e.jsx(aa,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:s.channelName||"Channel Data"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[s.dataLength," bytes • ",s.decrypted?"Decrypted":"Encrypted"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Os,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-sans",children:["Channel: ",e.jsxs("span",{className:"font-mono",children:["0x",s.channelHash]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:t})]}),s.decrypted&&s.decryptedHex&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-1 font-sans",children:"Decrypted Data"}),e.jsx("div",{className:"max-w-full overflow-x-auto",children:e.jsx(J,{size:"compact",copy:!0,className:"inline-block",children:e.jsx("span",{className:"break-all text-xs",children:s.decryptedHex.toUpperCase()})})})]})]})]})})}function cn({decoded:s,timestamp:a,isLoading:t=!1,onDecrypted:n}){const i=a?ie(a):"Unknown",[l,r]=m.useState(""),[c,x]=m.useState(!1),[g,u]=m.useState(null),[y,k]=m.useState(!1),b=m.useCallback(async()=>{if(!(!l.trim()||!s.ciphertextHex||!s.macHex)){x(!0),u(null);try{const d=parseInt(s.channelHash,16),C=hs(s.macHex),M=hs(s.ciphertextHex),o=await Nt(l.trim(),d,C,M);if(o.success){const N=o.result.plaintext,f=new TextDecoder("utf-8",{fatal:!1}).decode(N.slice(5)),_=f.indexOf(": "),v={...s,channelName:o.result.channelName,decrypted:!0,timestamp:N[0]|N[1]<<8|N[2]<<16|N[3]<<24,flags:N[4],senderName:_>0?f.slice(0,_):void 0,text:_>0?f.slice(_+2):f};n==null||n(v),r(""),k(!1)}else u(o.error)}catch(d){u(d instanceof Error?d.message:"Unknown error")}finally{x(!1)}}},[l,s,n]);return t?e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-xl p-4 sm:p-5",style:{backgroundColor:"color-mix(in srgb, var(--elevated) 60%, var(--body))",boxShadow:` @@ -40,4 +40,4 @@ import{e as Se,bN as nt,bO as Ps,q as rt,n as lt,j as e,c as H,B as ns,t as it,r inset 0 0 0 1px color-mix(in srgb, var(--fg-primary) 6%, transparent), inset 0 1px 0 color-mix(in srgb, white 3%, transparent), 0 1px 2px color-mix(in srgb, black 5%, transparent) - `},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.senderName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["From ",e.jsx("span",{className:"text-fg-secondary font-medium",children:s.senderName})]}),s.channelName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["in ",e.jsx("span",{className:"text-sys-cyan font-medium",children:s.channelName})]})]}),e.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tl-md",style:{background:"linear-gradient(135deg, var(--sys-blue) 0%, color-mix(in srgb, var(--sys-blue) 85%, var(--sys-cyan)) 100%)"},children:e.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:s.text})})]})}):e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-zinc-500/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--zinc-500) 0%, color-mix(in srgb, var(--zinc-500) 70%, black) 100%)"},children:e.jsx(cs,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:s.isPublicHashChannel?"Public Hash Channel":"Encrypted Message"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Channel hash: ",e.jsxs("span",{className:"font-mono",children:["0x",s.channelHash]})]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-zinc-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:i})]}),s.ciphertextHex&&s.macHex&&e.jsx("div",{className:"space-y-2",children:y?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:l,onChange:d=>r(d.target.value),placeholder:"Channel name (e.g. south-bay)",className:"flex-1 px-3 py-1.5 text-sm rounded-lg bg-subtle-fill-strong border border-edge-subtle text-fg-primary placeholder:text-fg-muted focus:outline-none focus:border-zinc-500",onKeyDown:d=>d.key==="Enter"&&b(),disabled:c}),e.jsx("button",{onClick:b,disabled:c||!l.trim(),className:"px-3 py-1.5 text-sm font-medium rounded-lg bg-zinc-600 hover:bg-zinc-500 text-white disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:c?"Testing...":"Try"}),e.jsx("button",{onClick:()=>{k(!1),u(null),r("")},className:"px-2 py-1.5 text-sm rounded-lg hover:bg-subtle-fill-strong text-fg-muted transition-colors",children:"×"})]}),g&&e.jsx("p",{className:"text-xs text-sys-red",children:g})]}):e.jsx("button",{onClick:()=>k(!0),className:"text-xs text-zinc-400 hover:text-zinc-300 underline underline-offset-2 transition-colors",children:"Know the channel name? Try to decrypt"})}),!y&&e.jsx("p",{className:"text-xs text-fg-muted",children:s.isPublicHashChannel?"Public hash channel message. Key not in common channel list.":"Unknown hash channel. Channel name required for decryption."})]})]})})}function on({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown";return e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:"linear-gradient(135deg, var(--sys-green) 0%, var(--sys-teal) 100%)"},children:e.jsx(bt,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Acknowledgment"}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:["CRC: ",e.jsxs("span",{className:"font-mono text-sys-green",children:["0x",s.crc]})," · ",t]})]})]})}function dn({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown",n=s.path.length;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-amber/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-amber) 0%, var(--sys-orange) 100%)"},children:e.jsx(sa,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Path Response"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[n," ",n===1?"hop":"hops"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:t})]}),s.path.length>0&&e.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.path.map((i,l)=>e.jsxs("div",{className:"flex items-center gap-2",children:[l>0&&e.jsx(he,{className:"w-4 h-4 text-sys-amber"}),e.jsx(B,{color:"amber",className:"font-mono",children:i})]},l))})})]})]})})}function xn({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown",n=s.pathHashes.length,i=s.snrValues.length,l=r=>r>=7?"green":r>=0?"yellow":r>=-5?"orange":"red";return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-blue/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-blue) 0%, var(--sys-indigo) 100%)"},children:e.jsx(ta,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:["Trace ",s.isComplete?"Complete":"In Progress"]}),e.jsxs("p",{className:"text-sm text-fg-muted mt-0.5",children:["Tag: 0x",s.traceTag.slice(0,8),s.isComplete&&" • ✓"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary",children:t})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-fg-muted",children:[e.jsxs("span",{children:[n," target ",n===1?"hop":"hops"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[i," SNR ",i===1?"sample":"samples"]}),s.authCode!==0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:["Auth: ",s.authCode]})]})]}),s.pathHashes.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:s.pathHashes.map((r,c)=>{const x=s.snrValues[c],g=x!==void 0?l(x):"zinc",u=x!==void 0;return e.jsxs("div",{className:"flex items-center gap-2",children:[c>0&&e.jsx(he,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{color:u?"blue":"zinc",className:"font-mono",children:r}),u&&e.jsxs(B,{color:g,className:"font-mono",children:[x>=0?"+":"",Number.isInteger(x)?x:x.toFixed(1),"dB"]})]})]},c)})})]})]})})}function mn({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown";return s.encrypted?e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:"linear-gradient(135deg, var(--sys-indigo) 0%, var(--sys-blue) 100%)"},children:e.jsx(cs,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Encrypted Message"}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[s.srcHash," → ",s.destHash," · ",t]})]})]}):e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 px-1",children:[e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:[e.jsx("span",{className:"font-mono text-fg-secondary",children:s.srcHash})," → ",e.jsx("span",{className:"font-mono text-fg-secondary",children:s.destHash})]}),e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["· ",t]})]}),e.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tr-md ml-auto",style:{background:"linear-gradient(135deg, var(--sys-green) 0%, var(--sys-teal) 100%)"},children:e.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:s.text})})]})}function hn({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown",n=(s.partNumber+1)/s.totalParts*100;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-yellow/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-yellow) 0%, var(--sys-amber) 100%)"},children:e.jsx(ea,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Multipart Segment"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Part ",s.partNumber+1," of ",s.totalParts]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsx("div",{children:e.jsx("div",{className:"h-2 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${n}%`,background:"linear-gradient(90deg, var(--sys-yellow), var(--sys-amber))"}})})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Os,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-sans",children:["Message ID: ",e.jsx("span",{className:"font-mono",children:s.messageId})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:t})]})]})]})})}function un({decoded:s,timestamp:a,payloadType:t}){const n=a?ie(a):"Unknown",l=(()=>{switch(t){case le.REQ:return{icon:vt,gradient:"var(--sys-orange), var(--sys-red)",bg:"rgba(249, 115, 22, 0.15)",label:"Request"};case le.RESPONSE:return{icon:da,gradient:"var(--sys-green), var(--sys-teal)",bg:"rgba(34, 197, 94, 0.15)",label:"Response"};case le.ANON_REQ:return{icon:cs,gradient:"var(--sys-indigo), var(--sys-pink)",bg:"rgba(91, 91, 214, 0.15)",label:"Anonymous Request"};default:return{icon:Yt,gradient:"var(--sys-gray), var(--sys-slate)",bg:"rgba(107, 114, 128, 0.15)",label:s.payloadTypeName}}})(),r=l.icon;return e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:`linear-gradient(135deg, ${l.gradient})`},children:e.jsx(r,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:l.label}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[s.length," bytes · ",n]})]})]})}function pn({pathHex:s}){if(!s)return null;const a=Qe(s);return e.jsx("div",{className:"flex flex-wrap items-center gap-2 py-2",children:a.map((t,n)=>e.jsxs("div",{className:"flex items-center gap-2",children:[n>0&&e.jsx(he,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(J,{size:"compact",copy:!0,children:t.toUpperCase()}),e.jsx("span",{className:"text-xs text-fg-muted font-sans tabular-nums w-4 text-left",children:n+1})]})]},n))})}function fn({decoded:s,payloadType:a}){const t=yt[a]||`TYPE_${a}`;switch(s.type){case"advert":{const n=s.nodeType==="chat"?"companion":s.nodeType.replace("_"," "),i=s.latitude!==void 0&&s.longitude!==void 0&&!(s.latitude===0&&s.longitude===0);return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Role:"})," ",n]}),s.name&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Name:"})," ",s.name]}),i&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Location:"})," ",s.latitude.toFixed(4),"°, ",s.longitude.toFixed(4),"°"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Time:"})," ",ie(s.timestamp)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Flags:"})," ",s.flagsDescription]})]})}case"ack":return e.jsx("div",{className:"text-xs text-fg-primary space-y-0.5",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"CRC:"})," 0x",s.crc]})});case"path":return e.jsx("div",{className:"text-xs text-fg-primary space-y-1",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Path:"})," ",s.pathString||"(empty)"]})});case"trace":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Tag:"})," 0x",s.traceTag]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Target Path:"})," ",s.pathString||"(empty)"]}),s.snrValues.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"SNR:"})," ",s.snrValues.map(n=>`${n>=0?"+":""}${Number.isInteger(n)?n:n.toFixed(1)}dB`).join(" → ")]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Status:"})," ",s.isComplete?"✓ Complete":`In progress (${s.snrValues.length}/${s.pathHashes.length})`]})]});case"txt_msg":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",s.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",s.srcHash]}),s.encrypted?e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted content"}):e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",s.text]})]});case"grp_txt":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",s.channelName?e.jsx("span",{className:"text-sys-green",children:s.channelName}):s.isPublicHashChannel?e.jsx("span",{className:"text-sys-indigo",children:"Public Hash Channel"}):e.jsxs("span",{className:"font-mono",children:["0x",s.channelHash]})]}),s.decrypted?e.jsxs(e.Fragment,{children:[s.senderName&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"From:"})," ",s.senderName]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",s.text]})]}):s.isPublicHashChannel?e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (public hash channel)"}):e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (unknown channel)"})]});case"grp_data":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",s.channelName?e.jsx("span",{className:"text-sys-teal",children:s.channelName}):e.jsxs("span",{className:"font-mono",children:["0x",s.channelHash]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",s.dataLength," bytes ",s.decrypted?"(decrypted)":"(encrypted)"]})]});case"multipart":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Part:"})," ",s.partNumber+1,"/",s.totalParts]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Message ID:"})," ",s.messageId]})]});case"control":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Control:"})," ",s.subtypeName]}),s.dataLength>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",s.dataLength," bytes"]})]});case"req":case"response":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",s.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",s.srcHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",s.ciphertextLength," bytes"]})]});case"anon_req":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",s.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Pub Key:"})," ",e.jsxs("span",{className:"font-mono break-all",children:[s.senderPublicKey.slice(0,16),"…"]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",s.ciphertextLength," bytes"]})]});default:return e.jsxs("p",{className:"text-xs text-fg-secondary",children:[t," (","length"in s?s.length:0," bytes)"]})}}function gn({packet:s,decodedGrpTxt:a}){var E,X;const t=s.raw_packet||"",n=t.length/2,i=mt(),[l,r]=m.useState(null),[c,x]=m.useState(null),[g,u]=m.useState(!1),[y,k]=m.useState(null),b=m.useCallback(F=>{k(D=>D===F?null:F)},[]),d=m.useMemo(()=>zt(t),[t]),C=(E=d==null?void 0:d.packet)==null?void 0:E.payloadType,M=(d==null?void 0:d.payloadHex)||"",o=(X=d==null?void 0:d.packet)==null?void 0:X.payload,N=C===le.GRP_TXT,f=C===le.GRP_DATA,_=N&&!a&&(!i||g);if(m.useEffect(()=>{if(r(null),u(!1),a||!N||!o||o.length<4)return;if(!i){u(!0);return}u(!0);let F=!1;return ht(o).then(D=>{F||(r(D),u(!1))}),()=>{F=!0}},[M,N,i,a]),m.useEffect(()=>{if(x(null),!f||!o||o.length<4||!i)return;let F=!1;return ut(o).then(D=>{F||x(D)}),()=>{F=!0}},[M,f,i]),!d||t.length===0)return e.jsx("div",{className:"p-4 text-center text-fg-muted",children:e.jsx("p",{className:"text-sm",children:"No raw packet data available"})});const{packet:v}=d;let p=d.decoded;a&&d.decoded.type==="grp_txt"?p=a:l&&d.decoded.type==="grp_txt"?p=l:c&&d.decoded.type==="grp_data"&&(p=c);const I=()=>{switch(p.type){case"advert":return e.jsx(rn,{advert:p,timestamp:s.timestamp});case"grp_data":return e.jsx(ln,{decoded:p,timestamp:s.timestamp});case"grp_txt":return e.jsx(cn,{decoded:p,timestamp:s.timestamp,isLoading:_,onDecrypted:r});case"ack":return e.jsx(on,{decoded:p,timestamp:s.timestamp});case"path":return e.jsx(dn,{decoded:p,timestamp:s.timestamp});case"trace":return e.jsx(xn,{decoded:p,timestamp:s.timestamp});case"txt_msg":return e.jsx(mn,{decoded:p,timestamp:s.timestamp});case"multipart":return e.jsx(hn,{decoded:p,timestamp:s.timestamp});case"generic":return v.payloadType===le.REQ||v.payloadType===le.RESPONSE||v.payloadType===le.ANON_REQ?e.jsx(un,{decoded:p,timestamp:s.timestamp,payloadType:v.payloadType}):null;default:return null}},V=m.useMemo(()=>tn(p,d.payloadHex),[p,d.payloadHex]),q=y==="payload"||ye(y),Y=m.useMemo(()=>{const F=[{id:"header",hex:d.headerHex,color:"red"},...d.transportCodesHex?[{id:"transportCodes",hex:d.transportCodesHex,color:"indigo"}]:[],{id:"pathLength",hex:d.pathLengthHex,color:"green"},...d.pathDataHex?[{id:"pathData",hex:d.pathDataHex,color:"amber"}]:[]];return q?[...F,...an(V)]:[...F,{id:"payload",hex:d.payloadHex,color:"cyan"}]},[d,q,V]);return e.jsxs("div",{className:"font-mono space-y-2 min-w-0 overflow-hidden",children:[I(),e.jsx(Wa,{rawHex:t,hexSegments:Y,selectedSegment:y,onSegmentClick:b}),e.jsx(pt,{children:e.jsx(ce.div,{layout:!0,transition:ts,className:"space-y-2 min-w-0",children:(()=>{var T,$,ee,ne;const D=[{id:"header",title:"Header",color:"red",startByte:0,endByte:0,hexBytes:`0x${d.headerHex.toUpperCase()}`,condition:!0,content:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"type-micro text-fg-muted font-sans",children:[e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Bits"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Field"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Value"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Binary"})})]})}),e.jsx("tbody",{children:d.headerFields.map(P=>e.jsx(nn,{...P},P.bits))})]})},{id:"transportCodes",title:"Transport Codes",color:"indigo",startByte:1,endByte:4,hexBytes:((T=d.transportCodesHex)==null?void 0:T.toUpperCase())||"",condition:!!d.transportCodesHex,content:e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-fg-muted",children:"Two 16-bit transport codes for encrypted routing"}),e.jsxs("div",{className:"mt-1 text-xs text-fg-secondary",children:["Code 1: 0x",($=d.transportCodesHex)==null?void 0:$.slice(0,4).toUpperCase()," | Code 2: 0x",(ee=d.transportCodesHex)==null?void 0:ee.slice(4,8).toUpperCase()]})]})},{id:"pathLength",title:"Path Length",color:"green",startByte:d.transportCodesHex?5:1,endByte:d.transportCodesHex?5:1,hexBytes:`0x${d.pathLengthHex.toUpperCase()}`,condition:!0,content:e.jsxs("p",{className:"text-xs text-fg-muted pt-1",children:[v.pathLen," bytes showing route taken (increases as packet floods)"]})},{id:"pathData",title:"Path Data",color:"amber",startByte:d.transportCodesHex?6:2,endByte:(d.transportCodesHex?5:1)+v.pathLen,hexBytes:((ne=d.pathDataHex)==null?void 0:ne.toUpperCase())||"",condition:v.pathLen>0,content:e.jsxs("div",{className:"space-y-3",children:[e.jsx(pn,{pathHex:d.pathDataHex}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Historical route taken (bytes are added as packet floods through network)"})]})},{id:"payload",title:"Payload",color:"cyan",startByte:d.payloadStartByte,endByte:n-1,hexBytes:d.payloadHex.toUpperCase(),condition:!0,content:e.jsxs(e.Fragment,{children:[!ye(y)&&e.jsxs("div",{className:"p-3 radius-inner bg-inset depth-stroke-inset",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-1.5 font-sans",children:"Decoded"}),e.jsx(fn,{decoded:p,payloadType:v.payloadType})]}),!ye(y)&&V.length>0&&e.jsx("p",{className:"type-micro text-fg-muted mt-3 font-sans",children:"Click a field below to highlight its bytes"}),ye(y)&&e.jsx("p",{className:"type-micro text-fg-muted font-sans",children:"↑ Selected field above • Other fields below ↓"})]})}].filter(P=>P.condition),W=ye(y)?V.find(P=>P.id===y):null,Z=ye(y)?[...D].sort((P,h)=>P.id==="payload"?-1:h.id==="payload"?1:0):[...D].sort((P,h)=>P.id===y?-1:h.id===y?1:0),O=ye(y)?V.filter(P=>P.id!==y):[];return e.jsxs(e.Fragment,{children:[W&&e.jsx(js,{id:`subfield-${W.id}`,title:W.title,color:W.color,startByte:d.payloadStartByte+W.startByte,endByte:d.payloadStartByte+W.endByte,hexBytes:W.hex.toUpperCase(),isSelected:!0,children:W.decoded},W.id),Z.map(P=>e.jsx(js,{id:`section-${P.id}`,title:P.title,color:P.color,startByte:P.startByte,endByte:P.endByte,hexBytes:P.hexBytes,isSelected:P.id===y,children:P.content},P.id)),O.map(P=>e.jsxs(ce.div,{layout:"position",layoutId:`subfield-${P.id}`,transition:ts,className:"w-full min-w-0 overflow-hidden radius-inner p-4 sm:p-5 space-y-4",style:{backgroundColor:_e.cardRestBg,boxShadow:_e.cardRestShadow},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 min-w-0",children:[e.jsx(B,{color:P.color,children:P.title}),P.hex.length<=32&&Qe(P.hex).map((h,se)=>e.jsx(B,{color:P.color,className:"font-mono",children:h.toUpperCase()},se))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",d.payloadStartByte+P.startByte,"-",d.payloadStartByte+P.endByte]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden p-3 radius-inner bg-inset depth-stroke-inset",children:P.decoded})]},P.id))]})})()})})]})}const bs=m.memo(gn);function Ns(s){if(!s)return[];if(Array.isArray(s))return s;try{const a=JSON.parse(s);return Array.isArray(a)?a:[]}catch{return[]}}function as({hop:s,compact:a=!1,index:t=0,highlightIndex:n=-1,isTrace:i=!1}){var c;const l=t===n,r=ga();return m.useEffect(()=>{l&&i&&r.start({boxShadow:["0 0 0 0px rgba(113, 156, 223, 0)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 0px rgba(113, 156, 223, 0)"],transition:{duration:.5,times:[0,.2,.7,1],ease:"easeInOut"}})},[l,i,r]),e.jsxs(ce.div,{className:H("flex items-center gap-1.5",a?"flex-row":"flex-col"),animate:{scale:l?1.05:1,opacity:l?1:.85},transition:{duration:.3,ease:"easeInOut"},children:[e.jsxs(ce.div,{className:H("flex items-center gap-1.5 px-2.5 py-1 rounded-md","font-mono text-xs font-semibold",s.isLocal?"bg-sys-amber/20 text-sys-amber ring-1 ring-sys-amber/30":"bg-elevated/50 text-fg-primary ring-1 ring-edge-strong/50"),animate:r,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},children:[s.isLocal&&e.jsx(na,{className:"w-3 h-3"}),e.jsx("span",{children:s.prefix}),s.confidence!==void 0&&s.confidence<.9&&e.jsxs("span",{className:"text-[9px] opacity-70",children:[(s.confidence*100).toFixed(0),"%"]})]}),!a&&((c=s.neighborInfo)==null?void 0:c.name)&&e.jsx("span",{className:"text-xs text-fg-muted truncate max-w-[80px]",children:s.neighborInfo.name})]})}function yn({snr:s,sf:a}){const t=_t(s,a),i=Ct()[t]||"#6b7280",l=Number.isInteger(s)?s.toString():s.toFixed(1);return e.jsxs(B,{customColor:i,compact:!0,className:"font-mono",children:[s>=0?"+":"",l,"dB"]})}function jn({hops:s,compact:a,isTrace:t=!1,sf:n}){const[i,l]=m.useState(-1);return m.useEffect(()=>{if(s.length===0)return;const r=setTimeout(()=>{l(0)},400),c=setInterval(()=>{l(x=>{const g=x+1;return g>=s.length?(clearInterval(c),-1):g})},t?500:600);return()=>{clearTimeout(r),clearInterval(c)}},[s.length,t]),e.jsx("div",{className:"p-6",style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"4px 8px"},children:s.map((r,c)=>{const x=c%2===0,g=c===s.length-1;return e.jsxs("div",{className:"contents",children:[e.jsx("div",{className:H("flex items-center","justify-end"),children:x&&e.jsx(as,{hop:r,compact:a,index:c,highlightIndex:i,isTrace:t})}),e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[28px]",children:!g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px flex-1 bg-border-strong/40 min-h-[8px]"}),r.snr!==void 0&&e.jsx(yn,{snr:r.snr,sf:n}),e.jsx("svg",{className:"w-3 h-3 text-fg-muted flex-shrink-0",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M6 2v8M3 7l3 3 3-3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})}),e.jsx("div",{className:H("flex items-center","justify-start"),children:!x&&e.jsx(as,{hop:r,compact:a,index:c,highlightIndex:i,isTrace:t})})]},`${r.prefix}-${c}`)})})}function bn({packet:s,neighbors:a,localHash:t,neighborAffinity:n,ghostPrefixes:i,direction:l="horizontal",compact:r=!1,traceSnr:c,overridePath:x}){const g=c!==void 0&&c.length>0,u=wt(),y=Ns(s.original_path),k=Ns(s.forwarded_path),b=x??(k.length>0?k:y),d=t?je(t):"",C=m.useMemo(()=>b.map((o,N)=>{const f=o.toUpperCase(),_=f===d,v=(i==null?void 0:i.has(f))??!1,p=kt(f,a,n);return{prefix:f,fullHash:p==null?void 0:p.hash,neighborInfo:p==null?void 0:p.info,isLocal:_,isGhost:v,confidence:p==null?void 0:p.confidence,snr:c==null?void 0:c[N]}}),[b,a,n,d,i,c]);if(C.length===0)return e.jsxs("div",{className:"flex items-center gap-2 text-fg-muted text-xs",children:[e.jsx(oe,{className:"w-4 h-4 opacity-50"}),e.jsx("span",{children:"Direct / No path data"})]});if(l==="flowchart")return e.jsx(jn,{hops:C,compact:r,isTrace:g,sf:u});const M=l==="horizontal"?he:Us;return e.jsx("div",{className:H("flex gap-1.5",l==="horizontal"?"flex-row flex-wrap items-center":"flex-col items-start"),children:C.map((o,N)=>e.jsxs("div",{className:H("flex items-center gap-1.5",l==="vertical"&&"flex-col"),children:[e.jsx(as,{hop:o,compact:r}),N"blue",Nn=[{fn:"id",group:"identity",fmt:"int",read:s=>ae(s.id),color:Q},{fn:"packet_hash",group:"identity",fmt:"hex",read:s=>s.packet_hash||void 0,color:Q},{fn:"timestamp",group:"identity",fmt:"epoch",read:s=>s.timestamp?String(s.timestamp):void 0,color:Q,annotate:s=>s.timestamp>0?Je(s.timestamp):void 0},{fn:"type",group:"classification",fmt:"enum",read:s=>ae(s.type??s.payload_type),color:Q},{fn:"route",group:"classification",fmt:"enum",read:s=>ae(s.route??s.route_type),color:Q},{fn:"rssi",group:"signal",fmt:"int",read:s=>ae(s.rssi,"dBm"),color:Q},{fn:"snr",group:"signal",fmt:"float",read:s=>ae(s.snr,"dB"),color:Q},{fn:"path_length",group:"size",fmt:"int",read:s=>{if(s.path_length!=null)return s.path_length===0?"zero-hop":`${s.path_length} hops`},color:Q},{fn:"payload_length",group:"size",fmt:"int",read:s=>ae(s.payload_length,"B"),color:Q},{fn:"airtime",group:"size",fmt:"float",read:s=>ae(s.airtime_ms,"ms"),color:Q},{fn:"src_hash",group:"addressing",fmt:"hex<2>",read:s=>s.src_hash??void 0,color:Q},{fn:"dst_hash",group:"addressing",fmt:"hex<2>",read:s=>s.dst_hash??void 0,color:Q},{fn:"path_hash",group:"addressing",fmt:"hex[]|hex",read:s=>Array.isArray(s.path_hash)?`[${s.path_hash.join(", ")}]`:ae(s.path_hash),color:Q,renderValue:s=>Array.isArray(s.path_hash)?Ye(s.path_hash):null},{fn:"score",group:"addressing",fmt:"int",read:s=>ae(s.score),color:Q},{fn:"original_path",group:"paths",fmt:"hex[]",read:s=>Array.isArray(s.original_path)?`[${s.original_path.join(", ")}]`:void 0,color:Q,renderValue:s=>Array.isArray(s.original_path)&&s.original_path.length>0?Ye(s.original_path,s.src_hash||void 0,s.dst_hash||void 0,!0):null},{fn:"forwarded_path",group:"paths",fmt:"hex[]",read:s=>Array.isArray(s.forwarded_path)?`[${s.forwarded_path.join(", ")}]`:void 0,color:Q,renderValue:s=>Array.isArray(s.forwarded_path)&&s.forwarded_path.length>0?Ye(s.forwarded_path):null},{fn:"transmitted",group:"status",fmt:"bool",read:s=>ae(s.transmitted),color:Q},{fn:"is_duplicate",group:"status",fmt:"bool",read:s=>ae(s.is_duplicate),color:Q},{fn:"drop_reason",group:"status",fmt:"string|null",read:s=>s.drop_reason??void 0,color:Q},{fn:"tx_delay",group:"status",fmt:"int",read:s=>ae(s.tx_delay_ms,"ms"),color:Q},{fn:"origin",group:"status",fmt:"enum",read:s=>s.packet_origin??void 0,color:Q},{fn:"duplicates",group:"status",fmt:"PacketDuplicate[]",read:s=>s.duplicates!=null&&s.duplicates.length>0?`${s.duplicates.length}`:ae(s.duplicates),color:Q},{fn:"lbt_attempts",group:"lbt",fmt:"int",read:s=>ae(s.lbt_attempts),color:Q},{fn:"lbt_backoff",group:"lbt",fmt:"json",read:s=>ae(s.lbt_backoff_delays_ms),color:Q},{fn:"lbt_busy",group:"lbt",fmt:"bool|int",read:s=>ae(s.lbt_channel_busy),color:Q}];function Ye(s,a,t,n){const i=s.length>0,l=a||n,r=t||n;return e.jsxs("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[l&&e.jsxs(e.Fragment,{children:[a?e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:a}):e.jsx("span",{className:"inline-block border border-edge-subtle/50 rounded px-1.5 py-0.5 font-mono text-[11px] text-fg-muted/30",children:"XX"}),(i||r)&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"})]}),s.map((c,x)=>e.jsxs(m.Fragment,{children:[x>0&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:c})]},x)),r&&e.jsxs(e.Fragment,{children:[i&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),t?e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:t}):e.jsx("span",{className:"inline-block border border-edge-subtle/50 rounded px-1.5 py-0.5 font-mono text-[11px] text-fg-muted/30",children:"XX"})]})]})}let Ee=null;function vn(){if(!Ee){Ee=new Map;for(const s of Nn)Ee.set(s.fn,s)}return Ee}function vs(s,a){var r;const t=vn().get(a);if(!t)return null;const n=t.read(s);if(n===void 0)return null;const i=t.color(s),l=(r=t.annotate)==null?void 0:r.call(t,s);return l?{text:n,color:i,annotation:l}:{text:n,color:i}}function ws(s){if(!s)return[];if(Array.isArray(s))return s;try{const a=JSON.parse(s);return Array.isArray(a)?a:[]}catch{return[]}}function ks({packets:s,selectedIndex:a,onSelect:t,compact:n=!1}){if(s.length<=1)return null;const i=a>0,l=ai&&t(a-1),disabled:!i,className:H("p-0.5 radius-badge transition-base",i?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Previous observation",children:e.jsx(Vs,{className:n?"size-3":"size-4"})}),e.jsx("div",{className:"flex items-center gap-0.5",children:s.map((r,c)=>{const x=c===a,u=new Date(r.timestamp*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsx(Rt,{color:x?"cyan":"zinc",filled:x,compact:n,onClick:()=>t(c),title:`Observation ${c+1} at ${u}`,className:H("transition-all duration-150",!x&&"opacity-60 hover:opacity-100"),children:n?e.jsx("span",{className:"tabular-nums",children:c+1}):e.jsxs("span",{className:"tabular-nums text-xs",children:["#",c+1,r.rssi!=null&&e.jsx("span",{className:"ml-1 opacity-70",children:r.rssi})]})},`${r.timestamp}_${c}`)})}),e.jsx("button",{onClick:()=>l&&t(a+1),disabled:!l,className:H("p-0.5 radius-badge transition-base",l?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Next observation",children:e.jsx(is,{className:n?"size-3":"size-4"})}),e.jsxs("span",{className:H("text-fg-muted ml-1",n?"text-[9px]":"text-xs"),children:[e.jsx(rs,{className:"inline size-3 mr-0.5 opacity-50"}),s.length]})]})}function ze({icon:s,label:a,disabled:t=!1}){return e.jsx(ce.div,{className:"flex items-center gap-1 text-xs",title:a,animate:{opacity:t?.25:.6},transition:{duration:.15,ease:[.4,0,.2,1]},children:e.jsx("span",{className:H("flex items-center justify-center size-5 radius-badge border-control transition-base",t?"bg-subtle-fill border-edge-subtle":"bg-subtle-fill"),children:s})})}function wn({hasDuplicates:s,hasPrev:a,hasNext:t,canPrevDupe:n,canNextDupe:i}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(ze,{icon:e.jsx(At,{className:"size-3"}),label:"Previous packet (↑)",disabled:!a}),e.jsx(ze,{icon:e.jsx(Ht,{className:"size-3"}),label:"Next packet (↓)",disabled:!t})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-3 bg-subtle-fill-strong"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(ze,{icon:e.jsx(Vs,{className:"size-3"}),label:"Previous observation (←)",disabled:!n}),e.jsx(ze,{icon:e.jsx(is,{className:"size-3"}),label:"Next observation (→)",disabled:!i})]})]})]})}function kn({packets:s,initialIndex:a=0,onClose:t,onNavigatePrev:n,onNavigateNext:i,hasPrev:l=!1,hasNext:r=!1,resolveSource:c,getDecodedContent:x}){var De;const[g,u]=m.useState(a),y=s[g]??s[0],k=s.length>1,[b,d]=m.useState(null),[C,M]=m.useState(!1);m.useEffect(()=>{if(!y._stripped){d(null);return}let j=!1;M(!0);const w=y.packet_hash;if(!w){M(!1);return}return St(w).then(S=>{j||(S.success&&S.data&&(d(S.data),(S.data.type??S.data.payload_type)===le.GRP_TXT&&S.data.raw_packet&&Tt.getState().queueDecryption([S.data])),M(!1))}).catch(()=>{j||M(!1)}),()=>{j=!0}},[y]);const o=b??y,N=g>0,f=g{u(Math.max(0,Math.min(j,s.length-1)))},[s.length]);m.useEffect(()=>{const j=w=>{if(!(w.target instanceof HTMLInputElement||w.target instanceof HTMLTextAreaElement))switch(w.key){case"ArrowUp":w.preventDefault(),n==null||n();break;case"ArrowDown":w.preventDefault(),i==null||i();break;case"ArrowLeft":w.preventDefault(),N&&u(S=>S-1);break;case"ArrowRight":w.preventDefault(),f&&u(S=>S+1);break}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[n,i,N,f]);const v=Ds(),p=Pt(),I=Bt(),V=Mt(),q=m.useMemo(()=>new Set(V.map(j=>j.prefix.toUpperCase())),[V]),Y=o.payload_type_name||Hs(o.payload_type??o.type),E=o.route_type_name||Fs(o.route_type??o.route),X=o.payload_length??o.length??0,F=o.path_hash_size,D=ws(o.original_path),W=ws(o.forwarded_path),Z=D.length>0||W.length>0,O=W.length>0?W:D,T=m.useMemo(()=>{var j;if((j=v==null?void 0:v.config)!=null&&j.repeater)return{latitude:v.config.repeater.latitude,longitude:v.config.repeater.longitude,name:v.config.node_name||"Local Node"}},[v]),$=(v==null?void 0:v.neighbors)??{},ee=I.size>0?I:void 0,ne=o.raw_packet&&o.raw_packet.length>0,P=y._stripped&&C,h=m.useMemo(()=>c?c(o):null,[c,o]),se=Lt(o.packet_hash),te=m.useMemo(()=>!x||(o.payload_type??o.type)!==le.GRP_TXT?null:x(o),[x,o]),R=m.useMemo(()=>{if((o.payload_type??o.type)!==le.GRP_TXT)return null;if(se!=null&&se.decoded){const w=se.decoded;return{type:"grp_txt",channelHash:w.channelHash,channelName:w.channelName,text:w.text??"",decrypted:w.decrypted,senderName:w.senderName,timestamp:w.timestamp,flags:w.flags,macCorrupted:w.macCorrupted}}return te!=null&&te.decrypted?{type:"grp_txt",channelHash:te.channelHash??"",channelName:te.channelName??"",text:te.text??"",decrypted:!0,senderName:te.senderName??"",timestamp:0,flags:0,macCorrupted:te.corrupted}:null},[o,se,te]),U=m.useMemo(()=>Zt(o,R),[o,R]),G=U.kind==="trace"?U.data:null,z=U.kind==="trace"?U.snrValues:void 0,L=U.kind==="advert"?U.data:null,ue=U.kind==="advert"?U.sourceNode:void 0,Me=U.kind==="grp_txt"?U.wardriveSourceNode??void 0:void 0,re=U.kind==="anon_req"?U.data:null,Le=j=>!j||j===0?"Unknown":new Date(j*1e3).toLocaleString(),Te=(o.payload_type??o.type)===le.ADVERT&&(ue!==void 0||Z),be=Me!==void 0,He=ue??Me,Fe=Be[Y]??"zinc",qe=me[Fe]||me.zinc;return e.jsxs(As,{open:!0,onClose:t,size:"5xl",motionPlus:!0,solid:!0,className:"sm:h-[85vh] sm:max-h-[800px] md:h-[80vh] md:max-h-[900px]",children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsx("div",{className:"flex justify-center pt-2 pb-1",children:e.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-muted","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:Be[Y]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:Y}),e.jsx(B,{color:Ie[E]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:E}),e.jsxs(B,{color:"zinc",className:"!text-[9px] !px-1.5 !py-0",children:[X,"B"]}),F!=null&&F>1&&e.jsxs(B,{color:"orange",className:"!text-[9px] !px-1.5 !py-0",children:[F,"B hashes"]})]}),e.jsx("button",{onClick:t,className:"px-3 py-1.5 text-[15px] font-medium text-sys-blue active:text-sys-blue/80 transition-base flex-shrink-0 radius-inner active:bg-subtle-fill",children:"Done"})]}),k&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(ks,{packets:s,selectedIndex:g,onSelect:_,compact:!0})})]}),e.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{color:Be[Y]??"zinc",children:Y}),e.jsx(B,{color:Ie[E]??"zinc",children:E}),e.jsxs(B,{color:"zinc",children:[X,"B"]}),F!=null&&F>1&&e.jsxs(B,{color:"orange",children:[F,"B hashes"]}),k&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-4 bg-subtle-fill-strong"}),e.jsx(ks,{packets:s,selectedIndex:g,onSelect:_})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(wn,{hasDuplicates:k,hasPrev:l,hasNext:r,canPrevDupe:N,canNextDupe:f}),e.jsx("button",{onClick:t,className:"p-1.5 -m-1.5 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-elevated flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:qe,opacity:.6}}),e.jsxs(Es,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[e.jsx("div",{className:"md:hidden flex-1 overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"px-2 pt-2 space-y-2",children:[(o.rssi!=null||o.snr!=null)&&e.jsxs("div",{className:"relative flex items-center justify-between px-2 py-1.5 radius-inner bg-subtle-fill depth-stroke",children:[e.jsx(We,{mode:"popLayout",initial:!1,children:e.jsxs(ce.div,{className:"flex items-center gap-3",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[e.jsx($e,{rssi:o.rssi,snr:o.snr,compact:!0,showValues:!0,validated:Ue(o)}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:us(o.rssi)})]},g)}),O.length>0&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[O.length," hop",O.length!==1?"s":""]})]}),(Z&&O.length>0||Te||be)&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Ge,{path:O,neighbors:$,localNode:T,localHash:v==null?void 0:v.local_hash,srcHash:o.src_hash,dstHash:o.dst_hash,neighborAffinity:ee,hubNodes:[...p],traceSnr:z,advertiserSource:He})})}),G&&G.pathHashes.length>0&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsx("div",{className:"px-3 py-2 space-y-1.5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(B,{color:G.isComplete?"green":"amber",compact:!0,children:G.isComplete?"Complete":"In Progress"})})]})}),e.jsx(ke,{packet:o,neighbors:$,localHash:v==null?void 0:v.local_hash,neighborAffinity:ee,ghostPrefixes:q,direction:"flowchart",compact:!0,overridePath:G.pathHashes,traceSnr:G.snrValues})]}),Z&&!G&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),e.jsxs(B,{color:"zinc",compact:!0,children:[O.length," hop",O.length!==1?"s":""]})]}),e.jsx(ke,{packet:o,neighbors:$,localHash:v==null?void 0:v.local_hash,neighborAffinity:ee,ghostPrefixes:q,direction:"flowchart",compact:!0,traceSnr:z})]}),h&&(h.name||h.hash)&&!L&&!re&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(B,{color:h.isRepeater?"blue":h.isCompanion?"violet":h.type==="room_server"?"lime":"zinc",compact:!0,children:h.type==="room_server"?"room server":h.type})]}),e.jsxs("div",{className:"p-3 space-y-1.5",children:[h.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:h.name}),!h.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),h.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-data-xs text-fg-muted truncate font-mono",children:h.hash.length>16?`${h.hash.slice(0,16)}…${h.hash.slice(-8)}`:h.hash.startsWith("0x")?h.hash.slice(2,10)+"…":h.hash.slice(0,8)+"…"})]})]})]}),re&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(B,{color:h!=null&&h.isRepeater?"blue":h!=null&&h.isCompanion?"violet":(h==null?void 0:h.type)==="room_server"?"lime":"amber",compact:!0,children:h!=null&&h.type&&h.type!=="unknown"?h.type==="room_server"?"room server":h.type:"companion"})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[(h==null?void 0:h.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:h.name}),!h.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Dest: ",e.jsx("span",{className:"font-mono",children:re.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ve,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted break-all font-mono leading-relaxed",children:re.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[re.ciphertextLength,"B encrypted payload"]})]})]})]}),L&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser Info"}),e.jsx(B,{color:"lime",compact:!0,children:L.nodeType})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[L.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:L.name})]}),L.latitude&&L.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[L.latitude.toFixed(5),", ",L.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",children:[L.publicKey.slice(0,16),"...",L.publicKey.slice(-8)]})]}),L.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Le(L.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:L.flagsDescription||`Flags: 0x${L.flags.toString(16).padStart(2,"0")}`})]})]})]}),P?e.jsx("div",{className:"pt-1 px-3 py-6 text-center",children:e.jsx("span",{className:"text-xs text-fg-muted animate-pulse",children:"Loading packet details…"})}):ne?e.jsx("div",{className:"pt-1",children:e.jsx(bs,{packet:o,decodedGrpTxt:R})}):null]})}),e.jsxs("div",{className:"hidden md:grid md:grid-cols-2 flex-1 overflow-hidden",children:[e.jsx("div",{className:"overflow-y-auto overflow-x-hidden scrollbar-none px-4 pt-4",children:P?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("span",{className:"text-sm text-fg-muted animate-pulse",children:"Loading packet details…"})}):ne?e.jsx(bs,{packet:o,decodedGrpTxt:R}):null}),e.jsxs("div",{className:"grid overflow-hidden",style:{gridTemplateRows:"minmax(280px, 1fr) auto"},children:[e.jsx("div",{className:"overflow-hidden p-2",children:Z&&O.length>0||Te||be?e.jsx("div",{className:"h-full w-full overflow-hidden",children:e.jsx(Ge,{path:O,neighbors:$,localNode:T,localHash:v==null?void 0:v.local_hash,srcHash:o.src_hash,dstHash:o.dst_hash,neighborAffinity:ee,hubNodes:[...p],traceSnr:z,advertiserSource:He})}):e.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center text-center px-4",children:[e.jsx(oe,{className:"w-8 h-8 text-fg-muted/50 mb-2"}),e.jsx("span",{className:"text-sm text-fg-muted",children:"Direct Reception"}),e.jsx("span",{className:"text-xs text-fg-muted/70 mt-1",children:"Zero-hop packet — received directly from sender"})]})}),e.jsxs("div",{className:"overflow-y-auto max-h-[200px] p-2 space-y-2",children:[!G&&O.length<=1&&(o.rssi!=null||o.snr!=null)&&e.jsx("div",{className:"surface-base radius-inner p-4 depth-stroke",children:e.jsxs("dl",{className:"text-xs grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"Signal"}),e.jsx(We,{mode:"popLayout",initial:!1,children:e.jsxs(ce.dd,{className:"flex items-center gap-2",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[e.jsx($e,{rssi:o.rssi,snr:o.snr,validated:Ue(o)}),e.jsx("span",{className:"font-medium text-fg-primary",children:us(o.rssi)})]},g)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"RF"}),e.jsx(We,{mode:"popLayout",initial:!1,children:e.jsxs(ce.dd,{className:"type-data text-fg-secondary",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[(De=vs(o,"rssi"))==null?void 0:De.text,(()=>{const j=vs(o,"snr");return j?` · ${j.text}`:null})()]},g)})]})]})}),h&&(h.name||h.hash)&&!L&&!re&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(B,{color:h.isRepeater?"blue":h.isCompanion?"violet":h.type==="room_server"?"lime":"zinc",compact:!0,children:h.type==="room_server"?"room server":h.type})]}),e.jsxs("div",{className:"p-4 space-y-2",children:[h.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:h.name}),!h.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),h.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:h.hash.length>16?`${h.hash.slice(0,16)}…${h.hash.slice(-8)}`:h.hash.startsWith("0x")?h.hash.slice(2,10)+"…":h.hash.slice(0,8)+"…"})]})]})]}),re&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(B,{color:h!=null&&h.isRepeater?"blue":h!=null&&h.isCompanion?"violet":(h==null?void 0:h.type)==="room_server"?"lime":"amber",compact:!0,children:h!=null&&h.type&&h.type!=="unknown"?h.type==="room_server"?"room server":h.type:"companion"})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[(h==null?void 0:h.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:h.name}),!h.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Dest: ",e.jsx("span",{className:"font-mono",children:re.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ve,{className:"w-4 h-4 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-muted break-all leading-relaxed",children:re.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[re.ciphertextLength,"B encrypted payload"]})]})]})]}),L&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser"}),e.jsx(B,{color:"lime",compact:!0,children:L.nodeType})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[L.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:L.name})]}),L.latitude&&L.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[L.latitude.toFixed(5),", ",L.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:[L.publicKey.slice(0,16),"...",L.publicKey.slice(-8)]})]}),L.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Le(L.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:L.flagsDescription||`Flags: 0x${L.flags.toString(16).padStart(2,"0")}`})]})]})]}),G&&G.pathHashes.length>0&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"px-4 py-2 flex items-center justify-between",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:G.isComplete?"green":"amber",compact:!0,children:G.isComplete?"Complete":"In Progress"}),e.jsxs(B,{color:"teal",compact:!0,children:[G.pathHashes.length,"h"]})]})]}),e.jsx(ke,{packet:o,neighbors:$,localHash:v==null?void 0:v.local_hash,neighborAffinity:ee,ghostPrefixes:q,direction:"flowchart",compact:!0,overridePath:G.pathHashes,traceSnr:G.snrValues})]}),Z&&!G&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),e.jsxs(B,{color:"zinc",compact:!0,children:[O.length,"h"]})]}),e.jsx(ke,{packet:o,neighbors:$,localHash:v==null?void 0:v.local_hash,neighborAffinity:ee,ghostPrefixes:q,direction:"flowchart",compact:!0,traceSnr:z})]})]})]})]})]})]})}const Cn=m.memo(kn);function Cs({label:s,numericValue:a,unit:t,icon:n,subtext:i,showSign:l=!1}){return e.jsxs("div",{className:"radius-inner p-3 sm:radius-inset sm:p-4 bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[e.jsx("div",{className:"mb-1.5 sm:mb-2",children:e.jsx("span",{className:"text-xs sm:type-micro text-fg-muted",children:s})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(es,{value:a,format:{minimumFractionDigits:1,maximumFractionDigits:1,signDisplay:l?"always":"auto"},className:"type-data-hero tracking-tight text-fg-primary"}),e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx(n,{className:"w-[14px] h-[14px] text-fg-muted"}),t&&e.jsx("span",{className:"text-xs font-medium leading-tight text-fg-muted",children:t})]})]}),i&&e.jsx("p",{className:"mt-1.5 sm:mt-2 type-data-xs sm:text-[11px] text-fg-muted/80 truncate",children:i})]})}function _n({snr:s}){const a=s>=5?"bg-sys-teal":s>=0?"bg-sys-green":s>=-5?"bg-sys-amber":s>=-10?"bg-sys-orange":"bg-sys-red";return e.jsx("span",{className:H("w-1.5 h-1.5 rounded-full flex-shrink-0",a),title:`SNR: ${s.toFixed(1)} dB`})}function _s({fromPrefix:s,toPrefix:a,fromName:t,toName:n,snr:i,maxSnr:l,isWeakest:r,isStrongest:c,index:x=0}){const u=Math.max(l+5,15),y=Math.max(0,Math.min(100,(i- -20)/(u- -20)*100)),k="bg-[#0074BE]",b=i>=5?"bg-sys-teal":i>=0?"bg-sys-green":i>=-5?"bg-sys-amber":i>=-10?"bg-sys-orange":"bg-sys-red",d=.3+x*.15;return e.jsxs("div",{className:"relative p-3 pl-5 radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[e.jsx("span",{className:H("absolute left-0 top-1/2 -translate-y-1/2 h-4 w-0.5 rounded-full",b)}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5",children:e.jsx(_n,{snr:i})}),e.jsxs("div",{className:"sm:hidden",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:"text-[13px] font-medium text-fg-secondary truncate",children:t||s}),e.jsx(he,{className:"w-3 h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold text-fg-primary truncate",children:n||a})]}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-2 flex-shrink-0",children:[r&&e.jsx(B,{color:"red",compact:!0,children:"Low"}),c&&!r&&e.jsxs(B,{color:"amber",compact:!0,children:[e.jsx(gs,{className:"w-2.5 h-2.5"}),"Best"]}),e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[12px] font-mono font-bold tabular-nums bg-subtle-fill-hover text-fg-primary ring-1 ring-inset ring-edge-subtle",children:[i>=0?"+":"−",Math.abs(i).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx(ce.div,{className:H("h-full rounded-full",k),initial:{width:0},animate:{width:`${y}%`},transition:{duration:1.5,delay:d,ease:[.25,.1,.25,1]}})})]}),e.jsxs("div",{className:"hidden sm:block",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"type-data-xs text-fg-muted",children:s}),t&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:t})]}),e.jsx(he,{className:"w-3 h-3 text-fg-muted/40 flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"font-mono text-xs font-semibold text-fg-primary",children:a}),n&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[r&&e.jsx(B,{color:"red",compact:!0,children:"Bottleneck"}),c&&!r&&e.jsxs(B,{color:"amber",compact:!0,children:[e.jsx(gs,{className:"w-3 h-3"}),"Strongest"]}),e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-sm font-mono font-semibold tabular-nums bg-subtle-fill-hover text-fg-primary ring-1 ring-inset ring-edge-subtle",children:[i>=0?"+":"−",Math.abs(i).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-elevated rounded-full overflow-hidden",children:e.jsx(ce.div,{className:H("h-full rounded-full",k),initial:{width:0},animate:{width:`${y}%`},transition:{duration:1.5,delay:d,ease:[.25,.1,.25,1]}})})]})]})}function fe(s,a){if(s==="You")return"You";const t=s.toUpperCase();for(const[n,i]of Object.entries(a))if((n.startsWith("0x")?n.slice(2,4):n.slice(0,2)).toUpperCase()===t)return i.name||i.node_name||void 0}function Sn({report:s,onClose:a}){var g,u;const t=Ds(),n=(t==null?void 0:t.neighbors)??{},i=(g=t==null?void 0:t.config)!=null&&g.repeater?{latitude:t.config.repeater.latitude,longitude:t.config.repeater.longitude,name:t.config.node_name||"Local Node"}:void 0,l=(u=s.bestObservation)==null?void 0:u.decoded.snrValues,r=s.linkQuality?s.linkQuality.avgSnr>=5?"excellent":s.linkQuality.avgSnr>=0?"good":s.linkQuality.avgSnr>=-5?"fair":"poor":"unknown",x={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",poor:"var(--signal-poor)",unknown:"var(--fg-muted)"}[r];return e.jsxs(As,{open:!0,onClose:a,size:"5xl",motionPlus:!0,children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsx("div",{className:"flex justify-center pt-2 pb-1",children:e.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-primary/30","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-center justify-between px-4 pb-2",children:[e.jsx("h2",{className:"font-semibold text-[17px] text-fg-primary",children:"Trace Report"}),e.jsx("button",{onClick:a,className:"text-[17px] font-medium text-sys-blue active:text-sys-blue/80",children:"Done"})]})]}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:x,opacity:.6}}),e.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[e.jsx("h2",{className:"type-micro",children:"Trace Report"}),e.jsxs(B,{color:r==="excellent"||r==="good"?"green":r==="fair"?"amber":"red",children:[e.jsx(fs,{className:"w-3 h-3 mr-1"}),r==="excellent"?"Excellent":r==="good"?"Good":r==="fair"?"Fair":"Poor"]})]}),e.jsx("p",{className:"mt-1 text-xs sm:text-sm font-mono text-fg-muted tabular-nums",children:s.traceTag})]}),e.jsx("button",{onClick:a,className:"p-1.5 -m-1.5 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-elevated flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsxs("div",{className:"hidden sm:flex flex-wrap items-center gap-1.5 sm:gap-2 px-4 sm:px-6 pb-3 sm:pb-4 border-b border-edge-subtle",children:[e.jsxs(B,{color:"teal",children:[e.jsx("span",{className:"font-mono tabular-nums",children:s.targetHopCount}),e.jsxs("span",{className:"ml-1",children:["hop",s.targetHopCount!==1?"s":""]})]}),e.jsxs(B,{color:"zinc",children:[e.jsx("span",{className:"font-mono tabular-nums",children:s.observationCount}),e.jsx("span",{className:"ml-1",children:"obs"})]}),s.linkQuality&&e.jsxs(B,{color:"indigo",children:[e.jsx("span",{className:"font-mono tabular-nums",children:s.linkQuality.avgSnr.toFixed(1)}),e.jsx("span",{className:"ml-1",children:"dB avg"})]}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Ft(s.duration)}),s.linkQuality&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-muted/40",children:"•"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-sys-red/15 text-sys-red ring-1 ring-inset ring-sys-red/25",children:[e.jsx("span",{className:"opacity-70",children:"Min"}),e.jsx("span",{className:"font-mono tabular-nums",children:s.linkQuality.minSnr.toFixed(1)})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-sys-teal/15 text-sys-teal ring-1 ring-inset ring-sys-teal/25",children:[e.jsx("span",{className:"opacity-70",children:"Max"}),e.jsx("span",{className:"font-mono tabular-nums",children:s.linkQuality.maxSnr.toFixed(1)})]})]})]})]}),e.jsxs(Es,{className:"p-0 overflow-hidden",children:[e.jsx("div",{className:"md:hidden h-[75vh] max-h-[calc(100vh-80px)] overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[s.linkQuality&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[e.jsx(es,{value:Math.abs(s.linkQuality.minSnr),format:{maximumFractionDigits:0,signDisplay:"never"},prefix:s.linkQuality.minSnr<0?"-":"",className:"text-[20px] font-bold font-mono tabular-nums flex items-center justify-center text-fg-primary"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(Ze,{className:"w-2.5 h-2.5 text-fg-muted"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Min dB"})]})]}),e.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[e.jsx(es,{value:s.linkQuality.maxSnr,format:{maximumFractionDigits:0,signDisplay:"always"},className:"text-[20px] font-bold font-mono text-fg-primary tabular-nums flex items-center justify-center"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(ps,{className:"w-2.5 h-2.5 text-fg-muted"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Max dB"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(B,{color:r==="excellent"||r==="good"?"green":r==="fair"?"amber":"red",compact:!0,children:[e.jsx(fs,{className:"w-2.5 h-2.5 mr-0.5"}),r==="excellent"?"Excellent":r==="good"?"Good":r==="fair"?"Fair":"Poor"]}),e.jsxs(B,{color:"teal",compact:!0,children:[s.targetHopCount," hops"]}),e.jsxs(B,{color:"zinc",compact:!0,children:[s.observationCount," obs"]}),e.jsx("span",{className:"type-data-xs text-fg-muted ml-auto",children:s.traceTag.slice(0,8)})]}),s.targetPath.length>0&&e.jsx("div",{className:"overflow-hidden radius-inset",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Ge,{path:s.targetPath,neighbors:n,localNode:i,localHash:t==null?void 0:t.local_hash,srcHash:s.srcHash,dstHash:s.dstHash,traceSnr:l})})}),e.jsxs("div",{className:"radius-inset bg-body overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"text-[11px] font-medium text-fg-secondary",children:"Route Path"}),s.linkQuality&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:["SNR ",s.linkQuality.minSnr.toFixed(1)," → ",s.linkQuality.maxSnr.toFixed(1)," dB"]})]}),s.bestObservation?e.jsx(ke,{packet:s.bestObservation.packet,neighbors:n,localHash:t==null?void 0:t.local_hash,direction:"flowchart",compact:!0,overridePath:s.targetPath,traceSnr:s.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-6 text-center text-fg-muted text-xs",children:"No path data available"})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"type-micro text-fg-muted mb-2",children:["Link Quality · ",s.hopStats.length," hops"]}),e.jsx("div",{className:"space-y-1.5",children:s.hopStats.length>0?s.hopStats.map((y,k)=>{var M,o,N;const b=k{const y=s.targetPath[s.linkQuality.weakestLinkPosition],k=s.targetPath[s.linkQuality.weakestLinkPosition+1]||"You",b=fe(y,n),d=fe(k,n),C=s.targetPath[s.linkQuality.strongestLinkPosition],M=s.targetPath[s.linkQuality.strongestLinkPosition+1]||"You",o=fe(C,n),N=fe(M,n);return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Cs,{label:"Weakest Link",numericValue:s.linkQuality.minSnr,unit:"dB",icon:Ze,subtext:`${b||y} → ${d||k}`}),e.jsx(Cs,{label:"Best Link",numericValue:s.linkQuality.maxSnr,showSign:!0,unit:"dB",icon:ps,subtext:`${o||C} → ${N||M}`})]})})(),e.jsxs("div",{children:[e.jsx("h3",{className:"type-micro text-fg-muted mb-3",children:"Link Details"}),e.jsx("div",{className:"space-y-2",children:s.hopStats.length>0?s.hopStats.map((y,k)=>{var M,o,N;const b=k0&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-square w-full",children:e.jsx(Ge,{path:s.targetPath,neighbors:n,localNode:i,localHash:t==null?void 0:t.local_hash,srcHash:s.srcHash,dstHash:s.dstHash,traceSnr:l})})}),e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:s.isComplete?"green":"amber",compact:!0,children:s.isComplete?"Complete":`${s.maxHopsObserved}/${s.targetHopCount}`}),e.jsxs(B,{color:"teal",compact:!0,children:[s.targetHopCount," hop",s.targetHopCount!==1?"s":""]})]})]}),s.linkQuality&&s.bestObservation&&e.jsxs("div",{className:"flex items-center gap-4 px-4 pb-2 type-data-xs text-fg-muted",children:[e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"Tag"})," ",e.jsx("code",{className:"text-sys-teal tabular-nums",children:s.traceTag.slice(0,8)})]}),e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"SNR"})," ",e.jsxs("code",{className:"text-sys-indigo tabular-nums",children:[s.linkQuality.minSnr.toFixed(1),"–",s.linkQuality.maxSnr.toFixed(1)]}),e.jsx("span",{className:"opacity-60",children:" dB"})]})]}),s.bestObservation?e.jsx(ke,{packet:s.bestObservation.packet,neighbors:n,localHash:t==null?void 0:t.local_hash,direction:"flowchart",compact:!0,overridePath:s.targetPath,traceSnr:s.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-8 text-center text-fg-muted text-xs",children:"No path data available"})]})]})]})]})]})}const Tn=m.memo(Sn),Zs=[{target:"PacketList",fn:"type",minStage:1},{target:"PacketList",fn:"route",minStage:1},{target:"PacketList",fn:"rssi",minStage:1},{target:"PacketList",fn:"snr",minStage:1},{target:"PacketList",fn:"path",minStage:1,when:Vt},{target:"PacketList",fn:"src_hash",minStage:1,when:Gt},{target:"PacketList",fn:"text",minStage:1,when:Qt},{target:"PacketList",fn:"ack",minStage:1,when:qt},{target:"PacketList",fn:"decrypt",minStage:2,when:Wt},{target:"PacketList",fn:"duplicates",minStage:1}];Ot(Zs);const Pn=48,Bn=72,Mn=100,Ln=5,Rn=600,Js="(min-width: 640px)";let xe=null;function Hn(s){return typeof window>"u"?()=>{}:(xe||(xe=window.matchMedia(Js)),xe.addEventListener("change",s),()=>xe==null?void 0:xe.removeEventListener("change",s))}function Fn(){return typeof window>"u"?!0:(xe||(xe=window.matchMedia(Js)),xe.matches)}function Dn(){return m.useSyncExternalStore(Hn,Fn,()=>!0)}function An(s,a,t){const[n,i]=m.useState(1),l=t?Math.ceil(s/a):1;m.useEffect(()=>{n>l&&l>0&&queueMicrotask(()=>i(1))},[l,n]);const r=m.useCallback(x=>i(Math.max(1,Math.min(x,l))),[l]),c=m.useMemo(()=>ka(n,l),[n,l]);return{currentPage:n,totalPages:l,goToPage:r,pageRange:c}}function En(s,a){const[t,n]=m.useState(null),i=m.useRef(0);return m.useEffect(()=>{var u,y;if(!a||!s.length)return;const l=((u=s[0])==null?void 0:u.timestamp)??0,r=l>i.current&&i.current>0;if(i.current=l,!r)return;const c=(y=s[0])==null?void 0:y.packet_hash;if(!c)return;const x=requestAnimationFrame(()=>n(c)),g=setTimeout(()=>n(null),600);return()=>{cancelAnimationFrame(x),clearTimeout(g)}},[s,a]),t}function zn(s){if(!s||s.length<6)return null;const a=Dt(s);if(!a||a.offset>=s.length)return null;const t=s.slice(a.offset);return t.length>=38?t.slice(0,38):t}function In(s){if(s.length<=1)return s;const a=new Map,t=new Map,n=new Map;for(let r=0;r0?{packet:s[r].packet,dupeCount:s[r].dupeCount+c}:s[r])}return l}function $n(s){const a=new Map;for(const t of s)if((t.payload_type??t.type)===ls.TRACE&&t.packet_hash){const i=t._traceTag??(t.payload?zs(t.payload):null);i&&a.set(t.packet_hash,i)}return a}function Un(s){const a=new Map;if(s.length===0)return a;for(let t=0;tj.setModalMapOpen);m.useEffect(()=>(q(!!N),()=>q(!1)),[N,q]),m.useLayoutEffect(()=>{I({traceTag:null,dupeGroup:null})},[s]);const Y=a??s,E=m.useMemo(()=>l&&l>0&&!b?s.slice(0,l):s,[s,l,b]),X=m.useMemo(()=>{if(!b)return null;const j=Ca(E),w=In(j);return l&&l>0?w.slice(0,l):w},[E,b,l]),F=X?X.length:E.length,{currentPage:D,totalPages:W,goToPage:Z,pageRange:O}=An(F,r,c),T=m.useMemo(()=>{if(b||!c)return E;const j=(D-1)*r;return E.slice(j,j+r)},[E,c,D,r,b]),$=m.useMemo(()=>{if(!X)return null;if(!c)return X;const j=(D-1)*r;return X.slice(j,j+r)},[X,c,D,r]),ee=m.useMemo(()=>$n(T),[T]),ne=m.useMemo(()=>Un(T),[T]),P=En(s,g),h=Dn(),se=m.useMemo(()=>b&&$?$:T,[b,$,T]),te=o&&se.length>Mn,R=h?Pn:Bn,U=Et({count:te?se.length:0,getScrollElement:()=>V.current,estimateSize:()=>R,overscan:Ln}),G=m.useCallback((j,w)=>{var Ne,Ae;const S=j.packet_hash;if(!S)return[j];let A=w;for(;A>0&&((Ne=T[A-1])==null?void 0:Ne.packet_hash)===S;)A--;let K=w;for(;K{var A,K;const w=(A=T[j])==null?void 0:A.packet_hash;if(!w)return j;let S=j;for(;S>0&&((K=T[S-1])==null?void 0:K.packet_hash)===w;)S--;return S},[T]),L=m.useCallback(j=>{var A,K;const w=(A=T[j])==null?void 0:A.packet_hash;if(!w)return j;let S=j;for(;S{if(x){x(j);return}if(w!==void 0){const S=G(j,w),A=S.indexOf(j);f({packets:S,initialIndex:A>=0?A:0,rowIndex:w})}else f({packets:[j],initialIndex:0,rowIndex:0})},[x,G]),Me=m.useCallback(()=>{if(!N)return;const w=z(N.rowIndex)-1;if(w<0)return;const S=T[w];if(!S)return;const A=G(S,w);f({packets:A,initialIndex:0,rowIndex:w})},[N,T,z,G]),re=m.useCallback(()=>{if(!N)return;const w=L(N.rowIndex)+1;if(w>=T.length)return;const S=T[w];if(!S)return;const A=G(S,w);f({packets:A,initialIndex:0,rowIndex:w})},[N,T,L,G]),Le=m.useMemo(()=>N?z(N.rowIndex)>0:!1,[N,z]),os=m.useMemo(()=>N?L(N.rowIndex)I(w=>({...w,traceTag:j})),[]),Te=m.useCallback(j=>I(w=>({...w,dupeGroup:j})),[]),ds=m.useCallback(()=>{I({traceTag:null,dupeGroup:null})},[]),be=m.useCallback(j=>{const w=Y.filter(K=>(K.payload_type??K.type)===ls.TRACE&&K.payload&&zs(K.payload)===j);if(w.length===0)return;const A=It(w).get(j);A!=null&&A.length&&v($t(j,A))},[Y]),He=m.useCallback(j=>{const w=Y.find(S=>S.packet_hash===j);w&&(v(null),ue(w))},[Y,ue]),Fe=m.useCallback((j,w,S)=>{const A=h?Ra:Ha;if(S){const{packet:pe,dupeCount:st}=j,ms=pe.packet_hash?ee.get(pe.packet_hash):void 0,tt=p.traceTag!==null&&ms===p.traceTag;return e.jsx(A,{packet:pe,onClick:at=>ue(at,w),localHash:t,neighbors:n,resolveSource:M,isFlashing:g&&P===pe.packet_hash,traceTag:ms,isTraceHighlighted:tt,onTraceHover:Re,onViewTraceReport:be,dupeCount:st,getDecodedContent:d,onChannelClick:C},`${pe.packet_hash}_${pe.timestamp}_${w}`)}const K=j,Ne=K.packet_hash?ee.get(K.packet_hash):void 0,Ae=p.traceTag!==null&&Ne===p.traceTag,xs=ne.get(w),et=xs!==void 0&&p.dupeGroup!==null&&K.packet_hash===p.dupeGroup;return e.jsx(A,{packet:K,onClick:pe=>ue(pe,w),localHash:t,neighbors:n,resolveSource:M,isFlashing:g&&P===K.packet_hash,traceTag:Ne,isTraceHighlighted:Ae,onTraceHover:Re,onViewTraceReport:be,dupeGroupPosition:xs,isDupeGroupHovered:et,onDupeGroupHover:Te,getDecodedContent:d,onChannelClick:C},`${K.packet_hash}_${K.timestamp}_${w}`)},[h,ee,p.traceTag,p.dupeGroup,ue,t,n,M,g,P,Re,be,ne,Te,d,C]),qe=()=>{if(i&&s.length===0)return e.jsx(Ts,{});if(T.length===0)return e.jsx(Ss,{message:u});const j=b&&$!==null;return(j?$:T).map((S,A)=>Fe(S,A,j))},De=()=>{if(i&&s.length===0)return e.jsx(Ts,{});if(se.length===0)return e.jsx(Ss,{message:u});const j=b&&$!==null,w=U.getVirtualItems();return e.jsx("div",{style:{height:`${U.getTotalSize()}px`,width:"100%",position:"relative"},children:w.map(S=>{const A=se[S.index];return e.jsx("div",{"data-index":S.index,ref:U.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${S.start}px)`},children:Fe(A,S.index,j)},S.key)})})};return e.jsxs("div",{className:H("flex flex-col",y),onMouseLeave:ds,children:[te?e.jsx("div",{ref:V,className:"divide-y divide-edge-subtle overflow-auto",style:{maxHeight:Rn},children:De()}):e.jsx("div",{className:"divide-y divide-edge-subtle py-1",children:qe()}),c&&W>1&&e.jsx("nav",{className:"border-t border-edge-subtle px-4 py-3",children:e.jsxs(ya,{className:"justify-center",children:[e.jsx(ja,{onClick:()=>Z(D-1),disabled:D===1}),e.jsx(Na,{children:O.map((j,w)=>j==="gap"?e.jsx(wa,{},`gap-${w}`):e.jsx(va,{page:j,current:j===D,onClick:Z},j))}),e.jsx(ba,{onClick:()=>Z(D+1),disabled:D===W})]})}),e.jsx(On,{showPagination:c,currentPage:D,perPage:r,displayCount:$?$.length:T.length,totalCount:c?F:s.length,action:k}),!x&&N&&e.jsx(Cn,{packets:N.packets,initialIndex:N.initialIndex,onClose:()=>f(null),onNavigatePrev:Me,onNavigateNext:re,hasPrev:Le,hasNext:os,resolveSource:M,getDecodedContent:d}),_&&e.jsx(Tn,{report:_,onClose:()=>v(null),onViewPacket:He})]})}export{Ws as C,pr as P,fs as S,gs as T,Ta as g,ur as u}; + `},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.senderName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["From ",e.jsx("span",{className:"text-fg-secondary font-medium",children:s.senderName})]}),s.channelName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["in ",e.jsx("span",{className:"text-sys-cyan font-medium",children:s.channelName})]})]}),e.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tl-md",style:{background:"linear-gradient(135deg, var(--sys-blue) 0%, color-mix(in srgb, var(--sys-blue) 85%, var(--sys-cyan)) 100%)"},children:e.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:s.text})})]})}):e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-zinc-500/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--zinc-500) 0%, color-mix(in srgb, var(--zinc-500) 70%, black) 100%)"},children:e.jsx(cs,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:s.isPublicHashChannel?"Public Hash Channel":"Encrypted Message"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Channel hash: ",e.jsxs("span",{className:"font-mono",children:["0x",s.channelHash]})]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-zinc-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:i})]}),s.ciphertextHex&&s.macHex&&e.jsx("div",{className:"space-y-2",children:y?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:l,onChange:d=>r(d.target.value),placeholder:"Channel name (e.g. south-bay)",className:"flex-1 px-3 py-1.5 text-sm rounded-lg bg-subtle-fill-strong border border-edge-subtle text-fg-primary placeholder:text-fg-muted focus:outline-none focus:border-zinc-500",onKeyDown:d=>d.key==="Enter"&&b(),disabled:c}),e.jsx("button",{onClick:b,disabled:c||!l.trim(),className:"px-3 py-1.5 text-sm font-medium rounded-lg bg-zinc-600 hover:bg-zinc-500 text-white disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:c?"Testing...":"Try"}),e.jsx("button",{onClick:()=>{k(!1),u(null),r("")},className:"px-2 py-1.5 text-sm rounded-lg hover:bg-subtle-fill-strong text-fg-muted transition-colors",children:"×"})]}),g&&e.jsx("p",{className:"text-xs text-sys-red",children:g})]}):e.jsx("button",{onClick:()=>k(!0),className:"text-xs text-zinc-400 hover:text-zinc-300 underline underline-offset-2 transition-colors",children:"Know the channel name? Try to decrypt"})}),!y&&e.jsx("p",{className:"text-xs text-fg-muted",children:s.isPublicHashChannel?"Public hash channel message. Key not in common channel list.":"Unknown hash channel. Channel name required for decryption."})]})]})})}function on({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown";return e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:"linear-gradient(135deg, var(--sys-green) 0%, var(--sys-teal) 100%)"},children:e.jsx(bt,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Acknowledgment"}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:["CRC: ",e.jsxs("span",{className:"font-mono text-sys-green",children:["0x",s.crc]})," · ",t]})]})]})}function dn({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown",n=s.path.length;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-amber/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-amber) 0%, var(--sys-orange) 100%)"},children:e.jsx(sa,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Path Response"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[n," ",n===1?"hop":"hops"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:t})]}),s.path.length>0&&e.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.path.map((i,l)=>e.jsxs("div",{className:"flex items-center gap-2",children:[l>0&&e.jsx(he,{className:"w-4 h-4 text-sys-amber"}),e.jsx(B,{color:"amber",className:"font-mono",children:i})]},l))})})]})]})})}function xn({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown",n=s.pathHashes.length,i=s.snrValues.length,l=r=>r>=7?"green":r>=0?"yellow":r>=-5?"orange":"red";return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-blue/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-blue) 0%, var(--sys-indigo) 100%)"},children:e.jsx(ta,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:["Trace ",s.isComplete?"Complete":"In Progress"]}),e.jsxs("p",{className:"text-sm text-fg-muted mt-0.5",children:["Tag: 0x",s.traceTag.slice(0,8),s.isComplete&&" • ✓"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary",children:t})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-fg-muted",children:[e.jsxs("span",{children:[n," target ",n===1?"hop":"hops"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[i," SNR ",i===1?"sample":"samples"]}),s.authCode!==0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:["Auth: ",s.authCode]})]})]}),s.pathHashes.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:s.pathHashes.map((r,c)=>{const x=s.snrValues[c],g=x!==void 0?l(x):"zinc",u=x!==void 0;return e.jsxs("div",{className:"flex items-center gap-2",children:[c>0&&e.jsx(he,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{color:u?"blue":"zinc",className:"font-mono",children:r}),u&&e.jsxs(B,{color:g,className:"font-mono",children:[x>=0?"+":"",Number.isInteger(x)?x:x.toFixed(1),"dB"]})]})]},c)})})]})]})})}function mn({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown";return s.encrypted?e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:"linear-gradient(135deg, var(--sys-indigo) 0%, var(--sys-blue) 100%)"},children:e.jsx(cs,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Encrypted Message"}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[s.srcHash," → ",s.destHash," · ",t]})]})]}):e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 px-1",children:[e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:[e.jsx("span",{className:"font-mono text-fg-secondary",children:s.srcHash})," → ",e.jsx("span",{className:"font-mono text-fg-secondary",children:s.destHash})]}),e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["· ",t]})]}),e.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tr-md ml-auto",style:{background:"linear-gradient(135deg, var(--sys-green) 0%, var(--sys-teal) 100%)"},children:e.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:s.text})})]})}function hn({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown",n=(s.partNumber+1)/s.totalParts*100;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-yellow/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-yellow) 0%, var(--sys-amber) 100%)"},children:e.jsx(ea,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Multipart Segment"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Part ",s.partNumber+1," of ",s.totalParts]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsx("div",{children:e.jsx("div",{className:"h-2 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${n}%`,background:"linear-gradient(90deg, var(--sys-yellow), var(--sys-amber))"}})})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Os,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-sans",children:["Message ID: ",e.jsx("span",{className:"font-mono",children:s.messageId})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:t})]})]})]})})}function un({decoded:s,timestamp:a,payloadType:t}){const n=a?ie(a):"Unknown",l=(()=>{switch(t){case le.REQ:return{icon:vt,gradient:"var(--sys-orange), var(--sys-red)",bg:"rgba(249, 115, 22, 0.15)",label:"Request"};case le.RESPONSE:return{icon:da,gradient:"var(--sys-green), var(--sys-teal)",bg:"rgba(34, 197, 94, 0.15)",label:"Response"};case le.ANON_REQ:return{icon:cs,gradient:"var(--sys-indigo), var(--sys-pink)",bg:"rgba(91, 91, 214, 0.15)",label:"Anonymous Request"};default:return{icon:Yt,gradient:"var(--sys-gray), var(--sys-slate)",bg:"rgba(107, 114, 128, 0.15)",label:s.payloadTypeName}}})(),r=l.icon;return e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:`linear-gradient(135deg, ${l.gradient})`},children:e.jsx(r,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:l.label}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[s.length," bytes · ",n]})]})]})}function pn({pathHex:s}){if(!s)return null;const a=Qe(s);return e.jsx("div",{className:"flex flex-wrap items-center gap-2 py-2",children:a.map((t,n)=>e.jsxs("div",{className:"flex items-center gap-2",children:[n>0&&e.jsx(he,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(J,{size:"compact",copy:!0,children:t.toUpperCase()}),e.jsx("span",{className:"text-xs text-fg-muted font-sans tabular-nums w-4 text-left",children:n+1})]})]},n))})}function fn({decoded:s,payloadType:a}){const t=yt[a]||`TYPE_${a}`;switch(s.type){case"advert":{const n=s.nodeType==="chat"?"companion":s.nodeType.replace("_"," "),i=s.latitude!==void 0&&s.longitude!==void 0&&!(s.latitude===0&&s.longitude===0);return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Role:"})," ",n]}),s.name&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Name:"})," ",s.name]}),i&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Location:"})," ",s.latitude.toFixed(4),"°, ",s.longitude.toFixed(4),"°"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Time:"})," ",ie(s.timestamp)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Flags:"})," ",s.flagsDescription]})]})}case"ack":return e.jsx("div",{className:"text-xs text-fg-primary space-y-0.5",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"CRC:"})," 0x",s.crc]})});case"path":return e.jsx("div",{className:"text-xs text-fg-primary space-y-1",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Path:"})," ",s.pathString||"(empty)"]})});case"trace":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Tag:"})," 0x",s.traceTag]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Target Path:"})," ",s.pathString||"(empty)"]}),s.snrValues.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"SNR:"})," ",s.snrValues.map(n=>`${n>=0?"+":""}${Number.isInteger(n)?n:n.toFixed(1)}dB`).join(" → ")]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Status:"})," ",s.isComplete?"✓ Complete":`In progress (${s.snrValues.length}/${s.pathHashes.length})`]})]});case"txt_msg":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",s.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",s.srcHash]}),s.encrypted?e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted content"}):e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",s.text]})]});case"grp_txt":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",s.channelName?e.jsx("span",{className:"text-sys-green",children:s.channelName}):s.isPublicHashChannel?e.jsx("span",{className:"text-sys-indigo",children:"Public Hash Channel"}):e.jsxs("span",{className:"font-mono",children:["0x",s.channelHash]})]}),s.decrypted?e.jsxs(e.Fragment,{children:[s.senderName&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"From:"})," ",s.senderName]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",s.text]})]}):s.isPublicHashChannel?e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (public hash channel)"}):e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (unknown channel)"})]});case"grp_data":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",s.channelName?e.jsx("span",{className:"text-sys-teal",children:s.channelName}):e.jsxs("span",{className:"font-mono",children:["0x",s.channelHash]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",s.dataLength," bytes ",s.decrypted?"(decrypted)":"(encrypted)"]})]});case"multipart":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Part:"})," ",s.partNumber+1,"/",s.totalParts]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Message ID:"})," ",s.messageId]})]});case"control":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Control:"})," ",s.subtypeName]}),s.dataLength>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",s.dataLength," bytes"]})]});case"req":case"response":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",s.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",s.srcHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",s.ciphertextLength," bytes"]})]});case"anon_req":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",s.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Pub Key:"})," ",e.jsxs("span",{className:"font-mono break-all",children:[s.senderPublicKey.slice(0,16),"…"]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",s.ciphertextLength," bytes"]})]});default:return e.jsxs("p",{className:"text-xs text-fg-secondary",children:[t," (","length"in s?s.length:0," bytes)"]})}}function gn({packet:s,decodedGrpTxt:a}){var z,X;const t=s.raw_packet||"",n=t.length/2,i=mt(),[l,r]=m.useState(null),[c,x]=m.useState(null),[g,u]=m.useState(!1),[y,k]=m.useState(null),b=m.useCallback(F=>{k(D=>D===F?null:F)},[]),d=m.useMemo(()=>Et(t),[t]),C=(z=d==null?void 0:d.packet)==null?void 0:z.payloadType,M=(d==null?void 0:d.payloadHex)||"",o=(X=d==null?void 0:d.packet)==null?void 0:X.payload,N=C===le.GRP_TXT,f=C===le.GRP_DATA,_=N&&!a&&(!i||g);if(m.useEffect(()=>{if(r(null),u(!1),a||!N||!o||o.length<4)return;if(!i){u(!0);return}u(!0);let F=!1;return ht(o).then(D=>{F||(r(D),u(!1))}),()=>{F=!0}},[M,N,i,a]),m.useEffect(()=>{if(x(null),!f||!o||o.length<4||!i)return;let F=!1;return ut(o).then(D=>{F||x(D)}),()=>{F=!0}},[M,f,i]),!d||t.length===0)return e.jsx("div",{className:"p-4 text-center text-fg-muted",children:e.jsx("p",{className:"text-sm",children:"No raw packet data available"})});const{packet:v}=d;let p=d.decoded;a&&d.decoded.type==="grp_txt"?p=a:l&&d.decoded.type==="grp_txt"?p=l:c&&d.decoded.type==="grp_data"&&(p=c);const I=()=>{switch(p.type){case"advert":return e.jsx(rn,{advert:p,timestamp:s.timestamp});case"grp_data":return e.jsx(ln,{decoded:p,timestamp:s.timestamp});case"grp_txt":return e.jsx(cn,{decoded:p,timestamp:s.timestamp,isLoading:_,onDecrypted:r});case"ack":return e.jsx(on,{decoded:p,timestamp:s.timestamp});case"path":return e.jsx(dn,{decoded:p,timestamp:s.timestamp});case"trace":return e.jsx(xn,{decoded:p,timestamp:s.timestamp});case"txt_msg":return e.jsx(mn,{decoded:p,timestamp:s.timestamp});case"multipart":return e.jsx(hn,{decoded:p,timestamp:s.timestamp});case"generic":return v.payloadType===le.REQ||v.payloadType===le.RESPONSE||v.payloadType===le.ANON_REQ?e.jsx(un,{decoded:p,timestamp:s.timestamp,payloadType:v.payloadType}):null;default:return null}},V=m.useMemo(()=>tn(p,d.payloadHex),[p,d.payloadHex]),q=y==="payload"||ye(y),Y=m.useMemo(()=>{const F=[{id:"header",hex:d.headerHex,color:"red"},...d.transportCodesHex?[{id:"transportCodes",hex:d.transportCodesHex,color:"indigo"}]:[],{id:"pathLength",hex:d.pathLengthHex,color:"green"},...d.pathDataHex?[{id:"pathData",hex:d.pathDataHex,color:"amber"}]:[]];return q?[...F,...an(V)]:[...F,{id:"payload",hex:d.payloadHex,color:"cyan"}]},[d,q,V]);return e.jsxs("div",{className:"font-mono space-y-2 min-w-0 overflow-hidden",children:[I(),e.jsx(Wa,{rawHex:t,hexSegments:Y,selectedSegment:y,onSegmentClick:b}),e.jsx(pt,{children:e.jsx(ce.div,{layout:!0,transition:ts,className:"space-y-2 min-w-0",children:(()=>{var T,$,ee,ne;const D=[{id:"header",title:"Header",color:"red",startByte:0,endByte:0,hexBytes:`0x${d.headerHex.toUpperCase()}`,condition:!0,content:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"type-micro text-fg-muted font-sans",children:[e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Bits"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Field"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Value"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Binary"})})]})}),e.jsx("tbody",{children:d.headerFields.map(P=>e.jsx(nn,{...P},P.bits))})]})},{id:"transportCodes",title:"Transport Codes",color:"indigo",startByte:1,endByte:4,hexBytes:((T=d.transportCodesHex)==null?void 0:T.toUpperCase())||"",condition:!!d.transportCodesHex,content:e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-fg-muted",children:"Two 16-bit transport codes for encrypted routing"}),e.jsxs("div",{className:"mt-1 text-xs text-fg-secondary",children:["Code 1: 0x",($=d.transportCodesHex)==null?void 0:$.slice(0,4).toUpperCase()," | Code 2: 0x",(ee=d.transportCodesHex)==null?void 0:ee.slice(4,8).toUpperCase()]})]})},{id:"pathLength",title:"Path Length",color:"green",startByte:d.transportCodesHex?5:1,endByte:d.transportCodesHex?5:1,hexBytes:`0x${d.pathLengthHex.toUpperCase()}`,condition:!0,content:e.jsxs("p",{className:"text-xs text-fg-muted pt-1",children:[v.pathLen," bytes showing route taken (increases as packet floods)"]})},{id:"pathData",title:"Path Data",color:"amber",startByte:d.transportCodesHex?6:2,endByte:(d.transportCodesHex?5:1)+v.pathLen,hexBytes:((ne=d.pathDataHex)==null?void 0:ne.toUpperCase())||"",condition:v.pathLen>0,content:e.jsxs("div",{className:"space-y-3",children:[e.jsx(pn,{pathHex:d.pathDataHex}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Historical route taken (bytes are added as packet floods through network)"})]})},{id:"payload",title:"Payload",color:"cyan",startByte:d.payloadStartByte,endByte:n-1,hexBytes:d.payloadHex.toUpperCase(),condition:!0,content:e.jsxs(e.Fragment,{children:[!ye(y)&&e.jsxs("div",{className:"p-3 radius-inner bg-inset depth-stroke-inset",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-1.5 font-sans",children:"Decoded"}),e.jsx(fn,{decoded:p,payloadType:v.payloadType})]}),!ye(y)&&V.length>0&&e.jsx("p",{className:"type-micro text-fg-muted mt-3 font-sans",children:"Click a field below to highlight its bytes"}),ye(y)&&e.jsx("p",{className:"type-micro text-fg-muted font-sans",children:"↑ Selected field above • Other fields below ↓"})]})}].filter(P=>P.condition),W=ye(y)?V.find(P=>P.id===y):null,Z=ye(y)?[...D].sort((P,h)=>P.id==="payload"?-1:h.id==="payload"?1:0):[...D].sort((P,h)=>P.id===y?-1:h.id===y?1:0),O=ye(y)?V.filter(P=>P.id!==y):[];return e.jsxs(e.Fragment,{children:[W&&e.jsx(js,{id:`subfield-${W.id}`,title:W.title,color:W.color,startByte:d.payloadStartByte+W.startByte,endByte:d.payloadStartByte+W.endByte,hexBytes:W.hex.toUpperCase(),isSelected:!0,children:W.decoded},W.id),Z.map(P=>e.jsx(js,{id:`section-${P.id}`,title:P.title,color:P.color,startByte:P.startByte,endByte:P.endByte,hexBytes:P.hexBytes,isSelected:P.id===y,children:P.content},P.id)),O.map(P=>e.jsxs(ce.div,{layout:"position",layoutId:`subfield-${P.id}`,transition:ts,className:"w-full min-w-0 overflow-hidden radius-inner p-4 sm:p-5 space-y-4",style:{backgroundColor:_e.cardRestBg,boxShadow:_e.cardRestShadow},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 min-w-0",children:[e.jsx(B,{color:P.color,children:P.title}),P.hex.length<=32&&Qe(P.hex).map((h,se)=>e.jsx(B,{color:P.color,className:"font-mono",children:h.toUpperCase()},se))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",d.payloadStartByte+P.startByte,"-",d.payloadStartByte+P.endByte]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden p-3 radius-inner bg-inset depth-stroke-inset",children:P.decoded})]},P.id))]})})()})})]})}const bs=m.memo(gn);function Ns(s){if(!s)return[];if(Array.isArray(s))return s;try{const a=JSON.parse(s);return Array.isArray(a)?a:[]}catch{return[]}}function as({hop:s,compact:a=!1,index:t=0,highlightIndex:n=-1,isTrace:i=!1}){var c;const l=t===n,r=ga();return m.useEffect(()=>{l&&i&&r.start({boxShadow:["0 0 0 0px rgba(113, 156, 223, 0)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 0px rgba(113, 156, 223, 0)"],transition:{duration:.5,times:[0,.2,.7,1],ease:"easeInOut"}})},[l,i,r]),e.jsxs(ce.div,{className:H("flex items-center gap-1.5",a?"flex-row":"flex-col"),animate:{scale:l?1.05:1,opacity:l?1:.85},transition:{duration:.3,ease:"easeInOut"},children:[e.jsxs(ce.div,{className:H("flex items-center gap-1.5 px-2.5 py-1 rounded-md","font-mono text-xs font-semibold",s.isLocal?"bg-sys-amber/20 text-sys-amber ring-1 ring-sys-amber/30":"bg-elevated/50 text-fg-primary ring-1 ring-edge-strong/50"),animate:r,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},children:[s.isLocal&&e.jsx(na,{className:"w-3 h-3"}),e.jsx("span",{children:s.prefix}),s.confidence!==void 0&&s.confidence<.9&&e.jsxs("span",{className:"text-[9px] opacity-70",children:[(s.confidence*100).toFixed(0),"%"]})]}),!a&&((c=s.neighborInfo)==null?void 0:c.name)&&e.jsx("span",{className:"text-xs text-fg-muted truncate max-w-[80px]",children:s.neighborInfo.name})]})}function yn({snr:s,sf:a}){const t=_t(s,a),i=Ct()[t]||"#6b7280",l=Number.isInteger(s)?s.toString():s.toFixed(1);return e.jsxs(B,{customColor:i,compact:!0,className:"font-mono",children:[s>=0?"+":"",l,"dB"]})}function jn({hops:s,compact:a,isTrace:t=!1,sf:n}){const[i,l]=m.useState(-1);return m.useEffect(()=>{if(s.length===0)return;const r=setTimeout(()=>{l(0)},400),c=setInterval(()=>{l(x=>{const g=x+1;return g>=s.length?(clearInterval(c),-1):g})},t?500:600);return()=>{clearTimeout(r),clearInterval(c)}},[s.length,t]),e.jsx("div",{className:"p-6",style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"4px 8px"},children:s.map((r,c)=>{const x=c%2===0,g=c===s.length-1;return e.jsxs("div",{className:"contents",children:[e.jsx("div",{className:H("flex items-center","justify-end"),children:x&&e.jsx(as,{hop:r,compact:a,index:c,highlightIndex:i,isTrace:t})}),e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[28px]",children:!g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px flex-1 bg-border-strong/40 min-h-[8px]"}),r.snr!==void 0&&e.jsx(yn,{snr:r.snr,sf:n}),e.jsx("svg",{className:"w-3 h-3 text-fg-muted flex-shrink-0",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M6 2v8M3 7l3 3 3-3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})}),e.jsx("div",{className:H("flex items-center","justify-start"),children:!x&&e.jsx(as,{hop:r,compact:a,index:c,highlightIndex:i,isTrace:t})})]},`${r.prefix}-${c}`)})})}function bn({packet:s,neighbors:a,localHash:t,neighborAffinity:n,ghostPrefixes:i,direction:l="horizontal",compact:r=!1,traceSnr:c,overridePath:x}){const g=c!==void 0&&c.length>0,u=wt(),y=Ns(s.original_path),k=Ns(s.forwarded_path),b=x??(k.length>0?k:y),d=t?je(t):"",C=m.useMemo(()=>b.map((o,N)=>{const f=o.toUpperCase(),_=f===d,v=(i==null?void 0:i.has(f))??!1,p=kt(f,a,n);return{prefix:f,fullHash:p==null?void 0:p.hash,neighborInfo:p==null?void 0:p.info,isLocal:_,isGhost:v,confidence:p==null?void 0:p.confidence,snr:c==null?void 0:c[N]}}),[b,a,n,d,i,c]);if(C.length===0)return e.jsxs("div",{className:"flex items-center gap-2 text-fg-muted text-xs",children:[e.jsx(oe,{className:"w-4 h-4 opacity-50"}),e.jsx("span",{children:"Direct / No path data"})]});if(l==="flowchart")return e.jsx(jn,{hops:C,compact:r,isTrace:g,sf:u});const M=l==="horizontal"?he:Us;return e.jsx("div",{className:H("flex gap-1.5",l==="horizontal"?"flex-row flex-wrap items-center":"flex-col items-start"),children:C.map((o,N)=>e.jsxs("div",{className:H("flex items-center gap-1.5",l==="vertical"&&"flex-col"),children:[e.jsx(as,{hop:o,compact:r}),N"blue",Nn=[{fn:"id",group:"identity",fmt:"int",read:s=>ae(s.id),color:Q},{fn:"packet_hash",group:"identity",fmt:"hex",read:s=>s.packet_hash||void 0,color:Q},{fn:"timestamp",group:"identity",fmt:"epoch",read:s=>s.timestamp?String(s.timestamp):void 0,color:Q,annotate:s=>s.timestamp>0?Je(s.timestamp):void 0},{fn:"type",group:"classification",fmt:"enum",read:s=>ae(s.type??s.payload_type),color:Q},{fn:"route",group:"classification",fmt:"enum",read:s=>ae(s.route??s.route_type),color:Q},{fn:"rssi",group:"signal",fmt:"int",read:s=>ae(s.rssi,"dBm"),color:Q},{fn:"snr",group:"signal",fmt:"float",read:s=>ae(s.snr,"dB"),color:Q},{fn:"path_length",group:"size",fmt:"int",read:s=>{if(s.path_length!=null)return s.path_length===0?"zero-hop":`${s.path_length} hops`},color:Q},{fn:"payload_length",group:"size",fmt:"int",read:s=>ae(s.payload_length,"B"),color:Q},{fn:"airtime",group:"size",fmt:"float",read:s=>ae(s.airtime_ms,"ms"),color:Q},{fn:"src_hash",group:"addressing",fmt:"hex<2>",read:s=>s.src_hash??void 0,color:Q},{fn:"dst_hash",group:"addressing",fmt:"hex<2>",read:s=>s.dst_hash??void 0,color:Q},{fn:"path_hash",group:"addressing",fmt:"hex[]|hex",read:s=>Array.isArray(s.path_hash)?`[${s.path_hash.join(", ")}]`:ae(s.path_hash),color:Q,renderValue:s=>Array.isArray(s.path_hash)?Ye(s.path_hash):null},{fn:"score",group:"addressing",fmt:"int",read:s=>ae(s.score),color:Q},{fn:"original_path",group:"paths",fmt:"hex[]",read:s=>Array.isArray(s.original_path)?`[${s.original_path.join(", ")}]`:void 0,color:Q,renderValue:s=>Array.isArray(s.original_path)&&s.original_path.length>0?Ye(s.original_path,s.src_hash||void 0,s.dst_hash||void 0,!0):null},{fn:"forwarded_path",group:"paths",fmt:"hex[]",read:s=>Array.isArray(s.forwarded_path)?`[${s.forwarded_path.join(", ")}]`:void 0,color:Q,renderValue:s=>Array.isArray(s.forwarded_path)&&s.forwarded_path.length>0?Ye(s.forwarded_path):null},{fn:"transmitted",group:"status",fmt:"bool",read:s=>ae(s.transmitted),color:Q},{fn:"is_duplicate",group:"status",fmt:"bool",read:s=>ae(s.is_duplicate),color:Q},{fn:"drop_reason",group:"status",fmt:"string|null",read:s=>s.drop_reason??void 0,color:Q},{fn:"tx_delay",group:"status",fmt:"int",read:s=>ae(s.tx_delay_ms,"ms"),color:Q},{fn:"origin",group:"status",fmt:"enum",read:s=>s.packet_origin??void 0,color:Q},{fn:"duplicates",group:"status",fmt:"PacketDuplicate[]",read:s=>s.duplicates!=null&&s.duplicates.length>0?`${s.duplicates.length}`:ae(s.duplicates),color:Q},{fn:"lbt_attempts",group:"lbt",fmt:"int",read:s=>ae(s.lbt_attempts),color:Q},{fn:"lbt_backoff",group:"lbt",fmt:"json",read:s=>ae(s.lbt_backoff_delays_ms),color:Q},{fn:"lbt_busy",group:"lbt",fmt:"bool|int",read:s=>ae(s.lbt_channel_busy),color:Q}];function Ye(s,a,t,n){const i=s.length>0,l=a||n,r=t||n;return e.jsxs("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[l&&e.jsxs(e.Fragment,{children:[a?e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:a}):e.jsx("span",{className:"inline-block border border-edge-subtle/50 rounded px-1.5 py-0.5 font-mono text-[11px] text-fg-muted/30",children:"XX"}),(i||r)&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"})]}),s.map((c,x)=>e.jsxs(m.Fragment,{children:[x>0&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:c})]},x)),r&&e.jsxs(e.Fragment,{children:[i&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),t?e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:t}):e.jsx("span",{className:"inline-block border border-edge-subtle/50 rounded px-1.5 py-0.5 font-mono text-[11px] text-fg-muted/30",children:"XX"})]})]})}let ze=null;function vn(){if(!ze){ze=new Map;for(const s of Nn)ze.set(s.fn,s)}return ze}function vs(s,a){var r;const t=vn().get(a);if(!t)return null;const n=t.read(s);if(n===void 0)return null;const i=t.color(s),l=(r=t.annotate)==null?void 0:r.call(t,s);return l?{text:n,color:i,annotation:l}:{text:n,color:i}}function ws(s){if(!s)return[];if(Array.isArray(s))return s;try{const a=JSON.parse(s);return Array.isArray(a)?a:[]}catch{return[]}}function ks({packets:s,selectedIndex:a,onSelect:t,compact:n=!1}){if(s.length<=1)return null;const i=a>0,l=ai&&t(a-1),disabled:!i,className:H("p-0.5 radius-badge transition-base",i?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Previous observation",children:e.jsx(Vs,{className:n?"size-3":"size-4"})}),e.jsx("div",{className:"flex items-center gap-0.5",children:s.map((r,c)=>{const x=c===a,u=new Date(r.timestamp*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsx(Rt,{color:x?"cyan":"zinc",filled:x,compact:n,onClick:()=>t(c),title:`Observation ${c+1} at ${u}`,className:H("transition-all duration-150",!x&&"opacity-60 hover:opacity-100"),children:n?e.jsx("span",{className:"tabular-nums",children:c+1}):e.jsxs("span",{className:"tabular-nums text-xs",children:["#",c+1,r.rssi!=null&&e.jsx("span",{className:"ml-1 opacity-70",children:r.rssi})]})},`${r.timestamp}_${c}`)})}),e.jsx("button",{onClick:()=>l&&t(a+1),disabled:!l,className:H("p-0.5 radius-badge transition-base",l?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Next observation",children:e.jsx(is,{className:n?"size-3":"size-4"})}),e.jsxs("span",{className:H("text-fg-muted ml-1",n?"text-[9px]":"text-xs"),children:[e.jsx(rs,{className:"inline size-3 mr-0.5 opacity-50"}),s.length]})]})}function Ee({icon:s,label:a,disabled:t=!1}){return e.jsx(ce.div,{className:"flex items-center gap-1 text-xs",title:a,animate:{opacity:t?.25:.6},transition:{duration:.15,ease:[.4,0,.2,1]},children:e.jsx("span",{className:H("flex items-center justify-center size-5 radius-badge border-control transition-base",t?"bg-subtle-fill border-edge-subtle":"bg-subtle-fill"),children:s})})}function wn({hasDuplicates:s,hasPrev:a,hasNext:t,canPrevDupe:n,canNextDupe:i}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Ee,{icon:e.jsx(At,{className:"size-3"}),label:"Previous packet (↑)",disabled:!a}),e.jsx(Ee,{icon:e.jsx(Ht,{className:"size-3"}),label:"Next packet (↓)",disabled:!t})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-3 bg-subtle-fill-strong"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Ee,{icon:e.jsx(Vs,{className:"size-3"}),label:"Previous observation (←)",disabled:!n}),e.jsx(Ee,{icon:e.jsx(is,{className:"size-3"}),label:"Next observation (→)",disabled:!i})]})]})]})}function kn({packets:s,initialIndex:a=0,onClose:t,onNavigatePrev:n,onNavigateNext:i,hasPrev:l=!1,hasNext:r=!1,resolveSource:c,getDecodedContent:x}){var De;const[g,u]=m.useState(a),y=s[g]??s[0],k=s.length>1,[b,d]=m.useState(null),[C,M]=m.useState(!1);m.useEffect(()=>{if(!y._stripped){d(null);return}let j=!1;M(!0);const w=y.packet_hash;if(!w){M(!1);return}return St(w).then(S=>{j||(S.success&&S.data&&(d(S.data),(S.data.type??S.data.payload_type)===le.GRP_TXT&&S.data.raw_packet&&Tt.getState().queueDecryption([S.data])),M(!1))}).catch(()=>{j||M(!1)}),()=>{j=!0}},[y]);const o=b??y,N=g>0,f=g{u(Math.max(0,Math.min(j,s.length-1)))},[s.length]);m.useEffect(()=>{const j=w=>{if(!(w.target instanceof HTMLInputElement||w.target instanceof HTMLTextAreaElement))switch(w.key){case"ArrowUp":w.preventDefault(),n==null||n();break;case"ArrowDown":w.preventDefault(),i==null||i();break;case"ArrowLeft":w.preventDefault(),N&&u(S=>S-1);break;case"ArrowRight":w.preventDefault(),f&&u(S=>S+1);break}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[n,i,N,f]);const v=Ds(),p=Pt(),I=Bt(),V=Mt(),q=m.useMemo(()=>new Set(V.map(j=>j.prefix.toUpperCase())),[V]),Y=o.payload_type_name||Hs(o.payload_type??o.type),z=o.route_type_name||Fs(o.route_type??o.route),X=o.payload_length??o.length??0,F=o.path_hash_size,D=ws(o.original_path),W=ws(o.forwarded_path),Z=D.length>0||W.length>0,O=W.length>0?W:D,T=m.useMemo(()=>{var j;if((j=v==null?void 0:v.config)!=null&&j.repeater)return{latitude:v.config.repeater.latitude,longitude:v.config.repeater.longitude,name:v.config.node_name||"Local Node"}},[v]),$=(v==null?void 0:v.neighbors)??{},ee=I.size>0?I:void 0,ne=o.raw_packet&&o.raw_packet.length>0,P=y._stripped&&C,h=m.useMemo(()=>c?c(o):null,[c,o]),se=Lt(o.packet_hash),te=m.useMemo(()=>!x||(o.payload_type??o.type)!==le.GRP_TXT?null:x(o),[x,o]),R=m.useMemo(()=>{if((o.payload_type??o.type)!==le.GRP_TXT)return null;if(se!=null&&se.decoded){const w=se.decoded;return{type:"grp_txt",channelHash:w.channelHash,channelName:w.channelName,text:w.text??"",decrypted:w.decrypted,senderName:w.senderName,timestamp:w.timestamp,flags:w.flags,macCorrupted:w.macCorrupted}}return te!=null&&te.decrypted?{type:"grp_txt",channelHash:te.channelHash??"",channelName:te.channelName??"",text:te.text??"",decrypted:!0,senderName:te.senderName??"",timestamp:0,flags:0,macCorrupted:te.corrupted}:null},[o,se,te]),U=m.useMemo(()=>Zt(o,R),[o,R]),G=U.kind==="trace"?U.data:null,E=U.kind==="trace"?U.snrValues:void 0,L=U.kind==="advert"?U.data:null,ue=U.kind==="advert"?U.sourceNode:void 0,Me=U.kind==="grp_txt"?U.wardriveSourceNode??void 0:void 0,re=U.kind==="anon_req"?U.data:null,Le=j=>!j||j===0?"Unknown":new Date(j*1e3).toLocaleString(),Te=(o.payload_type??o.type)===le.ADVERT&&(ue!==void 0||Z),be=Me!==void 0,He=ue??Me,Fe=Be[Y]??"zinc",qe=me[Fe]||me.zinc;return e.jsxs(As,{open:!0,onClose:t,size:"5xl",motionPlus:!0,solid:!0,className:"sm:h-[85vh] sm:max-h-[800px] md:h-[80vh] md:max-h-[900px]",children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsx("div",{className:"flex justify-center pt-2 pb-1",children:e.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-muted","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:Be[Y]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:Y}),e.jsx(B,{color:Ie[z]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:z}),e.jsxs(B,{color:"zinc",className:"!text-[9px] !px-1.5 !py-0",children:[X,"B"]}),F!=null&&F>1&&e.jsxs(B,{color:"orange",className:"!text-[9px] !px-1.5 !py-0",children:[F,"B hashes"]})]}),e.jsx("button",{onClick:t,className:"px-3 py-1.5 text-[15px] font-medium text-sys-blue active:text-sys-blue/80 transition-base flex-shrink-0 radius-inner active:bg-subtle-fill",children:"Done"})]}),k&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(ks,{packets:s,selectedIndex:g,onSelect:_,compact:!0})})]}),e.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{color:Be[Y]??"zinc",children:Y}),e.jsx(B,{color:Ie[z]??"zinc",children:z}),e.jsxs(B,{color:"zinc",children:[X,"B"]}),F!=null&&F>1&&e.jsxs(B,{color:"orange",children:[F,"B hashes"]}),k&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-4 bg-subtle-fill-strong"}),e.jsx(ks,{packets:s,selectedIndex:g,onSelect:_})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(wn,{hasDuplicates:k,hasPrev:l,hasNext:r,canPrevDupe:N,canNextDupe:f}),e.jsx("button",{onClick:t,className:"p-1.5 -m-1.5 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-elevated flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:qe,opacity:.6}}),e.jsxs(zs,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[e.jsx("div",{className:"md:hidden flex-1 overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"px-2 pt-2 space-y-2",children:[(o.rssi!=null||o.snr!=null)&&e.jsxs("div",{className:"relative flex items-center justify-between px-2 py-1.5 radius-inner bg-subtle-fill depth-stroke",children:[e.jsx(We,{mode:"popLayout",initial:!1,children:e.jsxs(ce.div,{className:"flex items-center gap-3",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[e.jsx($e,{rssi:o.rssi,snr:o.snr,compact:!0,showValues:!0,validated:Ue(o)}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:us(o.rssi)})]},g)}),O.length>0&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[O.length," hop",O.length!==1?"s":""]})]}),(Z&&O.length>0||Te||be)&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Ge,{path:O,neighbors:$,localNode:T,localHash:v==null?void 0:v.local_hash,srcHash:o.src_hash,dstHash:o.dst_hash,neighborAffinity:ee,hubNodes:[...p],traceSnr:E,advertiserSource:He})})}),G&&G.pathHashes.length>0&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsx("div",{className:"px-3 py-2 space-y-1.5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(B,{color:G.isComplete?"green":"amber",compact:!0,children:G.isComplete?"Complete":"In Progress"})})]})}),e.jsx(ke,{packet:o,neighbors:$,localHash:v==null?void 0:v.local_hash,neighborAffinity:ee,ghostPrefixes:q,direction:"flowchart",compact:!0,overridePath:G.pathHashes,traceSnr:G.snrValues})]}),Z&&!G&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),e.jsxs(B,{color:"zinc",compact:!0,children:[O.length," hop",O.length!==1?"s":""]})]}),e.jsx(ke,{packet:o,neighbors:$,localHash:v==null?void 0:v.local_hash,neighborAffinity:ee,ghostPrefixes:q,direction:"flowchart",compact:!0,traceSnr:E})]}),h&&(h.name||h.hash)&&!L&&!re&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(B,{color:h.isRepeater?"blue":h.isCompanion?"violet":h.type==="room_server"?"lime":"zinc",compact:!0,children:h.type==="room_server"?"room server":h.type})]}),e.jsxs("div",{className:"p-3 space-y-1.5",children:[h.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:h.name}),!h.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),h.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-data-xs text-fg-muted truncate font-mono",children:h.hash.length>16?`${h.hash.slice(0,16)}…${h.hash.slice(-8)}`:h.hash.startsWith("0x")?h.hash.slice(2,10)+"…":h.hash.slice(0,8)+"…"})]})]})]}),re&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(B,{color:h!=null&&h.isRepeater?"blue":h!=null&&h.isCompanion?"violet":(h==null?void 0:h.type)==="room_server"?"lime":"amber",compact:!0,children:h!=null&&h.type&&h.type!=="unknown"?h.type==="room_server"?"room server":h.type:"companion"})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[(h==null?void 0:h.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:h.name}),!h.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Dest: ",e.jsx("span",{className:"font-mono",children:re.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ve,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted break-all font-mono leading-relaxed",children:re.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[re.ciphertextLength,"B encrypted payload"]})]})]})]}),L&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser Info"}),e.jsx(B,{color:"lime",compact:!0,children:L.nodeType})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[L.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:L.name})]}),L.latitude&&L.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[L.latitude.toFixed(5),", ",L.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",children:[L.publicKey.slice(0,16),"...",L.publicKey.slice(-8)]})]}),L.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Le(L.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:L.flagsDescription||`Flags: 0x${L.flags.toString(16).padStart(2,"0")}`})]})]})]}),P?e.jsx("div",{className:"pt-1 px-3 py-6 text-center",children:e.jsx("span",{className:"text-xs text-fg-muted animate-pulse",children:"Loading packet details…"})}):ne?e.jsx("div",{className:"pt-1",children:e.jsx(bs,{packet:o,decodedGrpTxt:R})}):null]})}),e.jsxs("div",{className:"hidden md:grid md:grid-cols-2 flex-1 overflow-hidden",children:[e.jsx("div",{className:"overflow-y-auto overflow-x-hidden scrollbar-none px-4 pt-4",children:P?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("span",{className:"text-sm text-fg-muted animate-pulse",children:"Loading packet details…"})}):ne?e.jsx(bs,{packet:o,decodedGrpTxt:R}):null}),e.jsxs("div",{className:"grid overflow-hidden",style:{gridTemplateRows:"minmax(280px, 1fr) auto"},children:[e.jsx("div",{className:"overflow-hidden p-2",children:Z&&O.length>0||Te||be?e.jsx("div",{className:"h-full w-full overflow-hidden",children:e.jsx(Ge,{path:O,neighbors:$,localNode:T,localHash:v==null?void 0:v.local_hash,srcHash:o.src_hash,dstHash:o.dst_hash,neighborAffinity:ee,hubNodes:[...p],traceSnr:E,advertiserSource:He})}):e.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center text-center px-4",children:[e.jsx(oe,{className:"w-8 h-8 text-fg-muted/50 mb-2"}),e.jsx("span",{className:"text-sm text-fg-muted",children:"Direct Reception"}),e.jsx("span",{className:"text-xs text-fg-muted/70 mt-1",children:"Zero-hop packet — received directly from sender"})]})}),e.jsxs("div",{className:"overflow-y-auto max-h-[200px] p-2 space-y-2",children:[!G&&O.length<=1&&(o.rssi!=null||o.snr!=null)&&e.jsx("div",{className:"surface-base radius-inner p-4 depth-stroke",children:e.jsxs("dl",{className:"text-xs grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"Signal"}),e.jsx(We,{mode:"popLayout",initial:!1,children:e.jsxs(ce.dd,{className:"flex items-center gap-2",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[e.jsx($e,{rssi:o.rssi,snr:o.snr,validated:Ue(o)}),e.jsx("span",{className:"font-medium text-fg-primary",children:us(o.rssi)})]},g)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"RF"}),e.jsx(We,{mode:"popLayout",initial:!1,children:e.jsxs(ce.dd,{className:"type-data text-fg-secondary",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[(De=vs(o,"rssi"))==null?void 0:De.text,(()=>{const j=vs(o,"snr");return j?` · ${j.text}`:null})()]},g)})]})]})}),h&&(h.name||h.hash)&&!L&&!re&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(B,{color:h.isRepeater?"blue":h.isCompanion?"violet":h.type==="room_server"?"lime":"zinc",compact:!0,children:h.type==="room_server"?"room server":h.type})]}),e.jsxs("div",{className:"p-4 space-y-2",children:[h.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:h.name}),!h.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),h.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:h.hash.length>16?`${h.hash.slice(0,16)}…${h.hash.slice(-8)}`:h.hash.startsWith("0x")?h.hash.slice(2,10)+"…":h.hash.slice(0,8)+"…"})]})]})]}),re&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(B,{color:h!=null&&h.isRepeater?"blue":h!=null&&h.isCompanion?"violet":(h==null?void 0:h.type)==="room_server"?"lime":"amber",compact:!0,children:h!=null&&h.type&&h.type!=="unknown"?h.type==="room_server"?"room server":h.type:"companion"})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[(h==null?void 0:h.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:h.name}),!h.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Dest: ",e.jsx("span",{className:"font-mono",children:re.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ve,{className:"w-4 h-4 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-muted break-all leading-relaxed",children:re.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[re.ciphertextLength,"B encrypted payload"]})]})]})]}),L&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser"}),e.jsx(B,{color:"lime",compact:!0,children:L.nodeType})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[L.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:L.name})]}),L.latitude&&L.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[L.latitude.toFixed(5),", ",L.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:[L.publicKey.slice(0,16),"...",L.publicKey.slice(-8)]})]}),L.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Le(L.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:L.flagsDescription||`Flags: 0x${L.flags.toString(16).padStart(2,"0")}`})]})]})]}),G&&G.pathHashes.length>0&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"px-4 py-2 flex items-center justify-between",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:G.isComplete?"green":"amber",compact:!0,children:G.isComplete?"Complete":"In Progress"}),e.jsxs(B,{color:"teal",compact:!0,children:[G.pathHashes.length,"h"]})]})]}),e.jsx(ke,{packet:o,neighbors:$,localHash:v==null?void 0:v.local_hash,neighborAffinity:ee,ghostPrefixes:q,direction:"flowchart",compact:!0,overridePath:G.pathHashes,traceSnr:G.snrValues})]}),Z&&!G&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),e.jsxs(B,{color:"zinc",compact:!0,children:[O.length,"h"]})]}),e.jsx(ke,{packet:o,neighbors:$,localHash:v==null?void 0:v.local_hash,neighborAffinity:ee,ghostPrefixes:q,direction:"flowchart",compact:!0,traceSnr:E})]})]})]})]})]})]})}const Cn=m.memo(kn);function Cs({label:s,numericValue:a,unit:t,icon:n,subtext:i,showSign:l=!1}){return e.jsxs("div",{className:"radius-inner p-3 sm:radius-inset sm:p-4 bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[e.jsx("div",{className:"mb-1.5 sm:mb-2",children:e.jsx("span",{className:"text-xs sm:type-micro text-fg-muted",children:s})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(es,{value:a,format:{minimumFractionDigits:1,maximumFractionDigits:1,signDisplay:l?"always":"auto"},className:"type-data-hero tracking-tight text-fg-primary"}),e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx(n,{className:"w-[14px] h-[14px] text-fg-muted"}),t&&e.jsx("span",{className:"text-xs font-medium leading-tight text-fg-muted",children:t})]})]}),i&&e.jsx("p",{className:"mt-1.5 sm:mt-2 type-data-xs sm:text-[11px] text-fg-muted/80 truncate",children:i})]})}function _n({snr:s}){const a=s>=5?"bg-sys-teal":s>=0?"bg-sys-green":s>=-5?"bg-sys-amber":s>=-10?"bg-sys-orange":"bg-sys-red";return e.jsx("span",{className:H("w-1.5 h-1.5 rounded-full flex-shrink-0",a),title:`SNR: ${s.toFixed(1)} dB`})}function _s({fromPrefix:s,toPrefix:a,fromName:t,toName:n,snr:i,maxSnr:l,isWeakest:r,isStrongest:c,index:x=0}){const u=Math.max(l+5,15),y=Math.max(0,Math.min(100,(i- -20)/(u- -20)*100)),k="bg-[#0074BE]",b=i>=5?"bg-sys-teal":i>=0?"bg-sys-green":i>=-5?"bg-sys-amber":i>=-10?"bg-sys-orange":"bg-sys-red",d=.3+x*.15;return e.jsxs("div",{className:"relative p-3 pl-5 radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[e.jsx("span",{className:H("absolute left-0 top-1/2 -translate-y-1/2 h-4 w-0.5 rounded-full",b)}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5",children:e.jsx(_n,{snr:i})}),e.jsxs("div",{className:"sm:hidden",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:"text-[13px] font-medium text-fg-secondary truncate",children:t||s}),e.jsx(he,{className:"w-3 h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold text-fg-primary truncate",children:n||a})]}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-2 flex-shrink-0",children:[r&&e.jsx(B,{color:"red",compact:!0,children:"Low"}),c&&!r&&e.jsxs(B,{color:"amber",compact:!0,children:[e.jsx(gs,{className:"w-2.5 h-2.5"}),"Best"]}),e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[12px] font-mono font-bold tabular-nums bg-subtle-fill-hover text-fg-primary ring-1 ring-inset ring-edge-subtle",children:[i>=0?"+":"−",Math.abs(i).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx(ce.div,{className:H("h-full rounded-full",k),initial:{width:0},animate:{width:`${y}%`},transition:{duration:1.5,delay:d,ease:[.25,.1,.25,1]}})})]}),e.jsxs("div",{className:"hidden sm:block",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"type-data-xs text-fg-muted",children:s}),t&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:t})]}),e.jsx(he,{className:"w-3 h-3 text-fg-muted/40 flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"font-mono text-xs font-semibold text-fg-primary",children:a}),n&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[r&&e.jsx(B,{color:"red",compact:!0,children:"Bottleneck"}),c&&!r&&e.jsxs(B,{color:"amber",compact:!0,children:[e.jsx(gs,{className:"w-3 h-3"}),"Strongest"]}),e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-sm font-mono font-semibold tabular-nums bg-subtle-fill-hover text-fg-primary ring-1 ring-inset ring-edge-subtle",children:[i>=0?"+":"−",Math.abs(i).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-elevated rounded-full overflow-hidden",children:e.jsx(ce.div,{className:H("h-full rounded-full",k),initial:{width:0},animate:{width:`${y}%`},transition:{duration:1.5,delay:d,ease:[.25,.1,.25,1]}})})]})]})}function fe(s,a){if(s==="You")return"You";const t=s.toUpperCase();for(const[n,i]of Object.entries(a))if((n.startsWith("0x")?n.slice(2,4):n.slice(0,2)).toUpperCase()===t)return i.name||i.node_name||void 0}function Sn({report:s,onClose:a}){var g,u;const t=Ds(),n=(t==null?void 0:t.neighbors)??{},i=(g=t==null?void 0:t.config)!=null&&g.repeater?{latitude:t.config.repeater.latitude,longitude:t.config.repeater.longitude,name:t.config.node_name||"Local Node"}:void 0,l=(u=s.bestObservation)==null?void 0:u.decoded.snrValues,r=s.linkQuality?s.linkQuality.avgSnr>=5?"excellent":s.linkQuality.avgSnr>=0?"good":s.linkQuality.avgSnr>=-5?"fair":"poor":"unknown",x={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",poor:"var(--signal-poor)",unknown:"var(--fg-muted)"}[r];return e.jsxs(As,{open:!0,onClose:a,size:"5xl",motionPlus:!0,children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsx("div",{className:"flex justify-center pt-2 pb-1",children:e.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-primary/30","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-center justify-between px-4 pb-2",children:[e.jsx("h2",{className:"font-semibold text-[17px] text-fg-primary",children:"Trace Report"}),e.jsx("button",{onClick:a,className:"text-[17px] font-medium text-sys-blue active:text-sys-blue/80",children:"Done"})]})]}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:x,opacity:.6}}),e.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[e.jsx("h2",{className:"type-micro",children:"Trace Report"}),e.jsxs(B,{color:r==="excellent"||r==="good"?"green":r==="fair"?"amber":"red",children:[e.jsx(fs,{className:"w-3 h-3 mr-1"}),r==="excellent"?"Excellent":r==="good"?"Good":r==="fair"?"Fair":"Poor"]})]}),e.jsx("p",{className:"mt-1 text-xs sm:text-sm font-mono text-fg-muted tabular-nums",children:s.traceTag})]}),e.jsx("button",{onClick:a,className:"p-1.5 -m-1.5 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-elevated flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsxs("div",{className:"hidden sm:flex flex-wrap items-center gap-1.5 sm:gap-2 px-4 sm:px-6 pb-3 sm:pb-4 border-b border-edge-subtle",children:[e.jsxs(B,{color:"teal",children:[e.jsx("span",{className:"font-mono tabular-nums",children:s.targetHopCount}),e.jsxs("span",{className:"ml-1",children:["hop",s.targetHopCount!==1?"s":""]})]}),e.jsxs(B,{color:"zinc",children:[e.jsx("span",{className:"font-mono tabular-nums",children:s.observationCount}),e.jsx("span",{className:"ml-1",children:"obs"})]}),s.linkQuality&&e.jsxs(B,{color:"indigo",children:[e.jsx("span",{className:"font-mono tabular-nums",children:s.linkQuality.avgSnr.toFixed(1)}),e.jsx("span",{className:"ml-1",children:"dB avg"})]}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Ft(s.duration)}),s.linkQuality&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-muted/40",children:"•"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-sys-red/15 text-sys-red ring-1 ring-inset ring-sys-red/25",children:[e.jsx("span",{className:"opacity-70",children:"Min"}),e.jsx("span",{className:"font-mono tabular-nums",children:s.linkQuality.minSnr.toFixed(1)})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-sys-teal/15 text-sys-teal ring-1 ring-inset ring-sys-teal/25",children:[e.jsx("span",{className:"opacity-70",children:"Max"}),e.jsx("span",{className:"font-mono tabular-nums",children:s.linkQuality.maxSnr.toFixed(1)})]})]})]})]}),e.jsxs(zs,{className:"p-0 overflow-hidden",children:[e.jsx("div",{className:"md:hidden h-[75vh] max-h-[calc(100vh-80px)] overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[s.linkQuality&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[e.jsx(es,{value:Math.abs(s.linkQuality.minSnr),format:{maximumFractionDigits:0,signDisplay:"never"},prefix:s.linkQuality.minSnr<0?"-":"",className:"text-[20px] font-bold font-mono tabular-nums flex items-center justify-center text-fg-primary"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(Ze,{className:"w-2.5 h-2.5 text-fg-muted"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Min dB"})]})]}),e.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[e.jsx(es,{value:s.linkQuality.maxSnr,format:{maximumFractionDigits:0,signDisplay:"always"},className:"text-[20px] font-bold font-mono text-fg-primary tabular-nums flex items-center justify-center"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(ps,{className:"w-2.5 h-2.5 text-fg-muted"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Max dB"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(B,{color:r==="excellent"||r==="good"?"green":r==="fair"?"amber":"red",compact:!0,children:[e.jsx(fs,{className:"w-2.5 h-2.5 mr-0.5"}),r==="excellent"?"Excellent":r==="good"?"Good":r==="fair"?"Fair":"Poor"]}),e.jsxs(B,{color:"teal",compact:!0,children:[s.targetHopCount," hops"]}),e.jsxs(B,{color:"zinc",compact:!0,children:[s.observationCount," obs"]}),e.jsx("span",{className:"type-data-xs text-fg-muted ml-auto",children:s.traceTag.slice(0,8)})]}),s.targetPath.length>0&&e.jsx("div",{className:"overflow-hidden radius-inset",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Ge,{path:s.targetPath,neighbors:n,localNode:i,localHash:t==null?void 0:t.local_hash,srcHash:s.srcHash,dstHash:s.dstHash,traceSnr:l})})}),e.jsxs("div",{className:"radius-inset bg-body overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"text-[11px] font-medium text-fg-secondary",children:"Route Path"}),s.linkQuality&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:["SNR ",s.linkQuality.minSnr.toFixed(1)," → ",s.linkQuality.maxSnr.toFixed(1)," dB"]})]}),s.bestObservation?e.jsx(ke,{packet:s.bestObservation.packet,neighbors:n,localHash:t==null?void 0:t.local_hash,direction:"flowchart",compact:!0,overridePath:s.targetPath,traceSnr:s.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-6 text-center text-fg-muted text-xs",children:"No path data available"})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"type-micro text-fg-muted mb-2",children:["Link Quality · ",s.hopStats.length," hops"]}),e.jsx("div",{className:"space-y-1.5",children:s.hopStats.length>0?s.hopStats.map((y,k)=>{var M,o,N;const b=k{const y=s.targetPath[s.linkQuality.weakestLinkPosition],k=s.targetPath[s.linkQuality.weakestLinkPosition+1]||"You",b=fe(y,n),d=fe(k,n),C=s.targetPath[s.linkQuality.strongestLinkPosition],M=s.targetPath[s.linkQuality.strongestLinkPosition+1]||"You",o=fe(C,n),N=fe(M,n);return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Cs,{label:"Weakest Link",numericValue:s.linkQuality.minSnr,unit:"dB",icon:Ze,subtext:`${b||y} → ${d||k}`}),e.jsx(Cs,{label:"Best Link",numericValue:s.linkQuality.maxSnr,showSign:!0,unit:"dB",icon:ps,subtext:`${o||C} → ${N||M}`})]})})(),e.jsxs("div",{children:[e.jsx("h3",{className:"type-micro text-fg-muted mb-3",children:"Link Details"}),e.jsx("div",{className:"space-y-2",children:s.hopStats.length>0?s.hopStats.map((y,k)=>{var M,o,N;const b=k0&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-square w-full",children:e.jsx(Ge,{path:s.targetPath,neighbors:n,localNode:i,localHash:t==null?void 0:t.local_hash,srcHash:s.srcHash,dstHash:s.dstHash,traceSnr:l})})}),e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:s.isComplete?"green":"amber",compact:!0,children:s.isComplete?"Complete":`${s.maxHopsObserved}/${s.targetHopCount}`}),e.jsxs(B,{color:"teal",compact:!0,children:[s.targetHopCount," hop",s.targetHopCount!==1?"s":""]})]})]}),s.linkQuality&&s.bestObservation&&e.jsxs("div",{className:"flex items-center gap-4 px-4 pb-2 type-data-xs text-fg-muted",children:[e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"Tag"})," ",e.jsx("code",{className:"text-sys-teal tabular-nums",children:s.traceTag.slice(0,8)})]}),e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"SNR"})," ",e.jsxs("code",{className:"text-sys-indigo tabular-nums",children:[s.linkQuality.minSnr.toFixed(1),"–",s.linkQuality.maxSnr.toFixed(1)]}),e.jsx("span",{className:"opacity-60",children:" dB"})]})]}),s.bestObservation?e.jsx(ke,{packet:s.bestObservation.packet,neighbors:n,localHash:t==null?void 0:t.local_hash,direction:"flowchart",compact:!0,overridePath:s.targetPath,traceSnr:s.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-8 text-center text-fg-muted text-xs",children:"No path data available"})]})]})]})]})]})}const Tn=m.memo(Sn),Zs=[{target:"PacketList",fn:"type",minStage:1},{target:"PacketList",fn:"route",minStage:1},{target:"PacketList",fn:"rssi",minStage:1},{target:"PacketList",fn:"snr",minStage:1},{target:"PacketList",fn:"path",minStage:1,when:Vt},{target:"PacketList",fn:"src_hash",minStage:1,when:Gt},{target:"PacketList",fn:"text",minStage:1,when:Qt},{target:"PacketList",fn:"ack",minStage:1,when:qt},{target:"PacketList",fn:"decrypt",minStage:2,when:Wt},{target:"PacketList",fn:"duplicates",minStage:1}];Ot(Zs);const Pn=48,Bn=72,Mn=100,Ln=5,Rn=600,Js="(min-width: 640px)";let xe=null;function Hn(s){return typeof window>"u"?()=>{}:(xe||(xe=window.matchMedia(Js)),xe.addEventListener("change",s),()=>xe==null?void 0:xe.removeEventListener("change",s))}function Fn(){return typeof window>"u"?!0:(xe||(xe=window.matchMedia(Js)),xe.matches)}function Dn(){return m.useSyncExternalStore(Hn,Fn,()=>!0)}function An(s,a,t){const[n,i]=m.useState(1),l=t?Math.ceil(s/a):1;m.useEffect(()=>{n>l&&l>0&&queueMicrotask(()=>i(1))},[l,n]);const r=m.useCallback(x=>i(Math.max(1,Math.min(x,l))),[l]),c=m.useMemo(()=>ka(n,l),[n,l]);return{currentPage:n,totalPages:l,goToPage:r,pageRange:c}}function zn(s,a){const[t,n]=m.useState(null),i=m.useRef(0);return m.useEffect(()=>{var u,y;if(!a||!s.length)return;const l=((u=s[0])==null?void 0:u.timestamp)??0,r=l>i.current&&i.current>0;if(i.current=l,!r)return;const c=(y=s[0])==null?void 0:y.packet_hash;if(!c)return;const x=requestAnimationFrame(()=>n(c)),g=setTimeout(()=>n(null),600);return()=>{cancelAnimationFrame(x),clearTimeout(g)}},[s,a]),t}function En(s){if(!s||s.length<6)return null;const a=Dt(s);if(!a||a.offset>=s.length)return null;const t=s.slice(a.offset);return t.length>=38?t.slice(0,38):t}function In(s){if(s.length<=1)return s;const a=new Map,t=new Map,n=new Map;for(let r=0;r0?{packet:s[r].packet,dupeCount:s[r].dupeCount+c}:s[r])}return l}function $n(s){const a=new Map;for(const t of s)if((t.payload_type??t.type)===ls.TRACE&&t.packet_hash){const i=t._traceTag??(t.payload?Es(t.payload):null);i&&a.set(t.packet_hash,i)}return a}function Un(s){const a=new Map;if(s.length===0)return a;for(let t=0;tj.setModalMapOpen);m.useEffect(()=>(q(!!N),()=>q(!1)),[N,q]),m.useLayoutEffect(()=>{I({traceTag:null,dupeGroup:null})},[s]);const Y=a??s,z=m.useMemo(()=>l&&l>0&&!b?s.slice(0,l):s,[s,l,b]),X=m.useMemo(()=>{if(!b)return null;const j=Ca(z),w=In(j);return l&&l>0?w.slice(0,l):w},[z,b,l]),F=X?X.length:z.length,{currentPage:D,totalPages:W,goToPage:Z,pageRange:O}=An(F,r,c),T=m.useMemo(()=>{if(b||!c)return z;const j=(D-1)*r;return z.slice(j,j+r)},[z,c,D,r,b]),$=m.useMemo(()=>{if(!X)return null;if(!c)return X;const j=(D-1)*r;return X.slice(j,j+r)},[X,c,D,r]),ee=m.useMemo(()=>$n(T),[T]),ne=m.useMemo(()=>Un(T),[T]),P=zn(s,g),h=Dn(),se=m.useMemo(()=>b&&$?$:T,[b,$,T]),te=o&&se.length>Mn,R=h?Pn:Bn,U=zt({count:te?se.length:0,getScrollElement:()=>V.current,estimateSize:()=>R,overscan:Ln}),G=m.useCallback((j,w)=>{var Ne,Ae;const S=j.packet_hash;if(!S)return[j];let A=w;for(;A>0&&((Ne=T[A-1])==null?void 0:Ne.packet_hash)===S;)A--;let K=w;for(;K{var A,K;const w=(A=T[j])==null?void 0:A.packet_hash;if(!w)return j;let S=j;for(;S>0&&((K=T[S-1])==null?void 0:K.packet_hash)===w;)S--;return S},[T]),L=m.useCallback(j=>{var A,K;const w=(A=T[j])==null?void 0:A.packet_hash;if(!w)return j;let S=j;for(;S{if(x){x(j);return}if(w!==void 0){const S=G(j,w),A=S.indexOf(j);f({packets:S,initialIndex:A>=0?A:0,rowIndex:w})}else f({packets:[j],initialIndex:0,rowIndex:0})},[x,G]),Me=m.useCallback(()=>{if(!N)return;const w=E(N.rowIndex)-1;if(w<0)return;const S=T[w];if(!S)return;const A=G(S,w);f({packets:A,initialIndex:0,rowIndex:w})},[N,T,E,G]),re=m.useCallback(()=>{if(!N)return;const w=L(N.rowIndex)+1;if(w>=T.length)return;const S=T[w];if(!S)return;const A=G(S,w);f({packets:A,initialIndex:0,rowIndex:w})},[N,T,L,G]),Le=m.useMemo(()=>N?E(N.rowIndex)>0:!1,[N,E]),os=m.useMemo(()=>N?L(N.rowIndex)I(w=>({...w,traceTag:j})),[]),Te=m.useCallback(j=>I(w=>({...w,dupeGroup:j})),[]),ds=m.useCallback(()=>{I({traceTag:null,dupeGroup:null})},[]),be=m.useCallback(j=>{const w=Y.filter(K=>(K.payload_type??K.type)===ls.TRACE&&K.payload&&Es(K.payload)===j);if(w.length===0)return;const A=It(w).get(j);A!=null&&A.length&&v($t(j,A))},[Y]),He=m.useCallback(j=>{const w=Y.find(S=>S.packet_hash===j);w&&(v(null),ue(w))},[Y,ue]),Fe=m.useCallback((j,w,S)=>{const A=h?Ra:Ha;if(S){const{packet:pe,dupeCount:st}=j,ms=pe.packet_hash?ee.get(pe.packet_hash):void 0,tt=p.traceTag!==null&&ms===p.traceTag;return e.jsx(A,{packet:pe,onClick:at=>ue(at,w),localHash:t,neighbors:n,resolveSource:M,isFlashing:g&&P===pe.packet_hash,traceTag:ms,isTraceHighlighted:tt,onTraceHover:Re,onViewTraceReport:be,dupeCount:st,getDecodedContent:d,onChannelClick:C},`${pe.packet_hash}_${pe.timestamp}_${w}`)}const K=j,Ne=K.packet_hash?ee.get(K.packet_hash):void 0,Ae=p.traceTag!==null&&Ne===p.traceTag,xs=ne.get(w),et=xs!==void 0&&p.dupeGroup!==null&&K.packet_hash===p.dupeGroup;return e.jsx(A,{packet:K,onClick:pe=>ue(pe,w),localHash:t,neighbors:n,resolveSource:M,isFlashing:g&&P===K.packet_hash,traceTag:Ne,isTraceHighlighted:Ae,onTraceHover:Re,onViewTraceReport:be,dupeGroupPosition:xs,isDupeGroupHovered:et,onDupeGroupHover:Te,getDecodedContent:d,onChannelClick:C},`${K.packet_hash}_${K.timestamp}_${w}`)},[h,ee,p.traceTag,p.dupeGroup,ue,t,n,M,g,P,Re,be,ne,Te,d,C]),qe=()=>{if(i&&s.length===0)return e.jsx(Ts,{});if(T.length===0)return e.jsx(Ss,{message:u});const j=b&&$!==null;return(j?$:T).map((S,A)=>Fe(S,A,j))},De=()=>{if(i&&s.length===0)return e.jsx(Ts,{});if(se.length===0)return e.jsx(Ss,{message:u});const j=b&&$!==null,w=U.getVirtualItems();return e.jsx("div",{style:{height:`${U.getTotalSize()}px`,width:"100%",position:"relative"},children:w.map(S=>{const A=se[S.index];return e.jsx("div",{"data-index":S.index,ref:U.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${S.start}px)`},children:Fe(A,S.index,j)},S.key)})})};return e.jsxs("div",{className:H("flex flex-col",y),onMouseLeave:ds,children:[te?e.jsx("div",{ref:V,className:"divide-y divide-edge-subtle overflow-auto",style:{maxHeight:Rn},children:De()}):e.jsx("div",{className:"divide-y divide-edge-subtle py-1",children:qe()}),c&&W>1&&e.jsx("nav",{className:"border-t border-edge-subtle px-4 py-3",children:e.jsxs(ya,{className:"justify-center",children:[e.jsx(ja,{onClick:()=>Z(D-1),disabled:D===1}),e.jsx(Na,{children:O.map((j,w)=>j==="gap"?e.jsx(wa,{},`gap-${w}`):e.jsx(va,{page:j,current:j===D,onClick:Z},j))}),e.jsx(ba,{onClick:()=>Z(D+1),disabled:D===W})]})}),e.jsx(On,{showPagination:c,currentPage:D,perPage:r,displayCount:$?$.length:T.length,totalCount:c?F:s.length,action:k}),!x&&N&&e.jsx(Cn,{packets:N.packets,initialIndex:N.initialIndex,onClose:()=>f(null),onNavigatePrev:Me,onNavigateNext:re,hasPrev:Le,hasNext:os,resolveSource:M,getDecodedContent:d}),_&&e.jsx(Tn,{report:_,onClose:()=>v(null),onViewPacket:He})]})}export{Ws as C,pr as P,fs as S,gs as T,Ta as g,ur as u}; diff --git a/frontend/dist/assets/PacketObservatory-CBpUbS9G.js b/frontend/dist/assets/PacketObservatory-Dkvi-AKO.js similarity index 99% rename from frontend/dist/assets/PacketObservatory-CBpUbS9G.js rename to frontend/dist/assets/PacketObservatory-Dkvi-AKO.js index cf417d04..ecbf0ef9 100644 --- a/frontend/dist/assets/PacketObservatory-CBpUbS9G.js +++ b/frontend/dist/assets/PacketObservatory-Dkvi-AKO.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/usePipelineStore-Do-g28wv.js","assets/index-C2xvS0Jd.js","assets/node-types-BD70swWz.js","assets/index-7uzBcJ1E.css"])))=>i.map(i=>d[i]); -import{cn as O,r as T,eU as Fe,eV as Ee,eW as Oe,eX as ze,bV as Be,eY as Ie,eZ as Ge,e_ as Ke,e$ as Ve,bU as Ne,_ as ue,f0 as Ue,f1 as we,b_ as pe,j as e,f2 as G,f3 as K,f4 as V,eu as xe,f5 as qe,V as M,c9 as We,ck as Ce,cu as Ye,f6 as Ze,f7 as Xe,f8 as Qe,f9 as Je,fa as et,fb as J,fc as tt,fd as st,fe as nt,ff as he,at as me,ao as Se,bP as rt,t as at,fg as lt,Q as ot,a6 as ct,fh as it,P as dt,dL as ut}from"./index-C2xvS0Jd.js";import{usePipelineStore as Y}from"./usePipelineStore-Do-g28wv.js";import{e as Te,p as pt,A as I,S as U,a as se,c as E,K as i,H as A,B as xt,R as F,T as d,P as re,d as ht,f as S,C as _e,s as ee,h as mt}from"./primitives-Ctn6pdEU.js";import{m as ke,i as gt}from"./node-types-BD70swWz.js";import{a as ft}from"./payload-detail-BAEvS7Pl.js";function bt(t){const s=t.type??t.payload_type,r=t.duplicates??[],c=t.is_duplicate,a=r.length;let n=null,l=null;if(a>0){const x=[t.rssi,...r.map(g=>g.rssi).filter(g=>g!=null)],m=[t.snr,...r.map(g=>g.snr).filter(g=>g!=null)];x.length>1&&(n=[Math.min(...x),Math.max(...x)]),m.length>1&&(l=[Math.min(...m),Math.max(...m)])}const o=s===O.TRACE;return{isDuplicate:c,dupeCount:a,rssiRange:n,snrRange:l,hashIncludesPathLen:o}}function yt(t,s,r){const c={traceTag:null,siblingCount:0,isLocallyOriginated:!1,method:"none",confidence:"none",inferredSrc:null,inferredName:null,evidence:[],thisPathLen:0,minPathLen:0,firstHopPrefix:null};let a=t._traceTag;if(!a&&t.payload&&(a=Te(t.payload)),!a)return{...c,evidence:["no traceTag — cannot correlate"]};const n=s.get(a)??[],l=N=>N.path_length!=null?N.path_length:Array.isArray(N.original_path)?N.original_path.length:0,o=l(t),x=n.length>0?Math.min(...n.map(l)):o,m=t.payload?t.payload.slice(18):"",g=m.length>=2?m.slice(0,2).toUpperCase():null,u=[];if(u.push(`traceTag: ${a}`),u.push(`siblings: ${n.length} observation${n.length!==1?"s":""}`),t.packet_origin==="tx_local")return u.push("packet_origin = tx_local → we initiated this trace"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!0,method:"tx_local",confidence:"certain",inferredSrc:"LOCAL",inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g};const v=n.find(N=>N.packet_origin==="tx_local");if(v)return u.push(`sibling (hash ${v.packet_hash}) has packet_origin = tx_local`),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!0,method:"tx_local",confidence:"certain",inferredSrc:"LOCAL",inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g};if(u.push(`this observation: path_len=${o}, min across siblings: ${x}`),g){if(u.push(`first hop in target path: ${g}`),o===0)return u.push("path_len = 0 → heard directly from initiator (no SNR appended yet)"),u.push("initiator is a direct RF neighbor"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"min_path_len",confidence:"speculative",inferredSrc:null,inferredName:null,evidence:[...u,"initiator is within direct RF range (zero forwarding hops)"],thisPathLen:o,minPathLen:x,firstHopPrefix:g};const f=Object.entries(r).filter(([k])=>k.replace(/^0x/i,"").slice(0,2).toUpperCase()===g);if(f.length===1){const[k,$]=f[0],h=$.name||$.node_name||null;return u.push(`first hop ${g} → unique neighbor: ${h??k}`),u.push("initiator is whoever sent TO this first hop"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"first_hop_neighbor",confidence:"likely",inferredSrc:g,inferredName:h,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g}}else f.length>1?u.push(`first hop ${g} matches ${f.length} neighbors (ambiguous)`):u.push(`first hop ${g} is not a known neighbor`)}return u.push("insufficient data to identify initiator"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"none",confidence:"none",inferredSrc:null,inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g}}let ne=null,ce=null;typeof window<"u"&&setTimeout(()=>{ue(()=>import("./usePipelineStore-Do-g28wv.js"),__vite__mapDeps([0,1,2,3])).then(t=>{ne=t}),ue(()=>import("./index-C2xvS0Jd.js").then(t=>t.ho),__vite__mapDeps([1,3])).then(t=>{ce=t})},0);const He={advertSender:null,advertNodeType:null,advertFlags:null,advertHasLocation:null,advertHasName:null,advertName:null,advertLatitude:null,advertLongitude:null,channelHash:null,byteLength:void 0,hopCount:0,isZeroHop:!0,preComputed:!1};function jt(t,s){const r=t.type??t.payload_type,c=Ne(r),a=Be(t.route),n=r===O.ADVERT,l=r===O.TRACE,o=r===O.PATH,x=r===O.GRP_TXT||r===O.GRP_DATA,m=Ie(t.snr,t.rssi),g=(m==null?void 0:m.finalGrade)??"critical",u=Ge(t.route),v=Ke(t.route),N=Ve(t.route),f=t.route==null?"unknown":u?"flood":v?"direct":"unknown",k=N?`transport-${f}`:f,$=!!s.advertSender;let h="none";$?h="pubkey":x?h="encrypted":t.src_hash&&(h="prefix");const y=gt(r),p=s.advertNodeType!=null?ke(s.advertNodeType):"unknown",_=y!=="unknown"?y:p,H=t.packet_origin??"rx",C=Math.floor(Date.now()/1e3)-t.timestamp,D=C<10?"live":C<300?"recent":C<3600?"warm":C<86400?"stale":"historic",L=t.path_length??(Array.isArray(t.original_path)?t.original_path.length:void 0),P=Array.isArray(t.original_path)&&t.original_path.length>0,R=L??0,b=s.byteLength??(t.raw_packet?Math.floor(t.raw_packet.length/2):0),w=bt(t);return{pType:r,payloadTypeName:c,routeTypeName:a,isAdvert:n,isTrace:l,isPath:o,isGrp:x,signalClass:g,routeClass:k,isFlood:u,isDirect:v,hasTransport:N,senderTier:h,hasPubkey:$,inferredType:y,advertType:p,effectiveType:_,origin:H,age:D,pathLen:L,pathAvail:P,pathHopCount:R,byteLen:b,dupeAnalysis:w}}function vt(t){var f,k,$,h,y,p;const s=ft(t);if(!s||s.pathHashes.length===0)return null;const{pathHashes:r,snrValues:c}=s;if(r.length<2||!ne||!ce)return null;const a=ne.usePipelineStore.getState().srcHashResolverMap,n=ne.usePipelineStore.getState().neighborContext,l=(n==null?void 0:n.hashToName)??new Map,o=ce.useStore.getState().stats,x=(o==null?void 0:o.neighbors)??{},m=o==null?void 0:o.local_hash,g=(k=(f=o==null?void 0:o.config)==null?void 0:f.repeater)==null?void 0:k.latitude,u=(h=($=o==null?void 0:o.config)==null?void 0:$.repeater)==null?void 0:h.longitude,v=Object.keys(x).length>0?Ue([],x,m,g,u):null,N=[];for(let _=0;_0?[r[_-1].toUpperCase()]:[]],P=ge(H,_,L,a,v),R=[H,..._+20?N:null}function ge(t,s,r,c,a){if(s===0){const l=c==null?void 0:c.get(t);if(l)return{hash:l,confidence:.8};if(a){const o=pe(a,t,{position:s,adjacentPrefixes:r});if(o.hash)return{hash:o.hash,confidence:o.confidence}}}else{if(a){const o=pe(a,t,{position:s,adjacentPrefixes:r});if(o.hash)return{hash:o.hash,confidence:o.confidence}}const l=c==null?void 0:c.get(t);if(l)return{hash:l,confidence:.6}}return{hash:null,confidence:0}}function Nt(t){var l;const s=t.raw_packet;if(!s||s.length<2)return null;const r=s.replace(/\s/g,""),c=Math.floor(r.length/2),a=((l=r.match(/.{1,2}/g))==null?void 0:l.join(" "))??"";let n="";for(let o=0;o=32&&x<=126?String.fromCharCode(x):"·"}return{hexBytes:a,utf8:n,byteCount:c}}function wt(t){const s=new Map;let r=0,c="";for(const a of t){if((a.type??a.payload_type)!==O.TRACE)continue;r++,c=a.packet_hash;const l=a._traceTag??(a.payload?Te(a.payload):null);if(!l)continue;let o=s.get(l);o||(o=[],s.set(l,o)),o.push(a)}return{index:s,fingerprint:`${r}:${c}`}}function Ct(t,s,r){const c=T.useRef({parse:0,decode:0,enrich:0,traceIndex:0,total:0}),a=T.useMemo(()=>t?Nt(t):null,[t]),n=T.useMemo(()=>{if(!s||s.length<4)return c.current.parse=0,c.current.decode=0,null;const h=performance.now(),y=pt(s),p=performance.now()-h;return y?(c.current.parse=p,c.current.decode=0,{protocolPacket:y.packet,display:{headerFields:y.headerFields,transportCodesHex:y.transportCodesHex,pathLengthHex:y.pathLengthHex,pathDataHex:y.pathDataHex,payloadHex:y.payloadHex,payloadByteOffset:y.payloadStartByte,pathByteOffset:y.pathByteOffset,pathLenByteOffset:y.pathLenByteOffset},decoded:y.decoded,error:null}):(c.current.parse=p,c.current.decode=0,{protocolPacket:null,display:null,decoded:null,error:"Packet.fromHex() returned failure"})},[s]),l=T.useMemo(()=>{if(!t)return c.current.enrich=0,He;const h=performance.now();if(t._advertSender!==void 0)return c.current.enrich=performance.now()-h,{advertSender:t._advertSender??null,advertNodeType:t._advertNodeType??null,advertFlags:t._advertFlags??null,advertHasLocation:t._advertHasLocation??null,advertHasName:t._advertHasName??null,advertName:t._advertName??null,advertLatitude:t._advertLatitude??null,advertLongitude:t._advertLongitude??null,channelHash:t._channelHash??null,byteLength:t._byteLength,hopCount:t._hopCount??0,isZeroHop:t._isZeroHop??!0,preComputed:!0};const y=t.type??t.payload_type,p=Fe(s,y),_=Ee(s,y),H=Oe(s,t),C=ze(t);return c.current.enrich=performance.now()-h,{...p,channelHash:_,byteLength:H,...C,preComputed:!1}},[t,s]),o=T.useRef({fingerprint:"",index:new Map}),x=T.useMemo(()=>{const h=performance.now(),{index:y,fingerprint:p}=wt(r);return c.current.traceIndex=performance.now()-h,p===o.current.fingerprint?o.current.index:(o.current={fingerprint:p,index:y},y)},[r]),m=T.useMemo(()=>{const h=c.current;return{parse:h.parse,decode:h.decode,enrich:h.enrich,traceIndex:h.traceIndex,total:h.parse+h.decode+h.enrich+h.traceIndex}},[n,l,x]);if(!t)return null;const g=s?n?n.error:"rawHex too short":"No raw_packet (warm-tier)",u=(n==null?void 0:n.protocolPacket)??null,v=u?u.payloadVersion:null,N=v===0,f=v===1,k=jt(t,l);let $=null;return k.isTrace&&($=vt(t)),{wire:a,display:(n==null?void 0:n.display)??null,parseError:g,protocolPacket:u,decoded:(n==null?void 0:n.decoded)??null,payloadVersion:v,isV1:N,isV2:f,enrichment:l,traceTagIndex:x,analysis:k,traceHopDetail:$,timing:m}}function ae({options:t,nextFn:s}){var n;const r=t.find(l=>l.active),c=(r==null?void 0:r.color)??"green",a=((n=I[c])==null?void 0:n.stem)??"bg-edge-subtle";return e.jsxs("div",{className:"flex flex-col items-start py-1 gap-0 px-2",children:[e.jsx("div",{className:`w-px h-2 ml-4 ${a}`}),e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-md overflow-hidden w-full",children:[t.map((l,o)=>{const x=I[l.color??"green"]??I.green;return e.jsxs("div",{className:`flex items-center gap-1.5 px-2 py-px font-mono text-[10px] leading-relaxed transition-opacity ${l.active?x.row:"opacity-25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${l.active?x.dot:"border border-zinc-500/40"}`}),e.jsx("span",{className:`w-16 shrink-0 font-medium ${l.active?"text-fg-primary":"text-fg-muted"}`,children:l.label}),l.detail&&e.jsx("span",{className:l.active?"text-fg-primary/70":"text-fg-muted",children:l.detail})]},o)}),s&&e.jsx("div",{className:"flex items-center px-2 py-0.5 border-t border-edge-subtle",children:e.jsxs("span",{className:"text-[10px] text-fg-muted font-mono",children:["→ ",s]})})]}),e.jsx("div",{className:`w-px h-2 ml-4 ${a}`})]})}function St({tokens:t,nextFn:s}){var n;const r=t.find(l=>l.active),c=(r==null?void 0:r.color)??"green",a=((n=I[c])==null?void 0:n.stem)??"bg-edge-subtle";return e.jsxs("div",{className:"flex flex-col items-start py-1 gap-0 px-2",children:[e.jsx("div",{className:`w-px h-2 ml-4 ${a}`}),e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-md overflow-hidden w-full",children:[t.map((l,o)=>{const x=I[l.color??"green"]??I.green;return e.jsxs("div",{className:`flex items-center gap-1 px-2 py-px font-mono text-[10px] leading-relaxed transition-opacity ${l.active?x.row:"opacity-25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${l.active?x.dot:"border border-zinc-500/40"}`}),e.jsx("span",{className:"text-fg-muted shrink-0",children:l.fn}),e.jsxs("span",{className:l.active?"text-fg-primary":"text-fg-muted",children:["(",l.value??"",")"]})]},o)}),s&&e.jsx("div",{className:"flex items-center px-2 py-0.5 border-t border-edge-subtle",children:e.jsxs("span",{className:"text-[10px] text-fg-muted font-mono",children:["→ ",s]})})]}),e.jsx("div",{className:`w-px h-2 ml-4 ${a}`})]})}const Tt={0:"border-l-sys-green",1:"border-l-sys-blue",2:"border-l-sys-teal",3:"border-l-sys-purple"};function le({stage:t,name:s,fn:r,verdict:c,timeMs:a,skipped:n,skipReason:l,children:o}){const x=Tt[t]??"";return e.jsx(e.Fragment,{children:e.jsx(G,{defaultOpen:!n,children:e.jsxs("div",{className:`surface-base rounded-lg border border-edge-subtle overflow-hidden border-l-2 ${x}`,children:[e.jsxs(K,{className:"px-3 py-2 w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"font-mono text-xs font-bold text-sys-blue shrink-0",children:t}),e.jsx("span",{className:"font-mono text-xs font-medium text-fg-primary truncate",children:s}),r&&!c&&e.jsx("span",{className:"font-mono text-[11px] text-fg-muted truncate hidden sm:inline",children:r}),c&&e.jsx("span",{className:"font-mono text-[11px] text-fg-muted/70 truncate hidden sm:inline",children:c})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[n&&e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-zinc-500/20 text-fg-muted",children:"N/A"}),a!=null&&!n&&e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:a<1?`${(a*1e3).toFixed(0)}µs`:`${a.toFixed(2)}ms`})]})]}),e.jsx(V,{children:e.jsx("div",{className:"px-3 pb-3 font-mono text-xs",children:n?e.jsx("p",{className:"text-fg-muted italic",children:l??"Not applicable for this packet type"}):o})})]})})})}function _t(t,s){return s?"manual":t._stripped?"bulk-tier":qe.isConnected()?"ws-push":"rest-poll"}const kt={connected:"green",degraded:"amber",offline:"red"};function Ht({packet:t,isSynthetic:s}){const r=xe(g=>g.wsState),c=xe(g=>g.health),a=_t(t,s),l=!!t._stripped?"WARM":"HOT",o=[{label:"ws-push",detail:"wsConnected && onPacket()",active:a==="ws-push",color:"green"},{label:"rest-poll",detail:"!wsConnected, 3s interval",active:a==="rest-poll",color:"amber"},{label:"catchup",detail:"wsReconnected, delta > 50",active:a==="catchup",color:"amber"},{label:"bulk-tier",detail:"user extends time range → gzip",active:a==="bulk-tier",color:"blue"},{label:"manual",detail:"hex input — no transport",active:a==="manual",color:"zinc"}],x=[{fn:"transport",value:a,group:"transport",color:a==="ws-push"?"green":a==="bulk-tier"?"blue":"amber"},{fn:"tier",value:l,group:"transport",color:"blue"},{fn:"wsState",value:r,group:"transport",color:r==="connected"?"green":"amber"},{fn:"health",value:c,group:"transport",color:kt[c]}],m=s?"manual hex input":`${a} (${c})`;return e.jsx(le,{stage:0,name:"TRANSPORT",fn:"websocketService / useStore.startPolling",verdict:m,children:s?e.jsx("p",{className:"text-fg-muted italic",children:"Manual hex input — no transport context"}):e.jsx(U,{prefix:"transport",children:e.jsxs("div",{className:"space-y-0",children:[e.jsx(ae,{options:o,nextFn:"ingest()"}),e.jsx(se,{tokens:x})]})})})}function q({start:t,end:s}){const r=s!=null&&s!==t?`[${t}..${s}]`:`[${t}]`;return e.jsx("span",{className:"text-fg-muted text-[9px] font-mono mr-1 select-none",children:r})}const $t={advert:"decodeAdvert()",ack:"decodeAck()",path:"decodePath()",trace:"decodeTraceWithSnr()",txt_msg:"decodeTextMessage()",grp_txt:"decodeGroupText()",grp_data:"decodeGroupData()",multipart:"decodeMultipart()",control:"decodeControl()",req:"decodeRequest()",response:"decodeResponse()",anon_req:"decodeAnonReq()",generic:"decodeGeneric()"};function Dt({rawHex:t,display:s,protocolPacket:r,parseError:c,parseTimeMs:a,payloadVersion:n,isV1:l,isV2:o}){return e.jsx("dl",{className:"space-y-0.5",children:s&&r&&t?e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"A. Parse — Packet.fromHex()"}),a>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:a<1?`${(a*1e3).toFixed(0)}µs`:`${a.toFixed(2)}ms`})}),e.jsxs(i,{label:"header byte",children:[e.jsx(q,{start:0}),e.jsx(A,{value:t.slice(0,2)})," ",e.jsx(xt,{value:parseInt(t.slice(0,2),16)})]}),s.headerFields.map(x=>e.jsx(i,{label:` ${x.field}`,children:e.jsx(F,{raw:e.jsxs("span",{className:"text-[10px]",children:["bits[",x.bits,"] = ",x.binary]}),children:e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber",children:x.value})})},x.field)),e.jsx(i,{label:" version",children:n!=null?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(d,{fn:"payloadVer",value:`${n}`,color:"amber"}),e.jsx(M,{color:l?"green":o?"blue":"zinc",children:l?"v1":o?"v2":`v${n}`}),l&&e.jsx("span",{className:"text-fg-muted text-[10px]",children:"1-byte hashes, 2-byte MAC"}),o&&e.jsx("span",{className:"text-sys-blue text-[10px]",children:"2-byte hashes, 4-byte MAC (speculative)"})]}):e.jsx("span",{className:"text-fg-muted",children:"unknown"})}),e.jsx(E,{title:"Wire Framing"}),e.jsx(i,{label:"transportCodes",children:s.transportCodesHex?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(q,{start:1,end:4}),e.jsx(d,{fn:"transport",value:s.transportCodesHex,color:"amber"})]}):e.jsx("span",{className:"text-fg-muted",children:"N/A (non-transport route)"})}),e.jsx(i,{label:"pathLen",children:e.jsx(F,{raw:e.jsxs(e.Fragment,{children:[e.jsx(q,{start:s.pathLenByteOffset}),e.jsx(A,{value:s.pathLengthHex})]}),children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(q,{start:s.pathLenByteOffset}),e.jsx(d,{fn:"pathLen",value:`${r.pathLen} hop${r.pathLen!==1?"s":""}`,color:"amber"})]})})}),e.jsx(i,{label:"path",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.pathLen>0&&e.jsx(q,{start:s.pathByteOffset,end:s.pathByteOffset+r.pathLen-1}),e.jsx(re,{hops:r.pathHexArray,hexPrefix:s.pathDataHex||void 0})]})}),e.jsx(i,{label:"payloadLen",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(q,{start:s.payloadByteOffset,end:s.payloadByteOffset+s.payloadHex.length/2-1}),e.jsx(d,{fn:"payloadLen",value:`${s.payloadHex.length/2} bytes`,color:"amber"})]})}),e.jsx(i,{label:"payloadHex",children:e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber break-all",children:s.payloadHex})})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"A. Parse"}),e.jsxs(i,{label:"result",children:[e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber",children:"Skipped"}),e.jsx("span",{className:"ml-1 text-fg-muted",children:c??"No raw_packet (warm-tier)"})]})]})})}function Lt({decoded:t,packet:s}){if(!t)return e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"B. Decode"}),e.jsx("p",{className:"text-fg-muted italic text-[10px]",children:"No decoded payload"})]});const r=$t[t.type]??`decode${t.type}()`;return e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"B. Decode — decodePayload()"}),e.jsx(U,{prefix:"decodePayload",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsx(i,{label:"dispatched",children:r}),e.jsx(E,{}),e.jsx(Pt,{decoded:t,packet:s})]})})]})}function Pt({decoded:t,packet:s}){var r;switch(t.type){case"advert":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"publicKey",children:e.jsx(F,{raw:e.jsx("span",{className:"text-[10px] break-all",children:t.publicKey}),children:e.jsx(d,{fn:"publicKey",value:t.publicKey,color:"green"})})}),e.jsx(i,{label:"timestamp",children:e.jsx(d,{fn:"timestamp",value:String(t.timestamp),color:"green"})}),e.jsx(i,{label:"flags",children:e.jsx(F,{raw:e.jsx(A,{value:t.flags}),children:e.jsx(d,{fn:"flags",value:t.flagsDescription,color:"green"})})}),e.jsx(i,{label:"nodeType",children:e.jsx(d,{fn:"nodeType",value:t.nodeType,color:"green"})}),t.latitude!=null&&e.jsx(i,{label:"latitude",children:e.jsx(d,{fn:"lat",value:t.latitude.toFixed(6),color:"green"})}),t.longitude!=null&&e.jsx(i,{label:"longitude",children:e.jsx(d,{fn:"lon",value:t.longitude.toFixed(6),color:"green"})}),t.name&&e.jsx(i,{label:"name",children:e.jsx(d,{fn:"name",value:t.name,color:"green"})})]});case"ack":return e.jsx(i,{label:"crc",children:e.jsx(F,{raw:e.jsx("span",{className:"text-[10px]",children:t.crc}),children:e.jsx(d,{fn:"crc",value:t.crc,color:"green"})})});case"trace":{const c=s!=null&&s.src_hash?s.src_hash.replace(/^0x/i,"").slice(0,2).toUpperCase():null;return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"traceTag",children:e.jsx(d,{fn:"traceTag",value:t.traceTag,color:"green"})}),e.jsx(i,{label:"authCode",children:e.jsx(d,{fn:"authCode",value:String(t.authCode),color:"green"})}),e.jsx(i,{label:"flags",children:e.jsx(A,{value:t.flags})}),e.jsx(i,{label:"target path",children:t.pathHashes.length>0?e.jsx(re,{hops:t.pathHashes.map(a=>a.toUpperCase()),color:"green"}):e.jsx("span",{className:"text-fg-muted italic",children:"∅ empty"})}),e.jsx(i,{label:"complete",children:t.isComplete?e.jsxs("span",{className:"text-sys-green",children:["✓ all ",t.pathHashes.length," hops reported SNR"]}):e.jsxs("span",{className:"text-sys-amber",children:["✗ ",t.snrValues.length,"/",t.pathHashes.length," hops reported"]})}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1 text-[10px]",children:"Directional Edge SNR — per-hop link quality"}),t.snrValues.length===0?e.jsx("p",{className:"text-fg-muted italic text-[11px] ml-2",children:"No SNR values in path field"}):e.jsx("div",{className:"space-y-0.5 ml-2",children:t.snrValues.map((a,n)=>{var g,u,v,N,f;const l=((g=t.pathHashes[n])==null?void 0:g.toUpperCase())??"??",o=n===0?c??"SRC":((u=t.pathHashes[n-1])==null?void 0:u.toUpperCase())??"??",x=(f=(N=(v=Ye.getState().stats)==null?void 0:v.config)==null?void 0:N.radio)==null?void 0:f.spreading_factor,m=we(a,x);return e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted w-3 text-right",children:n}),e.jsx("span",{className:"text-fg-primary",children:o}),e.jsx("span",{className:"text-fg-muted",children:"→"}),e.jsx("span",{className:"text-fg-primary",children:l}),e.jsx("span",{className:"text-fg-muted",children:"@"}),e.jsxs("span",{className:"font-bold text-sys-green",children:[a>0?"+":"",a.toFixed(1)," dB"]}),e.jsx(M,{color:"green",children:m})]},n)})})]})]})}case"path":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"pathLength",children:e.jsx(d,{fn:"pathLength",value:String(t.pathLength),color:"green"})}),e.jsx(i,{label:"path",children:t.path&&t.path.length>0?e.jsx(re,{hops:t.path.map(c=>c.toUpperCase()),color:"green"}):e.jsx("span",{className:"text-fg-muted italic",children:"∅ empty"})}),t.extraType!=null&&e.jsx(i,{label:"extraType",children:e.jsx(d,{fn:"extraType",value:t.extraTypeName??String(t.extraType),color:"purple"})}),t.extraData&&e.jsxs(i,{label:"extraData",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.extraData}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.extraData.length/2,"B)"]})]})]});case"txt_msg":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsx(i,{label:"timestamp",children:e.jsx(d,{fn:"timestamp",value:String(t.timestamp),color:"green"})}),e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:t.text,color:"green"})}),e.jsx(i,{label:"encrypted",children:e.jsx(d,{fn:"encrypted",value:String(t.encrypted),color:"green"})})]});case"grp_txt":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channelHash",children:e.jsx(A,{value:t.channelHash})}),t.channelName&&e.jsx(i,{label:"channelName",children:e.jsx(d,{fn:"channel",value:t.channelName,color:"green"})}),e.jsx(i,{label:"decrypted",children:e.jsx(d,{fn:"decrypted",value:String(t.decrypted),color:"green"})}),t.text&&e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:t.text,color:"green"})}),t.senderName&&e.jsx(i,{label:"senderName",children:e.jsx(d,{fn:"sender",value:t.senderName,color:"green"})}),t.macCorrupted&&e.jsx(i,{label:"macCorrupted",children:e.jsx(d,{fn:"macCorrupted",value:"true",color:"green"})})]});case"grp_data":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channelHash",children:e.jsx(A,{value:t.channelHash})}),e.jsx(i,{label:"dataLength",children:t.dataLength}),e.jsx(i,{label:"decrypted",children:String(t.decrypted)})]});case"multipart":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"messageId",children:t.messageId}),e.jsxs(i,{label:"part",children:[t.partNumber+1," / ",t.totalParts]})]});case"control":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"controlType",children:e.jsx(F,{raw:e.jsx(A,{value:t.controlType}),children:e.jsx(d,{fn:"controlType",value:t.subtypeName,color:"green"})})}),e.jsx(i,{label:"subtype",children:e.jsx(d,{fn:"subtype",value:`0x${t.subtype.toString(16).padStart(2,"0")}`,color:"green"})}),t.nodeTypeName&&e.jsxs(i,{label:"nodeType",children:[e.jsx(d,{fn:"nodeType",value:t.nodeTypeName,color:"green"}),e.jsxs("span",{className:"text-fg-muted text-[10px] ml-1",children:["(flags & 0x0F = 0x",(r=t.nodeType)==null?void 0:r.toString(16).padStart(2,"0"),")"]})]}),t.snrDb!=null&&e.jsxs(i,{label:"snr",children:[e.jsxs("span",{className:"font-bold text-sys-green",children:[t.snrDb>0?"+":"",t.snrDb.toFixed(1)," dB"]}),e.jsx(M,{color:"green",children:t.snrDb>=5?"strong":t.snrDb>=0?"fair":"weak"})]}),t.tag&&e.jsx(i,{label:"tag",children:e.jsx(d,{fn:"tag",value:t.tag,color:"green"})}),t.publicKey&&e.jsxs(i,{label:"publicKey",children:[e.jsx("span",{className:"break-all text-[10px] font-mono text-sys-green",children:t.publicKey}),e.jsx(M,{color:t.publicKeyFull?"green":"amber",children:t.publicKeyFull?"32B full":`${t.publicKey.length/2}B prefix`})]}),t.typeFilter!=null&&e.jsx(i,{label:"typeFilter",children:e.jsx(F,{raw:e.jsx(A,{value:t.typeFilter}),children:e.jsx(d,{fn:"typeFilter",value:t.typeFilterDescription??"none",color:"green"})})}),t.prefixOnly!=null&&e.jsx(i,{label:"prefixOnly",children:e.jsx(d,{fn:"prefixOnly",value:String(t.prefixOnly),color:"green"})}),t.since!=null&&e.jsx(i,{label:"since",children:e.jsx(d,{fn:"since",value:t.since===0?"all (0)":String(t.since),color:"green"})}),!t.nodeTypeName&&t.typeFilter==null&&t.dataLength>0&&e.jsxs(i,{label:"data",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.dataHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.dataLength,"B)"]})]})]});case"req":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"response":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"anon_req":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"senderPubKey",children:e.jsx("span",{className:"break-all text-[10px] font-mono text-sys-green",children:t.senderPublicKey})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"generic":return e.jsxs(e.Fragment,{children:[e.jsxs(i,{label:"payloadType",children:[e.jsx(ht,{value:t.payloadType})," (",t.payloadTypeName,")"]}),e.jsx(i,{label:"length",children:t.length}),e.jsx(i,{label:"rawHex",children:e.jsx("span",{className:"break-all",children:t.rawHex})})]});default:return e.jsx("p",{className:"text-fg-muted",children:"Unknown decoded type"})}}function Mt({protocolPacket:t,packetHash:s}){const r=t==null?void 0:t.payloadType,c=r===Ze||r===Xe,a=T.useMemo(()=>{if(!c||!t)return null;const p=t.payload;return p.length<4?null:{channelHash:p[0],mac:p.slice(1,3),ciphertext:p.slice(3)}},[t,c]),[n,l]=T.useState("pending"),[o,x]=T.useState([]),[m,g]=T.useState(0);T.useEffect(()=>{if(!a){l(null);return}let p=!1;return(async()=>{const H=performance.now(),C=await Qe(a.channelHash,a.mac,a.ciphertext);p||(l(C),g(performance.now()-H));const D=await Je(a.channelHash);p||x(D)})(),()=>{p=!0}},[a]);const[u,v]=T.useState(""),[N,f]=T.useState(null),[k,$]=T.useState(!1),h=T.useCallback(async()=>{if(!(!a||!u.trim())){$(!0);try{const p=await We(u.trim(),a.channelHash,a.mac,a.ciphertext);if(p.success){const _=new TextDecoder("utf-8",{fatal:!1}).decode(p.result.plaintext.slice(5));f({success:!0,text:_})}else f({success:!1,error:p.error})}catch(p){f({success:!1,error:String(p)})}finally{$(!1)}}},[a,u]),y=Ce(s);return!c||!a?null:e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"C. Decrypt — tryDecryptGroupMessage()"}),m>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:m<1?`${(m*1e3).toFixed(0)}µs`:`${m.toFixed(2)}ms`})}),e.jsx(U,{prefix:"tryDecryptGroupMessage",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsx(i,{label:"channelHash",children:e.jsx(d,{fn:"channelHash",value:`0x${a.channelHash.toString(16).toUpperCase().padStart(2,"0")}`,color:"teal"})}),e.jsx(i,{label:"mac",children:e.jsx(d,{fn:"mac",value:Array.from(a.mac).map(p=>p.toString(16).padStart(2,"0")).join(""),color:"teal"})}),e.jsx(i,{label:"cipherLen",children:e.jsx(d,{fn:"cipherLen",value:`${a.ciphertext.length}B`,color:"teal"})}),e.jsx(i,{label:"candidates",children:e.jsx(d,{fn:"candidates",value:o.length>0?`${o.length} names`:"0",color:o.length>0?"teal":"zinc"})}),o.length>0&&e.jsxs("details",{className:"mt-1",children:[e.jsx("summary",{className:"text-fg-muted cursor-pointer hover:text-fg-primary text-[10px]",children:"show candidate names"}),e.jsx("div",{className:"mt-1 text-[10px] text-fg-muted break-all max-h-24 overflow-y-auto",children:o.join(", ")})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"Result:"}),n==="pending"?e.jsx("p",{className:"text-fg-muted italic",children:"decrypting…"}):n?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channel",children:e.jsx(d,{fn:"channel",value:n.channelName,color:"teal"})}),e.jsx(i,{label:"plaintext",children:e.jsx(d,{fn:"plaintext",value:new TextDecoder("utf-8",{fatal:!1}).decode(n.plaintext.slice(5)).trim()||"(empty)",color:"teal"})}),e.jsx(i,{label:"macValid",children:e.jsx(d,{fn:"macValid",value:n.macCorrupted?"false":"true",color:"teal"})})]}):e.jsxs(i,{label:"decrypt",children:[e.jsx(d,{fn:"decrypt",value:"failed",color:"red"}),e.jsx("span",{className:"text-fg-muted ml-1",children:"channel not in known list"})]})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"testChannelName() — manual test:"}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("input",{type:"text",value:u,onChange:p=>{v(p.target.value),f(null)},onKeyDown:p=>p.key==="Enter"&&h(),placeholder:"channel name",className:"surface-input px-2 py-1 rounded text-[11px] font-mono text-fg-primary w-40"}),e.jsx("button",{onClick:h,disabled:k||!u.trim(),className:"px-2 py-1 rounded text-[10px] font-mono bg-sys-blue/20 text-sys-blue hover:bg-sys-blue/30 disabled:opacity-40 transition-colors",children:k?"…":"Try"})]}),N&&e.jsx("div",{className:"mt-1",children:N.success?e.jsx(i,{label:"result",children:e.jsx(d,{fn:"plaintext",value:N.text??"(empty)",color:"teal"})}):e.jsx(i,{label:"error",children:e.jsx(d,{fn:"error",value:N.error??"unknown",color:"red"})})})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"useDecodedMessage() store result:"}),y?y.decoded?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channel",children:e.jsx(d,{fn:"channel",value:y.decoded.channelName??"?",color:"teal"})}),e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:y.decoded.text,color:"teal"})})]}):e.jsx(i,{label:"decrypt",children:e.jsx(d,{fn:"decrypt",value:"failed",color:"red"})}):e.jsx(i,{label:"decrypt",children:e.jsx(d,{fn:"decrypt",value:"pending",color:"zinc"})})]})]})})]})}function Rt(t){const{rawHex:s,display:r,protocolPacket:c,decoded:a,parseError:n,parseTimeMs:l,payloadVersion:o,isV1:x,isV2:m,packetHash:g,packet:u}=t,v=!!s&&s.length>=4;return e.jsxs(G,{children:[e.jsx(K,{className:"w-full mt-2 mb-1",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-[10px] font-mono text-fg-muted",children:"🔬"}),e.jsx("span",{className:"text-[10px] font-mono font-medium text-fg-muted",children:"Wire Inspection"}),e.jsx("span",{className:"text-[9px] text-fg-muted/50",children:"observatory diagnostic — not a runtime stage"})]})}),e.jsx(V,{children:e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-lg p-3 space-y-1 bg-surface/30",children:[e.jsx("p",{className:"text-[9px] text-fg-muted/50 mb-2",children:"The backend parsed these fields server-side. This panel verifies the wire-level encoding client-side."}),v?e.jsxs(e.Fragment,{children:[e.jsx(Dt,{rawHex:s,display:r,protocolPacket:c,parseError:n,parseTimeMs:l,payloadVersion:o,isV1:x,isV2:m}),e.jsx(Lt,{decoded:a,packet:u}),e.jsx(Mt,{protocolPacket:c,packetHash:g})]}):e.jsx("p",{className:"text-fg-muted italic text-[10px]",children:n??"No raw_packet — wire inspection unavailable (warm-tier packet)"})]})})]})}function fe(t){if(!t)return[{fn:"decode",value:"no raw_packet",group:"decode",color:"zinc"}];switch(t.type){case"advert":{const s=t,r=[{fn:"decode.nodeType",value:s.nodeType,group:"decode",color:"blue"}];return s.name&&r.push({fn:"decode.name",value:s.name,group:"decode",color:"blue"}),s.latitude!=null&&s.longitude!=null&&r.push({fn:"decode.location",value:`${s.latitude.toFixed(4)}, ${s.longitude.toFixed(4)}`,group:"decode",color:"blue"}),r.push({fn:"decode.publicKey",value:s.publicKey,group:"decode",color:"blue"}),r}case"trace":{const s=t;return[{fn:"decode.traceTag",value:s.traceTag,group:"decode",color:"blue"},{fn:"decode.hops",value:s.pathHashes.length>0?s.pathString:"empty",group:"decode",color:"blue"},{fn:"decode.snr",value:s.snrValues.length>0?`${s.snrValues.length} values`:"none",group:"decode",color:s.snrValues.length>0?"blue":"zinc"},{fn:"decode.complete",value:s.isComplete?"yes":"partial",group:"decode",color:s.isComplete?"green":"amber"}]}case"path":{const s=t,r=[{fn:"decode.pathLength",value:String(s.pathLength),group:"decode",color:"blue"},{fn:"decode.path",value:s.path.length>0?s.pathString:"empty",group:"decode",color:"blue"}];return s.extraType!=null&&r.push({fn:"decode.extraType",value:s.extraTypeName??String(s.extraType),group:"decode",color:"purple"}),s.extraData&&r.push({fn:"decode.extraData",value:`${s.extraData.length/2}B`,group:"decode",color:"purple"}),r}case"ack":return[{fn:"decode.crc",value:t.crc,group:"decode",color:"blue"}];case"grp_txt":return[{fn:"decode.channelHash",value:t.channelHash,group:"decode",color:"blue"},{fn:"decode.encrypted",value:"true — decrypt at cascade",group:"decode",color:"zinc"}];case"grp_data":{const s=t;return[{fn:"decode.channelHash",value:s.channelHash,group:"decode",color:"blue"},{fn:"decode.dataLength",value:`${s.dataLength}B`,group:"decode",color:"blue"}]}case"txt_msg":{const s=t;return[{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.encrypted",value:s.encrypted?"true":"false",group:"decode",color:s.encrypted?"zinc":"green"},...s.encrypted?[]:[{fn:"decode.text",value:s.text,group:"decode",color:"blue"}]]}case"multipart":{const s=t;return[{fn:"decode.part",value:`${s.partNumber+1}/${s.totalParts}`,group:"decode",color:"blue"},{fn:"decode.msgId",value:s.messageId,group:"decode",color:"blue"}]}case"control":{const s=t,r=[{fn:"decode.subtype",value:s.subtypeName,group:"decode",color:"blue"}];return s.nodeTypeName&&r.push({fn:"decode.nodeType",value:s.nodeTypeName,group:"decode",color:"blue"}),s.snrDb!=null&&r.push({fn:"decode.snr",value:`${s.snrDb>0?"+":""}${s.snrDb.toFixed(1)} dB`,group:"decode",color:"blue"}),s.tag&&r.push({fn:"decode.tag",value:s.tag,group:"decode",color:"blue"}),s.publicKey&&r.push({fn:"decode.publicKey",value:s.publicKey,group:"decode",color:s.publicKeyFull?"green":"blue"}),s.typeFilter!=null&&r.push({fn:"decode.typeFilter",value:s.typeFilterDescription??`0x${s.typeFilter.toString(16)}`,group:"decode",color:"blue"}),s.prefixOnly!=null&&r.push({fn:"decode.prefixOnly",value:String(s.prefixOnly),group:"decode",color:"blue"}),!s.nodeTypeName&&!s.tag&&(r.push({fn:"decode.subtypeFlags",value:`0x${s.subtypeFlags.toString(16)}`,group:"decode",color:"blue"}),r.push({fn:"decode.dataLength",value:`${s.dataLength}B`,group:"decode",color:"blue"})),r}case"req":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"response":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"anon_req":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.senderPubKey",value:s.senderPublicKey,group:"decode",color:"green"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"generic":return[{fn:"decode.raw",value:`${t.length}B`,group:"decode",color:"zinc"}];default:return[]}}function At({packet:t,pipeline:s,rawHex:r,traceTagIndex:c,neighbors:a}){const{enrichment:n,timing:l,display:o,protocolPacket:x,decoded:m,parseError:g,payloadVersion:u,isV1:v,isV2:N,analysis:f}=s,$=(t.type??t.payload_type)===et,h=f.dupeAnalysis,y=T.useRef(0),p=T.useMemo(()=>{if(!$)return null;const D=performance.now(),L=yt(t,c,a);return y.current=performance.now()-D,L},[t,c,a,$]),_=l.enrich+y.current,H=[];f.byteLen&&H.push(`${f.byteLen}B`),H.push(f.payloadTypeName),n.advertName&&H.push(`"${n.advertName}"`),n.isZeroHop?H.push("zero-hop"):f.pathHopCount>0&&H.push(`${f.pathHopCount}h`),H.push(`${t.rssi}dBm`),h.isDuplicate&&H.push("DUPE");const C=H.join(" — ");return e.jsxs(le,{stage:1,name:"INGEST",fn:n.preComputed?"PacketCache.mergePackets()":"extractAdvertData() + extractHopData() + ...",verdict:C,timeMs:_,children:[e.jsx(Rt,{rawHex:r,display:o,protocolPacket:x,decoded:m,parseError:g,parseTimeMs:l.parse,payloadVersion:u,isV1:v,isV2:N,packetHash:t.packet_hash,packet:t}),e.jsx(E,{title:"Cache Enrichment"}),e.jsx(U,{prefix:"packetCache",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsxs("div",{className:"mb-1.5",children:[n.preComputed?e.jsx(M,{color:"green",children:"PacketCache"}):e.jsx(M,{color:"amber",children:"computed"}),e.jsx("span",{className:"text-[10px] text-fg-muted ml-1.5",children:n.preComputed?"pre-enriched by real pipeline":"synthetic — computed on the fly"})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1 mb-1",children:[e.jsx(d,{fn:"_byteLength",value:n.byteLength!=null?`${n.byteLength}B`:void 0,color:"blue"}),e.jsx(d,{fn:"_hopCount",value:String(n.hopCount),color:"blue"}),e.jsx(d,{fn:"_isZeroHop",value:String(n.isZeroHop),color:n.isZeroHop?"green":"blue"}),n.isZeroHop&&e.jsx(M,{color:"blue",children:"direct"}),n.channelHash!=null&&e.jsx(d,{fn:"_channelHash",value:n.channelHash,color:"blue"}),$&&t._traceTag&&e.jsx(d,{fn:"_traceTag",value:t._traceTag,color:"blue"})]}),n.advertSender||n.advertNodeType!=null||n.advertName!=null?e.jsxs("div",{className:"mt-1 mb-1",children:[e.jsx("p",{className:"text-[10px] text-sys-blue font-medium mb-0.5",children:"ADVERT Enrichment"}),e.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[n.advertSender&&e.jsx(d,{fn:"_advertSender",value:n.advertSender.slice(0,16)+"…",color:"blue"}),n.advertNodeType!=null&&e.jsx(d,{fn:"_advertNodeType",value:ke(n.advertNodeType),color:"blue"}),n.advertName!=null&&e.jsx(d,{fn:"_advertName",value:n.advertName,color:"blue"}),n.advertFlags!=null&&e.jsx(d,{fn:"_advertFlags",value:`0x${n.advertFlags.toString(16).padStart(2,"0")}`,color:"blue"}),n.advertHasLocation!=null&&e.jsx(d,{fn:"_advertHasLocation",value:String(n.advertHasLocation),color:"blue"}),n.advertHasName!=null&&e.jsx(d,{fn:"_advertHasName",value:String(n.advertHasName),color:"blue"}),n.advertLatitude!=null&&n.advertLongitude!=null&&e.jsx(d,{fn:"location",value:`${n.advertLatitude.toFixed(4)}, ${n.advertLongitude.toFixed(4)}`,color:"blue"})]})]}):e.jsx("p",{className:"text-[10px] text-fg-muted/30 mb-1",children:"ADVERT fields: N/A (non-ADVERT packet)"}),e.jsx(E,{title:"Payload Decode"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${m?"bg-sys-blue":"bg-zinc-500/40"}`}),e.jsx("span",{className:"font-mono text-[10px] font-medium text-fg-primary",children:"decodePayload()"}),e.jsx("span",{className:"text-[9px] text-fg-muted",children:"sync — wire data only, no crypto"})]}),e.jsx("div",{className:"ml-3",children:m?e.jsx("div",{className:"flex flex-wrap gap-x-1.5 gap-y-1",children:fe(m).map((D,L)=>e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5",children:e.jsx(d,{fn:D.fn,value:D.value,color:D.color})},L))}):e.jsx(S,{children:"no raw_packet — warm-tier packet, decode unavailable"})})]}),e.jsx(E,{}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted",children:"dupe:"}),h.isDuplicate?e.jsx(d,{fn:"is_duplicate",value:"true",color:"purple"}):e.jsx(S,{children:"none"}),h.dupeCount>0&&e.jsx(d,{fn:"dupeCount",value:`×${h.dupeCount}`,color:"purple"}),h.rssiRange&&e.jsxs(S,{c:"text-fg-primary",children:["Δ",Math.abs(h.rssiRange[1]-h.rssiRange[0]),"dB RSSI"]})]}),p&&e.jsxs(e.Fragment,{children:[e.jsx(E,{}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted",children:"TRACE SRC:"}),p.inferredSrc?e.jsxs(e.Fragment,{children:[e.jsx(d,{fn:"inferredSrc",value:p.inferredSrc,color:"purple"}),p.inferredName&&e.jsx(d,{fn:"name",value:p.inferredName,color:"purple"})]}):e.jsx(S,{children:"unresolvable"}),e.jsx(_e,{color:"purple",children:p.method}),e.jsxs(S,{children:["(",p.confidence,")"]}),e.jsxs(S,{children:["siblings=",p.siblingCount]})]})]}),(()=>{const D=f.pType!=null?`0x${f.pType.toString(16).toUpperCase().padStart(2,"0")}`:void 0,L=t.route!=null?`0x${t.route.toString(16).toUpperCase().padStart(2,"0")}`:void 0,P=fe(m),R=f.signalClass==="excellent"||f.signalClass==="good"?"green":f.signalClass==="fair"?"amber":"red",b=f.senderTier==="pubkey"?"green":f.senderTier==="prefix"?"amber":f.senderTier==="encrypted"?"teal":"zinc",w=[{fn:"type",value:f.payloadTypeName,raw:D,group:"wire",color:"blue"},{fn:"route",value:f.routeTypeName,raw:L,group:"wire",color:"blue"},{fn:"src_hash",value:t.src_hash||void 0,group:"wire",color:"blue"},{fn:"rssi",value:`${t.rssi}dBm`,group:"wire",color:"blue"},{fn:"snr",value:`${t.snr}dB`,group:"wire",color:"blue"},{fn:"_byteLength",value:f.byteLen?`${f.byteLen}B`:void 0,group:"enrichment",color:"blue"},{fn:"_hopCount",value:String(n.hopCount),group:"enrichment",color:"blue"},{fn:"_isZeroHop",value:String(n.isZeroHop),group:"enrichment",color:"blue"},{fn:"_advertSender",value:n.advertSender||void 0,group:"enrichment",color:"blue"},{fn:"_advertNodeType",value:f.advertType!=="unknown"?f.advertType:void 0,group:"enrichment",color:"blue"},{fn:"_advertName",value:n.advertName||void 0,group:"enrichment",color:"blue"},{fn:"_channelHash",value:n.channelHash||void 0,group:"enrichment",color:"blue"},...P,{fn:"is_duplicate",value:String(h.isDuplicate),group:"analysis",color:"purple"},p!=null&&p.inferredSrc?{fn:"traceSrc",value:p.inferredSrc,group:"analysis",color:"purple"}:{fn:"traceSrc"},{fn:"_signalClass",value:f.signalClass,group:"analysis",color:R},{fn:"_routeClass",value:f.routeClass,group:"analysis",color:"purple"},{fn:"_senderTier",value:f.senderTier,group:"analysis",color:b},{fn:"_origin",value:f.origin,group:"analysis",color:f.origin==="tx_local"?"green":f.origin==="tx_forward"?"amber":"purple"},{fn:"_pathAvail",value:f.pathAvail?`${f.pathHopCount} hops`:"none",group:"analysis",color:f.pathAvail?"green":"zinc"},{fn:"_age",value:f.age,group:"analysis",color:f.age==="live"||f.age==="recent"?"green":"zinc"},...h.dupeCount>0?[{fn:"_dupeCount",value:`×${h.dupeCount}`,group:"analysis",color:"purple"},...h.rssiRange?[{fn:"_multipath",value:`Δ${Math.abs(h.rssiRange[1]-h.rssiRange[0])}dB`,group:"analysis",color:Math.abs(h.rssiRange[1]-h.rssiRange[0])>6?"amber":"green"}]:[]]:[],...t.lbt_attempts!=null?[{fn:"_lbt",value:`${t.lbt_attempts} attempt${t.lbt_attempts!==1?"s":""}`,group:"analysis",color:(t.lbt_attempts??0)>1?"amber":"green"}]:[],...t.drop_reason?[{fn:"_dropReason",value:t.drop_reason,group:"analysis",color:"red"}]:[]];return e.jsx(se,{tokens:w})})()]})})]})}function be(t){switch(t){case"excellent":return"green";case"good":return"green";case"fair":return"amber";case"poor":return"red";case"critical":return"red";default:return"zinc"}}function ye(t){return`${Math.round(t*100)}%`}function je(t,s,r){return t||(s?s.slice(0,12):`~${r}`)}function Ft({hops:t}){return t.length===0?null:e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/40",children:[e.jsx("p",{className:"text-[9px] text-fg-muted/40 uppercase tracking-widest font-mono mb-1.5",children:"per-hop trace inspection"}),e.jsx("div",{className:"space-y-1",children:t.map(s=>e.jsx(U,{prefix:`trace.hop[${s.hopIndex}]`,children:e.jsxs("div",{className:"border border-edge-subtle/40 rounded px-2 py-1.5",children:[e.jsxs(i,{label:"link",children:[e.jsx(re,{hops:[s.fromPrefix,s.toPrefix],color:"blue"}),e.jsx("span",{className:"ml-1.5",children:e.jsx(_e,{color:be(s.quality),children:s.quality})})]}),e.jsx(i,{label:"snr",children:e.jsx(F,{raw:e.jsx("span",{className:"text-sys-blue",children:s.snrRaw}),children:e.jsx(d,{fn:"snr",value:`${s.snrRaw.toFixed(1)} dB`,color:be(s.quality)})})}),e.jsxs(i,{label:"from",children:[e.jsx(d,{fn:"resolve",value:je(s.fromName,s.fromHash,s.fromPrefix),color:s.fromHash?s.fromConfidence>=.8?"green":"amber":"purple"}),e.jsx("span",{className:"ml-1",children:e.jsx(d,{fn:"conf",value:ye(s.fromConfidence),color:"zinc"})})]}),e.jsxs(i,{label:"to",children:[e.jsx(d,{fn:"resolve",value:je(s.toName,s.toHash,s.toPrefix),color:s.toHash?s.toConfidence>=.8?"green":"amber":"purple"}),e.jsx("span",{className:"ml-1",children:e.jsx(d,{fn:"conf",value:ye(s.toConfidence),color:"zinc"})})]})]})},s.hopIndex))}),e.jsx(se,{label:"trace contributes",tokens:Et(t)})]})}function Et(t){const s=t.reduce((n,l)=>n+(l.fromHash?1:0)+(l.toHash?1:0),0),r=t.length*2,c=r-s,a=t.length>0?t.reduce((n,l)=>n+l.snrRaw,0)/t.length:0;return[{fn:"hops",value:String(t.length),group:"wire",color:"blue"},{fn:"resolved",value:`${s}/${r}`,group:"worker",color:"green"},...c>0?[{fn:"ghosts",value:String(c),group:"worker",color:"purple"}]:[],{fn:"avgSnr",value:`${a.toFixed(1)} dB`,group:"analysis",color:a>=5?"green":a>=0?"amber":"red"}]}function Ot(t){if(!t)return"never";const s=Math.floor((Date.now()-t)/1e3);return s<60?`${s}s ago`:s<3600?`${Math.floor(s/60)}m ago`:`${Math.floor(s/3600)}h ago`}function zt(t){if(!t)return[];const s=t.decoded;if(!s)return[{fn:"decrypt.result",value:"failed",group:"crypto",color:"red"}];if(!s.decrypted)return[{fn:"decrypt.result",value:"no key match",group:"crypto",color:"zinc"}];const r=[];return s.channelName&&r.push({fn:"decrypt.channelName",value:s.channelName,group:"crypto",color:"teal"}),s.senderName&&r.push({fn:"decrypt.senderName",value:s.senderName,group:"crypto",color:"teal"}),s.text&&r.push({fn:"decrypt.text",value:s.text,group:"crypto",color:"teal"}),s.timestamp&&r.push({fn:"decrypt.timestamp",value:new Date(s.timestamp*1e3).toISOString().slice(11,19),group:"crypto",color:"teal"}),s.macCorrupted&&r.push({fn:"decrypt.macCorrupted",value:"true",group:"crypto",color:"amber"}),r}function Bt({packet:t,decrypted:s,pipeline:r}){var b;const c=J(w=>w.isComputing),a=J(w=>w.lastUpdated),n=J(w=>w.lastComputeTimeMs),l=J(w=>w.topology.edges.length),o=J(w=>w.topology.discoveredNodes.length),x=tt(),m=st(),g=nt(),u=he(w=>w.isComputing),v=he(w=>w.nodeCount),N=me(w=>w.progress),f=me(w=>w.initialDecodeComplete),k=t.type??t.payload_type,$=k===O.GRP_TXT||k===O.GRP_DATA,h=k===O.TRACE,y=k===O.PATH,p=$,_=[{label:"full",detail:"all GRP_TXT → decryption worker",active:p&&f,color:"teal"},{label:"quick",detail:"100 most recent (initial load)",active:p&&!f,color:"amber"},{label:"skip",detail:"non-GRP or catchup path",active:!p,color:"zinc"}],H=zt(s),C=((b=s==null?void 0:s.decoded)==null?void 0:b.decrypted)===!0,D=c?"running":`${l}e ${o}g`,L=u?"running":`${v}n`,P=p?C?"decrypted":N.isDecoding?`${N.percent}%`:"pending":"N/A",R=`topo ${c?"○":"✓"} ${D} · spark ${u?"○":"✓"} ${L} · decrypt ${P}`;return e.jsx(le,{stage:2,name:"CASCADE",fn:"hydrateDownstream()",verdict:R,children:e.jsx(U,{prefix:"cascade",children:e.jsxs("div",{className:"space-y-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 py-1.5 text-[11px] font-mono",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c?"bg-sys-amber animate-pulse":"bg-sys-green"}`}),e.jsx("span",{className:"text-fg-primary",children:"topology"}),e.jsxs("span",{className:"text-fg-muted",children:[l,"e ",o,"g"]}),(h||y)&&e.jsx("span",{className:"text-sys-green text-[9px]",children:"↑signal"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${u?"bg-sys-amber animate-pulse":"bg-sys-green"}`}),e.jsx("span",{className:"text-fg-primary",children:"sparkline"}),e.jsxs("span",{className:"text-fg-muted",children:[v,"n"]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N.isDecoding?"bg-sys-amber animate-pulse":p?"bg-sys-teal":"bg-zinc-500/40"}`}),e.jsx("span",{className:"text-fg-primary",children:"decrypt"}),e.jsx("span",{className:p?"text-sys-teal":"text-fg-muted",children:p?C?"decrypted":N.isDecoding?`${N.percent}%`:"pending":"N/A"})]})]}),e.jsxs(G,{defaultOpen:h||y,children:[e.jsx(K,{className:"text-[10px] w-full border-t border-edge-subtle pt-1.5",children:e.jsx("span",{className:"font-mono text-fg-muted/50",children:"topology detail…"})}),e.jsx(V,{children:e.jsxs("div",{className:"ml-3 pb-2",children:[e.jsx(i,{label:"status",children:e.jsx(d,{fn:"isComputing",value:c?"running":"idle",color:c?"amber":"green"})}),e.jsxs(i,{label:"last",children:[e.jsx(d,{fn:"lastUpdated",value:Ot(a),color:"zinc"}),n>0&&e.jsxs("span",{className:"ml-2 text-fg-muted text-[10px]",children:["(",n<1e3?`${n.toFixed(0)}ms`:`${(n/1e3).toFixed(1)}s`,")"]})]}),e.jsxs(i,{label:"output",children:[e.jsx(d,{fn:"edges",value:String(l),color:"green"}),e.jsx(d,{fn:"ghostNodes",value:String(o),color:"purple"})]}),m&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{label:"trace links",children:[e.jsx(d,{fn:"directed",value:String(x.totalDirectedLinks),color:"teal"}),e.jsx(d,{fn:"bidir",value:String(x.bidirectionalLinks),color:"teal"}),e.jsx(d,{fn:"traces",value:String(x.totalTraces),color:"zinc"})]}),e.jsxs(i,{label:"trace SNR",children:[e.jsx(d,{fn:"mean",value:`${x.meanSnr.toFixed(1)} dB`,color:x.meanSnr>=5?"green":x.meanSnr>=0?"amber":"red"}),e.jsx(d,{fn:"median",value:`${x.medianSnr.toFixed(1)} dB`,color:"zinc"}),e.jsx(d,{fn:"confidence",value:`${Math.round(x.avgConfidence*100)}%`,color:"zinc"})]}),h&&e.jsxs(i,{label:"quality",children:[e.jsx(d,{fn:"excellent",value:String(x.qualityCounts.excellent),color:"green"}),e.jsx(d,{fn:"good",value:String(x.qualityCounts.good),color:"green"}),e.jsx(d,{fn:"fair",value:String(x.qualityCounts.fair),color:"amber"}),e.jsx(d,{fn:"poor",value:String(x.qualityCounts.poor),color:"red"}),e.jsx(d,{fn:"critical",value:String(x.qualityCounts.critical),color:"red"})]}),g.confirmedResolutions.size>0&&e.jsxs(i,{label:"feedback",children:[e.jsx(d,{fn:"feedback.confirmed",value:String(g.confirmedResolutions.size),color:"teal"}),e.jsx(d,{fn:"feedback.links",value:String(g.confirmedLinks.length),color:"teal"})]})]}),h&&(r==null?void 0:r.traceHopDetail)&&e.jsx(Ft,{hops:r.traceHopDetail})]})})]}),p&&e.jsx("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:e.jsxs("div",{className:"ml-3",children:[e.jsx(i,{label:"mode",children:e.jsx(ae,{options:_,nextFn:"queueDecryption()"})}),e.jsx(i,{label:"result",children:e.jsx(d,{fn:"decrypt",value:C?"decrypted":s?"failed":"pending",color:C?"teal":s?"red":"zinc"})}),C&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-x-1.5 gap-y-1",children:H.map((w,oe)=>e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5",children:e.jsx(d,{fn:w.fn,value:w.value,color:w.color})},oe))})]})}),(()=>{const w=[{fn:"topology.edges",value:String(l),group:"worker",color:"green"},{fn:"topology.ghostNodes",value:String(o),group:"worker",color:"purple"},{fn:"sparkline.nodes",value:`${v}`,group:"worker",color:"green"},...m?[{fn:"trace.directedLinks",value:String(x.totalDirectedLinks),group:"worker",color:"teal"},{fn:"trace.meanSnr",value:`${x.meanSnr.toFixed(1)} dB`,group:"worker",color:"teal"}]:[],...H];return e.jsx(se,{tokens:w})})()]})})})}function It(t,s,r,c){var n;const a=t.src_hash?Se(t.src_hash):"";if(t._advertSender&&s.hash&&s.confident)return{tier:1,label:"_advertSender → pubkey",detail:"ADVERT carried full 32-byte public key — definitive match"};if(c&&s.confident&&((n=s.name)==null?void 0:n.toLowerCase())===c.toLowerCase())return{tier:1.5,label:"decrypt.senderName → nameToHash",detail:`Decrypted sender name “${c}” matched neighbor — high-confidence`};if(a&&r.crossClassPrefixes.has(a))return{tier:2,label:"cross-class prefix",detail:"Prefix has mixed types (repeater + non-repeater); payload type narrows to one class"};if(s.confident){const l=r.prefixIndex.get(a);return(l==null?void 0:l.length)===1?{tier:3,label:"single candidate",detail:"Only one node matches this prefix — unambiguous"}:{tier:3,label:"resolver",detail:"Multi-signal scoring selected best candidate from collision set"}}return{tier:4,label:"ambiguous",detail:"Cannot confidently resolve — multiple same-class candidates, insufficient scoring separation"}}function Gt(t,s){const r=t.original_path??t.forwarded_path,c=new Set;if(r&&Array.isArray(r))for(const a of r){const n=String(a).toUpperCase();n.length>=2&&!rt(n,s)&&c.add(n)}return c}function Kt(t,s,r,c,a,n,l){const o=Math.floor(Date.now()/1e3),x=new Map(r.map(m=>[m.hash,m]));return t.map(m=>{const g=s[m.hash],u=x.get(m.hash);let v=!0,N="";c!=="unknown"?m.type!=="unknown"&&m.type!==c?(v=!1,N=`${m.type} ≠ required ${c}`):m.type===c?N="type matches":N="type unknown — not ruled out":N="payload ambiguous — all types eligible";const f=!!(g!=null&&g.zero_hop),k=(g==null?void 0:g.last_seen)??0;let $=0;if(f&&k>0){const b=(o-k)/3600;$=50*Math.exp(-b/l)}let h=0;if(k>0){const b=(o-k)/3600;h=Math.exp(-b/n)}const y=h*20,p=!!(g!=null&&g.latitude&&(g!=null&&g.longitude)&&(g.latitude!==0||g.longitude!==0)),_=p?5:0,H=(u==null?void 0:u.advertCount)??0,C=Math.min(H*2,30),D=(u==null?void 0:u.forwarderPrefixes.size)??0,L=Math.min(D*3,15);let P=0;if(u&&u.totalForwarderObservations>0&&a.size>0){let b=0;for(const w of a)u.forwarderPrefixes.has(w)&&b++;P=b/a.size}const R=$+y+_+C+L;return{hash:m.hash,name:m.name,type:m.type,roleCompatible:v,roleReason:N,zeroHop:f,zeroHopScore:$,lastSeen:k,recencyScore:h,recencyPoints:y,hasGps:p,gpsScore:_,advertCount:H,advertScore:C,topoWidth:D,topoScore:L,affinity:P,total:R}}).sort((m,g)=>g.total-m.total)}function Vt({packet:t,pipeline:s,resolved:r,resolveTimeMs:c,advertName:a,neighbors:n,decrypted:l}){var ie,de;const o=Y(j=>j.neighborContext),x=Y(j=>j.topologyProfiles),m=Y(j=>j.config),{analysis:g}=s,u=r??{hash:null,type:"unknown",name:null,confident:!1},v=t.src_hash?Se(t.src_hash):"",N=v?o.prefixIndex.get(v)??[]:[],f=v?x.get(v)??[]:[],k=g.pType??-1,$=k>=0?k.toString(16).toUpperCase().padStart(2,"0"):"??",h=g.inferredType,y=g.advertType,p=g.effectiveType,_=t._advertNodeType!=null?t._advertNodeType.toString(16).padStart(2,"0").toUpperCase():"",H=((ie=l==null?void 0:l.decoded)==null?void 0:ie.senderName)??null,C=It(t,u,o,H),D=T.useMemo(()=>Gt(t,v),[t,v]),L=g.pathLen,P=T.useMemo(()=>Kt(N,n,f,p,D,m.recencyDecayHours,m.zeroHopDecayHours),[N,n,f,p,D,m.recencyDecayHours,m.zeroHopDecayHours]),R=P.filter(j=>!j.roleCompatible),b=P.filter(j=>j.roleCompatible),w=t._advertSender?o.pubKeyMap.get(t._advertSender)??null:null,oe=C.tier===1,De=[{fn:"src_hash",value:v||"",active:!!v,color:"blue"},{fn:"_advertSender",value:t._advertSender?t._advertSender.slice(0,12)+"…":"",active:!!t._advertSender,color:"blue"},{fn:"_advertNodeType",value:_?`0x${_}`:"",active:t._advertNodeType!=null,color:"blue"},{fn:"path_length",value:L!=null?L===0?"zero-hop":String(L):"",active:L!=null,color:"blue"},{fn:"decrypt.senderName",value:H??"",active:!!H,color:"teal"}],Le=[{label:"hit",detail:"pubKeyMap.get(_advertSender) → definitive",active:!!w,color:"green"},{label:"miss",detail:t._advertSender?"pubkey not in neighbor table":"no _advertSender",active:!w,color:"zinc"}],Pe=[{label:"payload",detail:`inferDeviceType(0x${$}) → ${h}`,active:h!=="unknown",color:"amber"},{label:"flags",detail:_?`mapAdvertTypeCode(0x${_}) → ${y}`:"no _advertNodeType",active:h==="unknown"&&y!=="unknown",color:"green"},{label:"ambiguous",detail:"all types eligible",active:p==="unknown",color:"zinc"}],Me=u.name??((de=u.hash)==null?void 0:de.slice(0,12))??"?",Re=u.confident?"confident":"ambiguous",Ae=`→ ${Me} (${Re}, Tier ${C.tier})`;return e.jsx(le,{stage:3,name:"RESOLVE",fn:"usePipelineStore.resolveSource()",verdict:Ae,timeMs:c,children:e.jsx(U,{prefix:"resolvePacketSource",children:e.jsxs("div",{className:"space-y-0",children:[e.jsx("div",{className:"pt-1 pb-1",children:e.jsx(St,{tokens:De,nextFn:"resolvePacketSource()"})}),t.src_hash?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"1"})," ","PUBKEY LOOKUP"]}),e.jsx(ae,{options:Le,nextFn:"pubKeyMap.get()"}),e.jsx("div",{className:"ml-3 mt-1",children:w?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"resolved",children:e.jsx(d,{fn:"hash",value:w,color:"green"})}),a&&e.jsxs(i,{label:"name",children:[e.jsx(d,{fn:"name",value:a,color:"green"}),u.name&&a===u.name&&e.jsx(S,{c:"text-sys-green ml-1",children:"✓ neighbor match"})]}),e.jsxs(i,{label:"result",children:[e.jsx(M,{color:"green",children:"Tier 1"}),e.jsx(S,{c:"text-fg-primary ml-1",children:"definitive — scoring bypassed"})]})]}):t._advertSender?e.jsx(i,{label:"status",children:e.jsx(S,{c:"text-sys-amber",children:"✗ pubkey not in neighbor table"})}):e.jsx(i,{label:"status",children:e.jsx(S,{children:"no _advertSender — skip to prefix resolution"})})})]}),oe?e.jsx("div",{className:"border-t border-edge-subtle py-2",children:e.jsx("p",{className:"text-[11px] text-fg-muted/40 font-mono ml-3",children:"Steps 2–5 bypassed — pubkey definitive"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"2"})," ","CANDIDATE POOL — ",N.length," node",N.length!==1?"s":"",' match "',v,'"']}),e.jsxs("div",{className:"space-y-0.5 ml-3",children:[P.map(j=>e.jsxs("div",{className:"flex gap-2 items-center text-[11px]",children:[e.jsx("span",{className:"break-all text-[10px]",children:j.hash}),e.jsx(M,{color:"zinc",children:j.type||"unknown"}),j.name&&e.jsx(S,{children:j.name})]},j.hash)),N.length===0&&e.jsx(S,{children:"no known nodes for this prefix"})]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"3"})," ","TYPE INFERENCE"]}),e.jsx(ae,{options:Pe,nextFn:"effectiveType()"}),e.jsx("div",{className:"ml-3 mt-1",children:e.jsx(i,{label:"effective",children:e.jsx(d,{fn:"effectiveType",value:p,color:p!=="unknown"?h!=="unknown"?"amber":"green":"zinc"})})})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"4"})," ","ROLE-TYPE SCRUB"]}),e.jsx("div",{className:"space-y-0.5 ml-3",children:P.map(j=>e.jsxs("div",{className:"flex gap-2 items-center text-[11px]",children:[e.jsx("span",{className:j.roleCompatible?"text-sys-green":"text-sys-red",children:j.roleCompatible?"✓":"✗"}),e.jsx("span",{className:`break-all text-[10px] ${j.roleCompatible?"":"line-through text-fg-muted"}`,children:j.hash}),e.jsx(M,{color:j.roleCompatible?"zinc":"red",children:j.type||"unknown"}),e.jsx(S,{c:j.roleCompatible?"text-fg-muted":"text-sys-red",children:j.roleReason})]},j.hash))}),R.length>0&&e.jsxs("p",{className:"text-[10px] text-fg-muted mt-1 ml-3",children:[R.length," eliminated, ",b.length," surviving"]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"5"})," ","CANDIDATE SCORING"]}),b.length===0?e.jsx("p",{className:"text-fg-muted italic ml-3",children:"No surviving candidates"}):b.length===1?e.jsxs("div",{className:"ml-3 text-[11px]",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(S,{c:"text-sys-green",children:"→"}),e.jsx("span",{className:"break-all text-[10px]",children:b[0].hash}),b[0].name&&e.jsx(S,{c:"text-fg-muted ml-1",children:b[0].name})]}),e.jsx("p",{className:"text-fg-muted ml-4",children:"single survivor — scoring not needed"})]}):e.jsxs(G,{children:[e.jsx(K,{className:"text-[10px] ml-3",children:e.jsxs("span",{className:"font-mono text-fg-muted/50",children:[b.length," candidates scored…"]})}),e.jsx(V,{children:e.jsx("div",{className:"space-y-2 ml-3 mt-1",children:b.map(j=>{const Q=j.hash===u.hash;return e.jsxs("div",{className:`text-[11px] leading-relaxed rounded px-2 py-1 ${Q?"bg-sys-green/8 border border-sys-green/20":"bg-zinc-500/5"}`,children:[e.jsxs("div",{className:"flex gap-2 items-center mb-0.5",children:[e.jsx(S,{c:Q?"text-sys-green":"text-fg-muted",children:Q?"→":" "}),e.jsx("span",{className:`break-all text-[10px] ${Q?"text-fg-primary":"text-fg-muted"}`,children:j.hash}),e.jsx(M,{color:Q?"green":"zinc",children:j.type||"unknown"}),j.name&&e.jsx(S,{children:j.name})]}),e.jsxs("div",{className:"ml-4 flex flex-wrap gap-x-3 gap-y-0.5",children:[e.jsxs("span",{children:[e.jsx(S,{children:"zero_hop:"})," ",e.jsx(S,{c:j.zeroHop?"text-sys-green":"text-fg-muted",children:j.zeroHop?"✓":"✗"})," ",e.jsxs(M,{color:ee(j.zeroHopScore),children:["+",j.zeroHopScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"recency:"})," ",e.jsx(S,{c:"text-fg-primary",children:mt(j.lastSeen)})," ",e.jsxs(M,{color:ee(j.recencyPoints),children:["+",j.recencyPoints.toFixed(1)]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"gps:"})," ",e.jsx(S,{c:j.hasGps?"text-sys-green":"text-fg-muted",children:j.hasGps?"✓":"✗"})," ",e.jsxs(M,{color:ee(j.gpsScore),children:["+",j.gpsScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"adverts:"})," ",e.jsx(S,{c:"text-fg-primary",children:j.advertCount})," ",e.jsxs(M,{color:ee(j.advertScore),children:["+",j.advertScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"topo:"})," ",e.jsx(S,{c:"text-fg-primary",children:j.topoWidth})," ",e.jsxs(M,{color:ee(j.topoScore),children:["+",j.topoScore]})]})]}),e.jsxs("div",{className:"ml-4 mt-0.5",children:[e.jsx(S,{children:"score ≈"})," ",e.jsx(S,{c:"text-fg-primary font-bold",children:j.total.toFixed(1)})]})]},j.hash)})})})]})]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-green font-bold",children:"✓"})," ","RESOLUTION"]}),e.jsxs("div",{className:"ml-3",children:[e.jsx(i,{label:"hash",children:u.hash?e.jsx(d,{fn:"resolved.hash",value:u.hash,color:"green"}):e.jsx(S,{children:"null"})}),e.jsx(i,{label:"type",children:e.jsx(d,{fn:"resolved.type",value:u.type,color:u.confident?"green":"zinc"})}),e.jsx(i,{label:"name",children:u.name?e.jsx(d,{fn:"resolved.name",value:u.name,color:u.confident?"green":"amber"}):e.jsx(S,{children:"null"})}),e.jsx(i,{label:"confident",children:e.jsx(S,{c:u.confident?"text-sys-green":"text-sys-red",children:String(u.confident)})}),e.jsxs(i,{label:"tier",children:[e.jsx(M,{color:C.tier<=2?"green":C.tier===3?"amber":"red",children:C.tier}),e.jsx(S,{c:"text-fg-primary ml-1",children:C.label})]})]})]})]}):e.jsx("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx(S,{c:"text-sys-amber",children:"⚠ no src_hash"}),H&&e.jsx(d,{fn:"decrypt.senderName",value:H,color:"teal"}),u.confident?e.jsxs(S,{c:"text-sys-green",children:["→ resolved via ",C.label]}):e.jsx(S,{c:"text-sys-red",children:"ambiguous"})]})}),(()=>{const j=[{fn:"resolved.hash",value:u.hash??"null",group:"resolution",color:u.confident?"green":"zinc"},{fn:"resolved.type",value:u.type,group:"resolution",color:u.type!=="unknown"?u.confident?"green":"amber":"zinc"},{fn:"resolved.name",value:u.name??"null",group:"resolution",color:u.confident?"green":u.name?"amber":"zinc"},{fn:"resolved.confident",value:String(u.confident),group:"resolution",color:u.confident?"green":"red"}];return e.jsx(se,{tokens:j})})()]})})})}const Ut={id:"packet-parse",label:"Packet Parse",inputs:["rawPacket"],outputs:["parsedPacket","decoded","headerFields"],emits:[{fn:"routeType",group:"wire",color:"blue"},{fn:"payloadType",group:"wire",color:"blue"},{fn:"pathLength",group:"wire",color:"blue"},{fn:"version",group:"wire",color:"blue"}],async:!1,observatoryStage:0},qt={id:"enrichment",label:"Ingestion Enrichment",inputs:["parsedPacket"],outputs:["advertSender","channelHash","hopData","byteLength"],emits:[{fn:"_advertSender",group:"enrichment",color:"blue"},{fn:"_advertNodeType",group:"enrichment",color:"blue"},{fn:"_channelHash",group:"enrichment",color:"blue"},{fn:"_hopCount",group:"enrichment",color:"blue"},{fn:"_isZeroHop",group:"enrichment",color:"blue"},{fn:"_byteLength",group:"enrichment",color:"blue"}],async:!1,observatoryStage:1},Wt={id:"topology",label:"Topology Analysis",inputs:["packets","neighbors","srcHashResolver"],outputs:["edges","nodeMetrics","pathHealth","ghostNodes","centrality","loops"],emits:[{fn:"edges",group:"worker",color:"green"},{fn:"ghostNodes",group:"worker",color:"purple"},{fn:"loops",group:"analysis",color:"amber"},{fn:"nodeMetrics",group:"worker",color:"green"},{fn:"pathHealth",group:"worker",color:"green"},{fn:"centrality",group:"worker",color:"green"}],async:!0,worker:"topology.worker.ts",observatoryStage:2},Yt={id:"trace-enrichment",label:"Trace Link Quality",inputs:["packets","prefixLookup","srcHashResolver","edges","pathHealth","nodeMetrics"],outputs:["traceLinks","traceLinkSummary","traceDisambiguationFeedback"],emits:[{fn:"traceLinks.directed",group:"worker",color:"teal"},{fn:"traceLinks.bidir",group:"worker",color:"teal"},{fn:"traceSummary.meanSnr",group:"analysis",color:"green"},{fn:"traceSummary.medianSnr",group:"analysis",color:"zinc"},{fn:"traceSummary.confidence",group:"analysis",color:"zinc"},{fn:"feedback.confirmed",group:"worker",color:"teal"},{fn:"feedback.links",group:"worker",color:"teal"}],async:!1,observatoryStage:2},Zt={id:"disambiguation",label:"Source Disambiguation",inputs:["packets","neighbors","decodedMessages"],outputs:["srcHashResolverMap","neighborContext"],emits:[{fn:"resolvedHash",group:"resolution",color:"purple"},{fn:"resolvedName",group:"resolution",color:"purple"},{fn:"resolvedType",group:"resolution",color:"purple"},{fn:"confidence",group:"resolution",color:"green"}],async:!1,observatoryStage:3},Xt={id:"sparkline",label:"Sparkline Computation",inputs:["packets","neighbors"],outputs:["sparklineData"],emits:[{fn:"sparklines",group:"worker",color:"blue"}],async:!1},Qt={id:"decryption",label:"Channel Decryption",inputs:["packets","channelKeys"],outputs:["decodedMessages"],emits:[{fn:"decrypt.text",group:"crypto",color:"teal"},{fn:"decrypt.senderName",group:"crypto",color:"teal"},{fn:"decrypt.channelName",group:"crypto",color:"teal"},{fn:"decrypt.macCorrupted",group:"crypto",color:"amber"}],async:!0,worker:"decryption.worker.ts",observatoryStage:2},Jt={id:"decoded-content",label:"Decoded Content Policy",inputs:["decodedMessages","packets"],outputs:["decodedContent","contentInheritance"],emits:[{fn:"content.senderName",group:"crypto",color:"teal"},{fn:"content.text",group:"crypto",color:"teal"},{fn:"content.channelName",group:"crypto",color:"teal"},{fn:"content.corrupted",group:"crypto",color:"amber"},{fn:"content.inherited",group:"analysis",color:"purple"}],async:!1},Z=[Ut,qt,Wt,Yt,Zt,Xt,Qt,Jt],es=new Map(Z.map(t=>[t.id,t])),ts=new Map;for(const t of Z)for(const s of t.emits)ts.set(s.fn,t);const $e=new Map;for(const t of Z)for(const s of t.outputs)$e.set(s,t);function ss(){const t=new Map,s=new Map;for(const a of Z)t.has(a.id)||t.set(a.id,0),s.has(a.id)||s.set(a.id,new Set);for(const a of Z)for(const n of a.inputs){const l=$e.get(n);if(l&&l.id!==a.id){const o=s.get(l.id);o.has(a.id)||(o.add(a.id),t.set(a.id,(t.get(a.id)??0)+1))}}const r=[];for(const[a,n]of t)n===0&&r.push(a);const c=[];for(;r.length>0;){const a=r.shift(),n=es.get(a);n&&c.push(n);for(const l of s.get(a)??[]){const o=(t.get(l)??1)-1;t.set(l,o),o===0&&r.push(l)}}for(const a of Z)c.includes(a)||c.push(a);return c}const ns={0:"text-sys-green",1:"text-sys-blue",2:"text-sys-teal",3:"text-sys-purple"};function rs({stage:t,isActive:s,onClick:r}){const c=t.observatoryStage!=null?ns[t.observatoryStage]??"text-fg-muted":"text-fg-muted/40";return e.jsxs("button",{type:"button",onClick:r,className:` +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/usePipelineStore-DDHEHTlZ.js","assets/index-D33fcA3L.js","assets/node-types-BoqnL0Eg.js","assets/index-7uzBcJ1E.css"])))=>i.map(i=>d[i]); +import{co as O,r as T,eU as Fe,eV as Ee,eW as Oe,eX as ze,bW as Be,eY as Ie,eZ as Ge,e_ as Ke,e$ as Ve,bV as Ne,_ as ue,f0 as Ue,f1 as we,b$ as pe,j as e,f2 as G,f3 as K,f4 as V,eu as xe,f5 as qe,V as M,ca as We,cl as Ce,cv as Ye,f6 as Ze,f7 as Xe,f8 as Qe,f9 as Je,fa as et,fb as J,fc as tt,fd as st,fe as nt,ff as he,at as me,ao as Se,bQ as rt,t as at,fg as lt,Q as ot,a6 as ct,fh as it,P as dt,dL as ut}from"./index-D33fcA3L.js";import{usePipelineStore as Y}from"./usePipelineStore-DDHEHTlZ.js";import{e as Te,p as pt,A as I,S as U,a as se,c as E,K as i,H as A,B as xt,R as F,T as d,P as re,d as ht,f as S,C as _e,s as ee,h as mt}from"./primitives-C8YoaXqf.js";import{m as ke,i as gt}from"./node-types-BoqnL0Eg.js";import{a as ft}from"./payload-detail-DbnSd5NL.js";function bt(t){const s=t.type??t.payload_type,r=t.duplicates??[],c=t.is_duplicate,a=r.length;let n=null,l=null;if(a>0){const x=[t.rssi,...r.map(g=>g.rssi).filter(g=>g!=null)],m=[t.snr,...r.map(g=>g.snr).filter(g=>g!=null)];x.length>1&&(n=[Math.min(...x),Math.max(...x)]),m.length>1&&(l=[Math.min(...m),Math.max(...m)])}const o=s===O.TRACE;return{isDuplicate:c,dupeCount:a,rssiRange:n,snrRange:l,hashIncludesPathLen:o}}function yt(t,s,r){const c={traceTag:null,siblingCount:0,isLocallyOriginated:!1,method:"none",confidence:"none",inferredSrc:null,inferredName:null,evidence:[],thisPathLen:0,minPathLen:0,firstHopPrefix:null};let a=t._traceTag;if(!a&&t.payload&&(a=Te(t.payload)),!a)return{...c,evidence:["no traceTag — cannot correlate"]};const n=s.get(a)??[],l=N=>N.path_length!=null?N.path_length:Array.isArray(N.original_path)?N.original_path.length:0,o=l(t),x=n.length>0?Math.min(...n.map(l)):o,m=t.payload?t.payload.slice(18):"",g=m.length>=2?m.slice(0,2).toUpperCase():null,u=[];if(u.push(`traceTag: ${a}`),u.push(`siblings: ${n.length} observation${n.length!==1?"s":""}`),t.packet_origin==="tx_local")return u.push("packet_origin = tx_local → we initiated this trace"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!0,method:"tx_local",confidence:"certain",inferredSrc:"LOCAL",inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g};const v=n.find(N=>N.packet_origin==="tx_local");if(v)return u.push(`sibling (hash ${v.packet_hash}) has packet_origin = tx_local`),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!0,method:"tx_local",confidence:"certain",inferredSrc:"LOCAL",inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g};if(u.push(`this observation: path_len=${o}, min across siblings: ${x}`),g){if(u.push(`first hop in target path: ${g}`),o===0)return u.push("path_len = 0 → heard directly from initiator (no SNR appended yet)"),u.push("initiator is a direct RF neighbor"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"min_path_len",confidence:"speculative",inferredSrc:null,inferredName:null,evidence:[...u,"initiator is within direct RF range (zero forwarding hops)"],thisPathLen:o,minPathLen:x,firstHopPrefix:g};const f=Object.entries(r).filter(([k])=>k.replace(/^0x/i,"").slice(0,2).toUpperCase()===g);if(f.length===1){const[k,$]=f[0],h=$.name||$.node_name||null;return u.push(`first hop ${g} → unique neighbor: ${h??k}`),u.push("initiator is whoever sent TO this first hop"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"first_hop_neighbor",confidence:"likely",inferredSrc:g,inferredName:h,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g}}else f.length>1?u.push(`first hop ${g} matches ${f.length} neighbors (ambiguous)`):u.push(`first hop ${g} is not a known neighbor`)}return u.push("insufficient data to identify initiator"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"none",confidence:"none",inferredSrc:null,inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g}}let ne=null,ce=null;typeof window<"u"&&setTimeout(()=>{ue(()=>import("./usePipelineStore-DDHEHTlZ.js"),__vite__mapDeps([0,1,2,3])).then(t=>{ne=t}),ue(()=>import("./index-D33fcA3L.js").then(t=>t.ho),__vite__mapDeps([1,3])).then(t=>{ce=t})},0);const He={advertSender:null,advertNodeType:null,advertFlags:null,advertHasLocation:null,advertHasName:null,advertName:null,advertLatitude:null,advertLongitude:null,channelHash:null,byteLength:void 0,hopCount:0,isZeroHop:!0,preComputed:!1};function jt(t,s){const r=t.type??t.payload_type,c=Ne(r),a=Be(t.route),n=r===O.ADVERT,l=r===O.TRACE,o=r===O.PATH,x=r===O.GRP_TXT||r===O.GRP_DATA,m=Ie(t.snr,t.rssi),g=(m==null?void 0:m.finalGrade)??"critical",u=Ge(t.route),v=Ke(t.route),N=Ve(t.route),f=t.route==null?"unknown":u?"flood":v?"direct":"unknown",k=N?`transport-${f}`:f,$=!!s.advertSender;let h="none";$?h="pubkey":x?h="encrypted":t.src_hash&&(h="prefix");const y=gt(r),p=s.advertNodeType!=null?ke(s.advertNodeType):"unknown",_=y!=="unknown"?y:p,H=t.packet_origin??"rx",C=Math.floor(Date.now()/1e3)-t.timestamp,D=C<10?"live":C<300?"recent":C<3600?"warm":C<86400?"stale":"historic",L=t.path_length??(Array.isArray(t.original_path)?t.original_path.length:void 0),P=Array.isArray(t.original_path)&&t.original_path.length>0,R=L??0,b=s.byteLength??(t.raw_packet?Math.floor(t.raw_packet.length/2):0),w=bt(t);return{pType:r,payloadTypeName:c,routeTypeName:a,isAdvert:n,isTrace:l,isPath:o,isGrp:x,signalClass:g,routeClass:k,isFlood:u,isDirect:v,hasTransport:N,senderTier:h,hasPubkey:$,inferredType:y,advertType:p,effectiveType:_,origin:H,age:D,pathLen:L,pathAvail:P,pathHopCount:R,byteLen:b,dupeAnalysis:w}}function vt(t){var f,k,$,h,y,p;const s=ft(t);if(!s||s.pathHashes.length===0)return null;const{pathHashes:r,snrValues:c}=s;if(r.length<2||!ne||!ce)return null;const a=ne.usePipelineStore.getState().srcHashResolverMap,n=ne.usePipelineStore.getState().neighborContext,l=(n==null?void 0:n.hashToName)??new Map,o=ce.useStore.getState().stats,x=(o==null?void 0:o.neighbors)??{},m=o==null?void 0:o.local_hash,g=(k=(f=o==null?void 0:o.config)==null?void 0:f.repeater)==null?void 0:k.latitude,u=(h=($=o==null?void 0:o.config)==null?void 0:$.repeater)==null?void 0:h.longitude,v=Object.keys(x).length>0?Ue([],x,m,g,u):null,N=[];for(let _=0;_0?[r[_-1].toUpperCase()]:[]],P=ge(H,_,L,a,v),R=[H,..._+20?N:null}function ge(t,s,r,c,a){if(s===0){const l=c==null?void 0:c.get(t);if(l)return{hash:l,confidence:.8};if(a){const o=pe(a,t,{position:s,adjacentPrefixes:r});if(o.hash)return{hash:o.hash,confidence:o.confidence}}}else{if(a){const o=pe(a,t,{position:s,adjacentPrefixes:r});if(o.hash)return{hash:o.hash,confidence:o.confidence}}const l=c==null?void 0:c.get(t);if(l)return{hash:l,confidence:.6}}return{hash:null,confidence:0}}function Nt(t){var l;const s=t.raw_packet;if(!s||s.length<2)return null;const r=s.replace(/\s/g,""),c=Math.floor(r.length/2),a=((l=r.match(/.{1,2}/g))==null?void 0:l.join(" "))??"";let n="";for(let o=0;o=32&&x<=126?String.fromCharCode(x):"·"}return{hexBytes:a,utf8:n,byteCount:c}}function wt(t){const s=new Map;let r=0,c="";for(const a of t){if((a.type??a.payload_type)!==O.TRACE)continue;r++,c=a.packet_hash;const l=a._traceTag??(a.payload?Te(a.payload):null);if(!l)continue;let o=s.get(l);o||(o=[],s.set(l,o)),o.push(a)}return{index:s,fingerprint:`${r}:${c}`}}function Ct(t,s,r){const c=T.useRef({parse:0,decode:0,enrich:0,traceIndex:0,total:0}),a=T.useMemo(()=>t?Nt(t):null,[t]),n=T.useMemo(()=>{if(!s||s.length<4)return c.current.parse=0,c.current.decode=0,null;const h=performance.now(),y=pt(s),p=performance.now()-h;return y?(c.current.parse=p,c.current.decode=0,{protocolPacket:y.packet,display:{headerFields:y.headerFields,transportCodesHex:y.transportCodesHex,pathLengthHex:y.pathLengthHex,pathDataHex:y.pathDataHex,payloadHex:y.payloadHex,payloadByteOffset:y.payloadStartByte,pathByteOffset:y.pathByteOffset,pathLenByteOffset:y.pathLenByteOffset},decoded:y.decoded,error:null}):(c.current.parse=p,c.current.decode=0,{protocolPacket:null,display:null,decoded:null,error:"Packet.fromHex() returned failure"})},[s]),l=T.useMemo(()=>{if(!t)return c.current.enrich=0,He;const h=performance.now();if(t._advertSender!==void 0)return c.current.enrich=performance.now()-h,{advertSender:t._advertSender??null,advertNodeType:t._advertNodeType??null,advertFlags:t._advertFlags??null,advertHasLocation:t._advertHasLocation??null,advertHasName:t._advertHasName??null,advertName:t._advertName??null,advertLatitude:t._advertLatitude??null,advertLongitude:t._advertLongitude??null,channelHash:t._channelHash??null,byteLength:t._byteLength,hopCount:t._hopCount??0,isZeroHop:t._isZeroHop??!0,preComputed:!0};const y=t.type??t.payload_type,p=Fe(s,y),_=Ee(s,y),H=Oe(s,t),C=ze(t);return c.current.enrich=performance.now()-h,{...p,channelHash:_,byteLength:H,...C,preComputed:!1}},[t,s]),o=T.useRef({fingerprint:"",index:new Map}),x=T.useMemo(()=>{const h=performance.now(),{index:y,fingerprint:p}=wt(r);return c.current.traceIndex=performance.now()-h,p===o.current.fingerprint?o.current.index:(o.current={fingerprint:p,index:y},y)},[r]),m=T.useMemo(()=>{const h=c.current;return{parse:h.parse,decode:h.decode,enrich:h.enrich,traceIndex:h.traceIndex,total:h.parse+h.decode+h.enrich+h.traceIndex}},[n,l,x]);if(!t)return null;const g=s?n?n.error:"rawHex too short":"No raw_packet (warm-tier)",u=(n==null?void 0:n.protocolPacket)??null,v=u?u.payloadVersion:null,N=v===0,f=v===1,k=jt(t,l);let $=null;return k.isTrace&&($=vt(t)),{wire:a,display:(n==null?void 0:n.display)??null,parseError:g,protocolPacket:u,decoded:(n==null?void 0:n.decoded)??null,payloadVersion:v,isV1:N,isV2:f,enrichment:l,traceTagIndex:x,analysis:k,traceHopDetail:$,timing:m}}function ae({options:t,nextFn:s}){var n;const r=t.find(l=>l.active),c=(r==null?void 0:r.color)??"green",a=((n=I[c])==null?void 0:n.stem)??"bg-edge-subtle";return e.jsxs("div",{className:"flex flex-col items-start py-1 gap-0 px-2",children:[e.jsx("div",{className:`w-px h-2 ml-4 ${a}`}),e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-md overflow-hidden w-full",children:[t.map((l,o)=>{const x=I[l.color??"green"]??I.green;return e.jsxs("div",{className:`flex items-center gap-1.5 px-2 py-px font-mono text-[10px] leading-relaxed transition-opacity ${l.active?x.row:"opacity-25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${l.active?x.dot:"border border-zinc-500/40"}`}),e.jsx("span",{className:`w-16 shrink-0 font-medium ${l.active?"text-fg-primary":"text-fg-muted"}`,children:l.label}),l.detail&&e.jsx("span",{className:l.active?"text-fg-primary/70":"text-fg-muted",children:l.detail})]},o)}),s&&e.jsx("div",{className:"flex items-center px-2 py-0.5 border-t border-edge-subtle",children:e.jsxs("span",{className:"text-[10px] text-fg-muted font-mono",children:["→ ",s]})})]}),e.jsx("div",{className:`w-px h-2 ml-4 ${a}`})]})}function St({tokens:t,nextFn:s}){var n;const r=t.find(l=>l.active),c=(r==null?void 0:r.color)??"green",a=((n=I[c])==null?void 0:n.stem)??"bg-edge-subtle";return e.jsxs("div",{className:"flex flex-col items-start py-1 gap-0 px-2",children:[e.jsx("div",{className:`w-px h-2 ml-4 ${a}`}),e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-md overflow-hidden w-full",children:[t.map((l,o)=>{const x=I[l.color??"green"]??I.green;return e.jsxs("div",{className:`flex items-center gap-1 px-2 py-px font-mono text-[10px] leading-relaxed transition-opacity ${l.active?x.row:"opacity-25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${l.active?x.dot:"border border-zinc-500/40"}`}),e.jsx("span",{className:"text-fg-muted shrink-0",children:l.fn}),e.jsxs("span",{className:l.active?"text-fg-primary":"text-fg-muted",children:["(",l.value??"",")"]})]},o)}),s&&e.jsx("div",{className:"flex items-center px-2 py-0.5 border-t border-edge-subtle",children:e.jsxs("span",{className:"text-[10px] text-fg-muted font-mono",children:["→ ",s]})})]}),e.jsx("div",{className:`w-px h-2 ml-4 ${a}`})]})}const Tt={0:"border-l-sys-green",1:"border-l-sys-blue",2:"border-l-sys-teal",3:"border-l-sys-purple"};function le({stage:t,name:s,fn:r,verdict:c,timeMs:a,skipped:n,skipReason:l,children:o}){const x=Tt[t]??"";return e.jsx(e.Fragment,{children:e.jsx(G,{defaultOpen:!n,children:e.jsxs("div",{className:`surface-base rounded-lg border border-edge-subtle overflow-hidden border-l-2 ${x}`,children:[e.jsxs(K,{className:"px-3 py-2 w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"font-mono text-xs font-bold text-sys-blue shrink-0",children:t}),e.jsx("span",{className:"font-mono text-xs font-medium text-fg-primary truncate",children:s}),r&&!c&&e.jsx("span",{className:"font-mono text-[11px] text-fg-muted truncate hidden sm:inline",children:r}),c&&e.jsx("span",{className:"font-mono text-[11px] text-fg-muted/70 truncate hidden sm:inline",children:c})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[n&&e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-zinc-500/20 text-fg-muted",children:"N/A"}),a!=null&&!n&&e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:a<1?`${(a*1e3).toFixed(0)}µs`:`${a.toFixed(2)}ms`})]})]}),e.jsx(V,{children:e.jsx("div",{className:"px-3 pb-3 font-mono text-xs",children:n?e.jsx("p",{className:"text-fg-muted italic",children:l??"Not applicable for this packet type"}):o})})]})})})}function _t(t,s){return s?"manual":t._stripped?"bulk-tier":qe.isConnected()?"ws-push":"rest-poll"}const kt={connected:"green",degraded:"amber",offline:"red"};function Ht({packet:t,isSynthetic:s}){const r=xe(g=>g.wsState),c=xe(g=>g.health),a=_t(t,s),l=!!t._stripped?"WARM":"HOT",o=[{label:"ws-push",detail:"wsConnected && onPacket()",active:a==="ws-push",color:"green"},{label:"rest-poll",detail:"!wsConnected, 3s interval",active:a==="rest-poll",color:"amber"},{label:"catchup",detail:"wsReconnected, delta > 50",active:a==="catchup",color:"amber"},{label:"bulk-tier",detail:"user extends time range → gzip",active:a==="bulk-tier",color:"blue"},{label:"manual",detail:"hex input — no transport",active:a==="manual",color:"zinc"}],x=[{fn:"transport",value:a,group:"transport",color:a==="ws-push"?"green":a==="bulk-tier"?"blue":"amber"},{fn:"tier",value:l,group:"transport",color:"blue"},{fn:"wsState",value:r,group:"transport",color:r==="connected"?"green":"amber"},{fn:"health",value:c,group:"transport",color:kt[c]}],m=s?"manual hex input":`${a} (${c})`;return e.jsx(le,{stage:0,name:"TRANSPORT",fn:"websocketService / useStore.startPolling",verdict:m,children:s?e.jsx("p",{className:"text-fg-muted italic",children:"Manual hex input — no transport context"}):e.jsx(U,{prefix:"transport",children:e.jsxs("div",{className:"space-y-0",children:[e.jsx(ae,{options:o,nextFn:"ingest()"}),e.jsx(se,{tokens:x})]})})})}function q({start:t,end:s}){const r=s!=null&&s!==t?`[${t}..${s}]`:`[${t}]`;return e.jsx("span",{className:"text-fg-muted text-[9px] font-mono mr-1 select-none",children:r})}const $t={advert:"decodeAdvert()",ack:"decodeAck()",path:"decodePath()",trace:"decodeTraceWithSnr()",txt_msg:"decodeTextMessage()",grp_txt:"decodeGroupText()",grp_data:"decodeGroupData()",multipart:"decodeMultipart()",control:"decodeControl()",req:"decodeRequest()",response:"decodeResponse()",anon_req:"decodeAnonReq()",generic:"decodeGeneric()"};function Dt({rawHex:t,display:s,protocolPacket:r,parseError:c,parseTimeMs:a,payloadVersion:n,isV1:l,isV2:o}){return e.jsx("dl",{className:"space-y-0.5",children:s&&r&&t?e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"A. Parse — Packet.fromHex()"}),a>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:a<1?`${(a*1e3).toFixed(0)}µs`:`${a.toFixed(2)}ms`})}),e.jsxs(i,{label:"header byte",children:[e.jsx(q,{start:0}),e.jsx(A,{value:t.slice(0,2)})," ",e.jsx(xt,{value:parseInt(t.slice(0,2),16)})]}),s.headerFields.map(x=>e.jsx(i,{label:` ${x.field}`,children:e.jsx(F,{raw:e.jsxs("span",{className:"text-[10px]",children:["bits[",x.bits,"] = ",x.binary]}),children:e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber",children:x.value})})},x.field)),e.jsx(i,{label:" version",children:n!=null?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(d,{fn:"payloadVer",value:`${n}`,color:"amber"}),e.jsx(M,{color:l?"green":o?"blue":"zinc",children:l?"v1":o?"v2":`v${n}`}),l&&e.jsx("span",{className:"text-fg-muted text-[10px]",children:"1-byte hashes, 2-byte MAC"}),o&&e.jsx("span",{className:"text-sys-blue text-[10px]",children:"2-byte hashes, 4-byte MAC (speculative)"})]}):e.jsx("span",{className:"text-fg-muted",children:"unknown"})}),e.jsx(E,{title:"Wire Framing"}),e.jsx(i,{label:"transportCodes",children:s.transportCodesHex?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(q,{start:1,end:4}),e.jsx(d,{fn:"transport",value:s.transportCodesHex,color:"amber"})]}):e.jsx("span",{className:"text-fg-muted",children:"N/A (non-transport route)"})}),e.jsx(i,{label:"pathLen",children:e.jsx(F,{raw:e.jsxs(e.Fragment,{children:[e.jsx(q,{start:s.pathLenByteOffset}),e.jsx(A,{value:s.pathLengthHex})]}),children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(q,{start:s.pathLenByteOffset}),e.jsx(d,{fn:"pathLen",value:`${r.pathLen} hop${r.pathLen!==1?"s":""}`,color:"amber"})]})})}),e.jsx(i,{label:"path",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.pathLen>0&&e.jsx(q,{start:s.pathByteOffset,end:s.pathByteOffset+r.pathLen-1}),e.jsx(re,{hops:r.pathHexArray,hexPrefix:s.pathDataHex||void 0})]})}),e.jsx(i,{label:"payloadLen",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(q,{start:s.payloadByteOffset,end:s.payloadByteOffset+s.payloadHex.length/2-1}),e.jsx(d,{fn:"payloadLen",value:`${s.payloadHex.length/2} bytes`,color:"amber"})]})}),e.jsx(i,{label:"payloadHex",children:e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber break-all",children:s.payloadHex})})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"A. Parse"}),e.jsxs(i,{label:"result",children:[e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber",children:"Skipped"}),e.jsx("span",{className:"ml-1 text-fg-muted",children:c??"No raw_packet (warm-tier)"})]})]})})}function Lt({decoded:t,packet:s}){if(!t)return e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"B. Decode"}),e.jsx("p",{className:"text-fg-muted italic text-[10px]",children:"No decoded payload"})]});const r=$t[t.type]??`decode${t.type}()`;return e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"B. Decode — decodePayload()"}),e.jsx(U,{prefix:"decodePayload",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsx(i,{label:"dispatched",children:r}),e.jsx(E,{}),e.jsx(Pt,{decoded:t,packet:s})]})})]})}function Pt({decoded:t,packet:s}){var r;switch(t.type){case"advert":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"publicKey",children:e.jsx(F,{raw:e.jsx("span",{className:"text-[10px] break-all",children:t.publicKey}),children:e.jsx(d,{fn:"publicKey",value:t.publicKey,color:"green"})})}),e.jsx(i,{label:"timestamp",children:e.jsx(d,{fn:"timestamp",value:String(t.timestamp),color:"green"})}),e.jsx(i,{label:"flags",children:e.jsx(F,{raw:e.jsx(A,{value:t.flags}),children:e.jsx(d,{fn:"flags",value:t.flagsDescription,color:"green"})})}),e.jsx(i,{label:"nodeType",children:e.jsx(d,{fn:"nodeType",value:t.nodeType,color:"green"})}),t.latitude!=null&&e.jsx(i,{label:"latitude",children:e.jsx(d,{fn:"lat",value:t.latitude.toFixed(6),color:"green"})}),t.longitude!=null&&e.jsx(i,{label:"longitude",children:e.jsx(d,{fn:"lon",value:t.longitude.toFixed(6),color:"green"})}),t.name&&e.jsx(i,{label:"name",children:e.jsx(d,{fn:"name",value:t.name,color:"green"})})]});case"ack":return e.jsx(i,{label:"crc",children:e.jsx(F,{raw:e.jsx("span",{className:"text-[10px]",children:t.crc}),children:e.jsx(d,{fn:"crc",value:t.crc,color:"green"})})});case"trace":{const c=s!=null&&s.src_hash?s.src_hash.replace(/^0x/i,"").slice(0,2).toUpperCase():null;return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"traceTag",children:e.jsx(d,{fn:"traceTag",value:t.traceTag,color:"green"})}),e.jsx(i,{label:"authCode",children:e.jsx(d,{fn:"authCode",value:String(t.authCode),color:"green"})}),e.jsx(i,{label:"flags",children:e.jsx(A,{value:t.flags})}),e.jsx(i,{label:"target path",children:t.pathHashes.length>0?e.jsx(re,{hops:t.pathHashes.map(a=>a.toUpperCase()),color:"green"}):e.jsx("span",{className:"text-fg-muted italic",children:"∅ empty"})}),e.jsx(i,{label:"complete",children:t.isComplete?e.jsxs("span",{className:"text-sys-green",children:["✓ all ",t.pathHashes.length," hops reported SNR"]}):e.jsxs("span",{className:"text-sys-amber",children:["✗ ",t.snrValues.length,"/",t.pathHashes.length," hops reported"]})}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1 text-[10px]",children:"Directional Edge SNR — per-hop link quality"}),t.snrValues.length===0?e.jsx("p",{className:"text-fg-muted italic text-[11px] ml-2",children:"No SNR values in path field"}):e.jsx("div",{className:"space-y-0.5 ml-2",children:t.snrValues.map((a,n)=>{var g,u,v,N,f;const l=((g=t.pathHashes[n])==null?void 0:g.toUpperCase())??"??",o=n===0?c??"SRC":((u=t.pathHashes[n-1])==null?void 0:u.toUpperCase())??"??",x=(f=(N=(v=Ye.getState().stats)==null?void 0:v.config)==null?void 0:N.radio)==null?void 0:f.spreading_factor,m=we(a,x);return e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted w-3 text-right",children:n}),e.jsx("span",{className:"text-fg-primary",children:o}),e.jsx("span",{className:"text-fg-muted",children:"→"}),e.jsx("span",{className:"text-fg-primary",children:l}),e.jsx("span",{className:"text-fg-muted",children:"@"}),e.jsxs("span",{className:"font-bold text-sys-green",children:[a>0?"+":"",a.toFixed(1)," dB"]}),e.jsx(M,{color:"green",children:m})]},n)})})]})]})}case"path":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"pathLength",children:e.jsx(d,{fn:"pathLength",value:String(t.pathLength),color:"green"})}),e.jsx(i,{label:"path",children:t.path&&t.path.length>0?e.jsx(re,{hops:t.path.map(c=>c.toUpperCase()),color:"green"}):e.jsx("span",{className:"text-fg-muted italic",children:"∅ empty"})}),t.extraType!=null&&e.jsx(i,{label:"extraType",children:e.jsx(d,{fn:"extraType",value:t.extraTypeName??String(t.extraType),color:"purple"})}),t.extraData&&e.jsxs(i,{label:"extraData",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.extraData}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.extraData.length/2,"B)"]})]})]});case"txt_msg":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsx(i,{label:"timestamp",children:e.jsx(d,{fn:"timestamp",value:String(t.timestamp),color:"green"})}),e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:t.text,color:"green"})}),e.jsx(i,{label:"encrypted",children:e.jsx(d,{fn:"encrypted",value:String(t.encrypted),color:"green"})})]});case"grp_txt":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channelHash",children:e.jsx(A,{value:t.channelHash})}),t.channelName&&e.jsx(i,{label:"channelName",children:e.jsx(d,{fn:"channel",value:t.channelName,color:"green"})}),e.jsx(i,{label:"decrypted",children:e.jsx(d,{fn:"decrypted",value:String(t.decrypted),color:"green"})}),t.text&&e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:t.text,color:"green"})}),t.senderName&&e.jsx(i,{label:"senderName",children:e.jsx(d,{fn:"sender",value:t.senderName,color:"green"})}),t.macCorrupted&&e.jsx(i,{label:"macCorrupted",children:e.jsx(d,{fn:"macCorrupted",value:"true",color:"green"})})]});case"grp_data":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channelHash",children:e.jsx(A,{value:t.channelHash})}),e.jsx(i,{label:"dataLength",children:t.dataLength}),e.jsx(i,{label:"decrypted",children:String(t.decrypted)})]});case"multipart":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"messageId",children:t.messageId}),e.jsxs(i,{label:"part",children:[t.partNumber+1," / ",t.totalParts]})]});case"control":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"controlType",children:e.jsx(F,{raw:e.jsx(A,{value:t.controlType}),children:e.jsx(d,{fn:"controlType",value:t.subtypeName,color:"green"})})}),e.jsx(i,{label:"subtype",children:e.jsx(d,{fn:"subtype",value:`0x${t.subtype.toString(16).padStart(2,"0")}`,color:"green"})}),t.nodeTypeName&&e.jsxs(i,{label:"nodeType",children:[e.jsx(d,{fn:"nodeType",value:t.nodeTypeName,color:"green"}),e.jsxs("span",{className:"text-fg-muted text-[10px] ml-1",children:["(flags & 0x0F = 0x",(r=t.nodeType)==null?void 0:r.toString(16).padStart(2,"0"),")"]})]}),t.snrDb!=null&&e.jsxs(i,{label:"snr",children:[e.jsxs("span",{className:"font-bold text-sys-green",children:[t.snrDb>0?"+":"",t.snrDb.toFixed(1)," dB"]}),e.jsx(M,{color:"green",children:t.snrDb>=5?"strong":t.snrDb>=0?"fair":"weak"})]}),t.tag&&e.jsx(i,{label:"tag",children:e.jsx(d,{fn:"tag",value:t.tag,color:"green"})}),t.publicKey&&e.jsxs(i,{label:"publicKey",children:[e.jsx("span",{className:"break-all text-[10px] font-mono text-sys-green",children:t.publicKey}),e.jsx(M,{color:t.publicKeyFull?"green":"amber",children:t.publicKeyFull?"32B full":`${t.publicKey.length/2}B prefix`})]}),t.typeFilter!=null&&e.jsx(i,{label:"typeFilter",children:e.jsx(F,{raw:e.jsx(A,{value:t.typeFilter}),children:e.jsx(d,{fn:"typeFilter",value:t.typeFilterDescription??"none",color:"green"})})}),t.prefixOnly!=null&&e.jsx(i,{label:"prefixOnly",children:e.jsx(d,{fn:"prefixOnly",value:String(t.prefixOnly),color:"green"})}),t.since!=null&&e.jsx(i,{label:"since",children:e.jsx(d,{fn:"since",value:t.since===0?"all (0)":String(t.since),color:"green"})}),!t.nodeTypeName&&t.typeFilter==null&&t.dataLength>0&&e.jsxs(i,{label:"data",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.dataHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.dataLength,"B)"]})]})]});case"req":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"response":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"anon_req":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"senderPubKey",children:e.jsx("span",{className:"break-all text-[10px] font-mono text-sys-green",children:t.senderPublicKey})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"generic":return e.jsxs(e.Fragment,{children:[e.jsxs(i,{label:"payloadType",children:[e.jsx(ht,{value:t.payloadType})," (",t.payloadTypeName,")"]}),e.jsx(i,{label:"length",children:t.length}),e.jsx(i,{label:"rawHex",children:e.jsx("span",{className:"break-all",children:t.rawHex})})]});default:return e.jsx("p",{className:"text-fg-muted",children:"Unknown decoded type"})}}function Mt({protocolPacket:t,packetHash:s}){const r=t==null?void 0:t.payloadType,c=r===Ze||r===Xe,a=T.useMemo(()=>{if(!c||!t)return null;const p=t.payload;return p.length<4?null:{channelHash:p[0],mac:p.slice(1,3),ciphertext:p.slice(3)}},[t,c]),[n,l]=T.useState("pending"),[o,x]=T.useState([]),[m,g]=T.useState(0);T.useEffect(()=>{if(!a){l(null);return}let p=!1;return(async()=>{const H=performance.now(),C=await Qe(a.channelHash,a.mac,a.ciphertext);p||(l(C),g(performance.now()-H));const D=await Je(a.channelHash);p||x(D)})(),()=>{p=!0}},[a]);const[u,v]=T.useState(""),[N,f]=T.useState(null),[k,$]=T.useState(!1),h=T.useCallback(async()=>{if(!(!a||!u.trim())){$(!0);try{const p=await We(u.trim(),a.channelHash,a.mac,a.ciphertext);if(p.success){const _=new TextDecoder("utf-8",{fatal:!1}).decode(p.result.plaintext.slice(5));f({success:!0,text:_})}else f({success:!1,error:p.error})}catch(p){f({success:!1,error:String(p)})}finally{$(!1)}}},[a,u]),y=Ce(s);return!c||!a?null:e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"C. Decrypt — tryDecryptGroupMessage()"}),m>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:m<1?`${(m*1e3).toFixed(0)}µs`:`${m.toFixed(2)}ms`})}),e.jsx(U,{prefix:"tryDecryptGroupMessage",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsx(i,{label:"channelHash",children:e.jsx(d,{fn:"channelHash",value:`0x${a.channelHash.toString(16).toUpperCase().padStart(2,"0")}`,color:"teal"})}),e.jsx(i,{label:"mac",children:e.jsx(d,{fn:"mac",value:Array.from(a.mac).map(p=>p.toString(16).padStart(2,"0")).join(""),color:"teal"})}),e.jsx(i,{label:"cipherLen",children:e.jsx(d,{fn:"cipherLen",value:`${a.ciphertext.length}B`,color:"teal"})}),e.jsx(i,{label:"candidates",children:e.jsx(d,{fn:"candidates",value:o.length>0?`${o.length} names`:"0",color:o.length>0?"teal":"zinc"})}),o.length>0&&e.jsxs("details",{className:"mt-1",children:[e.jsx("summary",{className:"text-fg-muted cursor-pointer hover:text-fg-primary text-[10px]",children:"show candidate names"}),e.jsx("div",{className:"mt-1 text-[10px] text-fg-muted break-all max-h-24 overflow-y-auto",children:o.join(", ")})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"Result:"}),n==="pending"?e.jsx("p",{className:"text-fg-muted italic",children:"decrypting…"}):n?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channel",children:e.jsx(d,{fn:"channel",value:n.channelName,color:"teal"})}),e.jsx(i,{label:"plaintext",children:e.jsx(d,{fn:"plaintext",value:new TextDecoder("utf-8",{fatal:!1}).decode(n.plaintext.slice(5)).trim()||"(empty)",color:"teal"})}),e.jsx(i,{label:"macValid",children:e.jsx(d,{fn:"macValid",value:n.macCorrupted?"false":"true",color:"teal"})})]}):e.jsxs(i,{label:"decrypt",children:[e.jsx(d,{fn:"decrypt",value:"failed",color:"red"}),e.jsx("span",{className:"text-fg-muted ml-1",children:"channel not in known list"})]})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"testChannelName() — manual test:"}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("input",{type:"text",value:u,onChange:p=>{v(p.target.value),f(null)},onKeyDown:p=>p.key==="Enter"&&h(),placeholder:"channel name",className:"surface-input px-2 py-1 rounded text-[11px] font-mono text-fg-primary w-40"}),e.jsx("button",{onClick:h,disabled:k||!u.trim(),className:"px-2 py-1 rounded text-[10px] font-mono bg-sys-blue/20 text-sys-blue hover:bg-sys-blue/30 disabled:opacity-40 transition-colors",children:k?"…":"Try"})]}),N&&e.jsx("div",{className:"mt-1",children:N.success?e.jsx(i,{label:"result",children:e.jsx(d,{fn:"plaintext",value:N.text??"(empty)",color:"teal"})}):e.jsx(i,{label:"error",children:e.jsx(d,{fn:"error",value:N.error??"unknown",color:"red"})})})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"useDecodedMessage() store result:"}),y?y.decoded?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channel",children:e.jsx(d,{fn:"channel",value:y.decoded.channelName??"?",color:"teal"})}),e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:y.decoded.text,color:"teal"})})]}):e.jsx(i,{label:"decrypt",children:e.jsx(d,{fn:"decrypt",value:"failed",color:"red"})}):e.jsx(i,{label:"decrypt",children:e.jsx(d,{fn:"decrypt",value:"pending",color:"zinc"})})]})]})})]})}function Rt(t){const{rawHex:s,display:r,protocolPacket:c,decoded:a,parseError:n,parseTimeMs:l,payloadVersion:o,isV1:x,isV2:m,packetHash:g,packet:u}=t,v=!!s&&s.length>=4;return e.jsxs(G,{children:[e.jsx(K,{className:"w-full mt-2 mb-1",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-[10px] font-mono text-fg-muted",children:"🔬"}),e.jsx("span",{className:"text-[10px] font-mono font-medium text-fg-muted",children:"Wire Inspection"}),e.jsx("span",{className:"text-[9px] text-fg-muted/50",children:"observatory diagnostic — not a runtime stage"})]})}),e.jsx(V,{children:e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-lg p-3 space-y-1 bg-surface/30",children:[e.jsx("p",{className:"text-[9px] text-fg-muted/50 mb-2",children:"The backend parsed these fields server-side. This panel verifies the wire-level encoding client-side."}),v?e.jsxs(e.Fragment,{children:[e.jsx(Dt,{rawHex:s,display:r,protocolPacket:c,parseError:n,parseTimeMs:l,payloadVersion:o,isV1:x,isV2:m}),e.jsx(Lt,{decoded:a,packet:u}),e.jsx(Mt,{protocolPacket:c,packetHash:g})]}):e.jsx("p",{className:"text-fg-muted italic text-[10px]",children:n??"No raw_packet — wire inspection unavailable (warm-tier packet)"})]})})]})}function fe(t){if(!t)return[{fn:"decode",value:"no raw_packet",group:"decode",color:"zinc"}];switch(t.type){case"advert":{const s=t,r=[{fn:"decode.nodeType",value:s.nodeType,group:"decode",color:"blue"}];return s.name&&r.push({fn:"decode.name",value:s.name,group:"decode",color:"blue"}),s.latitude!=null&&s.longitude!=null&&r.push({fn:"decode.location",value:`${s.latitude.toFixed(4)}, ${s.longitude.toFixed(4)}`,group:"decode",color:"blue"}),r.push({fn:"decode.publicKey",value:s.publicKey,group:"decode",color:"blue"}),r}case"trace":{const s=t;return[{fn:"decode.traceTag",value:s.traceTag,group:"decode",color:"blue"},{fn:"decode.hops",value:s.pathHashes.length>0?s.pathString:"empty",group:"decode",color:"blue"},{fn:"decode.snr",value:s.snrValues.length>0?`${s.snrValues.length} values`:"none",group:"decode",color:s.snrValues.length>0?"blue":"zinc"},{fn:"decode.complete",value:s.isComplete?"yes":"partial",group:"decode",color:s.isComplete?"green":"amber"}]}case"path":{const s=t,r=[{fn:"decode.pathLength",value:String(s.pathLength),group:"decode",color:"blue"},{fn:"decode.path",value:s.path.length>0?s.pathString:"empty",group:"decode",color:"blue"}];return s.extraType!=null&&r.push({fn:"decode.extraType",value:s.extraTypeName??String(s.extraType),group:"decode",color:"purple"}),s.extraData&&r.push({fn:"decode.extraData",value:`${s.extraData.length/2}B`,group:"decode",color:"purple"}),r}case"ack":return[{fn:"decode.crc",value:t.crc,group:"decode",color:"blue"}];case"grp_txt":return[{fn:"decode.channelHash",value:t.channelHash,group:"decode",color:"blue"},{fn:"decode.encrypted",value:"true — decrypt at cascade",group:"decode",color:"zinc"}];case"grp_data":{const s=t;return[{fn:"decode.channelHash",value:s.channelHash,group:"decode",color:"blue"},{fn:"decode.dataLength",value:`${s.dataLength}B`,group:"decode",color:"blue"}]}case"txt_msg":{const s=t;return[{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.encrypted",value:s.encrypted?"true":"false",group:"decode",color:s.encrypted?"zinc":"green"},...s.encrypted?[]:[{fn:"decode.text",value:s.text,group:"decode",color:"blue"}]]}case"multipart":{const s=t;return[{fn:"decode.part",value:`${s.partNumber+1}/${s.totalParts}`,group:"decode",color:"blue"},{fn:"decode.msgId",value:s.messageId,group:"decode",color:"blue"}]}case"control":{const s=t,r=[{fn:"decode.subtype",value:s.subtypeName,group:"decode",color:"blue"}];return s.nodeTypeName&&r.push({fn:"decode.nodeType",value:s.nodeTypeName,group:"decode",color:"blue"}),s.snrDb!=null&&r.push({fn:"decode.snr",value:`${s.snrDb>0?"+":""}${s.snrDb.toFixed(1)} dB`,group:"decode",color:"blue"}),s.tag&&r.push({fn:"decode.tag",value:s.tag,group:"decode",color:"blue"}),s.publicKey&&r.push({fn:"decode.publicKey",value:s.publicKey,group:"decode",color:s.publicKeyFull?"green":"blue"}),s.typeFilter!=null&&r.push({fn:"decode.typeFilter",value:s.typeFilterDescription??`0x${s.typeFilter.toString(16)}`,group:"decode",color:"blue"}),s.prefixOnly!=null&&r.push({fn:"decode.prefixOnly",value:String(s.prefixOnly),group:"decode",color:"blue"}),!s.nodeTypeName&&!s.tag&&(r.push({fn:"decode.subtypeFlags",value:`0x${s.subtypeFlags.toString(16)}`,group:"decode",color:"blue"}),r.push({fn:"decode.dataLength",value:`${s.dataLength}B`,group:"decode",color:"blue"})),r}case"req":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"response":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"anon_req":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.senderPubKey",value:s.senderPublicKey,group:"decode",color:"green"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"generic":return[{fn:"decode.raw",value:`${t.length}B`,group:"decode",color:"zinc"}];default:return[]}}function At({packet:t,pipeline:s,rawHex:r,traceTagIndex:c,neighbors:a}){const{enrichment:n,timing:l,display:o,protocolPacket:x,decoded:m,parseError:g,payloadVersion:u,isV1:v,isV2:N,analysis:f}=s,$=(t.type??t.payload_type)===et,h=f.dupeAnalysis,y=T.useRef(0),p=T.useMemo(()=>{if(!$)return null;const D=performance.now(),L=yt(t,c,a);return y.current=performance.now()-D,L},[t,c,a,$]),_=l.enrich+y.current,H=[];f.byteLen&&H.push(`${f.byteLen}B`),H.push(f.payloadTypeName),n.advertName&&H.push(`"${n.advertName}"`),n.isZeroHop?H.push("zero-hop"):f.pathHopCount>0&&H.push(`${f.pathHopCount}h`),H.push(`${t.rssi}dBm`),h.isDuplicate&&H.push("DUPE");const C=H.join(" — ");return e.jsxs(le,{stage:1,name:"INGEST",fn:n.preComputed?"PacketCache.mergePackets()":"extractAdvertData() + extractHopData() + ...",verdict:C,timeMs:_,children:[e.jsx(Rt,{rawHex:r,display:o,protocolPacket:x,decoded:m,parseError:g,parseTimeMs:l.parse,payloadVersion:u,isV1:v,isV2:N,packetHash:t.packet_hash,packet:t}),e.jsx(E,{title:"Cache Enrichment"}),e.jsx(U,{prefix:"packetCache",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsxs("div",{className:"mb-1.5",children:[n.preComputed?e.jsx(M,{color:"green",children:"PacketCache"}):e.jsx(M,{color:"amber",children:"computed"}),e.jsx("span",{className:"text-[10px] text-fg-muted ml-1.5",children:n.preComputed?"pre-enriched by real pipeline":"synthetic — computed on the fly"})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1 mb-1",children:[e.jsx(d,{fn:"_byteLength",value:n.byteLength!=null?`${n.byteLength}B`:void 0,color:"blue"}),e.jsx(d,{fn:"_hopCount",value:String(n.hopCount),color:"blue"}),e.jsx(d,{fn:"_isZeroHop",value:String(n.isZeroHop),color:n.isZeroHop?"green":"blue"}),n.isZeroHop&&e.jsx(M,{color:"blue",children:"direct"}),n.channelHash!=null&&e.jsx(d,{fn:"_channelHash",value:n.channelHash,color:"blue"}),$&&t._traceTag&&e.jsx(d,{fn:"_traceTag",value:t._traceTag,color:"blue"})]}),n.advertSender||n.advertNodeType!=null||n.advertName!=null?e.jsxs("div",{className:"mt-1 mb-1",children:[e.jsx("p",{className:"text-[10px] text-sys-blue font-medium mb-0.5",children:"ADVERT Enrichment"}),e.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[n.advertSender&&e.jsx(d,{fn:"_advertSender",value:n.advertSender.slice(0,16)+"…",color:"blue"}),n.advertNodeType!=null&&e.jsx(d,{fn:"_advertNodeType",value:ke(n.advertNodeType),color:"blue"}),n.advertName!=null&&e.jsx(d,{fn:"_advertName",value:n.advertName,color:"blue"}),n.advertFlags!=null&&e.jsx(d,{fn:"_advertFlags",value:`0x${n.advertFlags.toString(16).padStart(2,"0")}`,color:"blue"}),n.advertHasLocation!=null&&e.jsx(d,{fn:"_advertHasLocation",value:String(n.advertHasLocation),color:"blue"}),n.advertHasName!=null&&e.jsx(d,{fn:"_advertHasName",value:String(n.advertHasName),color:"blue"}),n.advertLatitude!=null&&n.advertLongitude!=null&&e.jsx(d,{fn:"location",value:`${n.advertLatitude.toFixed(4)}, ${n.advertLongitude.toFixed(4)}`,color:"blue"})]})]}):e.jsx("p",{className:"text-[10px] text-fg-muted/30 mb-1",children:"ADVERT fields: N/A (non-ADVERT packet)"}),e.jsx(E,{title:"Payload Decode"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${m?"bg-sys-blue":"bg-zinc-500/40"}`}),e.jsx("span",{className:"font-mono text-[10px] font-medium text-fg-primary",children:"decodePayload()"}),e.jsx("span",{className:"text-[9px] text-fg-muted",children:"sync — wire data only, no crypto"})]}),e.jsx("div",{className:"ml-3",children:m?e.jsx("div",{className:"flex flex-wrap gap-x-1.5 gap-y-1",children:fe(m).map((D,L)=>e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5",children:e.jsx(d,{fn:D.fn,value:D.value,color:D.color})},L))}):e.jsx(S,{children:"no raw_packet — warm-tier packet, decode unavailable"})})]}),e.jsx(E,{}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted",children:"dupe:"}),h.isDuplicate?e.jsx(d,{fn:"is_duplicate",value:"true",color:"purple"}):e.jsx(S,{children:"none"}),h.dupeCount>0&&e.jsx(d,{fn:"dupeCount",value:`×${h.dupeCount}`,color:"purple"}),h.rssiRange&&e.jsxs(S,{c:"text-fg-primary",children:["Δ",Math.abs(h.rssiRange[1]-h.rssiRange[0]),"dB RSSI"]})]}),p&&e.jsxs(e.Fragment,{children:[e.jsx(E,{}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted",children:"TRACE SRC:"}),p.inferredSrc?e.jsxs(e.Fragment,{children:[e.jsx(d,{fn:"inferredSrc",value:p.inferredSrc,color:"purple"}),p.inferredName&&e.jsx(d,{fn:"name",value:p.inferredName,color:"purple"})]}):e.jsx(S,{children:"unresolvable"}),e.jsx(_e,{color:"purple",children:p.method}),e.jsxs(S,{children:["(",p.confidence,")"]}),e.jsxs(S,{children:["siblings=",p.siblingCount]})]})]}),(()=>{const D=f.pType!=null?`0x${f.pType.toString(16).toUpperCase().padStart(2,"0")}`:void 0,L=t.route!=null?`0x${t.route.toString(16).toUpperCase().padStart(2,"0")}`:void 0,P=fe(m),R=f.signalClass==="excellent"||f.signalClass==="good"?"green":f.signalClass==="fair"?"amber":"red",b=f.senderTier==="pubkey"?"green":f.senderTier==="prefix"?"amber":f.senderTier==="encrypted"?"teal":"zinc",w=[{fn:"type",value:f.payloadTypeName,raw:D,group:"wire",color:"blue"},{fn:"route",value:f.routeTypeName,raw:L,group:"wire",color:"blue"},{fn:"src_hash",value:t.src_hash||void 0,group:"wire",color:"blue"},{fn:"rssi",value:`${t.rssi}dBm`,group:"wire",color:"blue"},{fn:"snr",value:`${t.snr}dB`,group:"wire",color:"blue"},{fn:"_byteLength",value:f.byteLen?`${f.byteLen}B`:void 0,group:"enrichment",color:"blue"},{fn:"_hopCount",value:String(n.hopCount),group:"enrichment",color:"blue"},{fn:"_isZeroHop",value:String(n.isZeroHop),group:"enrichment",color:"blue"},{fn:"_advertSender",value:n.advertSender||void 0,group:"enrichment",color:"blue"},{fn:"_advertNodeType",value:f.advertType!=="unknown"?f.advertType:void 0,group:"enrichment",color:"blue"},{fn:"_advertName",value:n.advertName||void 0,group:"enrichment",color:"blue"},{fn:"_channelHash",value:n.channelHash||void 0,group:"enrichment",color:"blue"},...P,{fn:"is_duplicate",value:String(h.isDuplicate),group:"analysis",color:"purple"},p!=null&&p.inferredSrc?{fn:"traceSrc",value:p.inferredSrc,group:"analysis",color:"purple"}:{fn:"traceSrc"},{fn:"_signalClass",value:f.signalClass,group:"analysis",color:R},{fn:"_routeClass",value:f.routeClass,group:"analysis",color:"purple"},{fn:"_senderTier",value:f.senderTier,group:"analysis",color:b},{fn:"_origin",value:f.origin,group:"analysis",color:f.origin==="tx_local"?"green":f.origin==="tx_forward"?"amber":"purple"},{fn:"_pathAvail",value:f.pathAvail?`${f.pathHopCount} hops`:"none",group:"analysis",color:f.pathAvail?"green":"zinc"},{fn:"_age",value:f.age,group:"analysis",color:f.age==="live"||f.age==="recent"?"green":"zinc"},...h.dupeCount>0?[{fn:"_dupeCount",value:`×${h.dupeCount}`,group:"analysis",color:"purple"},...h.rssiRange?[{fn:"_multipath",value:`Δ${Math.abs(h.rssiRange[1]-h.rssiRange[0])}dB`,group:"analysis",color:Math.abs(h.rssiRange[1]-h.rssiRange[0])>6?"amber":"green"}]:[]]:[],...t.lbt_attempts!=null?[{fn:"_lbt",value:`${t.lbt_attempts} attempt${t.lbt_attempts!==1?"s":""}`,group:"analysis",color:(t.lbt_attempts??0)>1?"amber":"green"}]:[],...t.drop_reason?[{fn:"_dropReason",value:t.drop_reason,group:"analysis",color:"red"}]:[]];return e.jsx(se,{tokens:w})})()]})})]})}function be(t){switch(t){case"excellent":return"green";case"good":return"green";case"fair":return"amber";case"poor":return"red";case"critical":return"red";default:return"zinc"}}function ye(t){return`${Math.round(t*100)}%`}function je(t,s,r){return t||(s?s.slice(0,12):`~${r}`)}function Ft({hops:t}){return t.length===0?null:e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/40",children:[e.jsx("p",{className:"text-[9px] text-fg-muted/40 uppercase tracking-widest font-mono mb-1.5",children:"per-hop trace inspection"}),e.jsx("div",{className:"space-y-1",children:t.map(s=>e.jsx(U,{prefix:`trace.hop[${s.hopIndex}]`,children:e.jsxs("div",{className:"border border-edge-subtle/40 rounded px-2 py-1.5",children:[e.jsxs(i,{label:"link",children:[e.jsx(re,{hops:[s.fromPrefix,s.toPrefix],color:"blue"}),e.jsx("span",{className:"ml-1.5",children:e.jsx(_e,{color:be(s.quality),children:s.quality})})]}),e.jsx(i,{label:"snr",children:e.jsx(F,{raw:e.jsx("span",{className:"text-sys-blue",children:s.snrRaw}),children:e.jsx(d,{fn:"snr",value:`${s.snrRaw.toFixed(1)} dB`,color:be(s.quality)})})}),e.jsxs(i,{label:"from",children:[e.jsx(d,{fn:"resolve",value:je(s.fromName,s.fromHash,s.fromPrefix),color:s.fromHash?s.fromConfidence>=.8?"green":"amber":"purple"}),e.jsx("span",{className:"ml-1",children:e.jsx(d,{fn:"conf",value:ye(s.fromConfidence),color:"zinc"})})]}),e.jsxs(i,{label:"to",children:[e.jsx(d,{fn:"resolve",value:je(s.toName,s.toHash,s.toPrefix),color:s.toHash?s.toConfidence>=.8?"green":"amber":"purple"}),e.jsx("span",{className:"ml-1",children:e.jsx(d,{fn:"conf",value:ye(s.toConfidence),color:"zinc"})})]})]})},s.hopIndex))}),e.jsx(se,{label:"trace contributes",tokens:Et(t)})]})}function Et(t){const s=t.reduce((n,l)=>n+(l.fromHash?1:0)+(l.toHash?1:0),0),r=t.length*2,c=r-s,a=t.length>0?t.reduce((n,l)=>n+l.snrRaw,0)/t.length:0;return[{fn:"hops",value:String(t.length),group:"wire",color:"blue"},{fn:"resolved",value:`${s}/${r}`,group:"worker",color:"green"},...c>0?[{fn:"ghosts",value:String(c),group:"worker",color:"purple"}]:[],{fn:"avgSnr",value:`${a.toFixed(1)} dB`,group:"analysis",color:a>=5?"green":a>=0?"amber":"red"}]}function Ot(t){if(!t)return"never";const s=Math.floor((Date.now()-t)/1e3);return s<60?`${s}s ago`:s<3600?`${Math.floor(s/60)}m ago`:`${Math.floor(s/3600)}h ago`}function zt(t){if(!t)return[];const s=t.decoded;if(!s)return[{fn:"decrypt.result",value:"failed",group:"crypto",color:"red"}];if(!s.decrypted)return[{fn:"decrypt.result",value:"no key match",group:"crypto",color:"zinc"}];const r=[];return s.channelName&&r.push({fn:"decrypt.channelName",value:s.channelName,group:"crypto",color:"teal"}),s.senderName&&r.push({fn:"decrypt.senderName",value:s.senderName,group:"crypto",color:"teal"}),s.text&&r.push({fn:"decrypt.text",value:s.text,group:"crypto",color:"teal"}),s.timestamp&&r.push({fn:"decrypt.timestamp",value:new Date(s.timestamp*1e3).toISOString().slice(11,19),group:"crypto",color:"teal"}),s.macCorrupted&&r.push({fn:"decrypt.macCorrupted",value:"true",group:"crypto",color:"amber"}),r}function Bt({packet:t,decrypted:s,pipeline:r}){var b;const c=J(w=>w.isComputing),a=J(w=>w.lastUpdated),n=J(w=>w.lastComputeTimeMs),l=J(w=>w.topology.edges.length),o=J(w=>w.topology.discoveredNodes.length),x=tt(),m=st(),g=nt(),u=he(w=>w.isComputing),v=he(w=>w.nodeCount),N=me(w=>w.progress),f=me(w=>w.initialDecodeComplete),k=t.type??t.payload_type,$=k===O.GRP_TXT||k===O.GRP_DATA,h=k===O.TRACE,y=k===O.PATH,p=$,_=[{label:"full",detail:"all GRP_TXT → decryption worker",active:p&&f,color:"teal"},{label:"quick",detail:"100 most recent (initial load)",active:p&&!f,color:"amber"},{label:"skip",detail:"non-GRP or catchup path",active:!p,color:"zinc"}],H=zt(s),C=((b=s==null?void 0:s.decoded)==null?void 0:b.decrypted)===!0,D=c?"running":`${l}e ${o}g`,L=u?"running":`${v}n`,P=p?C?"decrypted":N.isDecoding?`${N.percent}%`:"pending":"N/A",R=`topo ${c?"○":"✓"} ${D} · spark ${u?"○":"✓"} ${L} · decrypt ${P}`;return e.jsx(le,{stage:2,name:"CASCADE",fn:"hydrateDownstream()",verdict:R,children:e.jsx(U,{prefix:"cascade",children:e.jsxs("div",{className:"space-y-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 py-1.5 text-[11px] font-mono",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c?"bg-sys-amber animate-pulse":"bg-sys-green"}`}),e.jsx("span",{className:"text-fg-primary",children:"topology"}),e.jsxs("span",{className:"text-fg-muted",children:[l,"e ",o,"g"]}),(h||y)&&e.jsx("span",{className:"text-sys-green text-[9px]",children:"↑signal"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${u?"bg-sys-amber animate-pulse":"bg-sys-green"}`}),e.jsx("span",{className:"text-fg-primary",children:"sparkline"}),e.jsxs("span",{className:"text-fg-muted",children:[v,"n"]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N.isDecoding?"bg-sys-amber animate-pulse":p?"bg-sys-teal":"bg-zinc-500/40"}`}),e.jsx("span",{className:"text-fg-primary",children:"decrypt"}),e.jsx("span",{className:p?"text-sys-teal":"text-fg-muted",children:p?C?"decrypted":N.isDecoding?`${N.percent}%`:"pending":"N/A"})]})]}),e.jsxs(G,{defaultOpen:h||y,children:[e.jsx(K,{className:"text-[10px] w-full border-t border-edge-subtle pt-1.5",children:e.jsx("span",{className:"font-mono text-fg-muted/50",children:"topology detail…"})}),e.jsx(V,{children:e.jsxs("div",{className:"ml-3 pb-2",children:[e.jsx(i,{label:"status",children:e.jsx(d,{fn:"isComputing",value:c?"running":"idle",color:c?"amber":"green"})}),e.jsxs(i,{label:"last",children:[e.jsx(d,{fn:"lastUpdated",value:Ot(a),color:"zinc"}),n>0&&e.jsxs("span",{className:"ml-2 text-fg-muted text-[10px]",children:["(",n<1e3?`${n.toFixed(0)}ms`:`${(n/1e3).toFixed(1)}s`,")"]})]}),e.jsxs(i,{label:"output",children:[e.jsx(d,{fn:"edges",value:String(l),color:"green"}),e.jsx(d,{fn:"ghostNodes",value:String(o),color:"purple"})]}),m&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{label:"trace links",children:[e.jsx(d,{fn:"directed",value:String(x.totalDirectedLinks),color:"teal"}),e.jsx(d,{fn:"bidir",value:String(x.bidirectionalLinks),color:"teal"}),e.jsx(d,{fn:"traces",value:String(x.totalTraces),color:"zinc"})]}),e.jsxs(i,{label:"trace SNR",children:[e.jsx(d,{fn:"mean",value:`${x.meanSnr.toFixed(1)} dB`,color:x.meanSnr>=5?"green":x.meanSnr>=0?"amber":"red"}),e.jsx(d,{fn:"median",value:`${x.medianSnr.toFixed(1)} dB`,color:"zinc"}),e.jsx(d,{fn:"confidence",value:`${Math.round(x.avgConfidence*100)}%`,color:"zinc"})]}),h&&e.jsxs(i,{label:"quality",children:[e.jsx(d,{fn:"excellent",value:String(x.qualityCounts.excellent),color:"green"}),e.jsx(d,{fn:"good",value:String(x.qualityCounts.good),color:"green"}),e.jsx(d,{fn:"fair",value:String(x.qualityCounts.fair),color:"amber"}),e.jsx(d,{fn:"poor",value:String(x.qualityCounts.poor),color:"red"}),e.jsx(d,{fn:"critical",value:String(x.qualityCounts.critical),color:"red"})]}),g.confirmedResolutions.size>0&&e.jsxs(i,{label:"feedback",children:[e.jsx(d,{fn:"feedback.confirmed",value:String(g.confirmedResolutions.size),color:"teal"}),e.jsx(d,{fn:"feedback.links",value:String(g.confirmedLinks.length),color:"teal"})]})]}),h&&(r==null?void 0:r.traceHopDetail)&&e.jsx(Ft,{hops:r.traceHopDetail})]})})]}),p&&e.jsx("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:e.jsxs("div",{className:"ml-3",children:[e.jsx(i,{label:"mode",children:e.jsx(ae,{options:_,nextFn:"queueDecryption()"})}),e.jsx(i,{label:"result",children:e.jsx(d,{fn:"decrypt",value:C?"decrypted":s?"failed":"pending",color:C?"teal":s?"red":"zinc"})}),C&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-x-1.5 gap-y-1",children:H.map((w,oe)=>e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5",children:e.jsx(d,{fn:w.fn,value:w.value,color:w.color})},oe))})]})}),(()=>{const w=[{fn:"topology.edges",value:String(l),group:"worker",color:"green"},{fn:"topology.ghostNodes",value:String(o),group:"worker",color:"purple"},{fn:"sparkline.nodes",value:`${v}`,group:"worker",color:"green"},...m?[{fn:"trace.directedLinks",value:String(x.totalDirectedLinks),group:"worker",color:"teal"},{fn:"trace.meanSnr",value:`${x.meanSnr.toFixed(1)} dB`,group:"worker",color:"teal"}]:[],...H];return e.jsx(se,{tokens:w})})()]})})})}function It(t,s,r,c){var n;const a=t.src_hash?Se(t.src_hash):"";if(t._advertSender&&s.hash&&s.confident)return{tier:1,label:"_advertSender → pubkey",detail:"ADVERT carried full 32-byte public key — definitive match"};if(c&&s.confident&&((n=s.name)==null?void 0:n.toLowerCase())===c.toLowerCase())return{tier:1.5,label:"decrypt.senderName → nameToHash",detail:`Decrypted sender name “${c}” matched neighbor — high-confidence`};if(a&&r.crossClassPrefixes.has(a))return{tier:2,label:"cross-class prefix",detail:"Prefix has mixed types (repeater + non-repeater); payload type narrows to one class"};if(s.confident){const l=r.prefixIndex.get(a);return(l==null?void 0:l.length)===1?{tier:3,label:"single candidate",detail:"Only one node matches this prefix — unambiguous"}:{tier:3,label:"resolver",detail:"Multi-signal scoring selected best candidate from collision set"}}return{tier:4,label:"ambiguous",detail:"Cannot confidently resolve — multiple same-class candidates, insufficient scoring separation"}}function Gt(t,s){const r=t.original_path??t.forwarded_path,c=new Set;if(r&&Array.isArray(r))for(const a of r){const n=String(a).toUpperCase();n.length>=2&&!rt(n,s)&&c.add(n)}return c}function Kt(t,s,r,c,a,n,l){const o=Math.floor(Date.now()/1e3),x=new Map(r.map(m=>[m.hash,m]));return t.map(m=>{const g=s[m.hash],u=x.get(m.hash);let v=!0,N="";c!=="unknown"?m.type!=="unknown"&&m.type!==c?(v=!1,N=`${m.type} ≠ required ${c}`):m.type===c?N="type matches":N="type unknown — not ruled out":N="payload ambiguous — all types eligible";const f=!!(g!=null&&g.zero_hop),k=(g==null?void 0:g.last_seen)??0;let $=0;if(f&&k>0){const b=(o-k)/3600;$=50*Math.exp(-b/l)}let h=0;if(k>0){const b=(o-k)/3600;h=Math.exp(-b/n)}const y=h*20,p=!!(g!=null&&g.latitude&&(g!=null&&g.longitude)&&(g.latitude!==0||g.longitude!==0)),_=p?5:0,H=(u==null?void 0:u.advertCount)??0,C=Math.min(H*2,30),D=(u==null?void 0:u.forwarderPrefixes.size)??0,L=Math.min(D*3,15);let P=0;if(u&&u.totalForwarderObservations>0&&a.size>0){let b=0;for(const w of a)u.forwarderPrefixes.has(w)&&b++;P=b/a.size}const R=$+y+_+C+L;return{hash:m.hash,name:m.name,type:m.type,roleCompatible:v,roleReason:N,zeroHop:f,zeroHopScore:$,lastSeen:k,recencyScore:h,recencyPoints:y,hasGps:p,gpsScore:_,advertCount:H,advertScore:C,topoWidth:D,topoScore:L,affinity:P,total:R}}).sort((m,g)=>g.total-m.total)}function Vt({packet:t,pipeline:s,resolved:r,resolveTimeMs:c,advertName:a,neighbors:n,decrypted:l}){var ie,de;const o=Y(j=>j.neighborContext),x=Y(j=>j.topologyProfiles),m=Y(j=>j.config),{analysis:g}=s,u=r??{hash:null,type:"unknown",name:null,confident:!1},v=t.src_hash?Se(t.src_hash):"",N=v?o.prefixIndex.get(v)??[]:[],f=v?x.get(v)??[]:[],k=g.pType??-1,$=k>=0?k.toString(16).toUpperCase().padStart(2,"0"):"??",h=g.inferredType,y=g.advertType,p=g.effectiveType,_=t._advertNodeType!=null?t._advertNodeType.toString(16).padStart(2,"0").toUpperCase():"",H=((ie=l==null?void 0:l.decoded)==null?void 0:ie.senderName)??null,C=It(t,u,o,H),D=T.useMemo(()=>Gt(t,v),[t,v]),L=g.pathLen,P=T.useMemo(()=>Kt(N,n,f,p,D,m.recencyDecayHours,m.zeroHopDecayHours),[N,n,f,p,D,m.recencyDecayHours,m.zeroHopDecayHours]),R=P.filter(j=>!j.roleCompatible),b=P.filter(j=>j.roleCompatible),w=t._advertSender?o.pubKeyMap.get(t._advertSender)??null:null,oe=C.tier===1,De=[{fn:"src_hash",value:v||"",active:!!v,color:"blue"},{fn:"_advertSender",value:t._advertSender?t._advertSender.slice(0,12)+"…":"",active:!!t._advertSender,color:"blue"},{fn:"_advertNodeType",value:_?`0x${_}`:"",active:t._advertNodeType!=null,color:"blue"},{fn:"path_length",value:L!=null?L===0?"zero-hop":String(L):"",active:L!=null,color:"blue"},{fn:"decrypt.senderName",value:H??"",active:!!H,color:"teal"}],Le=[{label:"hit",detail:"pubKeyMap.get(_advertSender) → definitive",active:!!w,color:"green"},{label:"miss",detail:t._advertSender?"pubkey not in neighbor table":"no _advertSender",active:!w,color:"zinc"}],Pe=[{label:"payload",detail:`inferDeviceType(0x${$}) → ${h}`,active:h!=="unknown",color:"amber"},{label:"flags",detail:_?`mapAdvertTypeCode(0x${_}) → ${y}`:"no _advertNodeType",active:h==="unknown"&&y!=="unknown",color:"green"},{label:"ambiguous",detail:"all types eligible",active:p==="unknown",color:"zinc"}],Me=u.name??((de=u.hash)==null?void 0:de.slice(0,12))??"?",Re=u.confident?"confident":"ambiguous",Ae=`→ ${Me} (${Re}, Tier ${C.tier})`;return e.jsx(le,{stage:3,name:"RESOLVE",fn:"usePipelineStore.resolveSource()",verdict:Ae,timeMs:c,children:e.jsx(U,{prefix:"resolvePacketSource",children:e.jsxs("div",{className:"space-y-0",children:[e.jsx("div",{className:"pt-1 pb-1",children:e.jsx(St,{tokens:De,nextFn:"resolvePacketSource()"})}),t.src_hash?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"1"})," ","PUBKEY LOOKUP"]}),e.jsx(ae,{options:Le,nextFn:"pubKeyMap.get()"}),e.jsx("div",{className:"ml-3 mt-1",children:w?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"resolved",children:e.jsx(d,{fn:"hash",value:w,color:"green"})}),a&&e.jsxs(i,{label:"name",children:[e.jsx(d,{fn:"name",value:a,color:"green"}),u.name&&a===u.name&&e.jsx(S,{c:"text-sys-green ml-1",children:"✓ neighbor match"})]}),e.jsxs(i,{label:"result",children:[e.jsx(M,{color:"green",children:"Tier 1"}),e.jsx(S,{c:"text-fg-primary ml-1",children:"definitive — scoring bypassed"})]})]}):t._advertSender?e.jsx(i,{label:"status",children:e.jsx(S,{c:"text-sys-amber",children:"✗ pubkey not in neighbor table"})}):e.jsx(i,{label:"status",children:e.jsx(S,{children:"no _advertSender — skip to prefix resolution"})})})]}),oe?e.jsx("div",{className:"border-t border-edge-subtle py-2",children:e.jsx("p",{className:"text-[11px] text-fg-muted/40 font-mono ml-3",children:"Steps 2–5 bypassed — pubkey definitive"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"2"})," ","CANDIDATE POOL — ",N.length," node",N.length!==1?"s":"",' match "',v,'"']}),e.jsxs("div",{className:"space-y-0.5 ml-3",children:[P.map(j=>e.jsxs("div",{className:"flex gap-2 items-center text-[11px]",children:[e.jsx("span",{className:"break-all text-[10px]",children:j.hash}),e.jsx(M,{color:"zinc",children:j.type||"unknown"}),j.name&&e.jsx(S,{children:j.name})]},j.hash)),N.length===0&&e.jsx(S,{children:"no known nodes for this prefix"})]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"3"})," ","TYPE INFERENCE"]}),e.jsx(ae,{options:Pe,nextFn:"effectiveType()"}),e.jsx("div",{className:"ml-3 mt-1",children:e.jsx(i,{label:"effective",children:e.jsx(d,{fn:"effectiveType",value:p,color:p!=="unknown"?h!=="unknown"?"amber":"green":"zinc"})})})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"4"})," ","ROLE-TYPE SCRUB"]}),e.jsx("div",{className:"space-y-0.5 ml-3",children:P.map(j=>e.jsxs("div",{className:"flex gap-2 items-center text-[11px]",children:[e.jsx("span",{className:j.roleCompatible?"text-sys-green":"text-sys-red",children:j.roleCompatible?"✓":"✗"}),e.jsx("span",{className:`break-all text-[10px] ${j.roleCompatible?"":"line-through text-fg-muted"}`,children:j.hash}),e.jsx(M,{color:j.roleCompatible?"zinc":"red",children:j.type||"unknown"}),e.jsx(S,{c:j.roleCompatible?"text-fg-muted":"text-sys-red",children:j.roleReason})]},j.hash))}),R.length>0&&e.jsxs("p",{className:"text-[10px] text-fg-muted mt-1 ml-3",children:[R.length," eliminated, ",b.length," surviving"]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"5"})," ","CANDIDATE SCORING"]}),b.length===0?e.jsx("p",{className:"text-fg-muted italic ml-3",children:"No surviving candidates"}):b.length===1?e.jsxs("div",{className:"ml-3 text-[11px]",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(S,{c:"text-sys-green",children:"→"}),e.jsx("span",{className:"break-all text-[10px]",children:b[0].hash}),b[0].name&&e.jsx(S,{c:"text-fg-muted ml-1",children:b[0].name})]}),e.jsx("p",{className:"text-fg-muted ml-4",children:"single survivor — scoring not needed"})]}):e.jsxs(G,{children:[e.jsx(K,{className:"text-[10px] ml-3",children:e.jsxs("span",{className:"font-mono text-fg-muted/50",children:[b.length," candidates scored…"]})}),e.jsx(V,{children:e.jsx("div",{className:"space-y-2 ml-3 mt-1",children:b.map(j=>{const Q=j.hash===u.hash;return e.jsxs("div",{className:`text-[11px] leading-relaxed rounded px-2 py-1 ${Q?"bg-sys-green/8 border border-sys-green/20":"bg-zinc-500/5"}`,children:[e.jsxs("div",{className:"flex gap-2 items-center mb-0.5",children:[e.jsx(S,{c:Q?"text-sys-green":"text-fg-muted",children:Q?"→":" "}),e.jsx("span",{className:`break-all text-[10px] ${Q?"text-fg-primary":"text-fg-muted"}`,children:j.hash}),e.jsx(M,{color:Q?"green":"zinc",children:j.type||"unknown"}),j.name&&e.jsx(S,{children:j.name})]}),e.jsxs("div",{className:"ml-4 flex flex-wrap gap-x-3 gap-y-0.5",children:[e.jsxs("span",{children:[e.jsx(S,{children:"zero_hop:"})," ",e.jsx(S,{c:j.zeroHop?"text-sys-green":"text-fg-muted",children:j.zeroHop?"✓":"✗"})," ",e.jsxs(M,{color:ee(j.zeroHopScore),children:["+",j.zeroHopScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"recency:"})," ",e.jsx(S,{c:"text-fg-primary",children:mt(j.lastSeen)})," ",e.jsxs(M,{color:ee(j.recencyPoints),children:["+",j.recencyPoints.toFixed(1)]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"gps:"})," ",e.jsx(S,{c:j.hasGps?"text-sys-green":"text-fg-muted",children:j.hasGps?"✓":"✗"})," ",e.jsxs(M,{color:ee(j.gpsScore),children:["+",j.gpsScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"adverts:"})," ",e.jsx(S,{c:"text-fg-primary",children:j.advertCount})," ",e.jsxs(M,{color:ee(j.advertScore),children:["+",j.advertScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"topo:"})," ",e.jsx(S,{c:"text-fg-primary",children:j.topoWidth})," ",e.jsxs(M,{color:ee(j.topoScore),children:["+",j.topoScore]})]})]}),e.jsxs("div",{className:"ml-4 mt-0.5",children:[e.jsx(S,{children:"score ≈"})," ",e.jsx(S,{c:"text-fg-primary font-bold",children:j.total.toFixed(1)})]})]},j.hash)})})})]})]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-green font-bold",children:"✓"})," ","RESOLUTION"]}),e.jsxs("div",{className:"ml-3",children:[e.jsx(i,{label:"hash",children:u.hash?e.jsx(d,{fn:"resolved.hash",value:u.hash,color:"green"}):e.jsx(S,{children:"null"})}),e.jsx(i,{label:"type",children:e.jsx(d,{fn:"resolved.type",value:u.type,color:u.confident?"green":"zinc"})}),e.jsx(i,{label:"name",children:u.name?e.jsx(d,{fn:"resolved.name",value:u.name,color:u.confident?"green":"amber"}):e.jsx(S,{children:"null"})}),e.jsx(i,{label:"confident",children:e.jsx(S,{c:u.confident?"text-sys-green":"text-sys-red",children:String(u.confident)})}),e.jsxs(i,{label:"tier",children:[e.jsx(M,{color:C.tier<=2?"green":C.tier===3?"amber":"red",children:C.tier}),e.jsx(S,{c:"text-fg-primary ml-1",children:C.label})]})]})]})]}):e.jsx("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx(S,{c:"text-sys-amber",children:"⚠ no src_hash"}),H&&e.jsx(d,{fn:"decrypt.senderName",value:H,color:"teal"}),u.confident?e.jsxs(S,{c:"text-sys-green",children:["→ resolved via ",C.label]}):e.jsx(S,{c:"text-sys-red",children:"ambiguous"})]})}),(()=>{const j=[{fn:"resolved.hash",value:u.hash??"null",group:"resolution",color:u.confident?"green":"zinc"},{fn:"resolved.type",value:u.type,group:"resolution",color:u.type!=="unknown"?u.confident?"green":"amber":"zinc"},{fn:"resolved.name",value:u.name??"null",group:"resolution",color:u.confident?"green":u.name?"amber":"zinc"},{fn:"resolved.confident",value:String(u.confident),group:"resolution",color:u.confident?"green":"red"}];return e.jsx(se,{tokens:j})})()]})})})}const Ut={id:"packet-parse",label:"Packet Parse",inputs:["rawPacket"],outputs:["parsedPacket","decoded","headerFields"],emits:[{fn:"routeType",group:"wire",color:"blue"},{fn:"payloadType",group:"wire",color:"blue"},{fn:"pathLength",group:"wire",color:"blue"},{fn:"version",group:"wire",color:"blue"}],async:!1,observatoryStage:0},qt={id:"enrichment",label:"Ingestion Enrichment",inputs:["parsedPacket"],outputs:["advertSender","channelHash","hopData","byteLength"],emits:[{fn:"_advertSender",group:"enrichment",color:"blue"},{fn:"_advertNodeType",group:"enrichment",color:"blue"},{fn:"_channelHash",group:"enrichment",color:"blue"},{fn:"_hopCount",group:"enrichment",color:"blue"},{fn:"_isZeroHop",group:"enrichment",color:"blue"},{fn:"_byteLength",group:"enrichment",color:"blue"}],async:!1,observatoryStage:1},Wt={id:"topology",label:"Topology Analysis",inputs:["packets","neighbors","srcHashResolver"],outputs:["edges","nodeMetrics","pathHealth","ghostNodes","centrality","loops"],emits:[{fn:"edges",group:"worker",color:"green"},{fn:"ghostNodes",group:"worker",color:"purple"},{fn:"loops",group:"analysis",color:"amber"},{fn:"nodeMetrics",group:"worker",color:"green"},{fn:"pathHealth",group:"worker",color:"green"},{fn:"centrality",group:"worker",color:"green"}],async:!0,worker:"topology.worker.ts",observatoryStage:2},Yt={id:"trace-enrichment",label:"Trace Link Quality",inputs:["packets","prefixLookup","srcHashResolver","edges","pathHealth","nodeMetrics"],outputs:["traceLinks","traceLinkSummary","traceDisambiguationFeedback"],emits:[{fn:"traceLinks.directed",group:"worker",color:"teal"},{fn:"traceLinks.bidir",group:"worker",color:"teal"},{fn:"traceSummary.meanSnr",group:"analysis",color:"green"},{fn:"traceSummary.medianSnr",group:"analysis",color:"zinc"},{fn:"traceSummary.confidence",group:"analysis",color:"zinc"},{fn:"feedback.confirmed",group:"worker",color:"teal"},{fn:"feedback.links",group:"worker",color:"teal"}],async:!1,observatoryStage:2},Zt={id:"disambiguation",label:"Source Disambiguation",inputs:["packets","neighbors","decodedMessages"],outputs:["srcHashResolverMap","neighborContext"],emits:[{fn:"resolvedHash",group:"resolution",color:"purple"},{fn:"resolvedName",group:"resolution",color:"purple"},{fn:"resolvedType",group:"resolution",color:"purple"},{fn:"confidence",group:"resolution",color:"green"}],async:!1,observatoryStage:3},Xt={id:"sparkline",label:"Sparkline Computation",inputs:["packets","neighbors"],outputs:["sparklineData"],emits:[{fn:"sparklines",group:"worker",color:"blue"}],async:!1},Qt={id:"decryption",label:"Channel Decryption",inputs:["packets","channelKeys"],outputs:["decodedMessages"],emits:[{fn:"decrypt.text",group:"crypto",color:"teal"},{fn:"decrypt.senderName",group:"crypto",color:"teal"},{fn:"decrypt.channelName",group:"crypto",color:"teal"},{fn:"decrypt.macCorrupted",group:"crypto",color:"amber"}],async:!0,worker:"decryption.worker.ts",observatoryStage:2},Jt={id:"decoded-content",label:"Decoded Content Policy",inputs:["decodedMessages","packets"],outputs:["decodedContent","contentInheritance"],emits:[{fn:"content.senderName",group:"crypto",color:"teal"},{fn:"content.text",group:"crypto",color:"teal"},{fn:"content.channelName",group:"crypto",color:"teal"},{fn:"content.corrupted",group:"crypto",color:"amber"},{fn:"content.inherited",group:"analysis",color:"purple"}],async:!1},Z=[Ut,qt,Wt,Yt,Zt,Xt,Qt,Jt],es=new Map(Z.map(t=>[t.id,t])),ts=new Map;for(const t of Z)for(const s of t.emits)ts.set(s.fn,t);const $e=new Map;for(const t of Z)for(const s of t.outputs)$e.set(s,t);function ss(){const t=new Map,s=new Map;for(const a of Z)t.has(a.id)||t.set(a.id,0),s.has(a.id)||s.set(a.id,new Set);for(const a of Z)for(const n of a.inputs){const l=$e.get(n);if(l&&l.id!==a.id){const o=s.get(l.id);o.has(a.id)||(o.add(a.id),t.set(a.id,(t.get(a.id)??0)+1))}}const r=[];for(const[a,n]of t)n===0&&r.push(a);const c=[];for(;r.length>0;){const a=r.shift(),n=es.get(a);n&&c.push(n);for(const l of s.get(a)??[]){const o=(t.get(l)??1)-1;t.set(l,o),o===0&&r.push(l)}}for(const a of Z)c.includes(a)||c.push(a);return c}const ns={0:"text-sys-green",1:"text-sys-blue",2:"text-sys-teal",3:"text-sys-purple"};function rs({stage:t,isActive:s,onClick:r}){const c=t.observatoryStage!=null?ns[t.observatoryStage]??"text-fg-muted":"text-fg-muted/40";return e.jsxs("button",{type:"button",onClick:r,className:` flex items-center gap-1.5 w-full px-1.5 py-1 rounded transition-base text-left ${s?"bg-sys-blue/10 ring-1 ring-sys-blue/30":"hover:bg-zinc-500/5"} `,children:[e.jsx("span",{className:`font-mono text-[9px] font-bold w-3 shrink-0 text-center ${c}`,children:t.observatoryStage??"·"}),e.jsx("span",{className:"font-mono text-[9px] text-fg-primary truncate flex-1",children:t.label}),t.async&&e.jsx("span",{className:"font-mono text-[7px] px-1 py-px rounded bg-sys-amber/15 text-sys-amber shrink-0 leading-tight",children:"⚡"}),t.emits.length>0&&e.jsxs("span",{className:"flex items-center gap-px shrink-0",children:[t.emits.slice(0,6).map(a=>{var n;return e.jsx("span",{className:`inline-block w-1 h-1 rounded-full ${((n=I[a.color])==null?void 0:n.dot)??"bg-zinc-500"}`,title:`${a.fn} [${a.group}]`},a.fn)}),t.emits.length>6&&e.jsxs("span",{className:"font-mono text-[7px] text-fg-muted/40 ml-0.5",children:["+",t.emits.length-6]})]})]})}function as({activeStageId:t,onStageClick:s}){const r=T.useMemo(()=>ss(),[]),c=T.useMemo(()=>{const a=new Map;for(const l of r){const o=l.observatoryStage??"other";let x=a.get(o);x||(x=[],a.set(o,x)),x.push(l)}const n=[];for(const l of[0,1,2,3,"other"]){const o=a.get(l);o!=null&&o.length&&n.push({key:l,stages:o})}return n},[r]);return e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-[8px] text-fg-muted/40 uppercase tracking-widest",children:"Pipeline DAG"}),e.jsxs("span",{className:"font-mono text-[8px] text-fg-muted/30",children:[r.length," stages"]})]}),e.jsx("div",{className:"space-y-px",children:c.map((a,n)=>e.jsxs("div",{children:[n>0&&e.jsx("div",{className:"flex items-center pl-2.5 py-px",children:e.jsx("svg",{width:"6",height:"8",viewBox:"0 0 6 8",className:"text-fg-muted/20",children:e.jsx("path",{d:"M3 0 L3 6 M1 4 L3 6 L5 4",fill:"none",stroke:"currentColor",strokeWidth:"1"})})}),a.stages.map(l=>e.jsx(rs,{stage:l,isActive:t===l.id,onClick:s?()=>s(l.id):void 0},l.id))]},String(a.key)))})]})}const ve=200,z={status:"idle",lastDurationMs:null,lastTs:null,runCount:0};function ls(t,s,r){var c,a,n;switch(t.type){case"transport:ws:state":s.wsState=((c=t.data)==null?void 0:c.state)??r.wsState;break;case"transport:ws:packet":s.wsPacketCount=(s.wsPacketCount??r.wsPacketCount)+1;break;case"transport:ws:stats":s.wsStatsCount=(s.wsStatsCount??r.wsStatsCount)+1;break;case"transport:rest:stats":s.restStatsCount=(s.restStatsCount??r.restStatsCount)+1;break;case"transport:rest:packets":s.restPacketsCount=(s.restPacketsCount??r.restPacketsCount)+1;break;case"store:packets:ws-merge":s.wsMergeCount=(s.wsMergeCount??r.wsMergeCount)+1;break;case"cascade:hydrate":s.lastHydrateTs=t.ts,s.hydrateCount=(s.hydrateCount??r.hydrateCount)+1;break;case"worker:topology:start":case"worker:sparkline:start":{const l=t.type.split(":")[1],o=s.workers??r.workers,x=o[l]??{...z};s.workers={...o,[l]:{...x,status:"running",lastTs:t.ts}}}break;case"worker:topology:done":case"worker:sparkline:done":{const l=t.type.split(":")[1],o=s.workers??r.workers,x=o[l]??{...z},m=((a=t.data)==null?void 0:a.ms)??null;s.workers={...o,[l]:{...x,status:"done",lastDurationMs:m,lastTs:t.ts,runCount:x.runCount+1}}}break;case"worker:decryption:batch":{const l=s.workers??r.workers,o=l.decryption??{...z},x=((n=t.data)==null?void 0:n.ms)??null;s.workers={...l,decryption:{...o,status:"done",lastDurationMs:x,lastTs:t.ts,runCount:o.runCount+1}}}break;case"pipeline:disambig:recompute":s.disambigCount=(s.disambigCount??r.disambigCount)+1;break}}const te=at(t=>({events:[],eventCount:0,wsState:"disconnected",wsPacketCount:0,wsStatsCount:0,restStatsCount:0,restPacketsCount:0,workers:{topology:{...z},sparkline:{...z},decryption:{...z}},wsMergeCount:0,lastHydrateTs:null,hydrateCount:0,disambigCount:0,lastDisambigMs:null,_pushBatch:s=>t(r=>{if(s.length===0)return r;let c=[...r.events,...s];c.length>ve&&(c=c.slice(c.length-ve));const a={events:c,eventCount:r.eventCount+s.length};for(const n of s)ls(n,a,r);return a}),clear:()=>t({events:[],eventCount:0,wsState:"disconnected",wsPacketCount:0,wsStatsCount:0,restStatsCount:0,restPacketsCount:0,workers:{topology:{...z},sparkline:{...z},decryption:{...z}},wsMergeCount:0,lastHydrateTs:null,hydrateCount:0,disambigCount:0,lastDisambigMs:null})}));let W=null,B=[],X=null;function os(){if(X=null,B.length===0)return;const t=B;B=[],te.getState()._pushBatch(t)}function cs(){W||(B=[],W=lt.subscribe(t=>{B.push(t),X===null&&(X=requestAnimationFrame(os))}))}function is(){if(W==null||W(),W=null,X!==null&&(cancelAnimationFrame(X),X=null),B.length>0){const t=B;B=[],te.getState()._pushBatch(t)}}function ds(t){switch(t){case"active":return"●";case"skipped":return"○";case"inferred":return"◌"}}function us(t){switch(t){case"active":return"text-sys-green";case"skipped":return"text-fg-muted/30";case"inferred":return"text-sys-amber"}}function ps(t){switch(t){case"transport":return"text-sys-blue";case"store":return"text-sys-amber";case"worker":return"text-sys-violet";case"pipeline":return"text-sys-green";case"consumer":return"text-sys-teal"}}function xs(t,s,r,c,a){var m,g;const n=[];if(a?n.push({label:"Hex Input",detail:"Manual hex — no transport",status:"skipped",lane:"transport"}):s.age==="live"||s.age==="recent"?n.push({label:"WebSocket",detail:"ws:packet → real-time push",status:"active",lane:"transport"}):n.push({label:"REST Poll",detail:"fetchPackets → packetCache.poll()",status:"inferred",lane:"transport"}),!a){n.push({label:"Cache Merge",detail:"packetCache.mergePacketsDirectly()",status:"active",lane:"store"});const u=s.age==="live"||s.age==="recent";n.push({label:"Flash",detail:u?"flashReceived++ → sidebar blink":"Not newest — no flash",status:u?"active":"skipped",lane:"store"}),n.push({label:"Hydrate Cascade",detail:"hydrateDownstream() → schedule workers",status:"active",lane:"store"})}const l=s.pathAvail||s.pathHopCount>0;n.push({label:"Topology Worker",detail:l?`Path data (${s.pathHopCount} hops) → edge extraction`:"No path data — still included in batch recompute",status:"active",lane:"worker"}),n.push({label:"Sparkline Worker",detail:`Contributes to sparkline for src ${((m=t.src_hash)==null?void 0:m.slice(0,4))??"??"}`,status:"active",lane:"worker"});const o=s.isGrp;n.push({label:"Decryption Worker",detail:o?`GRP_TXT → queued for channel key search${c?" → decrypted ✓":""}`:`${s.payloadTypeName} — not encrypted, skipped`,status:o?"active":"skipped",lane:"worker"}),n.push({label:"Source Disambiguation",detail:r?`→ ${r.name??((g=r.hash)==null?void 0:g.slice(0,8))??"?"} (${r.type}${r.confident?", confident":", ambiguous"})`:"Pending recompute",status:r?"active":"inferred",lane:"pipeline"}),s.isAdvert&&n.push({label:"ADVERT Discovery",detail:"pubkey → extended hash-to-type + name extraction",status:"active",lane:"pipeline"}),o&&(c!=null&&c.decoded)&&n.push({label:"Decoded Content Policy",detail:`macCorrupted=${c.decoded.macCorrupted?"true":"false"} → cross-hash inheritance`,status:"active",lane:"pipeline"});const x=["Packets","Dashboard","Statistics"];return l&&x.push("Map","Graph"),s.isTrace&&x.push("Trace Detail"),n.push({label:"Page Hydration",detail:x.join(", "),status:"active",lane:"consumer"}),n}const hs=[],ms=["transport","store","worker","pipeline","consumer"],gs={transport:"Transport",store:"Store",worker:"Workers",pipeline:"Pipeline",consumer:"Consumers"};function fs(t){return t.replace("transport:","").replace("store:packets:","").replace("cascade:","").replace("worker:","w:").replace("pipeline:","p:").replace("packet","pkt").replace("sparkline","spark").replace("topology","topo").replace("decryption","dec").replace("disambig","dis").replace("recompute","recomp")}function bs(t){return t.startsWith("transport:")?"text-sys-blue":t.startsWith("store:")||t.startsWith("cascade:")?"text-sys-amber":t.startsWith("worker:")?"text-sys-violet":t.startsWith("pipeline:")?"text-sys-green":"text-fg-muted"}const ys=T.memo(function({event:s}){const r=`${(s.ts/1e3).toFixed(1)}s`,c=s.data?Object.entries(s.data).map(([a,n])=>{var l;return`${a}=${typeof n=="number"?((l=n.toFixed)==null?void 0:l.call(n,1))??n:n}`}).join(" "):"";return e.jsxs("div",{className:"flex gap-2 text-[9px] font-mono leading-tight",children:[e.jsx("span",{className:"text-fg-muted/40 w-12 shrink-0 text-right",children:r}),e.jsx("span",{className:`w-20 shrink-0 ${bs(s.type)}`,children:fs(s.type)}),e.jsx("span",{className:"text-fg-muted/60 truncate",children:c})]})});function js({packet:t,pipeline:s,resolved:r,decrypted:c,isSynthetic:a,liveMode:n}){const[l,o]=T.useState(!1);T.useEffect(()=>{if(l)return cs(),()=>{is()}},[l]);const x=s==null?void 0:s.analysis,m=T.useMemo(()=>!t||!x?null:xs(t,x,r,c,a),[t,x,r,c,a]),g=T.useMemo(()=>{if(!m)return null;const h=new Map;for(const y of m){let p=h.get(y.lane);p||(p=[],h.set(y.lane,p)),p.push(y)}return h},[m]),u=te(h=>l?h.events:hs),v=te(h=>l?h.eventCount:0),N=te(h=>h.clear),f=T.useRef(null);T.useEffect(()=>{l&&f.current&&(f.current.scrollTop=f.current.scrollHeight)},[v,l]);const k=(m==null?void 0:m.filter(h=>h.status==="active").length)??0,$=(m==null?void 0:m.length)??0;return e.jsxs(G,{defaultOpen:!0,children:[e.jsx(K,{className:"text-[10px]",children:e.jsxs("span",{className:"flex items-center gap-2 font-mono",children:[e.jsx("span",{className:"text-sys-green",children:"CFT"}),e.jsx("span",{className:"text-fg-muted/40",children:"Control Flow Trace"}),t&&e.jsxs("span",{className:"text-fg-muted/30",children:["— ",k,"/",$," stages active"]})]})}),e.jsx(V,{children:e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3 space-y-3",children:[t?g?e.jsx("div",{className:"space-y-2",children:ms.map(h=>{const y=g.get(h);return y?e.jsxs("div",{children:[e.jsx("div",{className:`text-[8px] uppercase tracking-widest font-mono mb-0.5 ${ps(h)}`,children:gs[h]}),y.map((p,_)=>e.jsxs("div",{className:"flex items-start gap-1.5 text-[10px] font-mono leading-snug ml-1",children:[e.jsx("span",{className:`shrink-0 ${us(p.status)}`,children:ds(p.status)}),e.jsx("span",{className:"text-fg-primary",children:p.label}),e.jsx("span",{className:"text-fg-muted/50 truncate",children:p.detail})]},_))]},h):null})}):null:e.jsx("div",{className:"text-[9px] text-fg-muted/30 font-mono py-2 text-center",children:"Select a packet to trace its flow"}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(h=>!h),className:`px-2 py-0.5 rounded text-[9px] font-mono transition-colors ${l?"bg-sys-green/20 text-sys-green":"bg-zinc-500/20 text-fg-muted hover:text-fg-primary"}`,children:l?"● LIVE":"○ LIVE"}),e.jsx("span",{className:"text-[9px] text-fg-muted/40 font-mono",children:l?`${v} events`:"Subscribe to all pipeline events"}),l&&e.jsx("button",{onClick:N,className:"text-[9px] text-fg-muted/40 hover:text-fg-muted font-mono transition-colors ml-auto",children:"clear"})]}),l&&e.jsx("div",{ref:f,className:"max-h-32 overflow-y-auto space-y-px",children:u.length===0?e.jsx("div",{className:"text-[9px] text-fg-muted/30 font-mono py-1 text-center",children:"Waiting for events…"}):u.map((h,y)=>e.jsx(ys,{event:h},`${h.ts}-${y}`))})]})})]})}function vs(t){const s=Ne(t.type??t.payload_type??-1).padEnd(7),r=t.packet_hash.slice(0,8),c=(t.src_hash??"—").replace(/^0x/i,"").slice(0,4).toUpperCase(),a=t._hopCount!=null?`${t._hopCount}h`:"",n=ut(t.timestamp);return`${r} ${s} ←${c} ${t.rssi}dBm ${a} ${n}`}function _s(){const t=ot(),s=ct(),r=it(),c=(s==null?void 0:s.neighbors)??{},a=Y(b=>b.resolveSource),n=Y(b=>b.config),l=Y(b=>b.setConfig),[o,x]=T.useState(-1),m=T.useMemo(()=>{let b=t;return o!==-1&&(b=t.filter(w=>(w.type??w.payload_type)===o)),b.slice(-50).reverse()},[t,o]),[g,u]=T.useState(""),[v,N]=T.useState(""),[f,k]=T.useState(!1),$=T.useRef(r);T.useEffect(()=>{f&&r!==$.current&&m.length>0&&(u(m[0].packet_hash),N("")),$.current=r},[r,f,m]),T.useEffect(()=>{!g&&m.length>0&&!v&&u(m[0].packet_hash)},[g,m,v]);const h=T.useMemo(()=>v.trim()?null:m.find(b=>b.packet_hash===g)??null,[g,m,v]),y=T.useMemo(()=>{const b=v.replace(/\s+/g,"").trim();return b?{packet_hash:"manual-hex-input",timestamp:0,rssi:0,snr:0,transmitted:!1,drop_reason:null,is_duplicate:!1,raw_packet:b}:null},[v]),p=h??y,_=!!v.trim(),H=v.trim().replace(/\s+/g,"")||(p==null?void 0:p.raw_packet),C=Ct(p,H,t),D=(C==null?void 0:C.enrichment)??He,L=Ce((p==null?void 0:p.packet_hash)??""),P=T.useRef(0),R=T.useMemo(()=>{if(!p)return null;const b=performance.now(),w=a(p);return P.current=performance.now()-b,w},[p,a]);return e.jsxs("div",{className:"max-w-[960px] mx-auto",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h1",{className:"text-sm font-bold text-fg-primary tracking-wide font-mono",children:"PACKET OBSERVATORY"}),e.jsx("p",{className:"text-[11px] text-fg-muted font-mono",children:"Pipeline introspection — select a packet to trace its journey"})]}),e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3 mb-3",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsxs("select",{value:o,onChange:b=>{x(Number(b.target.value)),u("")},className:"surface-input px-2 py-1 rounded text-[11px] font-mono text-fg-primary w-36",children:[e.jsx("option",{value:-1,children:"ALL TYPES"}),Object.entries(dt).map(([b,w])=>e.jsxs("option",{value:Number(b),children:["0x",Number(b).toString(16).toUpperCase().padStart(2,"0")," ",w]},b))]}),e.jsxs("select",{value:g,onChange:b=>{u(b.target.value),N("")},className:"surface-input flex-1 min-w-0 px-2 py-1 rounded text-[11px] font-mono text-fg-primary truncate",children:[m.map((b,w)=>e.jsx("option",{value:b.packet_hash,children:vs(b)},`${b.packet_hash}-${w}`)),m.length===0&&e.jsxs("option",{value:"",children:["No packets",o!==-1?" matching filter":" loaded"]})]}),e.jsx("button",{onClick:()=>k(b=>!b),className:`px-2 py-1 rounded text-[11px] font-mono transition-colors shrink-0 ${f?"bg-sys-green/20 text-sys-green":"bg-zinc-500/20 text-fg-muted hover:text-fg-primary"}`,children:f?"● LIVE":"○ LIVE"})]}),e.jsxs(G,{children:[e.jsx(K,{className:"text-[10px] text-fg-muted/50 hover:text-fg-muted mt-1.5",children:e.jsx("span",{className:"font-mono",children:"Paste hex…"})}),e.jsx(V,{children:e.jsx("textarea",{value:v,onChange:b=>N(b.target.value),placeholder:"Paste raw packet hex (overrides dropdown)",rows:2,className:"surface-input w-full mt-1 px-2 py-1 rounded text-[11px] font-mono text-fg-primary resize-y"})})]})]}),e.jsxs(G,{children:[e.jsx(K,{className:"text-[11px] mb-3 w-full",children:e.jsxs("span",{className:"flex items-center gap-2 font-mono",children:[e.jsx("span",{className:"text-fg-muted/50",children:"⚙"}),e.jsx("span",{className:"text-fg-muted/50",children:"Pipeline Config & Dev Tools"}),e.jsxs("span",{className:"text-fg-muted/30 text-[10px]",children:["disambig=",n.disambiguationEnabled?"on":"off"," mac=",n.macCorruptedPolicy," decay=",n.recencyDecayHours,"h"]})]})}),e.jsx(V,{children:e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3",children:[e.jsx("h2",{className:"text-[10px] text-fg-muted/50 uppercase tracking-widest font-mono mb-2",children:"Pipeline Config"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Disambiguation"}),e.jsx("button",{onClick:()=>l({disambiguationEnabled:!n.disambiguationEnabled}),className:`px-2 py-0.5 rounded text-[11px] font-mono transition-colors ${n.disambiguationEnabled?"bg-sys-green/20 text-sys-green":"bg-sys-red/20 text-sys-red"}`,children:n.disambiguationEnabled?"● ON":"○ OFF"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"MAC policy"}),e.jsxs("select",{value:n.macCorruptedPolicy,onChange:b=>l({macCorruptedPolicy:b.target.value}),className:"surface-input px-1.5 py-0.5 rounded text-[11px] font-mono text-fg-primary",children:[e.jsx("option",{value:"strict",children:"strict (drop)"}),e.jsx("option",{value:"name-only",children:"name-only"}),e.jsx("option",{value:"permissive",children:"permissive"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Recency decay"}),e.jsx("input",{type:"range",min:1,max:48,step:1,value:n.recencyDecayHours,onChange:b=>l({recencyDecayHours:Number(b.target.value)}),className:"flex-1 h-1 accent-sys-blue"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-primary w-8 text-right",children:[n.recencyDecayHours,"h"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Zero-hop decay"}),e.jsx("input",{type:"range",min:12,max:168,step:6,value:n.zeroHopDecayHours,onChange:b=>l({zeroHopDecayHours:Number(b.target.value)}),className:"flex-1 h-1 accent-sys-blue"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-primary w-10 text-right",children:[n.zeroHopDecayHours,"h"]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(js,{packet:p,pipeline:C,resolved:R,decrypted:L??null,isSynthetic:_,liveMode:f}),e.jsx(as,{})]})]})})]}),p?e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ht,{packet:p,isSynthetic:_}),e.jsx(At,{packet:p,pipeline:C,rawHex:H,traceTagIndex:(C==null?void 0:C.traceTagIndex)??new Map,neighbors:c}),e.jsx(Bt,{packet:p,decrypted:L??void 0,pipeline:C}),e.jsx(Vt,{packet:p,pipeline:C,resolved:R,decrypted:L??void 0,resolveTimeMs:P.current,neighbors:c,advertName:D.advertName})]}):e.jsx("div",{className:"surface-base rounded-lg border border-edge-subtle p-8 text-center",children:e.jsx("p",{className:"text-fg-muted text-xs",children:"Select a packet from the dropdown or paste hex above"})})]})}export{_s as default}; diff --git a/frontend/dist/assets/Packets-DkmiTj3L.js b/frontend/dist/assets/Packets-DmI71CFc.js similarity index 62% rename from frontend/dist/assets/Packets-DkmiTj3L.js rename to frontend/dist/assets/Packets-DmI71CFc.js index 370e8b3f..c3894303 100644 --- a/frontend/dist/assets/Packets-DkmiTj3L.js +++ b/frontend/dist/assets/Packets-DmI71CFc.js @@ -1,6 +1,6 @@ -import{r as c,aT as _,aU as dt,aV as Te,aW as We,aX as ut,aY as ce,aZ as Ye,a_ as pt,a$ as mt,b0 as bt,b1 as ge,b2 as ft,b3 as vt,b4 as Oe,b5 as U,b6 as xt,b7 as ke,b8 as X,b9 as re,ba as $e,bb as Ee,bc as gt,bd as Xe,be as Je,bf as he,bg as Pe,bh as ye,bi as ht,bj as yt,bk as St,bl as Re,bm as Ct,bn as Ot,bo as Ce,bp as wt,bq as Nt,br as jt,bs as ie,bt as Et,bu as W,bv as Pt,bw as It,bx as Tt,by as kt,bz as $t,bA as Rt,bB as Mt,bC as Ft,bD as Dt,bE as _t,bF as At,bG as Me,e as Vt,j as n,c as J,aE as Lt,a0 as zt,bH as Bt,a1 as Ht,bI as Ut,Q as Gt,a6 as qt,ac as Kt,ad as Wt,aA as Yt,aR as Xt,ae as Fe,P as De,bJ as _e,bK as Ae,B as Ne,bL as Ve,a7 as Le,bM as ze,a8 as Jt}from"./index-C2xvS0Jd.js";import{c as Qt}from"./node-types-BD70swWz.js";import{u as Zt}from"./chevron-up-CTCjpmk_.js";import{c as H,p as eo,a as ve,f as Be,b as to,L as oo,S as me,s as so,g as ao,u as no,d as lo}from"./element-movement-CSQuYFsD.js";import{F as io,y as ro,R as co,T as uo,w as He,A as po}from"./map-pin-CQk00ph2.js";import{F as mo}from"./use-tree-walker-BpJfMrbM.js";import{u as Ue,s as bo}from"./frozen-Cx4cJH6f.js";import{g as Qe,u as fo,P as vo}from"./PacketList-BlTe2eo4.js";import{useGetDecodedContent as xo,useResolveSource as go}from"./usePipelineStore-Do-g28wv.js";import{c as ho,a as yo,D as So,b as Co}from"./AnalyzerFilterPanel-CckWnD46.js";import{u as Oo,r as wo}from"./consumer-registry-DJyYnY6J.js";import{A as No}from"./arrow-down-4OY_dsXk.js";import{A as jo}from"./arrow-right-DySc3ssS.js";import{P as Eo,a as Po,B as Io,C as Ge}from"./PageLayout-Cg7r5tdt.js";import{T as To,M as ko}from"./MqttModeBadge-DOXwpg3i.js";import{F as qe}from"./funnel-DGVJFdsh.js";import{R as $o}from"./route-Awj5QSAO.js";import{S as Ro}from"./search-DPGHPI2q.js";import"./primitives-Ctn6pdEU.js";import"./badge-colors-Dl76Mz8m.js";import"./chat-utils-DnJ-lYj3.js";import"./SignalIndicator-DO8Lkax5.js";import"./arrow-up-C0VG8Et4.js";import"./chevron-right-C9GG0xWI.js";import"./payload-detail-BAEvS7Pl.js";import"./circle-question-mark-CF3fGjhH.js";import"./layers-BICmdhXR.js";import"./hash-DjqT3oXN.js";import"./clock-DU0z3qMB.js";import"./activity-BFfde9uG.js";import"./database-cyku2KnA.js";import"./useMapViewStore-DnPjO7Qt.js";import"./index-QCPybZMd.js";import"./index-wtt5rE5a.js";import"./shield-DvZvtyKV.js";import"./zap-v3FkQoQ-.js";function Ze(e){let o=c.useRef({value:"",selectionStart:null,selectionEnd:null});return dt(e,"blur",t=>{let l=t.target;Te(l)&&(o.current={value:l.value,selectionStart:l.selectionStart,selectionEnd:l.selectionEnd})}),_(()=>{if(!We(e)&&Te(e)&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==o.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:t,selectionEnd:l}=o.current;t!==null&&l!==null&&e.setSelectionRange(t,l)}o.current={value:"",selectionStart:null,selectionEnd:null}}})}var Mo=Object.defineProperty,Fo=(e,o,t)=>o in e?Mo(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,Ke=(e,o,t)=>(Fo(e,typeof o!="symbol"?o+"":o,t),t),S=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(S||{}),Q=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Q||{}),oe=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(oe||{}),et=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.DefaultToFirstOption=6]="DefaultToFirstOption",e[e.SetActivationTrigger=7]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=8]="UpdateVirtualConfiguration",e[e.SetInputElement=9]="SetInputElement",e[e.SetButtonElement=10]="SetButtonElement",e[e.SetOptionsElement=11]="SetOptionsElement",e[e.MarkInputAsMoved=12]="MarkInputAsMoved",e))(et||{});function je(e,o=t=>t){let t=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,l=o(e.options.slice()),a=l.length>0&&l[0].dataRef.current.order!==null?l.sort((d,x)=>d.dataRef.current.order-x.dataRef.current.order):mt(l,d=>d.dataRef.current.domRef.current),i=t?a.indexOf(t):null;return i===-1&&(i=null),{options:a,activeOptionIndex:i}}let Do={1(e){var o;if((o=e.dataRef.current)!=null&&o.disabled||e.comboboxState===1)return e;let t=e.inputElement?ve.Tracked(to(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:t,__demoMode:!1}},0(e){var o,t;if((o=e.dataRef.current)!=null&&o.disabled||e.comboboxState===0)return e;if((t=e.dataRef.current)!=null&&t.value){let l=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(l!==-1)return{...e,activeOptionIndex:l,comboboxState:0,__demoMode:!1,inputPositionState:ve.Idle}}return{...e,comboboxState:0,inputPositionState:ve.Idle,__demoMode:!1}},3(e,o){return e.isTyping===o.isTyping?e:{...e,isTyping:o.isTyping}},2(e,o){var t,l,a,i;if((t=e.dataRef.current)!=null&&t.disabled||e.optionsElement&&!((l=e.dataRef.current)!=null&&l.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:f,disabled:y}=e.virtual,N=o.focus===H.Specific?o.idx:Be(o,{resolveItems:()=>f,resolveActiveIndex:()=>{var b,m;return(m=(b=e.activeOptionIndex)!=null?b:f.findIndex(P=>!y(P)))!=null?m:null},resolveDisabled:y,resolveId(){throw new Error("Function not implemented.")}}),C=(a=o.trigger)!=null?a:2;return e.activeOptionIndex===N&&e.activationTrigger===C?e:{...e,activeOptionIndex:N,activationTrigger:C,isTyping:!1,__demoMode:!1}}let d=je(e);if(d.activeOptionIndex===null){let f=d.options.findIndex(y=>!y.dataRef.current.disabled);f!==-1&&(d.activeOptionIndex=f)}let x=o.focus===H.Specific?o.idx:Be(o,{resolveItems:()=>d.options,resolveActiveIndex:()=>d.activeOptionIndex,resolveId:f=>f.id,resolveDisabled:f=>f.dataRef.current.disabled}),p=(i=o.trigger)!=null?i:2;return e.activeOptionIndex===x&&e.activationTrigger===p?e:{...e,...d,isTyping:!1,activeOptionIndex:x,activationTrigger:p,__demoMode:!1}},4:(e,o)=>{var t,l,a,i;if((t=e.dataRef.current)!=null&&t.virtual)return{...e,options:[...e.options,o.payload]};let d=o.payload,x=je(e,f=>(f.push(d),f));e.activeOptionIndex===null&&(a=(l=e.dataRef.current).isSelected)!=null&&a.call(l,o.payload.dataRef.current.value)&&(x.activeOptionIndex=x.options.indexOf(d));let p={...e,...x,activationTrigger:2};return(i=e.dataRef.current)!=null&&i.__demoMode&&e.dataRef.current.value===void 0&&(p.activeOptionIndex=0),p},5:(e,o)=>{var t;if((t=e.dataRef.current)!=null&&t.virtual)return{...e,options:e.options.filter(a=>a.id!==o.id)};let l=je(e,a=>{let i=a.findIndex(d=>d.id===o.id);return i!==-1&&a.splice(i,1),a});return{...e,...l,activationTrigger:2}},6:(e,o)=>e.defaultToFirstOption===o.value?e:{...e,defaultToFirstOption:o.value},7:(e,o)=>e.activationTrigger===o.trigger?e:{...e,activationTrigger:o.trigger},8:(e,o)=>{var t,l;if(e.virtual===null)return{...e,virtual:{options:o.options,disabled:(t=o.disabled)!=null?t:()=>!1}};if(e.virtual.options===o.options&&e.virtual.disabled===o.disabled)return e;let a=e.activeOptionIndex;if(e.activeOptionIndex!==null){let i=o.options.indexOf(e.virtual.options[e.activeOptionIndex]);i!==-1?a=i:a=null}return{...e,activeOptionIndex:a,virtual:{options:o.options,disabled:(l=o.disabled)!=null?l:()=>!1}}},9:(e,o)=>e.inputElement===o.element?e:{...e,inputElement:o.element},10:(e,o)=>e.buttonElement===o.element?e:{...e,buttonElement:o.element},11:(e,o)=>e.optionsElement===o.element?e:{...e,optionsElement:o.element},12(e){return e.inputPositionState.kind!=="Tracked"?e:{...e,inputPositionState:ve.Moved}}};class Ie extends ut{constructor(o){super(o),Ke(this,"actions",{onChange:t=>{let{onChange:l,compare:a,mode:i,value:d}=this.state.dataRef.current;return ce(i,{0:()=>l==null?void 0:l(t),1:()=>{let x=d.slice(),p=x.findIndex(f=>a(f,t));return p===-1?x.push(t):x.splice(p,1),l==null?void 0:l(x)}})},registerOption:(t,l)=>(this.send({type:4,payload:{id:t,dataRef:l}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(l.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:t})}),goToOption:(t,l)=>(this.send({type:6,value:!1}),this.send({type:2,...t,trigger:l})),setIsTyping:t=>{this.send({type:3,isTyping:t})},closeCombobox:()=>{var t,l;this.send({type:1}),this.send({type:6,value:!1}),(l=(t=this.state.dataRef.current).onClose)==null||l.call(t)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:t=>{this.send({type:7,trigger:t})},selectActiveOption:()=>{let t=this.selectors.activeOptionIndex(this.state);if(t!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[t]);else{let{dataRef:l}=this.state.options[t];this.actions.onChange(l.current.value)}this.actions.goToOption({focus:H.Specific,idx:t})}},setInputElement:t=>{this.send({type:9,element:t})},setButtonElement:t=>{this.send({type:10,element:t})},setOptionsElement:t=>{this.send({type:11,element:t})}}),Ke(this,"selectors",{activeDescendantId:t=>{var l,a;let i=this.selectors.activeOptionIndex(t);if(i!==null)return t.virtual?(a=t.options.find(d=>!d.dataRef.current.disabled&&t.dataRef.current.compare(d.dataRef.current.value,t.virtual.options[i])))==null?void 0:a.id:(l=t.options[i])==null?void 0:l.id},activeOptionIndex:t=>{if(t.defaultToFirstOption&&t.activeOptionIndex===null&&(t.virtual?t.virtual.options.length>0:t.options.length>0)){if(t.virtual){let{options:a,disabled:i}=t.virtual,d=a.findIndex(x=>{var p;return!((p=i==null?void 0:i(x))!=null&&p)});if(d!==-1)return d}let l=t.options.findIndex(a=>!a.dataRef.current.disabled);if(l!==-1)return l}return t.activeOptionIndex},activeOption:t=>{var l,a;let i=this.selectors.activeOptionIndex(t);return i===null?null:t.virtual?t.virtual.options[i??0]:(a=(l=t.options[i])==null?void 0:l.dataRef.current.value)!=null?a:null},isActive:(t,l,a)=>{var i;let d=this.selectors.activeOptionIndex(t);return d===null?!1:t.virtual?d===t.dataRef.current.calculateIndex(l):((i=t.options[d])==null?void 0:i.id)===a},shouldScrollIntoView:(t,l,a)=>!(t.virtual||t.__demoMode||t.comboboxState!==0||t.activationTrigger===0||!this.selectors.isActive(t,l,a)),didInputMove(t){return t.inputPositionState.kind==="Moved"}});{let t=this.state.id,l=Ye.get(null);this.disposables.add(l.on(pt.Push,a=>{!l.selectors.isTop(a,t)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>l.actions.push(t)),this.on(1,()=>l.actions.pop(t))}this.disposables.group(t=>{this.on(1,l=>{l.inputElement&&(t.dispose(),t.add(eo(l.inputElement,l.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:o,virtual:t=null,__demoMode:l=!1}){var a;return new Ie({id:o,dataRef:{current:{}},comboboxState:l?0:1,isTyping:!1,options:[],virtual:t?{options:t.options,disabled:(a=t.disabled)!=null?a:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:l,inputPositionState:ve.Idle})}reduce(o,t){return ce(t.type,Do,o,t)}}const tt=c.createContext(null);function Se(e){let o=c.useContext(tt);if(o===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,ot),t}return o}function ot({id:e,virtual:o=null,__demoMode:t=!1}){let l=c.useMemo(()=>Ie.new({id:e,virtual:o,__demoMode:t}),[]);return bt(()=>l.dispose()),l}let xe=c.createContext(null);xe.displayName="ComboboxDataContext";function de(e){let o=c.useContext(xe);if(o===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,de),t}return o}let st=c.createContext(null);function _o(e){let o=Se("VirtualProvider"),t=de("VirtualProvider"),{options:l}=t.virtual,a=U(o,b=>b.optionsElement),[i,d]=c.useMemo(()=>{let b=a;if(!b)return[0,0];let m=window.getComputedStyle(b);return[parseFloat(m.paddingBlockStart||m.paddingTop),parseFloat(m.paddingBlockEnd||m.paddingBottom)]},[a]),x=Zt({enabled:l.length!==0,scrollPaddingStart:i,scrollPaddingEnd:d,count:l.length,estimateSize(){return 40},getScrollElement(){return o.state.optionsElement},overscan:12}),[p,f]=c.useState(0);ie(()=>{f(b=>b+1)},[l]);let y=x.getVirtualItems(),N=U(o,b=>b.activationTrigger===oe.Pointer),C=U(o,o.selectors.activeOptionIndex);return y.length===0?null:W.createElement(st.Provider,{value:x},W.createElement("div",{style:{position:"relative",width:"100%",height:`${x.getTotalSize()}px`},ref:b=>{b&&(N||C!==null&&l.length>C&&x.scrollToIndex(C))}},y.map(b=>{var m;return W.createElement(c.Fragment,{key:b.key},W.cloneElement((m=e.children)==null?void 0:m.call(e,{...e.slot,option:l[b.index]}),{key:`${p}-${b.key}`,"data-index":b.index,"aria-setsize":l.length,"aria-posinset":b.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${b.start}px)`,overflowAnchor:"none"}}))})))}let Ao=c.Fragment;function Vo(e,o){let t=c.useId(),l=$t(),{value:a,defaultValue:i,onChange:d,form:x,name:p,by:f,invalid:y=!1,disabled:N=l||!1,onClose:C,__demoMode:b=!1,multiple:m=!1,immediate:P=!1,virtual:u=null,nullable:M,...h}=e,O=Rt(i),[T=m?[]:void 0,L]=Mt(a,d,O),j=ot({id:t,virtual:u,__demoMode:b}),A=c.useRef({static:!1,hold:!1}),$=lo(f),F=_(I=>u?f===null?u.options.indexOf(I):u.options.findIndex(ne=>$(ne,I)):j.state.options.findIndex(ne=>$(ne.dataRef.current.value,I))),G=c.useCallback(I=>ce(V.mode,{[Q.Multi]:()=>T.some(ne=>$(ne,I)),[Q.Single]:()=>$(T,I)}),[T]),q=U(j,I=>I.virtual),E=_(()=>C==null?void 0:C()),V=c.useMemo(()=>({__demoMode:b,immediate:P,optionsPropsRef:A,value:T,defaultValue:O,disabled:N,invalid:y,mode:m?Q.Multi:Q.Single,virtual:u?q:null,onChange:L,isSelected:G,calculateIndex:F,compare:$,onClose:E}),[b,P,A,T,O,N,y,m,u,q,L,G,F,$,E]);ie(()=>{var I;u&&j.send({type:et.UpdateVirtualConfiguration,options:u.options,disabled:(I=u.disabled)!=null?I:null})},[u,u==null?void 0:u.options,u==null?void 0:u.disabled]),ie(()=>{j.state.dataRef.current=V},[V]);let[z,w,Y,le]=U(j,I=>[I.comboboxState,I.buttonElement,I.inputElement,I.optionsElement]),Z=Ye.get(null),ee=U(Z,c.useCallback(I=>Z.selectors.isTop(I,t),[Z,t]));Ft(ee,[w,Y,le],()=>j.actions.closeCombobox());let se=U(j,j.selectors.activeOptionIndex),ae=U(j,j.selectors.activeOption),v=he({open:z===S.Open,disabled:N,invalid:y,activeIndex:se,activeOption:ae,value:T}),[K,R]=Dt(),D=o===null?{}:{ref:o},k=c.useCallback(()=>{if(O!==void 0)return L==null?void 0:L(O)},[L,O]),B=ye();return W.createElement(R,{value:K,props:{htmlFor:Y==null?void 0:Y.id},slot:{open:z===S.Open,disabled:N}},W.createElement(po,null,W.createElement(xe.Provider,{value:V},W.createElement(tt.Provider,{value:j},W.createElement(_t,{value:ce(z,{[S.Open]:Ce.Open,[S.Closed]:Ce.Closed})},p!=null&&W.createElement(At,{disabled:N,data:T!=null?{[p]:T}:{},form:x,onReset:k}),B({ourProps:D,theirProps:h,slot:v,defaultTag:Ao,name:"Combobox"}))))))}let Lo="input";function zo(e,o){var t,l;let a=Se("Combobox.Input"),i=de("Combobox.Input"),d=c.useId(),x=vt(),{id:p=x||`headlessui-combobox-input-${d}`,onChange:f,displayValue:y,disabled:N=i.disabled||!1,autoFocus:C=!1,type:b="text",...m}=e,P=c.useRef(null),u=Oe(P,o,io(),a.actions.setInputElement),[M,h]=U(a,v=>[v.comboboxState,v.isTyping]),O=xt(),T=_(()=>{a.actions.onChange(null),a.state.optionsElement&&(a.state.optionsElement.scrollTop=0),a.actions.goToOption({focus:H.Nothing})}),L=c.useMemo(()=>{var v;return typeof y=="function"&&i.value!==void 0?(v=y(i.value))!=null?v:"":typeof i.value=="string"?i.value:""},[i.value,y]);ke(([v,K],[R,D])=>{if(a.state.isTyping)return;let k=P.current;k&&((D===S.Open&&K===S.Closed||v!==R)&&(k.value=v),requestAnimationFrame(()=>{if(a.state.isTyping||!k||We(k))return;let{selectionStart:B,selectionEnd:I}=k;Math.abs((I??0)-(B??0))===0&&B===0&&k.setSelectionRange(k.value.length,k.value.length)}))},[L,M,h]),ke(([v],[K])=>{if(v===S.Open&&K===S.Closed){if(a.state.isTyping)return;let R=P.current;if(!R)return;let D=R.value,{selectionStart:k,selectionEnd:B,selectionDirection:I}=R;R.value="",R.value=D,I!==null?R.setSelectionRange(k,B,I):R.setSelectionRange(k,B)}},[M]);let j=c.useRef(!1),A=_(()=>{j.current=!0}),$=_(()=>{O.nextFrame(()=>{j.current=!1})}),F=_(v=>{switch(a.actions.setIsTyping(!0),v.key){case X.Enter:if(a.state.comboboxState!==S.Open||j.current)return;if(v.preventDefault(),v.stopPropagation(),a.selectors.activeOptionIndex(a.state)===null){a.actions.closeCombobox();return}a.actions.selectActiveOption(),i.mode===Q.Single&&a.actions.closeCombobox();break;case X.ArrowDown:return v.preventDefault(),v.stopPropagation(),ce(a.state.comboboxState,{[S.Open]:()=>a.actions.goToOption({focus:H.Next}),[S.Closed]:()=>a.actions.openCombobox()});case X.ArrowUp:return v.preventDefault(),v.stopPropagation(),ce(a.state.comboboxState,{[S.Open]:()=>a.actions.goToOption({focus:H.Previous}),[S.Closed]:()=>{re.flushSync(()=>a.actions.openCombobox()),i.value||a.actions.goToOption({focus:H.Last})}});case X.Home:if(a.state.comboboxState===S.Closed||v.shiftKey)break;return v.preventDefault(),v.stopPropagation(),a.actions.goToOption({focus:H.First});case X.PageUp:return v.preventDefault(),v.stopPropagation(),a.actions.goToOption({focus:H.First});case X.End:if(a.state.comboboxState===S.Closed||v.shiftKey)break;return v.preventDefault(),v.stopPropagation(),a.actions.goToOption({focus:H.Last});case X.PageDown:return v.preventDefault(),v.stopPropagation(),a.actions.goToOption({focus:H.Last});case X.Escape:return a.state.comboboxState!==S.Open?void 0:(v.preventDefault(),a.state.optionsElement&&!i.optionsPropsRef.current.static&&v.stopPropagation(),i.mode===Q.Single&&i.value===null&&T(),a.actions.closeCombobox());case X.Tab:if(a.actions.setIsTyping(!1),a.state.comboboxState!==S.Open)return;i.mode===Q.Single&&a.state.activationTrigger!==oe.Focus&&a.actions.selectActiveOption(),a.actions.closeCombobox();break}}),G=_(v=>{f==null||f(v),i.mode===Q.Single&&v.target.value===""&&T(),a.actions.openCombobox()}),q=_(v=>{var K,R,D;let k=(K=v.relatedTarget)!=null?K:$e.find(B=>B!==v.currentTarget);if(!((R=a.state.optionsElement)!=null&&R.contains(k))&&!((D=a.state.buttonElement)!=null&&D.contains(k))&&a.state.comboboxState===S.Open)return v.preventDefault(),i.mode===Q.Single&&i.value===null&&T(),a.actions.closeCombobox()}),E=_(v=>{var K,R,D;let k=(K=v.relatedTarget)!=null?K:$e.find(B=>B!==v.currentTarget);(R=a.state.buttonElement)!=null&&R.contains(k)||(D=a.state.optionsElement)!=null&&D.contains(k)||i.disabled||i.immediate&&a.state.comboboxState!==S.Open&&O.microTask(()=>{re.flushSync(()=>a.actions.openCombobox()),a.actions.setActivationTrigger(oe.Focus)})}),V=Ee(),z=gt(),{isFocused:w,focusProps:Y}=Xe({autoFocus:C}),{isHovered:le,hoverProps:Z}=Je({isDisabled:N}),ee=U(a,v=>v.optionsElement),se=he({open:M===S.Open,disabled:N,invalid:i.invalid,hover:le,focus:w,autofocus:C}),ae=Pe({ref:u,id:p,role:"combobox",type:b,"aria-controls":ee==null?void 0:ee.id,"aria-expanded":M===S.Open,"aria-activedescendant":U(a,a.selectors.activeDescendantId),"aria-labelledby":V,"aria-describedby":z,"aria-autocomplete":"list",defaultValue:(l=(t=e.defaultValue)!=null?t:i.defaultValue!==void 0?y==null?void 0:y(i.defaultValue):null)!=null?l:i.defaultValue,disabled:N||void 0,autoFocus:C,onCompositionStart:A,onCompositionEnd:$,onKeyDown:F,onChange:G,onFocus:E,onBlur:q},Y,Z);return ye()({ourProps:ae,theirProps:m,slot:se,defaultTag:Lo,name:"Combobox.Input"})}let Bo="button";function Ho(e,o){let t=Se("Combobox.Button"),l=de("Combobox.Button"),[a,i]=c.useState(null),d=Oe(o,i,t.actions.setButtonElement),x=c.useId(),{id:p=`headlessui-combobox-button-${x}`,disabled:f=l.disabled||!1,autoFocus:y=!1,...N}=e,[C,b,m]=U(t,E=>[E.comboboxState,E.inputElement,E.optionsElement]),P=Ze(b),u=C===S.Open;oo(u,{trigger:a,action:c.useCallback(E=>{if(a!=null&&a.contains(E.target))return me.Ignore;if(b!=null&&b.contains(E.target))return me.Ignore;let V=E.target.closest('[role="option"]:not([data-disabled])');return ht(V)?me.Select(V):m!=null&&m.contains(E.target)?me.Ignore:me.Close},[a,b,m]),close:t.actions.closeCombobox,select:t.actions.selectActiveOption});let M=_(E=>{switch(E.key){case X.Space:case X.Enter:E.preventDefault(),E.stopPropagation(),t.state.comboboxState===S.Closed&&re.flushSync(()=>t.actions.openCombobox()),P();return;case X.ArrowDown:E.preventDefault(),E.stopPropagation(),t.state.comboboxState===S.Closed&&(re.flushSync(()=>t.actions.openCombobox()),t.state.dataRef.current.value||t.actions.goToOption({focus:H.First})),P();return;case X.ArrowUp:E.preventDefault(),E.stopPropagation(),t.state.comboboxState===S.Closed&&(re.flushSync(()=>t.actions.openCombobox()),t.state.dataRef.current.value||t.actions.goToOption({focus:H.Last})),P();return;case X.Escape:if(t.state.comboboxState!==S.Open)return;E.preventDefault(),t.state.optionsElement&&!l.optionsPropsRef.current.static&&E.stopPropagation(),re.flushSync(()=>t.actions.closeCombobox()),P();return;default:return}}),h=so(()=>{t.state.comboboxState===S.Open?t.actions.closeCombobox():t.actions.openCombobox(),P()}),O=Ee([p]),{isFocusVisible:T,focusProps:L}=Xe({autoFocus:y}),{isHovered:j,hoverProps:A}=Je({isDisabled:f}),{pressed:$,pressProps:F}=yt({disabled:f}),G=he({open:C===S.Open,active:$||C===S.Open,disabled:f,invalid:l.invalid,value:l.value,hover:j,focus:T}),q=Pe({ref:d,id:p,type:St(e,a),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":m==null?void 0:m.id,"aria-expanded":C===S.Open,"aria-labelledby":O,disabled:f||void 0,autoFocus:y,onKeyDown:M},h,L,A,F);return ye()({ourProps:q,theirProps:N,slot:G,defaultTag:Bo,name:"Combobox.Button"})}let Uo="div",Go=Me.RenderStrategy|Me.Static;function qo(e,o){var t,l,a;let i=c.useId(),{id:d=`headlessui-combobox-options-${i}`,hold:x=!1,anchor:p,portal:f=!1,modal:y=!0,transition:N=!1,...C}=e,b=Se("Combobox.Options"),m=de("Combobox.Options"),P=ro(p);P&&(f=!0);let[u,M]=co(P),[h,O]=c.useState(null),T=uo(),L=Oe(o,P?u:null,b.actions.setOptionsElement,O),[j,A,$,F,G]=U(b,s=>[s.comboboxState,s.inputElement,s.buttonElement,s.optionsElement,s.activationTrigger]),q=Re(A||$),E=Re(F),V=Ct(),[z,w]=Ot(N,h,V!==null?(V&Ce.Open)===Ce.Open:j===S.Open);wt(z,A,b.actions.closeCombobox);let Y=m.__demoMode?!1:y&&j===S.Open;Nt(Y,E);let le=m.__demoMode?!1:y&&j===S.Open;jt(le,{allowed:c.useCallback(()=>[A,$,F],[A,$,F])});let Z=U(b,b.selectors.didInputMove)?!1:z;ie(()=>{var s;m.optionsPropsRef.current.static=(s=e.static)!=null?s:!1},[m.optionsPropsRef,e.static]),ie(()=>{m.optionsPropsRef.current.hold=x},[m.optionsPropsRef,x]),mo(j===S.Open,{container:F,accept(s){return s.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:s.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(s){s.setAttribute("role","none")}});let ee=Ee([$==null?void 0:$.id]),se=he({open:j===S.Open,option:void 0}),ae=_(()=>{b.actions.setActivationTrigger(oe.Pointer)}),v=_(s=>{s.preventDefault(),b.actions.setActivationTrigger(oe.Pointer)}),K=Pe(P?T():{},{"aria-labelledby":ee,role:"listbox","aria-multiselectable":m.mode===Q.Multi?!0:void 0,id:d,ref:L,style:{...C.style,...M,"--input-width":He(z,A,!0).width,"--button-width":He(z,$,!0).width},onWheel:G===oe.Pointer?void 0:ae,onMouseDown:v,...Et(w)}),R=z&&j===S.Closed&&!e.static,D=Ue(R,(t=m.virtual)==null?void 0:t.options),k=Ue(R,m.value),B=c.useCallback(s=>m.compare(k,s),[m.compare,k]),I=c.useMemo(()=>{if(!m.virtual)return m;if(D===void 0)throw new Error("Missing `options` in virtual mode");return D!==m.virtual.options?{...m,virtual:{...m.virtual,options:D}}:m},[m,D,(l=m.virtual)==null?void 0:l.options]);m.virtual&&Object.assign(C,{children:W.createElement(xe.Provider,{value:I},W.createElement(_o,{slot:se},C.children))});let ne=ye(),we=c.useMemo(()=>m.mode===Q.Multi?m:{...m,isSelected:B},[m,B]);return W.createElement(Pt,{enabled:f?e.static||z:!1,ownerDocument:q},W.createElement(xe.Provider,{value:we},ne({ourProps:K,theirProps:{...C,children:W.createElement(bo,{freeze:R},typeof C.children=="function"?(a=C.children)==null?void 0:a.call(C,se):C.children)},slot:se,defaultTag:Uo,features:Go,visible:Z,name:"Combobox.Options"})))}let Ko="div";function Wo(e,o){var t,l,a;let i=de("Combobox.Option"),d=Se("Combobox.Option"),x=c.useId(),{id:p=`headlessui-combobox-option-${x}`,value:f,disabled:y=(a=(l=(t=i.virtual)==null?void 0:t.disabled)==null?void 0:l.call(t,f))!=null?a:!1,order:N=null,...C}=e,[b]=U(d,w=>[w.inputElement]),m=Ze(b),P=U(d,c.useCallback(w=>d.selectors.isActive(w,f,p),[f,p])),u=i.isSelected(f),M=c.useRef(null),h=It({disabled:y,value:f,domRef:M,order:N}),O=c.useContext(st),T=Oe(o,M,O?O.measureElement:null),L=_(()=>{d.actions.setIsTyping(!1),d.actions.onChange(f)});ie(()=>d.actions.registerOption(p,h),[h,p]);let j=U(d,c.useCallback(w=>d.selectors.shouldScrollIntoView(w,f,p),[f,p]));ie(()=>{if(j)return Tt().requestAnimationFrame(()=>{var w,Y;(Y=(w=M.current)==null?void 0:w.scrollIntoView)==null||Y.call(w,{block:"nearest"})})},[j,M]);let A=_(w=>{w.preventDefault(),w.button===ao.Left&&(y||(L(),kt()||requestAnimationFrame(()=>m()),i.mode===Q.Single&&d.actions.closeCombobox()))}),$=_(()=>{if(y)return d.actions.goToOption({focus:H.Nothing});let w=i.calculateIndex(f);d.actions.goToOption({focus:H.Specific,idx:w})}),F=no(),G=_(w=>F.update(w)),q=_(w=>{if(!F.wasMoved(w)||y||P&&d.state.activationTrigger===oe.Pointer)return;let Y=i.calculateIndex(f);d.actions.goToOption({focus:H.Specific,idx:Y},oe.Pointer)}),E=_(w=>{F.wasMoved(w)&&(y||P&&(i.optionsPropsRef.current.hold||d.state.activationTrigger===oe.Pointer&&d.actions.goToOption({focus:H.Nothing})))}),V=he({active:P,focus:P,selected:u,disabled:y}),z={id:p,ref:T,role:"option",tabIndex:y===!0?void 0:-1,"aria-disabled":y===!0?!0:void 0,"aria-selected":u,disabled:void 0,onMouseDown:A,onFocus:$,onPointerEnter:G,onMouseEnter:G,onPointerMove:q,onMouseMove:q,onPointerLeave:E,onMouseLeave:E};return ye()({ourProps:z,theirProps:C,slot:V,defaultTag:Ko,name:"Combobox.Option"})}let Yo=ge(Vo),at=ge(Ho),nt=ge(zo),Xo=ft,lt=ge(qo),it=ge(Wo),Jo=Object.assign(Yo,{Input:nt,Button:at,Label:Xo,Options:lt,Option:it});/** +import{r as c,aU as _,aV as dt,aW as Te,aX as We,aY as ut,aZ as ce,a_ as Ye,a$ as pt,b0 as mt,b1 as bt,b2 as ge,b3 as ft,b4 as vt,b5 as Oe,b6 as U,b7 as xt,b8 as ke,b9 as X,ba as re,bb as $e,bc as Ee,bd as gt,be as Xe,bf as Je,bg as he,bh as Pe,bi as ye,bj as ht,bk as yt,bl as St,bm as Re,bn as Ct,bo as Ot,bp as Ce,bq as wt,br as Nt,bs as jt,bt as ie,bu as Et,bv as W,bw as Pt,bx as It,by as Tt,bz as kt,bA as $t,bB as Rt,bC as Mt,bD as Ft,bE as Dt,bF as _t,bG as At,bH as Me,e as Vt,j as a,c as J,aF as Lt,a0 as zt,bI as Bt,a1 as Ht,bJ as Ut,Q as Gt,a6 as qt,ac as Kt,ad as Wt,aA as Yt,aS as Xt,ae as Fe,P as De,bK as _e,bL as Ae,B as Ne,bM as Ve,a7 as Le,bN as ze,a8 as Jt}from"./index-D33fcA3L.js";import{c as Qt}from"./node-types-BoqnL0Eg.js";import{u as Zt}from"./chevron-up-DyOgmQ5-.js";import{c as H,p as eo,a as ve,f as Be,b as to,L as oo,S as me,s as so,g as no,u as ao,d as lo}from"./element-movement-BL6huHzq.js";import{F as io,y as ro,R as co,T as uo,w as He,A as po}from"./map-pin-B_Rx-xpd.js";import{F as mo}from"./use-tree-walker-DjLWwhV9.js";import{u as Ue,s as bo}from"./frozen-C10EXZ59.js";import{g as Qe,u as fo,P as vo}from"./PacketList-CbRsdi2q.js";import{useGetDecodedContent as xo,useResolveSource as go}from"./usePipelineStore-DDHEHTlZ.js";import{c as ho,a as yo,D as So,b as Co}from"./AnalyzerFilterPanel-Cq7b3I2L.js";import{u as Oo,r as wo}from"./consumer-registry-DXaeZxMm.js";import{A as No}from"./arrow-down-BI9NpupK.js";import{A as jo}from"./arrow-right-aT_K-Mjc.js";import{P as Eo,a as Po,B as Io,C as Ge}from"./PageLayout-CRN-E5xi.js";import{T as To,M as ko}from"./MqttModeBadge-BtcQeS2v.js";import{F as qe}from"./funnel-BBIwSMOb.js";import{R as $o}from"./route-5o9tQENO.js";import{S as Ro}from"./search-DN8guzpX.js";import"./primitives-C8YoaXqf.js";import"./badge-colors-Dl76Mz8m.js";import"./chat-utils-DIy1-SG1.js";import"./SignalIndicator-DmWlnzMv.js";import"./arrow-up-C4DdHKHn.js";import"./chevron-right-D4kUPDBw.js";import"./payload-detail-DbnSd5NL.js";import"./circle-question-mark-CO80vHQp.js";import"./layers-DguV5fdN.js";import"./hash-Ba9bZo8v.js";import"./clock-D_m2QiHa.js";import"./activity-D6ySIfuC.js";import"./database-Bm4-qoOy.js";import"./useMapViewStore-Ey8vE9rr.js";import"./index-5slIee7x.js";import"./index-DuiHY5wq.js";import"./shield-Ceq641wy.js";import"./zap-C-Mue2DZ.js";function Ze(e){let o=c.useRef({value:"",selectionStart:null,selectionEnd:null});return dt(e,"blur",t=>{let l=t.target;Te(l)&&(o.current={value:l.value,selectionStart:l.selectionStart,selectionEnd:l.selectionEnd})}),_(()=>{if(!We(e)&&Te(e)&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==o.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:t,selectionEnd:l}=o.current;t!==null&&l!==null&&e.setSelectionRange(t,l)}o.current={value:"",selectionStart:null,selectionEnd:null}}})}var Mo=Object.defineProperty,Fo=(e,o,t)=>o in e?Mo(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,Ke=(e,o,t)=>(Fo(e,typeof o!="symbol"?o+"":o,t),t),S=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(S||{}),Q=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Q||{}),oe=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(oe||{}),et=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.DefaultToFirstOption=6]="DefaultToFirstOption",e[e.SetActivationTrigger=7]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=8]="UpdateVirtualConfiguration",e[e.SetInputElement=9]="SetInputElement",e[e.SetButtonElement=10]="SetButtonElement",e[e.SetOptionsElement=11]="SetOptionsElement",e[e.MarkInputAsMoved=12]="MarkInputAsMoved",e))(et||{});function je(e,o=t=>t){let t=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,l=o(e.options.slice()),n=l.length>0&&l[0].dataRef.current.order!==null?l.sort((d,x)=>d.dataRef.current.order-x.dataRef.current.order):mt(l,d=>d.dataRef.current.domRef.current),i=t?n.indexOf(t):null;return i===-1&&(i=null),{options:n,activeOptionIndex:i}}let Do={1(e){var o;if((o=e.dataRef.current)!=null&&o.disabled||e.comboboxState===1)return e;let t=e.inputElement?ve.Tracked(to(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:t,__demoMode:!1}},0(e){var o,t;if((o=e.dataRef.current)!=null&&o.disabled||e.comboboxState===0)return e;if((t=e.dataRef.current)!=null&&t.value){let l=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(l!==-1)return{...e,activeOptionIndex:l,comboboxState:0,__demoMode:!1,inputPositionState:ve.Idle}}return{...e,comboboxState:0,inputPositionState:ve.Idle,__demoMode:!1}},3(e,o){return e.isTyping===o.isTyping?e:{...e,isTyping:o.isTyping}},2(e,o){var t,l,n,i;if((t=e.dataRef.current)!=null&&t.disabled||e.optionsElement&&!((l=e.dataRef.current)!=null&&l.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:f,disabled:y}=e.virtual,N=o.focus===H.Specific?o.idx:Be(o,{resolveItems:()=>f,resolveActiveIndex:()=>{var b,m;return(m=(b=e.activeOptionIndex)!=null?b:f.findIndex(P=>!y(P)))!=null?m:null},resolveDisabled:y,resolveId(){throw new Error("Function not implemented.")}}),C=(n=o.trigger)!=null?n:2;return e.activeOptionIndex===N&&e.activationTrigger===C?e:{...e,activeOptionIndex:N,activationTrigger:C,isTyping:!1,__demoMode:!1}}let d=je(e);if(d.activeOptionIndex===null){let f=d.options.findIndex(y=>!y.dataRef.current.disabled);f!==-1&&(d.activeOptionIndex=f)}let x=o.focus===H.Specific?o.idx:Be(o,{resolveItems:()=>d.options,resolveActiveIndex:()=>d.activeOptionIndex,resolveId:f=>f.id,resolveDisabled:f=>f.dataRef.current.disabled}),p=(i=o.trigger)!=null?i:2;return e.activeOptionIndex===x&&e.activationTrigger===p?e:{...e,...d,isTyping:!1,activeOptionIndex:x,activationTrigger:p,__demoMode:!1}},4:(e,o)=>{var t,l,n,i;if((t=e.dataRef.current)!=null&&t.virtual)return{...e,options:[...e.options,o.payload]};let d=o.payload,x=je(e,f=>(f.push(d),f));e.activeOptionIndex===null&&(n=(l=e.dataRef.current).isSelected)!=null&&n.call(l,o.payload.dataRef.current.value)&&(x.activeOptionIndex=x.options.indexOf(d));let p={...e,...x,activationTrigger:2};return(i=e.dataRef.current)!=null&&i.__demoMode&&e.dataRef.current.value===void 0&&(p.activeOptionIndex=0),p},5:(e,o)=>{var t;if((t=e.dataRef.current)!=null&&t.virtual)return{...e,options:e.options.filter(n=>n.id!==o.id)};let l=je(e,n=>{let i=n.findIndex(d=>d.id===o.id);return i!==-1&&n.splice(i,1),n});return{...e,...l,activationTrigger:2}},6:(e,o)=>e.defaultToFirstOption===o.value?e:{...e,defaultToFirstOption:o.value},7:(e,o)=>e.activationTrigger===o.trigger?e:{...e,activationTrigger:o.trigger},8:(e,o)=>{var t,l;if(e.virtual===null)return{...e,virtual:{options:o.options,disabled:(t=o.disabled)!=null?t:()=>!1}};if(e.virtual.options===o.options&&e.virtual.disabled===o.disabled)return e;let n=e.activeOptionIndex;if(e.activeOptionIndex!==null){let i=o.options.indexOf(e.virtual.options[e.activeOptionIndex]);i!==-1?n=i:n=null}return{...e,activeOptionIndex:n,virtual:{options:o.options,disabled:(l=o.disabled)!=null?l:()=>!1}}},9:(e,o)=>e.inputElement===o.element?e:{...e,inputElement:o.element},10:(e,o)=>e.buttonElement===o.element?e:{...e,buttonElement:o.element},11:(e,o)=>e.optionsElement===o.element?e:{...e,optionsElement:o.element},12(e){return e.inputPositionState.kind!=="Tracked"?e:{...e,inputPositionState:ve.Moved}}};class Ie extends ut{constructor(o){super(o),Ke(this,"actions",{onChange:t=>{let{onChange:l,compare:n,mode:i,value:d}=this.state.dataRef.current;return ce(i,{0:()=>l==null?void 0:l(t),1:()=>{let x=d.slice(),p=x.findIndex(f=>n(f,t));return p===-1?x.push(t):x.splice(p,1),l==null?void 0:l(x)}})},registerOption:(t,l)=>(this.send({type:4,payload:{id:t,dataRef:l}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(l.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:t})}),goToOption:(t,l)=>(this.send({type:6,value:!1}),this.send({type:2,...t,trigger:l})),setIsTyping:t=>{this.send({type:3,isTyping:t})},closeCombobox:()=>{var t,l;this.send({type:1}),this.send({type:6,value:!1}),(l=(t=this.state.dataRef.current).onClose)==null||l.call(t)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:t=>{this.send({type:7,trigger:t})},selectActiveOption:()=>{let t=this.selectors.activeOptionIndex(this.state);if(t!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[t]);else{let{dataRef:l}=this.state.options[t];this.actions.onChange(l.current.value)}this.actions.goToOption({focus:H.Specific,idx:t})}},setInputElement:t=>{this.send({type:9,element:t})},setButtonElement:t=>{this.send({type:10,element:t})},setOptionsElement:t=>{this.send({type:11,element:t})}}),Ke(this,"selectors",{activeDescendantId:t=>{var l,n;let i=this.selectors.activeOptionIndex(t);if(i!==null)return t.virtual?(n=t.options.find(d=>!d.dataRef.current.disabled&&t.dataRef.current.compare(d.dataRef.current.value,t.virtual.options[i])))==null?void 0:n.id:(l=t.options[i])==null?void 0:l.id},activeOptionIndex:t=>{if(t.defaultToFirstOption&&t.activeOptionIndex===null&&(t.virtual?t.virtual.options.length>0:t.options.length>0)){if(t.virtual){let{options:n,disabled:i}=t.virtual,d=n.findIndex(x=>{var p;return!((p=i==null?void 0:i(x))!=null&&p)});if(d!==-1)return d}let l=t.options.findIndex(n=>!n.dataRef.current.disabled);if(l!==-1)return l}return t.activeOptionIndex},activeOption:t=>{var l,n;let i=this.selectors.activeOptionIndex(t);return i===null?null:t.virtual?t.virtual.options[i??0]:(n=(l=t.options[i])==null?void 0:l.dataRef.current.value)!=null?n:null},isActive:(t,l,n)=>{var i;let d=this.selectors.activeOptionIndex(t);return d===null?!1:t.virtual?d===t.dataRef.current.calculateIndex(l):((i=t.options[d])==null?void 0:i.id)===n},shouldScrollIntoView:(t,l,n)=>!(t.virtual||t.__demoMode||t.comboboxState!==0||t.activationTrigger===0||!this.selectors.isActive(t,l,n)),didInputMove(t){return t.inputPositionState.kind==="Moved"}});{let t=this.state.id,l=Ye.get(null);this.disposables.add(l.on(pt.Push,n=>{!l.selectors.isTop(n,t)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>l.actions.push(t)),this.on(1,()=>l.actions.pop(t))}this.disposables.group(t=>{this.on(1,l=>{l.inputElement&&(t.dispose(),t.add(eo(l.inputElement,l.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:o,virtual:t=null,__demoMode:l=!1}){var n;return new Ie({id:o,dataRef:{current:{}},comboboxState:l?0:1,isTyping:!1,options:[],virtual:t?{options:t.options,disabled:(n=t.disabled)!=null?n:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:l,inputPositionState:ve.Idle})}reduce(o,t){return ce(t.type,Do,o,t)}}const tt=c.createContext(null);function Se(e){let o=c.useContext(tt);if(o===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,ot),t}return o}function ot({id:e,virtual:o=null,__demoMode:t=!1}){let l=c.useMemo(()=>Ie.new({id:e,virtual:o,__demoMode:t}),[]);return bt(()=>l.dispose()),l}let xe=c.createContext(null);xe.displayName="ComboboxDataContext";function de(e){let o=c.useContext(xe);if(o===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,de),t}return o}let st=c.createContext(null);function _o(e){let o=Se("VirtualProvider"),t=de("VirtualProvider"),{options:l}=t.virtual,n=U(o,b=>b.optionsElement),[i,d]=c.useMemo(()=>{let b=n;if(!b)return[0,0];let m=window.getComputedStyle(b);return[parseFloat(m.paddingBlockStart||m.paddingTop),parseFloat(m.paddingBlockEnd||m.paddingBottom)]},[n]),x=Zt({enabled:l.length!==0,scrollPaddingStart:i,scrollPaddingEnd:d,count:l.length,estimateSize(){return 40},getScrollElement(){return o.state.optionsElement},overscan:12}),[p,f]=c.useState(0);ie(()=>{f(b=>b+1)},[l]);let y=x.getVirtualItems(),N=U(o,b=>b.activationTrigger===oe.Pointer),C=U(o,o.selectors.activeOptionIndex);return y.length===0?null:W.createElement(st.Provider,{value:x},W.createElement("div",{style:{position:"relative",width:"100%",height:`${x.getTotalSize()}px`},ref:b=>{b&&(N||C!==null&&l.length>C&&x.scrollToIndex(C))}},y.map(b=>{var m;return W.createElement(c.Fragment,{key:b.key},W.cloneElement((m=e.children)==null?void 0:m.call(e,{...e.slot,option:l[b.index]}),{key:`${p}-${b.key}`,"data-index":b.index,"aria-setsize":l.length,"aria-posinset":b.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${b.start}px)`,overflowAnchor:"none"}}))})))}let Ao=c.Fragment;function Vo(e,o){let t=c.useId(),l=$t(),{value:n,defaultValue:i,onChange:d,form:x,name:p,by:f,invalid:y=!1,disabled:N=l||!1,onClose:C,__demoMode:b=!1,multiple:m=!1,immediate:P=!1,virtual:u=null,nullable:M,...h}=e,O=Rt(i),[T=m?[]:void 0,L]=Mt(n,d,O),j=ot({id:t,virtual:u,__demoMode:b}),A=c.useRef({static:!1,hold:!1}),$=lo(f),F=_(I=>u?f===null?u.options.indexOf(I):u.options.findIndex(ae=>$(ae,I)):j.state.options.findIndex(ae=>$(ae.dataRef.current.value,I))),G=c.useCallback(I=>ce(V.mode,{[Q.Multi]:()=>T.some(ae=>$(ae,I)),[Q.Single]:()=>$(T,I)}),[T]),q=U(j,I=>I.virtual),E=_(()=>C==null?void 0:C()),V=c.useMemo(()=>({__demoMode:b,immediate:P,optionsPropsRef:A,value:T,defaultValue:O,disabled:N,invalid:y,mode:m?Q.Multi:Q.Single,virtual:u?q:null,onChange:L,isSelected:G,calculateIndex:F,compare:$,onClose:E}),[b,P,A,T,O,N,y,m,u,q,L,G,F,$,E]);ie(()=>{var I;u&&j.send({type:et.UpdateVirtualConfiguration,options:u.options,disabled:(I=u.disabled)!=null?I:null})},[u,u==null?void 0:u.options,u==null?void 0:u.disabled]),ie(()=>{j.state.dataRef.current=V},[V]);let[z,w,Y,le]=U(j,I=>[I.comboboxState,I.buttonElement,I.inputElement,I.optionsElement]),Z=Ye.get(null),ee=U(Z,c.useCallback(I=>Z.selectors.isTop(I,t),[Z,t]));Ft(ee,[w,Y,le],()=>j.actions.closeCombobox());let se=U(j,j.selectors.activeOptionIndex),ne=U(j,j.selectors.activeOption),v=he({open:z===S.Open,disabled:N,invalid:y,activeIndex:se,activeOption:ne,value:T}),[K,R]=Dt(),D=o===null?{}:{ref:o},k=c.useCallback(()=>{if(O!==void 0)return L==null?void 0:L(O)},[L,O]),B=ye();return W.createElement(R,{value:K,props:{htmlFor:Y==null?void 0:Y.id},slot:{open:z===S.Open,disabled:N}},W.createElement(po,null,W.createElement(xe.Provider,{value:V},W.createElement(tt.Provider,{value:j},W.createElement(_t,{value:ce(z,{[S.Open]:Ce.Open,[S.Closed]:Ce.Closed})},p!=null&&W.createElement(At,{disabled:N,data:T!=null?{[p]:T}:{},form:x,onReset:k}),B({ourProps:D,theirProps:h,slot:v,defaultTag:Ao,name:"Combobox"}))))))}let Lo="input";function zo(e,o){var t,l;let n=Se("Combobox.Input"),i=de("Combobox.Input"),d=c.useId(),x=vt(),{id:p=x||`headlessui-combobox-input-${d}`,onChange:f,displayValue:y,disabled:N=i.disabled||!1,autoFocus:C=!1,type:b="text",...m}=e,P=c.useRef(null),u=Oe(P,o,io(),n.actions.setInputElement),[M,h]=U(n,v=>[v.comboboxState,v.isTyping]),O=xt(),T=_(()=>{n.actions.onChange(null),n.state.optionsElement&&(n.state.optionsElement.scrollTop=0),n.actions.goToOption({focus:H.Nothing})}),L=c.useMemo(()=>{var v;return typeof y=="function"&&i.value!==void 0?(v=y(i.value))!=null?v:"":typeof i.value=="string"?i.value:""},[i.value,y]);ke(([v,K],[R,D])=>{if(n.state.isTyping)return;let k=P.current;k&&((D===S.Open&&K===S.Closed||v!==R)&&(k.value=v),requestAnimationFrame(()=>{if(n.state.isTyping||!k||We(k))return;let{selectionStart:B,selectionEnd:I}=k;Math.abs((I??0)-(B??0))===0&&B===0&&k.setSelectionRange(k.value.length,k.value.length)}))},[L,M,h]),ke(([v],[K])=>{if(v===S.Open&&K===S.Closed){if(n.state.isTyping)return;let R=P.current;if(!R)return;let D=R.value,{selectionStart:k,selectionEnd:B,selectionDirection:I}=R;R.value="",R.value=D,I!==null?R.setSelectionRange(k,B,I):R.setSelectionRange(k,B)}},[M]);let j=c.useRef(!1),A=_(()=>{j.current=!0}),$=_(()=>{O.nextFrame(()=>{j.current=!1})}),F=_(v=>{switch(n.actions.setIsTyping(!0),v.key){case X.Enter:if(n.state.comboboxState!==S.Open||j.current)return;if(v.preventDefault(),v.stopPropagation(),n.selectors.activeOptionIndex(n.state)===null){n.actions.closeCombobox();return}n.actions.selectActiveOption(),i.mode===Q.Single&&n.actions.closeCombobox();break;case X.ArrowDown:return v.preventDefault(),v.stopPropagation(),ce(n.state.comboboxState,{[S.Open]:()=>n.actions.goToOption({focus:H.Next}),[S.Closed]:()=>n.actions.openCombobox()});case X.ArrowUp:return v.preventDefault(),v.stopPropagation(),ce(n.state.comboboxState,{[S.Open]:()=>n.actions.goToOption({focus:H.Previous}),[S.Closed]:()=>{re.flushSync(()=>n.actions.openCombobox()),i.value||n.actions.goToOption({focus:H.Last})}});case X.Home:if(n.state.comboboxState===S.Closed||v.shiftKey)break;return v.preventDefault(),v.stopPropagation(),n.actions.goToOption({focus:H.First});case X.PageUp:return v.preventDefault(),v.stopPropagation(),n.actions.goToOption({focus:H.First});case X.End:if(n.state.comboboxState===S.Closed||v.shiftKey)break;return v.preventDefault(),v.stopPropagation(),n.actions.goToOption({focus:H.Last});case X.PageDown:return v.preventDefault(),v.stopPropagation(),n.actions.goToOption({focus:H.Last});case X.Escape:return n.state.comboboxState!==S.Open?void 0:(v.preventDefault(),n.state.optionsElement&&!i.optionsPropsRef.current.static&&v.stopPropagation(),i.mode===Q.Single&&i.value===null&&T(),n.actions.closeCombobox());case X.Tab:if(n.actions.setIsTyping(!1),n.state.comboboxState!==S.Open)return;i.mode===Q.Single&&n.state.activationTrigger!==oe.Focus&&n.actions.selectActiveOption(),n.actions.closeCombobox();break}}),G=_(v=>{f==null||f(v),i.mode===Q.Single&&v.target.value===""&&T(),n.actions.openCombobox()}),q=_(v=>{var K,R,D;let k=(K=v.relatedTarget)!=null?K:$e.find(B=>B!==v.currentTarget);if(!((R=n.state.optionsElement)!=null&&R.contains(k))&&!((D=n.state.buttonElement)!=null&&D.contains(k))&&n.state.comboboxState===S.Open)return v.preventDefault(),i.mode===Q.Single&&i.value===null&&T(),n.actions.closeCombobox()}),E=_(v=>{var K,R,D;let k=(K=v.relatedTarget)!=null?K:$e.find(B=>B!==v.currentTarget);(R=n.state.buttonElement)!=null&&R.contains(k)||(D=n.state.optionsElement)!=null&&D.contains(k)||i.disabled||i.immediate&&n.state.comboboxState!==S.Open&&O.microTask(()=>{re.flushSync(()=>n.actions.openCombobox()),n.actions.setActivationTrigger(oe.Focus)})}),V=Ee(),z=gt(),{isFocused:w,focusProps:Y}=Xe({autoFocus:C}),{isHovered:le,hoverProps:Z}=Je({isDisabled:N}),ee=U(n,v=>v.optionsElement),se=he({open:M===S.Open,disabled:N,invalid:i.invalid,hover:le,focus:w,autofocus:C}),ne=Pe({ref:u,id:p,role:"combobox",type:b,"aria-controls":ee==null?void 0:ee.id,"aria-expanded":M===S.Open,"aria-activedescendant":U(n,n.selectors.activeDescendantId),"aria-labelledby":V,"aria-describedby":z,"aria-autocomplete":"list",defaultValue:(l=(t=e.defaultValue)!=null?t:i.defaultValue!==void 0?y==null?void 0:y(i.defaultValue):null)!=null?l:i.defaultValue,disabled:N||void 0,autoFocus:C,onCompositionStart:A,onCompositionEnd:$,onKeyDown:F,onChange:G,onFocus:E,onBlur:q},Y,Z);return ye()({ourProps:ne,theirProps:m,slot:se,defaultTag:Lo,name:"Combobox.Input"})}let Bo="button";function Ho(e,o){let t=Se("Combobox.Button"),l=de("Combobox.Button"),[n,i]=c.useState(null),d=Oe(o,i,t.actions.setButtonElement),x=c.useId(),{id:p=`headlessui-combobox-button-${x}`,disabled:f=l.disabled||!1,autoFocus:y=!1,...N}=e,[C,b,m]=U(t,E=>[E.comboboxState,E.inputElement,E.optionsElement]),P=Ze(b),u=C===S.Open;oo(u,{trigger:n,action:c.useCallback(E=>{if(n!=null&&n.contains(E.target))return me.Ignore;if(b!=null&&b.contains(E.target))return me.Ignore;let V=E.target.closest('[role="option"]:not([data-disabled])');return ht(V)?me.Select(V):m!=null&&m.contains(E.target)?me.Ignore:me.Close},[n,b,m]),close:t.actions.closeCombobox,select:t.actions.selectActiveOption});let M=_(E=>{switch(E.key){case X.Space:case X.Enter:E.preventDefault(),E.stopPropagation(),t.state.comboboxState===S.Closed&&re.flushSync(()=>t.actions.openCombobox()),P();return;case X.ArrowDown:E.preventDefault(),E.stopPropagation(),t.state.comboboxState===S.Closed&&(re.flushSync(()=>t.actions.openCombobox()),t.state.dataRef.current.value||t.actions.goToOption({focus:H.First})),P();return;case X.ArrowUp:E.preventDefault(),E.stopPropagation(),t.state.comboboxState===S.Closed&&(re.flushSync(()=>t.actions.openCombobox()),t.state.dataRef.current.value||t.actions.goToOption({focus:H.Last})),P();return;case X.Escape:if(t.state.comboboxState!==S.Open)return;E.preventDefault(),t.state.optionsElement&&!l.optionsPropsRef.current.static&&E.stopPropagation(),re.flushSync(()=>t.actions.closeCombobox()),P();return;default:return}}),h=so(()=>{t.state.comboboxState===S.Open?t.actions.closeCombobox():t.actions.openCombobox(),P()}),O=Ee([p]),{isFocusVisible:T,focusProps:L}=Xe({autoFocus:y}),{isHovered:j,hoverProps:A}=Je({isDisabled:f}),{pressed:$,pressProps:F}=yt({disabled:f}),G=he({open:C===S.Open,active:$||C===S.Open,disabled:f,invalid:l.invalid,value:l.value,hover:j,focus:T}),q=Pe({ref:d,id:p,type:St(e,n),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":m==null?void 0:m.id,"aria-expanded":C===S.Open,"aria-labelledby":O,disabled:f||void 0,autoFocus:y,onKeyDown:M},h,L,A,F);return ye()({ourProps:q,theirProps:N,slot:G,defaultTag:Bo,name:"Combobox.Button"})}let Uo="div",Go=Me.RenderStrategy|Me.Static;function qo(e,o){var t,l,n;let i=c.useId(),{id:d=`headlessui-combobox-options-${i}`,hold:x=!1,anchor:p,portal:f=!1,modal:y=!0,transition:N=!1,...C}=e,b=Se("Combobox.Options"),m=de("Combobox.Options"),P=ro(p);P&&(f=!0);let[u,M]=co(P),[h,O]=c.useState(null),T=uo(),L=Oe(o,P?u:null,b.actions.setOptionsElement,O),[j,A,$,F,G]=U(b,s=>[s.comboboxState,s.inputElement,s.buttonElement,s.optionsElement,s.activationTrigger]),q=Re(A||$),E=Re(F),V=Ct(),[z,w]=Ot(N,h,V!==null?(V&Ce.Open)===Ce.Open:j===S.Open);wt(z,A,b.actions.closeCombobox);let Y=m.__demoMode?!1:y&&j===S.Open;Nt(Y,E);let le=m.__demoMode?!1:y&&j===S.Open;jt(le,{allowed:c.useCallback(()=>[A,$,F],[A,$,F])});let Z=U(b,b.selectors.didInputMove)?!1:z;ie(()=>{var s;m.optionsPropsRef.current.static=(s=e.static)!=null?s:!1},[m.optionsPropsRef,e.static]),ie(()=>{m.optionsPropsRef.current.hold=x},[m.optionsPropsRef,x]),mo(j===S.Open,{container:F,accept(s){return s.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:s.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(s){s.setAttribute("role","none")}});let ee=Ee([$==null?void 0:$.id]),se=he({open:j===S.Open,option:void 0}),ne=_(()=>{b.actions.setActivationTrigger(oe.Pointer)}),v=_(s=>{s.preventDefault(),b.actions.setActivationTrigger(oe.Pointer)}),K=Pe(P?T():{},{"aria-labelledby":ee,role:"listbox","aria-multiselectable":m.mode===Q.Multi?!0:void 0,id:d,ref:L,style:{...C.style,...M,"--input-width":He(z,A,!0).width,"--button-width":He(z,$,!0).width},onWheel:G===oe.Pointer?void 0:ne,onMouseDown:v,...Et(w)}),R=z&&j===S.Closed&&!e.static,D=Ue(R,(t=m.virtual)==null?void 0:t.options),k=Ue(R,m.value),B=c.useCallback(s=>m.compare(k,s),[m.compare,k]),I=c.useMemo(()=>{if(!m.virtual)return m;if(D===void 0)throw new Error("Missing `options` in virtual mode");return D!==m.virtual.options?{...m,virtual:{...m.virtual,options:D}}:m},[m,D,(l=m.virtual)==null?void 0:l.options]);m.virtual&&Object.assign(C,{children:W.createElement(xe.Provider,{value:I},W.createElement(_o,{slot:se},C.children))});let ae=ye(),we=c.useMemo(()=>m.mode===Q.Multi?m:{...m,isSelected:B},[m,B]);return W.createElement(Pt,{enabled:f?e.static||z:!1,ownerDocument:q},W.createElement(xe.Provider,{value:we},ae({ourProps:K,theirProps:{...C,children:W.createElement(bo,{freeze:R},typeof C.children=="function"?(n=C.children)==null?void 0:n.call(C,se):C.children)},slot:se,defaultTag:Uo,features:Go,visible:Z,name:"Combobox.Options"})))}let Ko="div";function Wo(e,o){var t,l,n;let i=de("Combobox.Option"),d=Se("Combobox.Option"),x=c.useId(),{id:p=`headlessui-combobox-option-${x}`,value:f,disabled:y=(n=(l=(t=i.virtual)==null?void 0:t.disabled)==null?void 0:l.call(t,f))!=null?n:!1,order:N=null,...C}=e,[b]=U(d,w=>[w.inputElement]),m=Ze(b),P=U(d,c.useCallback(w=>d.selectors.isActive(w,f,p),[f,p])),u=i.isSelected(f),M=c.useRef(null),h=It({disabled:y,value:f,domRef:M,order:N}),O=c.useContext(st),T=Oe(o,M,O?O.measureElement:null),L=_(()=>{d.actions.setIsTyping(!1),d.actions.onChange(f)});ie(()=>d.actions.registerOption(p,h),[h,p]);let j=U(d,c.useCallback(w=>d.selectors.shouldScrollIntoView(w,f,p),[f,p]));ie(()=>{if(j)return Tt().requestAnimationFrame(()=>{var w,Y;(Y=(w=M.current)==null?void 0:w.scrollIntoView)==null||Y.call(w,{block:"nearest"})})},[j,M]);let A=_(w=>{w.preventDefault(),w.button===no.Left&&(y||(L(),kt()||requestAnimationFrame(()=>m()),i.mode===Q.Single&&d.actions.closeCombobox()))}),$=_(()=>{if(y)return d.actions.goToOption({focus:H.Nothing});let w=i.calculateIndex(f);d.actions.goToOption({focus:H.Specific,idx:w})}),F=ao(),G=_(w=>F.update(w)),q=_(w=>{if(!F.wasMoved(w)||y||P&&d.state.activationTrigger===oe.Pointer)return;let Y=i.calculateIndex(f);d.actions.goToOption({focus:H.Specific,idx:Y},oe.Pointer)}),E=_(w=>{F.wasMoved(w)&&(y||P&&(i.optionsPropsRef.current.hold||d.state.activationTrigger===oe.Pointer&&d.actions.goToOption({focus:H.Nothing})))}),V=he({active:P,focus:P,selected:u,disabled:y}),z={id:p,ref:T,role:"option",tabIndex:y===!0?void 0:-1,"aria-disabled":y===!0?!0:void 0,"aria-selected":u,disabled:void 0,onMouseDown:A,onFocus:$,onPointerEnter:G,onMouseEnter:G,onPointerMove:q,onMouseMove:q,onPointerLeave:E,onMouseLeave:E};return ye()({ourProps:z,theirProps:C,slot:V,defaultTag:Ko,name:"Combobox.Option"})}let Yo=ge(Vo),nt=ge(Ho),at=ge(zo),Xo=ft,lt=ge(qo),it=ge(Wo),Jo=Object.assign(Yo,{Input:at,Button:nt,Label:Xo,Options:lt,Option:it});/** * @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 Qo=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Zo=Vt("sparkles",Qo);function es({options:e,value:o,onChange:t,defaultValue:l,displayValue:a,filter:i,placeholder:d,disabled:x,invalid:p,name:f,"aria-label":y,className:N,children:C}){const[b,m]=c.useState(""),P=a??(O=>O!=null?String(O):""),M=i??((O,T)=>P(O).toLowerCase().includes(T.toLowerCase())),h=c.useMemo(()=>b?e.filter(O=>M(O,b)):e,[e,b,M]);return n.jsx(Jo,{value:o,onChange:t,defaultValue:l,disabled:x,name:f,onClose:()=>m(""),children:n.jsxs("div",{className:J("relative",N),children:[n.jsxs("div",{className:"relative",children:[n.jsx(nt,{"aria-label":y,displayValue:P,onChange:O=>m(O.target.value),placeholder:d,className:J(["w-full radius-inner py-2 pl-3 pr-10","text-sm text-fg-primary placeholder:text-fg-muted","bg-input-bg",p?"border border-sys-red":"border border-input-border","ring-focus-inset","hover:border-edge-strong","disabled:opacity-40 disabled:pointer-events-none disabled:cursor-not-allowed","transition-colors"])}),n.jsx(at,{className:"absolute inset-y-0 right-0 flex items-center pr-3 group",children:n.jsx(Lt,{className:"w-4 h-4 text-fg-muted transition-transform duration-200 group-data-[open]:rotate-180"})})]}),n.jsx(lt,{anchor:"bottom start",transition:!0,className:J(["w-[var(--input-width)] min-w-[180px]","max-h-60 overflow-y-auto overscroll-contain scroll-py-1","radius-inset p-1 mt-1","surface-elevated","focus:outline-none","transition-opacity","data-[closed]:opacity-0","data-[enter]:duration-150 data-[leave]:duration-100","z-50"]),children:h.length===0&&b!==""?n.jsx("div",{className:"px-3 py-2 text-sm text-fg-muted",children:"No results found"}):h.map((O,T)=>n.jsx(c.Fragment,{children:C(O)},T))})]})})}function ts({value:e,disabled:o,className:t,children:l}){return n.jsx(it,{as:c.Fragment,value:e,disabled:o,children:({selected:a,focus:i})=>n.jsxs("div",{className:J("flex items-center gap-2 px-3 py-2 radius-control cursor-default","text-sm",i&&"bg-sys-blue text-white",!i&&"text-fg-primary",a&&!i&&"text-sys-blue",o&&"opacity-50 cursor-not-allowed",t),children:[n.jsx("span",{className:"w-4 flex-shrink-0",children:a&&n.jsx(zt,{className:"w-4 h-4"})}),n.jsx("span",{className:"truncate flex-1",children:l})]})})}function os({className:e,...o}){return n.jsx("span",{...o,className:J("truncate",e)})}function be({value:e,onChange:o,options:t,placeholder:l,disabled:a,className:i,"aria-label":d}){const x=t.find(p=>p.value===e);return n.jsx(es,{options:t,value:x,onChange:p=>{p&&o(p.value)},displayValue:p=>(p==null?void 0:p.label)??"",filter:(p,f)=>p.label.toLowerCase().includes(f.toLowerCase()),placeholder:l,disabled:a,className:i,"aria-label":d,children:p=>n.jsx(ts,{value:p,disabled:p.disabled,children:n.jsx(os,{children:p.label})})})}const rt=[{target:"PacketStats",fn:"type",minStage:1}];wo(rt);function fe({icon:e,label:o,value:t,color:l,percentage:a,onClick:i,active:d}){const x=i?"button":"div";return n.jsxs(x,{type:i?"button":void 0,onClick:i,className:J("flex items-center gap-2",i&&"cursor-pointer rounded-lg px-1.5 -mx-1.5 py-0.5 -my-0.5 transition-colors",i&&!d&&"hover:bg-subtle-fill",d&&"bg-sys-blue/10 ring-1 ring-sys-blue/25"),children:[n.jsx("div",{className:J("p-1.5 rounded-md",l),children:e}),n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:t.toLocaleString()}),n.jsxs("span",{className:"text-xs text-fg-muted leading-tight",children:[o,a!==void 0&&n.jsxs("span",{className:"ml-1 opacity-70",children:["(",a,"%)"]})]})]})]})}function ss({packets:e}){Oo(rt);const o=c.useMemo(()=>{let t=0,l=0,a=0;const i=new Set;let d=0,x=0;for(const N of e){switch(Qe(N)){case"forward":t++;break;case"dropped":l++;break;case"duplicate":a++;break}N.src_hash&&i.add(N.src_hash),N.rssi&&(d+=N.rssi,x++)}const p=e.length,f=x>0?Math.round(d/x):0;return{total:p,rx:p,fwd:t,dropped:l,duplicate:a,uniqueSources:i.size,avgRssi:f,rxPercent:100,fwdPercent:p>0?Math.round(t/p*100):0,droppedPercent:p>0?Math.round(l/p*100):0}},[e]);return n.jsx("div",{className:"surface-base depth-raised rounded-2xl p-3 pr-4 flex flex-col gap-2.5",children:n.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:flex sm:items-center sm:justify-between sm:gap-6",children:[n.jsx(fe,{icon:n.jsx(No,{className:"w-3.5 h-3.5 text-sys-blue"}),label:"Received",value:o.rx,color:"bg-sys-blue/10",percentage:o.rxPercent}),n.jsx(fe,{icon:n.jsx(jo,{className:"w-3.5 h-3.5 text-sys-green"}),label:"Forwarded",value:o.fwd,color:"bg-sys-green/10",percentage:o.fwdPercent}),n.jsx(fe,{icon:n.jsx(Bt,{className:"w-3.5 h-3.5 text-sys-red"}),label:"Dropped",value:o.dropped,color:"bg-sys-red/10",percentage:o.droppedPercent}),n.jsx(fe,{icon:n.jsx(Ht,{className:"w-3.5 h-3.5 text-fg-muted"}),label:"Duplicates",value:o.duplicate,color:"bg-subtle-fill"}),n.jsxs("div",{className:"hidden sm:flex items-center gap-6 ml-auto",children:[n.jsx(fe,{icon:n.jsx(Ut,{className:"w-3.5 h-3.5 text-sys-indigo"}),label:"Sources",value:o.uniqueSources,color:"bg-sys-indigo/10"}),n.jsxs("div",{className:"flex flex-col items-end pr-1",children:[n.jsxs("span",{className:"type-data-sm text-fg-secondary",children:[o.avgRssi," dBm"]}),n.jsx("span",{className:"text-xs text-fg-muted",children:"Avg Signal"})]})]})]})})}const as=c.memo(ss);function zs(){const e=Gt(),o=qt(),t=xo(),l=fo(s=>s.requestChannel),a=Kt(),i=o==null?void 0:o.local_hash,d=o==null?void 0:o.neighbors,x=Wt(),p=Yt(),y=Xt().isBackgroundLoading&&x>=5,[N,C]=c.useState(!1),[b,m]=c.useState(!0),P=c.useCallback(s=>m(s),[]),[u,M]=c.useState({status:"all"}),[h,O]=c.useState(ho),[T,L]=c.useState(""),[j,A]=c.useState(!1),$=c.useRef(null);c.useEffect(()=>{function s(r){$.current&&!$.current.contains(r.target)&&A(!1)}if(j)return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[j]);const F=c.useMemo(()=>{const s=Math.floor(Date.now()/1e3),r=Fe[x].minutes;return{start:s-r*60,end:s}},[x]),G=c.useMemo(()=>{const s=(o==null?void 0:o.neighbors)??{};return Object.fromEntries(Object.entries(s).filter(([r])=>!a.has(r)))},[o==null?void 0:o.neighbors,a]),q=c.useMemo(()=>Object.entries(G).map(([s,r])=>{const g=Qt(r);return{hash:s,name:r.name??r.node_name??s.slice(0,8),type:g.type,label:g.label}}).sort((s,r)=>s.name.localeCompare(r.name)),[G]),E=c.useMemo(()=>{if(!T)return q;const s=T.toLowerCase();return q.filter(r=>r.name.toLowerCase().includes(s)||r.hash.toLowerCase().includes(s))},[q,T]),V=go(),z=c.useMemo(()=>yo(e,h,V,F),[e,h,V,F]),w=c.useMemo(()=>[...z].sort((s,r)=>(r.timestamp??0)-(s.timestamp??0)),[z]),Y=e.length===0,le=c.useMemo(()=>{let s=w;if(u.type!==void 0){const r=De[u.type];s=s.filter(g=>{const te=g.type??g.payload_type,ue=g.payload_type_name;return te===u.type||ue===r})}if(u.route!==void 0){const r=_e[u.route];s=s.filter(g=>{const te=g.route??g.route_type,ue=g.route_type_name;return te===u.route||ue===r})}return u.status&&u.status!=="all"&&(s=s.filter(r=>Qe(r)===u.status)),u.signalMin!==void 0&&(s=s.filter(r=>r.rssi>=u.signalMin)),u.transportOnly&&(s=s.filter(r=>Ae(r.route??r.route_type))),u.v2Only&&(s=s.filter(r=>r._packetVersion===1)),s},[w,u.type,u.route,u.status,u.signalMin,u.transportOnly,u.v2Only]),Z=c.useMemo(()=>{let s=0,r=0;for(const te of w)Ae(te.route??te.route_type)&&s++,te._packetVersion===1&&r++;const g=w.length;return{transport:s,v2:r,transportPct:g>0?Math.round(s/g*100):0,v2Pct:g>0?Math.round(r/g*100):0}},[w]),ee=(s,r)=>M(g=>({...g,[s]:r})),se=()=>M({status:"all"}),ae=u.type!==void 0||u.route!==void 0||u.status&&u.status!=="all"||u.signalMin!==void 0||u.transportOnly||u.v2Only,v=c.useCallback(s=>{const r=new Set(h.deviceTypes);r.has(s)?r.delete(s):r.add(s),O(g=>({...g,deviceTypes:r}))},[h.deviceTypes]),K=c.useCallback(s=>{const r=new Set(h.nodeIds);r.has(s)?r.delete(s):r.add(s),O(g=>({...g,nodeIds:r})),L("")},[h.nodeIds]),R=c.useCallback(s=>{const r=new Set(h.nodeIds);r.delete(s);const g=new Set(h.disabledNodeIds);g.delete(s),O(te=>({...te,nodeIds:r,disabledNodeIds:g}))},[h.nodeIds,h.disabledNodeIds]),D=c.useCallback(s=>{const r=new Set(h.disabledNodeIds);r.has(s)?r.delete(s):r.add(s),O(g=>({...g,disabledNodeIds:r}))},[h.disabledNodeIds]),k=c.useCallback(()=>{O(s=>({...s,nodeFilterMode:s.nodeFilterMode==="source"?"observed":"source"}))},[]),B=c.useMemo(()=>{const s=new Map;for(const r of h.nodeIds){const g=G[r];s.set(r,(g==null?void 0:g.name)??(g==null?void 0:g.node_name)??r.slice(0,8))}return s},[h.nodeIds,G]),I=c.useCallback((s,r)=>{O(g=>({...g,timeStart:s,timeEnd:r}))},[]),ne=c.useCallback(()=>{M(s=>({...s,transportOnly:!s.transportOnly}))},[]),we=c.useCallback(()=>{M(s=>({...s,v2Only:!s.v2Only}))},[]);return n.jsxs(Eo,{children:[n.jsx(Po,{title:"Packet History",icon:n.jsx(Ve,{}),subtitle:n.jsx(ko,{}),controls:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(To,{ranges:Fe,selectedIndex:x,onSelect:p,isPending:y}),n.jsxs(Ne,{outline:!0,color:ae?"primary":"muted",onClick:()=>C(!N),className:"sm:hidden",children:[n.jsx(qe,{"data-slot":"icon"}),ae&&n.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-sys-blue"})]})]})}),n.jsxs(Io,{children:[n.jsxs(Ge,{neomorphic:!0,noPadding:!0,className:J("overflow-visible transition-all duration-200 relative z-10",N?"max-h-[600px] opacity-100":"max-h-0 opacity-0 sm:max-h-[600px] sm:opacity-100"),children:[n.jsx(Le,{listHeader:!0,icon:n.jsx(qe,{className:"icon-sm"}),title:"Filters",titleExtra:n.jsxs("div",{className:"flex items-center gap-1.5 ml-1",children:[n.jsxs("button",{type:"button",onClick:ne,className:J("inline-flex items-center gap-1 px-2.5 py-1 rounded-full type-data-xs font-medium transition-colors cursor-pointer select-none",u.transportOnly?"bg-sys-amber/15 text-sys-amber ring-1 ring-sys-amber/30":"bg-surface/80 depth-raised text-fg-muted hover:text-fg-secondary"),title:"Filter to transport-coded packets (T_FLOOD / T_DIRECT)",children:[n.jsx($o,{className:"w-3 h-3"}),n.jsx("span",{className:"hidden sm:inline",children:"Transport"}),n.jsx("span",{className:"tabular-nums",children:Z.transport}),n.jsxs("span",{className:"opacity-60 hidden lg:inline",children:["(",Z.transportPct,"%)"]})]}),n.jsxs("button",{type:"button",onClick:we,className:J("inline-flex items-center gap-1 px-2.5 py-1 rounded-full type-data-xs font-medium transition-colors cursor-pointer select-none",u.v2Only?"bg-sys-teal/15 text-sys-teal ring-1 ring-sys-teal/30":"bg-surface/80 depth-raised text-fg-muted hover:text-fg-secondary"),title:"Filter to V2 protocol packets",children:[n.jsx(Zo,{className:"w-3 h-3"}),n.jsx("span",{className:"hidden sm:inline",children:"V2"}),n.jsx("span",{className:"tabular-nums",children:Z.v2}),n.jsxs("span",{className:"opacity-60 hidden lg:inline",children:["(",Z.v2Pct,"%)"]})]})]}),actions:ae?n.jsxs(Ne,{plain:!0,color:"muted",onClick:se,className:"!text-xs !py-0.5 !px-1.5",children:[n.jsx(ze,{"data-slot":"icon",className:"!w-3 !h-3"}),"Clear"]}):void 0}),n.jsxs("div",{className:"p-3 sm:p-4 flex flex-col gap-3",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-0.5 -mb-0.5 shrink-0",children:So.map(({type:s,label:r,icon:g,buttonColor:te,iconColor:ue,hoverClass:ct})=>{const pe=h.deviceTypes.has(s);return n.jsxs(Ne,{color:pe?te:"zinc",outline:!pe,className:`!h-8 !py-0 ${pe?"":ct}`,onClick:()=>v(s),title:`Filter by ${r}`,children:[n.jsx(g,{"data-slot":"icon",className:pe?"":ue}),n.jsx("span",{className:`hidden sm:inline ${pe?"":"text-fg-muted"}`,children:r})]},s)})}),n.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden md:block"}),n.jsxs("div",{className:"relative flex items-center gap-1.5 flex-1 min-w-[120px] sm:min-w-[180px] h-8 px-2 rounded-md border border-edge-subtle bg-white/[0.03] transition-colors focus-within:border-sys-blue",ref:$,children:[n.jsx(Ro,{className:"w-3 h-3 text-fg-muted/50 shrink-0"}),n.jsx("input",{type:"text",className:"flex-1 min-w-[60px] type-data-xs py-0.5 bg-transparent text-fg-secondary placeholder:text-fg-muted/40 border-none focus:outline-none",placeholder:"Search nodes...",value:T,onChange:s=>{L(s.target.value),A(!0)},onFocus:()=>A(!0)}),j&&E.length>0&&n.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 z-[200] surface-popover border border-edge-subtle radius-inner max-h-48 overflow-y-auto",children:E.slice(0,20).map(s=>{const r=h.nodeIds.has(s.hash);return n.jsxs("button",{type:"button",onClick:()=>K(s.hash),className:J("w-full flex items-center gap-2 px-2.5 py-1.5 type-data-xs text-left transition-colors",r?"bg-sys-indigo/15 text-sys-indigo":"text-fg-secondary hover:bg-subtle-fill"),children:[n.jsx("span",{className:"flex-1 truncate",children:s.name}),n.jsx("span",{className:"text-fg-muted type-data-xs shrink-0",children:s.label})]},s.hash)})})]})]}),h.nodeIds.size>0&&n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Array.from(h.nodeIds).map(s=>{const r=h.disabledNodeIds.has(s);return n.jsxs("span",{role:"button",tabIndex:0,onClick:()=>D(s),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),D(s))},className:J("inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors select-none",r?"bg-zinc-500/10 text-fg-muted border-edge-subtle cursor-pointer hover:bg-zinc-500/15":"bg-sys-indigo/15 text-sys-indigo border-sys-indigo/25 cursor-pointer hover:bg-sys-indigo/25"),title:s,children:[B.get(s)??s.slice(0,8),n.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),R(s)},className:"hover:text-fg-primary transition-colors -mr-0.5",title:"Remove from filter",children:n.jsx(ze,{className:"w-3 h-3"})})]},s)}),n.jsx("button",{type:"button",onClick:k,className:J("inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors",h.nodeFilterMode==="observed"?"bg-sys-blue/15 text-sys-blue border-sys-blue/25 hover:bg-sys-blue/25":"bg-white/[0.04] text-fg-muted border-edge-subtle hover:text-fg-secondary hover:border-fg-muted/40"),title:h.nodeFilterMode==="source"?"Source Only — showing packets sent by selected node(s)":"Total Observed — showing all packets where selected node(s) appear (source, path, or destination)",children:h.nodeFilterMode==="source"?"Source Only":"Total Observed"})]}),n.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:flex-wrap gap-3",children:[n.jsxs("div",{className:"flex-1 min-w-[140px]",children:[n.jsx("label",{className:"type-micro block mb-1",children:"Type"}),n.jsx(be,{value:u.type??"",onChange:s=>ee("type",s===""?void 0:Number(s)),options:[{value:"",label:"All Types"},...Object.entries(De).map(([s,r])=>({value:Number(s),label:r}))],placeholder:"Search types...","aria-label":"Filter by packet type"})]}),n.jsxs("div",{className:"flex-1 min-w-[140px]",children:[n.jsx("label",{className:"type-micro block mb-1",children:"Route"}),n.jsx(be,{value:u.route??"",onChange:s=>ee("route",s===""?void 0:Number(s)),options:[{value:"",label:"All Routes"},...Object.entries(_e).map(([s,r])=>({value:Number(s),label:r}))],placeholder:"Search routes...","aria-label":"Filter by route type"})]}),n.jsxs("div",{className:"flex-1 min-w-[140px]",children:[n.jsx("label",{className:"type-micro block mb-1",children:"Status"}),n.jsx(be,{value:u.status??"all",onChange:s=>ee("status",s),options:[{value:"all",label:"All Status"},{value:"rx",label:"Received"},{value:"forward",label:"Forwarded"},{value:"dropped",label:"Dropped"},{value:"duplicate",label:"Duplicate"}],placeholder:"Search status...","aria-label":"Filter by status"})]}),n.jsxs("div",{className:"flex-1 min-w-[130px]",children:[n.jsx("label",{className:"type-micro block mb-1",children:"Signal"}),n.jsx(be,{value:u.signalMin??"",onChange:s=>ee("signalMin",s===""?void 0:Number(s)),options:[{value:"",label:"Any Signal"},{value:-90,label:"Strong (≥-90)"},{value:-100,label:"Good (≥-100)"},{value:-110,label:"Fair (≥-110)"},{value:-120,label:"Weak (≥-120)"}],placeholder:"Search signal...","aria-label":"Filter by signal strength"})]}),n.jsxs("div",{className:"flex-1 min-w-[100px]",children:[n.jsx("label",{className:"type-micro block mb-1",children:"Per Page"}),n.jsx(be,{value:u.perPage??50,onChange:s=>ee("perPage",s),options:[{value:25,label:"25"},{value:50,label:"50"},{value:100,label:"100"},{value:200,label:"200"},{value:500,label:"500"},{value:1e3,label:"1K"}],placeholder:"Per page...","aria-label":"Packets per page"})]})]}),n.jsx("div",{className:"flex items-center gap-3 pt-1 border-t border-edge-subtle",children:n.jsx("div",{className:"flex-1 min-w-[120px]",children:n.jsx(Co,{min:F.start,max:F.end,valueStart:h.timeStart,valueEnd:h.timeEnd,onChange:I})})})]})]}),n.jsx(as,{packets:le}),n.jsxs(Ge,{neomorphic:!0,noPadding:!0,className:"!overflow-visible",children:[n.jsx(Le,{listHeader:!0,icon:n.jsx(Ve,{className:"icon-sm"}),title:"Packet History",actions:n.jsx(Jt,{enabled:b,onChange:P,label:"Hide Dupes",size:"sm"})}),n.jsx(vo,{packets:le,allPackets:e,localHash:i,neighbors:d,resolveSource:V,getDecodedContent:t,onChannelClick:l,loading:Y,showPagination:!0,perPage:u.perPage??50,hideDupes:b,emptyMessage:"No packets found"})]})]})]})}export{zs as default}; + */const Qo=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Zo=Vt("sparkles",Qo);function es({options:e,value:o,onChange:t,defaultValue:l,displayValue:n,filter:i,placeholder:d,disabled:x,invalid:p,name:f,"aria-label":y,className:N,children:C}){const[b,m]=c.useState(""),P=n??(O=>O!=null?String(O):""),M=i??((O,T)=>P(O).toLowerCase().includes(T.toLowerCase())),h=c.useMemo(()=>b?e.filter(O=>M(O,b)):e,[e,b,M]);return a.jsx(Jo,{value:o,onChange:t,defaultValue:l,disabled:x,name:f,onClose:()=>m(""),children:a.jsxs("div",{className:J("relative",N),children:[a.jsxs("div",{className:"relative",children:[a.jsx(at,{"aria-label":y,displayValue:P,onChange:O=>m(O.target.value),placeholder:d,className:J(["w-full radius-inner py-2 pl-3 pr-10","text-sm text-fg-primary placeholder:text-fg-muted","bg-input-bg",p?"border border-sys-red":"border border-input-border","ring-focus-inset","hover:border-edge-strong","disabled:opacity-40 disabled:pointer-events-none disabled:cursor-not-allowed","transition-colors"])}),a.jsx(nt,{className:"absolute inset-y-0 right-0 flex items-center pr-3 group",children:a.jsx(Lt,{className:"w-4 h-4 text-fg-muted transition-transform duration-200 group-data-[open]:rotate-180"})})]}),a.jsx(lt,{anchor:"bottom start",transition:!0,className:J(["w-[var(--input-width)] min-w-[180px]","max-h-60 overflow-y-auto overscroll-contain scroll-py-1","radius-inset p-1 mt-1","surface-elevated","focus:outline-none","transition-opacity","data-[closed]:opacity-0","data-[enter]:duration-150 data-[leave]:duration-100","z-50"]),children:h.length===0&&b!==""?a.jsx("div",{className:"px-3 py-2 text-sm text-fg-muted",children:"No results found"}):h.map((O,T)=>a.jsx(c.Fragment,{children:C(O)},T))})]})})}function ts({value:e,disabled:o,className:t,children:l}){return a.jsx(it,{as:c.Fragment,value:e,disabled:o,children:({selected:n,focus:i})=>a.jsxs("div",{className:J("flex items-center gap-2 px-3 py-2 radius-control cursor-default","text-sm",i&&"bg-sys-blue text-white",!i&&"text-fg-primary",n&&!i&&"text-sys-blue",o&&"opacity-50 cursor-not-allowed",t),children:[a.jsx("span",{className:"w-4 flex-shrink-0",children:n&&a.jsx(zt,{className:"w-4 h-4"})}),a.jsx("span",{className:"truncate flex-1",children:l})]})})}function os({className:e,...o}){return a.jsx("span",{...o,className:J("truncate",e)})}function be({value:e,onChange:o,options:t,placeholder:l,disabled:n,className:i,"aria-label":d}){const x=t.find(p=>p.value===e);return a.jsx(es,{options:t,value:x,onChange:p=>{p&&o(p.value)},displayValue:p=>(p==null?void 0:p.label)??"",filter:(p,f)=>p.label.toLowerCase().includes(f.toLowerCase()),placeholder:l,disabled:n,className:i,"aria-label":d,children:p=>a.jsx(ts,{value:p,disabled:p.disabled,children:a.jsx(os,{children:p.label})})})}const rt=[{target:"PacketStats",fn:"type",minStage:1}];wo(rt);function fe({icon:e,label:o,value:t,color:l,percentage:n,onClick:i,active:d}){const x=i?"button":"div";return a.jsxs(x,{type:i?"button":void 0,onClick:i,className:J("flex items-center gap-2",i&&"cursor-pointer rounded-lg px-1.5 -mx-1.5 py-0.5 -my-0.5 transition-colors",i&&!d&&"hover:bg-subtle-fill",d&&"bg-sys-blue/10 ring-1 ring-sys-blue/25"),children:[a.jsx("div",{className:J("p-1.5 rounded-md",l),children:e}),a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:t.toLocaleString()}),a.jsxs("span",{className:"text-xs text-fg-muted leading-tight",children:[o,n!==void 0&&a.jsxs("span",{className:"ml-1 opacity-70",children:["(",n,"%)"]})]})]})]})}function ss({packets:e}){Oo(rt);const o=c.useMemo(()=>{let t=0,l=0,n=0;const i=new Set;let d=0,x=0;for(const N of e){switch(Qe(N)){case"forward":t++;break;case"dropped":l++;break;case"duplicate":n++;break}N.src_hash&&i.add(N.src_hash),N.rssi&&(d+=N.rssi,x++)}const p=e.length,f=x>0?Math.round(d/x):0;return{total:p,rx:p,fwd:t,dropped:l,duplicate:n,uniqueSources:i.size,avgRssi:f,rxPercent:100,fwdPercent:p>0?Math.round(t/p*100):0,droppedPercent:p>0?Math.round(l/p*100):0}},[e]);return a.jsx("div",{className:"surface-base depth-raised rounded-2xl p-3 pr-4 flex flex-col gap-2.5",children:a.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:flex sm:items-center sm:justify-between sm:gap-6",children:[a.jsx(fe,{icon:a.jsx(No,{className:"w-3.5 h-3.5 text-sys-blue"}),label:"Received",value:o.rx,color:"bg-sys-blue/10",percentage:o.rxPercent}),a.jsx(fe,{icon:a.jsx(jo,{className:"w-3.5 h-3.5 text-sys-green"}),label:"Forwarded",value:o.fwd,color:"bg-sys-green/10",percentage:o.fwdPercent}),a.jsx(fe,{icon:a.jsx(Bt,{className:"w-3.5 h-3.5 text-sys-red"}),label:"Dropped",value:o.dropped,color:"bg-sys-red/10",percentage:o.droppedPercent}),a.jsx(fe,{icon:a.jsx(Ht,{className:"w-3.5 h-3.5 text-fg-muted"}),label:"Duplicates",value:o.duplicate,color:"bg-subtle-fill"}),a.jsxs("div",{className:"hidden sm:flex items-center gap-6 ml-auto",children:[a.jsx(fe,{icon:a.jsx(Ut,{className:"w-3.5 h-3.5 text-sys-indigo"}),label:"Sources",value:o.uniqueSources,color:"bg-sys-indigo/10"}),a.jsxs("div",{className:"flex flex-col items-end pr-1",children:[a.jsxs("span",{className:"type-data-sm text-fg-secondary",children:[o.avgRssi," dBm"]}),a.jsx("span",{className:"text-xs text-fg-muted",children:"Avg Signal"})]})]})]})})}const ns=c.memo(ss);function zs(){const e=Gt(),o=qt(),t=xo(),l=fo(s=>s.requestChannel),n=Kt(),i=o==null?void 0:o.local_hash,d=o==null?void 0:o.neighbors,x=Wt(),p=Yt(),y=Xt().isBackgroundLoading&&x>=5,[N,C]=c.useState(!1),[b,m]=c.useState(!0),P=c.useCallback(s=>m(s),[]),[u,M]=c.useState({status:"all"}),[h,O]=c.useState(ho),[T,L]=c.useState(""),[j,A]=c.useState(!1),$=c.useRef(null);c.useEffect(()=>{function s(r){$.current&&!$.current.contains(r.target)&&A(!1)}if(j)return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[j]);const F=c.useMemo(()=>{const s=Math.floor(Date.now()/1e3),r=Fe[x].minutes;return{start:s-r*60,end:s}},[x]),G=c.useMemo(()=>{const s=(o==null?void 0:o.neighbors)??{};return Object.fromEntries(Object.entries(s).filter(([r])=>!n.has(r)))},[o==null?void 0:o.neighbors,n]),q=c.useMemo(()=>Object.entries(G).map(([s,r])=>{const g=Qt(r);return{hash:s,name:r.name??r.node_name??s.slice(0,8),type:g.type,label:g.label}}).sort((s,r)=>s.name.localeCompare(r.name)),[G]),E=c.useMemo(()=>{if(!T)return q;const s=T.toLowerCase();return q.filter(r=>r.name.toLowerCase().includes(s)||r.hash.toLowerCase().includes(s))},[q,T]),V=go(),z=c.useMemo(()=>yo(e,h,V,F),[e,h,V,F]),w=c.useMemo(()=>[...z].sort((s,r)=>(r.timestamp??0)-(s.timestamp??0)),[z]),Y=e.length===0,le=c.useMemo(()=>{let s=w;if(u.type!==void 0){const r=De[u.type];s=s.filter(g=>{const te=g.type??g.payload_type,ue=g.payload_type_name;return te===u.type||ue===r})}if(u.route!==void 0){const r=_e[u.route];s=s.filter(g=>{const te=g.route??g.route_type,ue=g.route_type_name;return te===u.route||ue===r})}return u.status&&u.status!=="all"&&(s=s.filter(r=>Qe(r)===u.status)),u.signalMin!==void 0&&(s=s.filter(r=>r.rssi>=u.signalMin)),u.transportOnly&&(s=s.filter(r=>Ae(r.route??r.route_type))),u.v2Only&&(s=s.filter(r=>r._packetVersion===1)),s},[w,u.type,u.route,u.status,u.signalMin,u.transportOnly,u.v2Only]),Z=c.useMemo(()=>{let s=0,r=0;for(const te of w)Ae(te.route??te.route_type)&&s++,te._packetVersion===1&&r++;const g=w.length;return{transport:s,v2:r,transportPct:g>0?Math.round(s/g*100):0,v2Pct:g>0?Math.round(r/g*100):0}},[w]),ee=(s,r)=>M(g=>({...g,[s]:r})),se=()=>M({status:"all"}),ne=u.type!==void 0||u.route!==void 0||u.status&&u.status!=="all"||u.signalMin!==void 0||u.transportOnly||u.v2Only,v=c.useCallback(s=>{const r=new Set(h.deviceTypes);r.has(s)?r.delete(s):r.add(s),O(g=>({...g,deviceTypes:r}))},[h.deviceTypes]),K=c.useCallback(s=>{const r=new Set(h.nodeIds);r.has(s)?r.delete(s):r.add(s),O(g=>({...g,nodeIds:r})),L("")},[h.nodeIds]),R=c.useCallback(s=>{const r=new Set(h.nodeIds);r.delete(s);const g=new Set(h.disabledNodeIds);g.delete(s),O(te=>({...te,nodeIds:r,disabledNodeIds:g}))},[h.nodeIds,h.disabledNodeIds]),D=c.useCallback(s=>{const r=new Set(h.disabledNodeIds);r.has(s)?r.delete(s):r.add(s),O(g=>({...g,disabledNodeIds:r}))},[h.disabledNodeIds]),k=c.useCallback(()=>{O(s=>({...s,nodeFilterMode:s.nodeFilterMode==="source"?"observed":"source"}))},[]),B=c.useMemo(()=>{const s=new Map;for(const r of h.nodeIds){const g=G[r];s.set(r,(g==null?void 0:g.name)??(g==null?void 0:g.node_name)??r.slice(0,8))}return s},[h.nodeIds,G]),I=c.useCallback((s,r)=>{O(g=>({...g,timeStart:s,timeEnd:r}))},[]),ae=c.useCallback(()=>{M(s=>({...s,transportOnly:!s.transportOnly}))},[]),we=c.useCallback(()=>{M(s=>({...s,v2Only:!s.v2Only}))},[]);return a.jsxs(Eo,{children:[a.jsx(Po,{title:"Packet History",icon:a.jsx(Ve,{}),subtitle:a.jsx(ko,{}),controls:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(To,{ranges:Fe,selectedIndex:x,onSelect:p,isPending:y}),a.jsxs(Ne,{outline:!0,color:ne?"primary":"muted",onClick:()=>C(!N),className:"sm:hidden",children:[a.jsx(qe,{"data-slot":"icon"}),ne&&a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-sys-blue"})]})]})}),a.jsxs(Io,{children:[a.jsxs(Ge,{neomorphic:!0,noPadding:!0,className:J("overflow-visible transition-all duration-200 relative z-10",N?"max-h-[600px] opacity-100":"max-h-0 opacity-0 sm:max-h-[600px] sm:opacity-100"),children:[a.jsx(Le,{listHeader:!0,icon:a.jsx(qe,{className:"icon-sm"}),title:"Filters",titleExtra:a.jsxs("div",{className:"flex items-center gap-1.5 ml-1",children:[a.jsxs("button",{type:"button",onClick:ae,className:J("inline-flex items-center gap-1 px-2.5 py-1 rounded-full type-data-xs font-medium transition-colors cursor-pointer select-none",u.transportOnly?"bg-sys-amber/15 text-sys-amber ring-1 ring-sys-amber/30":"bg-surface/80 depth-raised text-fg-muted hover:text-fg-secondary"),title:"Filter to transport-coded packets (T_FLOOD / T_DIRECT)",children:[a.jsx($o,{className:"w-3 h-3"}),a.jsx("span",{className:"hidden sm:inline",children:"Transport"}),a.jsx("span",{className:"tabular-nums",children:Z.transport}),a.jsxs("span",{className:"opacity-60 hidden lg:inline",children:["(",Z.transportPct,"%)"]})]}),a.jsxs("button",{type:"button",onClick:we,className:J("inline-flex items-center gap-1 px-2.5 py-1 rounded-full type-data-xs font-medium transition-colors cursor-pointer select-none",u.v2Only?"bg-sys-teal/15 text-sys-teal ring-1 ring-sys-teal/30":"bg-surface/80 depth-raised text-fg-muted hover:text-fg-secondary"),title:"Filter to V2 protocol packets",children:[a.jsx(Zo,{className:"w-3 h-3"}),a.jsx("span",{className:"hidden sm:inline",children:"V2"}),a.jsx("span",{className:"tabular-nums",children:Z.v2}),a.jsxs("span",{className:"opacity-60 hidden lg:inline",children:["(",Z.v2Pct,"%)"]})]})]}),actions:ne?a.jsxs(Ne,{plain:!0,color:"muted",onClick:se,className:"!text-xs !py-0.5 !px-1.5",children:[a.jsx(ze,{"data-slot":"icon",className:"!w-3 !h-3"}),"Clear"]}):void 0}),a.jsxs("div",{className:"p-3 sm:p-4 flex flex-col gap-3",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-0.5 -mb-0.5 shrink-0",children:So.map(({type:s,label:r,icon:g,buttonColor:te,iconColor:ue,hoverClass:ct})=>{const pe=h.deviceTypes.has(s);return a.jsxs(Ne,{color:pe?te:"zinc",outline:!pe,className:`!h-8 !py-0 ${pe?"":ct}`,onClick:()=>v(s),title:`Filter by ${r}`,children:[a.jsx(g,{"data-slot":"icon",className:pe?"":ue}),a.jsx("span",{className:`hidden sm:inline ${pe?"":"text-fg-muted"}`,children:r})]},s)})}),a.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden md:block"}),a.jsxs("div",{className:"relative flex items-center gap-1.5 flex-1 min-w-[120px] sm:min-w-[180px] h-8 px-2 rounded-md border border-edge-subtle bg-white/[0.03] transition-colors focus-within:border-sys-blue",ref:$,children:[a.jsx(Ro,{className:"w-3 h-3 text-fg-muted/50 shrink-0"}),a.jsx("input",{type:"text",className:"flex-1 min-w-[60px] type-data-xs py-0.5 bg-transparent text-fg-secondary placeholder:text-fg-muted/40 border-none focus:outline-none",placeholder:"Search nodes...",value:T,onChange:s=>{L(s.target.value),A(!0)},onFocus:()=>A(!0)}),j&&E.length>0&&a.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 z-[200] surface-popover border border-edge-subtle radius-inner max-h-48 overflow-y-auto",children:E.slice(0,20).map(s=>{const r=h.nodeIds.has(s.hash);return a.jsxs("button",{type:"button",onClick:()=>K(s.hash),className:J("w-full flex items-center gap-2 px-2.5 py-1.5 type-data-xs text-left transition-colors",r?"bg-sys-indigo/15 text-sys-indigo":"text-fg-secondary hover:bg-subtle-fill"),children:[a.jsx("span",{className:"flex-1 truncate",children:s.name}),a.jsx("span",{className:"text-fg-muted type-data-xs shrink-0",children:s.label})]},s.hash)})})]})]}),h.nodeIds.size>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Array.from(h.nodeIds).map(s=>{const r=h.disabledNodeIds.has(s);return a.jsxs("span",{role:"button",tabIndex:0,onClick:()=>D(s),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),D(s))},className:J("inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors select-none",r?"bg-zinc-500/10 text-fg-muted border-edge-subtle cursor-pointer hover:bg-zinc-500/15":"bg-sys-indigo/15 text-sys-indigo border-sys-indigo/25 cursor-pointer hover:bg-sys-indigo/25"),title:s,children:[B.get(s)??s.slice(0,8),a.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),R(s)},className:"hover:text-fg-primary transition-colors -mr-0.5",title:"Remove from filter",children:a.jsx(ze,{className:"w-3 h-3"})})]},s)}),a.jsx("button",{type:"button",onClick:k,className:J("inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors",h.nodeFilterMode==="observed"?"bg-sys-blue/15 text-sys-blue border-sys-blue/25 hover:bg-sys-blue/25":"bg-white/[0.04] text-fg-muted border-edge-subtle hover:text-fg-secondary hover:border-fg-muted/40"),title:h.nodeFilterMode==="source"?"Source Only — showing packets sent by selected node(s)":"Total Observed — showing all packets where selected node(s) appear (source, path, or destination)",children:h.nodeFilterMode==="source"?"Source Only":"Total Observed"})]}),a.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:flex-wrap gap-3",children:[a.jsxs("div",{className:"flex-1 min-w-[140px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Type"}),a.jsx(be,{value:u.type??"",onChange:s=>ee("type",s===""?void 0:Number(s)),options:[{value:"",label:"All Types"},...Object.entries(De).map(([s,r])=>({value:Number(s),label:r}))],placeholder:"Search types...","aria-label":"Filter by packet type"})]}),a.jsxs("div",{className:"flex-1 min-w-[140px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Route"}),a.jsx(be,{value:u.route??"",onChange:s=>ee("route",s===""?void 0:Number(s)),options:[{value:"",label:"All Routes"},...Object.entries(_e).map(([s,r])=>({value:Number(s),label:r}))],placeholder:"Search routes...","aria-label":"Filter by route type"})]}),a.jsxs("div",{className:"flex-1 min-w-[140px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Status"}),a.jsx(be,{value:u.status??"all",onChange:s=>ee("status",s),options:[{value:"all",label:"All Status"},{value:"rx",label:"Received"},{value:"forward",label:"Forwarded"},{value:"dropped",label:"Dropped"},{value:"duplicate",label:"Duplicate"}],placeholder:"Search status...","aria-label":"Filter by status"})]}),a.jsxs("div",{className:"flex-1 min-w-[130px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Signal"}),a.jsx(be,{value:u.signalMin??"",onChange:s=>ee("signalMin",s===""?void 0:Number(s)),options:[{value:"",label:"Any Signal"},{value:-90,label:"Strong (≥-90)"},{value:-100,label:"Good (≥-100)"},{value:-110,label:"Fair (≥-110)"},{value:-120,label:"Weak (≥-120)"}],placeholder:"Search signal...","aria-label":"Filter by signal strength"})]}),a.jsxs("div",{className:"flex-1 min-w-[100px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Per Page"}),a.jsx(be,{value:u.perPage??50,onChange:s=>ee("perPage",s),options:[{value:25,label:"25"},{value:50,label:"50"},{value:100,label:"100"},{value:200,label:"200"},{value:500,label:"500"},{value:1e3,label:"1K"}],placeholder:"Per page...","aria-label":"Packets per page"})]})]}),a.jsx("div",{className:"flex items-center gap-3 pt-1 border-t border-edge-subtle",children:a.jsx("div",{className:"flex-1 min-w-[120px]",children:a.jsx(Co,{min:F.start,max:F.end,valueStart:h.timeStart,valueEnd:h.timeEnd,onChange:I})})})]})]}),a.jsx(ns,{packets:le}),a.jsxs(Ge,{neomorphic:!0,noPadding:!0,className:"!overflow-visible",children:[a.jsx(Le,{listHeader:!0,icon:a.jsx(Ve,{className:"icon-sm"}),title:"Packet History",actions:a.jsx(Jt,{enabled:b,onChange:P,label:"Hide Dupes",size:"sm"})}),a.jsx(vo,{packets:le,allPackets:e,localHash:i,neighbors:d,resolveSource:V,getDecodedContent:t,onChannelClick:l,loading:Y,showPagination:!0,perPage:u.perPage??50,hideDupes:b,emptyMessage:"No packets found"})]})]})]})}export{zs as default}; diff --git a/frontend/dist/assets/PageLayout-Cg7r5tdt.js b/frontend/dist/assets/PageLayout-CRN-E5xi.js similarity index 90% rename from frontend/dist/assets/PageLayout-Cg7r5tdt.js rename to frontend/dist/assets/PageLayout-CRN-E5xi.js index 5576c40e..de98517e 100644 --- a/frontend/dist/assets/PageLayout-Cg7r5tdt.js +++ b/frontend/dist/assets/PageLayout-CRN-E5xi.js @@ -1 +1 @@ -import{j as e,Y as d,c as m,aQ as o,r as i,gw as f}from"./index-C2xvS0Jd.js";function p({children:a,className:s}){return e.jsx("div",{className:m("section-gap",s),children:a})}function g({children:a,className:s,ready:n}){const r=o(),t=n??r,[x,c]=i.useState(!1);return i.useEffect(()=>{if(!t){c(!1);return}let l=!1;return requestAnimationFrame(()=>{requestAnimationFrame(()=>{l||i.startTransition(()=>c(!0))})}),()=>{l=!0}},[t]),e.jsx(f.Provider,{value:x,children:e.jsx("div",{className:m("bento-section",s),children:a})})}function j({title:a,icon:s,controls:n,leading:r,subtitle:t}){return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 min-h-9",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("h1",{className:"type-title text-fg-primary flex items-baseline gap-2 sm:gap-3 min-w-0",children:[s&&e.jsx("span",{className:"text-icon-page-title flex-shrink-0 translate-y-[0.1em] [&>svg]:h-[1em] [&>svg]:w-[1em] [&>svg]:stroke-[1.5]",children:s}),e.jsx("span",{className:"truncate",children:a})]}),r]}),n&&e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:n})]}),t&&e.jsx("div",{children:t})]})}function h({size:a,...s}){return e.jsx(d,{...s})}export{g as B,h as C,p as P,j as a}; +import{j as e,Y as d,c as m,aR as o,r as i,gw as f}from"./index-D33fcA3L.js";function p({children:a,className:s}){return e.jsx("div",{className:m("section-gap",s),children:a})}function g({children:a,className:s,ready:n}){const r=o(),t=n??r,[x,c]=i.useState(!1);return i.useEffect(()=>{if(!t){c(!1);return}let l=!1;return requestAnimationFrame(()=>{requestAnimationFrame(()=>{l||i.startTransition(()=>c(!0))})}),()=>{l=!0}},[t]),e.jsx(f.Provider,{value:x,children:e.jsx("div",{className:m("bento-section",s),children:a})})}function j({title:a,icon:s,controls:n,leading:r,subtitle:t}){return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 min-h-9",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("h1",{className:"type-title text-fg-primary flex items-baseline gap-2 sm:gap-3 min-w-0",children:[s&&e.jsx("span",{className:"text-icon-page-title flex-shrink-0 translate-y-[0.1em] [&>svg]:h-[1em] [&>svg]:w-[1em] [&>svg]:stroke-[1.5]",children:s}),e.jsx("span",{className:"truncate",children:a})]}),r]}),n&&e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:n})]}),t&&e.jsx("div",{children:t})]})}function h({size:a,...s}){return e.jsx(d,{...s})}export{g as B,h as C,p as P,j as a}; diff --git a/frontend/dist/assets/PathMapMapLibre-CmQJ8_VP.js b/frontend/dist/assets/PathMapMapLibre-CmQJ8_VP.js deleted file mode 100644 index 106d8987..00000000 --- a/frontend/dist/assets/PathMapMapLibre-CmQJ8_VP.js +++ /dev/null @@ -1 +0,0 @@ -import{r as a,c$ as ae,cb as ie,b$ as le,gx as de,Z as J,ce,j as t,V as K,c as G,gy as ue}from"./index-C2xvS0Jd.js";import{M as pe,S as me,L as fe,a as _,P as ge}from"./maplibre-gl-C9QYi5T6.js";import{B as xe}from"./BasemapLayer-DQCsZLc0.js";import{C as he}from"./car-D35Wwv-5.js";import{H as be}from"./useMapViewStore-DnPjO7Qt.js";import"./index-QCPybZMd.js";import"./index-wtt5rE5a.js";const ye={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},h={nodeColor:"#4338CA",localColor:"#4F46E5",hubColor:"#6366F1",edgeColor:"#3B3F4A",ambiguousColor:"#F9D26F",highlightColor:"#B49DFF",sourceColor:"#39D98A",destinationColor:"#B49DFF"};function C(c,r){if(!c)return r;if(c.startsWith("#"))return c;const m=ue(c);return m?`#${m.r.toString(16).padStart(2,"0")}${m.g.toString(16).padStart(2,"0")}${m.b.toString(16).padStart(2,"0")}`:r}function z(){if(typeof document>"u")return h;const c=document.documentElement,r=getComputedStyle(c);return{nodeColor:C(r.getPropertyValue("--map-node-stroke").trim(),h.nodeColor),localColor:C(r.getPropertyValue("--map-local-color").trim(),h.localColor),hubColor:C(r.getPropertyValue("--map-hub-color").trim(),h.hubColor),edgeColor:C(r.getPropertyValue("--map-edge-rest").trim(),h.edgeColor),ambiguousColor:C(r.getPropertyValue("--sys-indigo").trim(),h.ambiguousColor),highlightColor:C(r.getPropertyValue("--sys-blue").trim(),h.highlightColor),sourceColor:C(r.getPropertyValue("--sys-green").trim(),h.sourceColor),destinationColor:C(r.getPropertyValue("--sys-blue").trim(),h.destinationColor)}}function Ce({prefix:c,isLocal:r,isSource:m,isDestination:B,isLastHop:b,isHighlighted:g,isWardrive:k,candidate:x,onHover:E,onLeave:N,onClick:S}){const[n,w]=a.useState(!1),P=a.useCallback(()=>{w(!0),E()},[E]),j=a.useCallback(()=>{w(!1),N()},[N]),D=()=>k?"orange":r?"amber":m?"green":b?"amber":B?"purple":"blue";return k?t.jsxs("div",{className:G("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded-full",n&&"relative z-50"),onMouseEnter:P,onMouseLeave:j,onClick:S,style:{pointerEvents:"auto"},children:[t.jsx("div",{className:G("flex items-center justify-center","w-7 h-7 rounded-full","bg-sys-orange text-white","shadow-lg border-2 border-sys-orange/50","transition-transform duration-150",n&&"scale-110"),children:t.jsx(he,{className:"w-4 h-4",strokeWidth:2.5})}),n&&t.jsxs(K,{color:"orange",filled:!0,className:"ml-1 type-data-xs shadow-lg",children:[c,x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})]}):t.jsx("div",{className:G("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded",n&&"relative z-50"),onMouseEnter:P,onMouseLeave:j,onClick:S,style:{pointerEvents:"auto"},children:t.jsxs(K,{color:D(),filled:!0,className:"type-data-xs shadow-lg border border-current/30",children:[r&&t.jsx(be,{className:"w-2.5 h-2.5 mr-1"}),c,n&&x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})})}function je({hopNumber:c,snr:r,edgeColor:m}){return t.jsxs("div",{className:"flex flex-col items-center gap-0.5 pointer-events-none",children:[t.jsx("span",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center font-mono font-bold tabular-nums shadow-md",style:{backgroundColor:m||J[500],color:"#fff",fontSize:"8px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:c}),r!==void 0&&t.jsx(K,{color:"zinc",compact:!0,className:"!text-[9px] font-mono tabular-nums shadow-sm",children:r.toFixed(1)})]})}function Ee({resolvedPath:c,localNode:r,hubNodes:m=[],hoveredHopIndex:B,onHoverHop:b,traceSnr:g}){const k=g!==void 0&&g.length>0,x=a.useRef(null),E=ae(),N=ie(),S=a.useMemo(()=>new Set(m),[m]),[n,w]=a.useState(null),P=le(),[j,D]=a.useState(!1),[Z,U]=a.useState(0);a.useEffect(()=>{var f;const e=(f=x.current)==null?void 0:f.getMap();if(!e)return;const o=e.getCanvas();if(!o)return;const s=l=>{l.preventDefault(),console.warn("[PathMapMapLibre] WebGL context lost")},i=()=>{console.warn("[PathMapMapLibre] WebGL context restored, remounting..."),U(l=>l+1)};return o.addEventListener("webglcontextlost",s),o.addEventListener("webglcontextrestored",i),()=>{o.removeEventListener("webglcontextlost",s),o.removeEventListener("webglcontextrestored",i)}},[Z]);const{positions:v,markers:W,edges:I}=a.useMemo(()=>{const e=[],o=[],s=[],i=[],f=(p,V)=>p!==0||V!==0;let l=0,y=!1;return c.hops.forEach((p,V)=>{const Y=p.candidates.filter(d=>f(d.latitude,d.longitude));if(Y.length===0)return;const R=[...Y].sort((d,F)=>F.probability-d.probability),A=R[0],L=[A.longitude,A.latitude];if(i.push(L),i.length>=2){const d=i[i.length-2],F=i.length-2,M=g==null?void 0:g[F],T=L[0]-d[0],se=L[1]-d[1],ne=Math.atan2(T,se)*(180/Math.PI),re=z();let $;y?$="#F97316":M!==void 0?$=de()[ce(M,N)]||J[500]:$=re.edgeColor,s.push({from:d,to:L,snrFwd:M,midpoint:[(d[0]+L[0])/2,(d[1]+L[1])/2],bearing:ne,color:$,isFromWardrive:y})}const te=p.isSource===!0,oe=p.isDestination===!0;y=A.isWardrive===!0,R.forEach((d,F)=>{const M=[d.latitude,d.longitude];e.push(M);const T=F===0;o.push({position:M,prefix:p.prefix,confidence:p.confidence,candidateCount:R.length,hopIndex:V,candidate:d,isHub:S.has(d.hash),isPrimary:T,isSource:te,isDestination:oe,validIndex:l})}),l++}),{positions:e,markers:o,edges:s}},[c,S,g,N]),q=a.useMemo(()=>I.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[I]),u=a.useMemo(()=>{const e=W.filter(l=>l.isPrimary&&(l.confidence>=.5||l.isSource||l.isDestination));if(e.length===0)return null;let o=1/0,s=-1/0,i=1/0,f=-1/0;for(const l of e){const[y,p]=l.position;ys&&(s=y),pf&&(f=p)}return[[i,o],[f,s]]},[W]),O=a.useMemo(()=>{if(v.length===0)return r?[r.longitude,r.latitude]:[0,0];let e=0,o=0;for(const[s,i]of v)e+=s,o+=i;return[o/v.length,e/v.length]},[v,r]),H=a.useCallback(()=>{var o;const e=(o=x.current)==null?void 0:o.getMap();if(!e||!u){D(!0);return}e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:0}),setTimeout(()=>{D(!0)},50)},[u]),X=a.useMemo(()=>u?`${u[0][0].toFixed(5)},${u[0][1].toFixed(5)},${u[1][0].toFixed(5)},${u[1][1].toFixed(5)}`:"",[u]);a.useEffect(()=>{var o;if(!j)return;const e=(o=x.current)==null?void 0:o.getMap();!e||!u||e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:300})},[X,j,u]);const Q=P&&j,ee=a.useCallback(e=>{w({longitude:e.position[1],latitude:e.position[0],marker:e})},[]);return v.length===0?t.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted text-sm bg-elevated",children:"No mappable path data"}):t.jsxs("div",{className:"h-full w-full relative radius-inner overflow-hidden depth-stroke-inset",children:[!Q&&t.jsx("div",{className:"absolute inset-0 bg-elevated flex items-center justify-center pointer-events-none",children:t.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),t.jsx("div",{className:"h-full w-full transition-opacity duration-300 ease-out",style:{opacity:Q?1:0},children:t.jsxs(pe,{ref:x,initialViewState:{longitude:O[0],latitude:O[1],zoom:10},onLoad:H,style:{height:"100%",width:"100%"},mapStyle:ye,attributionControl:!1,children:[t.jsx(xe,{mode:E}),I.map((e,o)=>t.jsx(me,{id:`edge-${o}`,type:"geojson",data:q[o],children:t.jsx(fe,{id:`edge-line-${o}`,type:"line",paint:{"line-color":e.color,"line-width":4,"line-opacity":1},layout:{"line-cap":"round","line-join":"round"}})},`edge-${o}`)),I.map((e,o)=>t.jsx(_,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx(je,{hopNumber:o+1,snr:k?e.snrFwd:void 0,edgeColor:e.color})},`hop-${o}`)),(()=>{const e=W.filter(s=>s.isPrimary),o=e.length>1?e.length-2:-1;return e.map((s,i)=>{const f=B===s.hopIndex,l=i===o&&!s.candidate.isLocal&&!s.isDestination;return t.jsx(_,{longitude:s.position[1],latitude:s.position[0],anchor:"center",children:t.jsx(Ce,{prefix:s.prefix,isLocal:s.candidate.isLocal||!1,isSource:s.isSource,isDestination:s.isDestination,isLastHop:l,isHighlighted:f,isWardrive:s.candidate.isWardrive||!1,candidate:s.candidate,onHover:()=>b==null?void 0:b(s.hopIndex),onLeave:()=>b==null?void 0:b(null),onClick:()=>ee(s)})},`${s.hopIndex}-${s.candidate.hash}`)})})(),n&&t.jsx(ge,{longitude:n.longitude,latitude:n.latitude,anchor:"bottom",offset:[0,-12],closeOnClick:!1,onClose:()=>w(null),className:"maplibre-popup",children:t.jsxs("div",{className:"text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"font-semibold",children:n.marker.candidate.name}),(()=>{const e=z();return t.jsxs(t.Fragment,{children:[n.marker.isSource&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.sourceColor,color:"#000"},children:"SRC"}),n.marker.isDestination&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.destinationColor,color:"#000"},children:"DST"}),n.marker.isHub&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.hubColor,color:"#000"},children:"HUB"}),n.marker.candidate.isLocal&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.localColor,color:"#fff"},children:"LOCAL"}),n.marker.candidate.isWardrive&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:"#F97316",color:"#fff"},children:"WARDRIVE"})]})})()]}),t.jsxs("div",{className:"text-fg-muted type-data-xs",children:[n.marker.prefix," • ",n.marker.candidate.hash.slice(0,10),"..."]}),!n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{style:{color:z().ambiguousColor},children:["Alternative (",(n.marker.candidate.probability*100).toFixed(0),"%)"]}),n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{className:"text-fg-muted",children:[n.marker.candidateCount," candidates"]})]})})]},Z)})]})}export{Ee as default}; diff --git a/frontend/dist/assets/PathMapMapLibre-DYyUo4Xc.js b/frontend/dist/assets/PathMapMapLibre-DYyUo4Xc.js new file mode 100644 index 00000000..cd95d66e --- /dev/null +++ b/frontend/dist/assets/PathMapMapLibre-DYyUo4Xc.js @@ -0,0 +1 @@ +import{r as a,d0 as ae,cc as ie,c0 as le,gx as de,Z as J,cf as ce,j as t,V as K,c as G,gy as ue}from"./index-D33fcA3L.js";import{M as pe,S as me,L as fe,a as _,P as ge}from"./maplibre-gl-B42P8ehE.js";import{B as xe}from"./BasemapLayer-DhvtWc_h.js";import{C as he}from"./car-CeuvJE3C.js";import{H as ye}from"./useMapViewStore-Ey8vE9rr.js";import"./index-5slIee7x.js";import"./index-DuiHY5wq.js";const be={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},h={nodeColor:"#4338CA",localColor:"#4F46E5",hubColor:"#6366F1",edgeColor:"#3B3F4A",ambiguousColor:"#F9D26F",highlightColor:"#B49DFF",sourceColor:"#39D98A",destinationColor:"#B49DFF"};function C(c,r){if(!c)return r;if(c.startsWith("#"))return c;const m=ue(c);return m?`#${m.r.toString(16).padStart(2,"0")}${m.g.toString(16).padStart(2,"0")}${m.b.toString(16).padStart(2,"0")}`:r}function z(){if(typeof document>"u")return h;const c=document.documentElement,r=getComputedStyle(c);return{nodeColor:C(r.getPropertyValue("--map-node-stroke").trim(),h.nodeColor),localColor:C(r.getPropertyValue("--map-local-color").trim(),h.localColor),hubColor:C(r.getPropertyValue("--map-hub-color").trim(),h.hubColor),edgeColor:C(r.getPropertyValue("--map-edge-rest").trim(),h.edgeColor),ambiguousColor:C(r.getPropertyValue("--sys-indigo").trim(),h.ambiguousColor),highlightColor:C(r.getPropertyValue("--sys-blue").trim(),h.highlightColor),sourceColor:C(r.getPropertyValue("--sys-green").trim(),h.sourceColor),destinationColor:C(r.getPropertyValue("--sys-blue").trim(),h.destinationColor)}}function Ce({prefix:c,isLocal:r,isSource:m,isDestination:W,isLastHop:y,isHighlighted:g,isWardrive:k,candidate:x,onHover:E,onLeave:N,onClick:S}){const[n,w]=a.useState(!1),P=a.useCallback(()=>{w(!0),E()},[E]),j=a.useCallback(()=>{w(!1),N()},[N]),D=()=>k?"orange":r?"amber":m?"green":y?"amber":W?"purple":"blue";return k?t.jsxs("div",{className:G("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded-full",n&&"relative z-50"),onMouseEnter:P,onMouseLeave:j,onClick:S,style:{pointerEvents:"auto"},children:[t.jsx("div",{className:G("flex items-center justify-center","w-7 h-7 rounded-full","bg-sys-orange text-white","shadow-lg border-2 border-sys-orange/50","transition-transform duration-150",n&&"scale-110"),children:t.jsx(he,{className:"w-4 h-4",strokeWidth:2.5})}),n&&t.jsxs(K,{color:"orange",filled:!0,className:"ml-1 type-data-xs shadow-lg",children:[c,x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})]}):t.jsx("div",{className:G("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded",n&&"relative z-50"),onMouseEnter:P,onMouseLeave:j,onClick:S,style:{pointerEvents:"auto"},children:t.jsxs(K,{color:D(),filled:!0,className:"type-data-xs shadow-lg border border-current/30",children:[r&&t.jsx(ye,{className:"w-2.5 h-2.5 mr-1"}),c,n&&x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})})}function je({hopNumber:c,snr:r,edgeColor:m}){return t.jsxs("div",{className:"flex flex-col items-center gap-0.5 pointer-events-none",children:[t.jsx("span",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center font-mono font-bold tabular-nums shadow-md",style:{backgroundColor:m||J[500],color:"#fff",fontSize:"8px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:c}),r!==void 0&&t.jsx(K,{color:"zinc",compact:!0,className:"!text-[9px] font-mono tabular-nums shadow-sm",children:r.toFixed(1)})]})}function Ee({resolvedPath:c,localNode:r,hubNodes:m=[],hoveredHopIndex:W,onHoverHop:y,traceSnr:g}){const k=g!==void 0&&g.length>0,x=a.useRef(null),E=ae(),N=ie(),S=a.useMemo(()=>new Set(m),[m]),[n,w]=a.useState(null),P=le(),[j,D]=a.useState(!1),[Z,U]=a.useState(0);a.useEffect(()=>{var f;const e=(f=x.current)==null?void 0:f.getMap();if(!e)return;const o=e.getCanvas();if(!o)return;const s=l=>{l.preventDefault(),console.warn("[PathMapMapLibre] WebGL context lost")},i=()=>{console.warn("[PathMapMapLibre] WebGL context restored, remounting..."),U(l=>l+1)};return o.addEventListener("webglcontextlost",s),o.addEventListener("webglcontextrestored",i),()=>{o.removeEventListener("webglcontextlost",s),o.removeEventListener("webglcontextrestored",i)}},[Z]);const{positions:v,markers:$,edges:I}=a.useMemo(()=>{const e=[],o=[],s=[],i=[],f=(p,V)=>p!==0||V!==0;let l=0,b=!1;return c.hops.forEach((p,V)=>{const Y=p.candidates.filter(d=>f(d.latitude,d.longitude));if(Y.length===0)return;const R=[...Y].sort((d,F)=>F.probability-d.probability),A=R[0],L=[A.longitude,A.latitude];if(i.push(L),i.length>=2){const d=i[i.length-2],F=i.length-2,M=g==null?void 0:g[F],T=L[0]-d[0],se=L[1]-d[1],ne=Math.atan2(T,se)*(180/Math.PI),re=z();let B;b?B="#F97316":M!==void 0?B=de()[ce(M,N)]||J[500]:B=re.edgeColor,s.push({from:d,to:L,snrFwd:M,midpoint:[(d[0]+L[0])/2,(d[1]+L[1])/2],bearing:ne,color:B,isFromWardrive:b})}const te=p.isSource===!0,oe=p.isDestination===!0;b=A.isWardrive===!0,R.forEach((d,F)=>{const M=[d.latitude,d.longitude];e.push(M);const T=F===0;o.push({position:M,prefix:p.prefix,confidence:p.confidence,candidateCount:R.length,hopIndex:V,candidate:d,isHub:S.has(d.hash),isPrimary:T,isSource:te,isDestination:oe,validIndex:l})}),l++}),{positions:e,markers:o,edges:s}},[c,S,g,N]),q=a.useMemo(()=>I.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[I]),u=a.useMemo(()=>{const e=$.filter(l=>l.isPrimary&&(l.confidence>=.5||l.isSource||l.isDestination));if(e.length===0)return null;let o=1/0,s=-1/0,i=1/0,f=-1/0;for(const l of e){const[b,p]=l.position;bs&&(s=b),pf&&(f=p)}return[[i,o],[f,s]]},[$]),O=a.useMemo(()=>{if(v.length===0)return r?[r.longitude,r.latitude]:[0,0];let e=0,o=0;for(const[s,i]of v)e+=s,o+=i;return[o/v.length,e/v.length]},[v,r]),H=a.useCallback(()=>{var o;const e=(o=x.current)==null?void 0:o.getMap();if(!e||!u){D(!0);return}e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:0}),setTimeout(()=>{D(!0)},50)},[u]),X=a.useMemo(()=>u?`${u[0][0].toFixed(5)},${u[0][1].toFixed(5)},${u[1][0].toFixed(5)},${u[1][1].toFixed(5)}`:"",[u]);a.useEffect(()=>{var o;if(!j)return;const e=(o=x.current)==null?void 0:o.getMap();!e||!u||e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:300})},[X,j,u]);const Q=P&&j,ee=a.useCallback(e=>{w({longitude:e.position[1],latitude:e.position[0],marker:e})},[]);return v.length===0?t.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted text-sm bg-elevated",children:"No mappable path data"}):t.jsxs("div",{className:"h-full w-full relative radius-inner overflow-hidden depth-stroke-inset",children:[!Q&&t.jsx("div",{className:"absolute inset-0 bg-elevated flex items-center justify-center pointer-events-none",children:t.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),t.jsx("div",{className:"h-full w-full transition-opacity duration-300 ease-out",style:{opacity:Q?1:0},children:t.jsxs(pe,{ref:x,initialViewState:{longitude:O[0],latitude:O[1],zoom:10},onLoad:H,style:{height:"100%",width:"100%"},mapStyle:be,attributionControl:!1,children:[t.jsx(xe,{mode:E}),I.map((e,o)=>t.jsx(me,{id:`edge-${o}`,type:"geojson",data:q[o],children:t.jsx(fe,{id:`edge-line-${o}`,type:"line",paint:{"line-color":e.color,"line-width":4,"line-opacity":1},layout:{"line-cap":"round","line-join":"round"}})},`edge-${o}`)),I.map((e,o)=>t.jsx(_,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx(je,{hopNumber:o+1,snr:k?e.snrFwd:void 0,edgeColor:e.color})},`hop-${o}`)),(()=>{const e=$.filter(s=>s.isPrimary),o=e.length>1?e.length-2:-1;return e.map((s,i)=>{const f=W===s.hopIndex,l=i===o&&!s.candidate.isLocal&&!s.isDestination;return t.jsx(_,{longitude:s.position[1],latitude:s.position[0],anchor:"center",children:t.jsx(Ce,{prefix:s.prefix,isLocal:s.candidate.isLocal||!1,isSource:s.isSource,isDestination:s.isDestination,isLastHop:l,isHighlighted:f,isWardrive:s.candidate.isWardrive||!1,candidate:s.candidate,onHover:()=>y==null?void 0:y(s.hopIndex),onLeave:()=>y==null?void 0:y(null),onClick:()=>ee(s)})},`${s.hopIndex}-${s.candidate.hash}`)})})(),n&&t.jsx(ge,{longitude:n.longitude,latitude:n.latitude,anchor:"bottom",offset:[0,-12],closeOnClick:!1,onClose:()=>w(null),className:"maplibre-popup",children:t.jsxs("div",{className:"text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"font-semibold",children:n.marker.candidate.name}),(()=>{const e=z();return t.jsxs(t.Fragment,{children:[n.marker.isSource&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.sourceColor,color:"#000"},children:"SRC"}),n.marker.isDestination&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.destinationColor,color:"#000"},children:"DST"}),n.marker.isHub&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.hubColor,color:"#000"},children:"HUB"}),n.marker.candidate.isLocal&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.localColor,color:"#fff"},children:"LOCAL"}),n.marker.candidate.isWardrive&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:"#F97316",color:"#fff"},children:"WARDRIVE"})]})})()]}),t.jsxs("div",{className:"text-fg-muted type-data-xs",children:[n.marker.prefix," • ",n.marker.candidate.hash.slice(0,10),"..."]}),!n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{style:{color:z().ambiguousColor},children:["Alternative (",(n.marker.candidate.probability*100).toFixed(0),"%)"]}),n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{className:"text-fg-muted",children:[n.marker.candidateCount," candidates"]})]})})]},Z)})]})}export{Ee as default}; diff --git a/frontend/dist/assets/RoomServer-BLm1y_Ek.js b/frontend/dist/assets/RoomServer-D7QRe_4I.js similarity index 92% rename from frontend/dist/assets/RoomServer-BLm1y_Ek.js rename to frontend/dist/assets/RoomServer-D7QRe_4I.js index 5ed255dd..6dc737d3 100644 --- a/frontend/dist/assets/RoomServer-BLm1y_Ek.js +++ b/frontend/dist/assets/RoomServer-D7QRe_4I.js @@ -1,21 +1,21 @@ -import{e as Y,r as l,j as e,cs as I,aa as De,c as A,aC as Ae,aK as $e,aD as Ke,V as U,I as E,eJ as Fe,B as b,ca as we,aE as ie,O as Oe,a7 as te,a3 as Ce,a0 as G,a1 as Be,eK as Se,eL as ze,bI as _e,eM as qe,eN as He,eO as Ve,eP as Ue,eQ as Ge,eR as Ie,eS as We,eT as Ye,a6 as Qe,Q as Je,eE as Xe,cu as ce}from"./index-C2xvS0Jd.js";import{C as q,P as de,a as me,B as Ze}from"./PageLayout-Cg7r5tdt.js";import{R as es,C as ue}from"./Grid-kVOI-wJp.js";import{c as ss,m as ts}from"./node-types-BD70swWz.js";import{R as as}from"./repeat-CprMAEnr.js";import{L as ns,a as rs,b as ls}from"./listbox-DnHpTyQt.js";import{P as os}from"./plus-CH14Vv92.js";import{F as P,L as D,D as is}from"./fieldset-DQmrmWyj.js";import{M as Z}from"./map-pin-CQk00ph2.js";import{T as Re}from"./trash-2-Def3YmfN.js";import{S as ee,K as W}from"./KeycapButton-BVIaMPId.js";import{C as xe}from"./ConfirmModal-eC-cl0ep.js";import{S as cs,C as ds}from"./ChatBubble-DsIWWOdr.js";import{e as ms,g as us,a as xs}from"./chat-utils-DnJ-lYj3.js";import{W as se}from"./wifi-Bc9OxL0c.js";import{M as ps}from"./message-square-text-B47-Hjgn.js";import{K as hs}from"./key-round-DBZOsqH6.js";import"./element-movement-CSQuYFsD.js";import"./use-text-value-CU5Ho7TY.js";import"./frozen-Cx4cJH6f.js";import"./keycap-sfx-ByZp-njj.js";/** +import{e as I,r as l,j as e,ct as W,aa as De,c as A,aC as Ae,aL as $e,aD as Ke,V as U,I as E,eJ as Fe,B as b,cb as we,aF as ie,O as Oe,a7 as te,a3 as Ce,a0 as G,a1 as Be,eK as Se,eL as ze,bJ as _e,eM as qe,eN as He,eO as Ve,eP as Ue,eQ as Ge,eR as We,eS as Ye,eT as Ie,a6 as Je,Q as Qe,eE as Xe,cv as ce}from"./index-D33fcA3L.js";import{C as q,P as de,a as me,B as Ze}from"./PageLayout-CRN-E5xi.js";import{R as es,C as ue}from"./Grid-DQYUnZsY.js";import{c as ss,m as ts}from"./node-types-BoqnL0Eg.js";import{R as as}from"./repeat-DUo9RRDi.js";import{L as ns,a as rs,b as ls}from"./listbox-DkfYDEqr.js";import{P as os}from"./plus-C0dCjBh9.js";import{F as P,L as D,D as is}from"./fieldset-DsbEWHIy.js";import{M as Z}from"./map-pin-B_Rx-xpd.js";import{T as Re}from"./trash-2-CUY4NG5t.js";import{S as ee,K as Y}from"./KeycapButton-xWUX1i8p.js";import{C as xe}from"./ConfirmModal-J2_Sxirm.js";import{S as cs,C as ds}from"./ChatBubble-BqRoJxSW.js";import{e as ms,g as us,a as xs}from"./chat-utils-DIy1-SG1.js";import{W as se}from"./wifi-D716s0ef.js";import{M as ps}from"./message-square-text-DlzXvsDV.js";import{K as hs}from"./key-round-n5zCigFv.js";import"./element-movement-BL6huHzq.js";import"./use-text-value-iYUkduzo.js";import"./frozen-C10EXZ59.js";import"./keycap-sfx-ByZp-njj.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 fs=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],Me=Y("message-circle",fs);/** + */const fs=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],Me=I("message-circle",fs);/** * @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 gs=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],js=Y("message-square-plus",gs);/** + */const gs=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],js=I("message-square-plus",gs);/** * @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 ys=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],pe=Y("terminal",ys);/** + */const ys=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],pe=I("terminal",ys);/** * @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 vs=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],Ns=Y("user-x",vs);function bs(s,t){return l.useMemo(()=>{const a=new Map;for(const[n,c]of Object.entries(s)){const m=c.name||c.node_name||null,{type:d}=ss(c);a.set(n.toLowerCase(),{name:m,type:d})}const r=new Map;for(let n=t.length-1;n>=0;n--){const c=t[n];if(!c._advertSender)continue;const m=c._advertSender.toLowerCase();if(r.has(m))continue;const d=c._advertName??null,o=c._advertNodeType!=null?ts(c._advertNodeType):"companion";r.set(m,{name:d,type:o})}return function(c){const m=c.toLowerCase(),d=a.get(m);if(d!=null&&d.name)return d;const o=r.get(m);return o!=null&&o.name?o:d||o||{name:null,type:"companion"}}},[s,t])}function he({icon:s,title:t,description:i,onClick:a,accent:r}){return e.jsxs("button",{onClick:a,className:A("flex flex-col items-center gap-3 p-6 rounded-2xl text-center","ring-1 ring-edge-subtle hover:ring-2 transition-all duration-150","w-full max-w-[260px]",r==="primary"?"hover:ring-sys-blue hover:bg-sys-blue/5":"hover:ring-sys-indigo hover:bg-sys-indigo/5"),children:[e.jsx("div",{className:A("p-3 rounded-xl",r==="primary"?"bg-sys-blue/10 text-sys-blue":"bg-sys-indigo/10 text-sys-indigo"),children:s}),e.jsx("p",{className:"type-body-sm font-medium text-fg-primary",children:t}),e.jsx("p",{className:"type-data-xs text-fg-muted leading-relaxed",children:i})]})}function ks({onCreateRoom:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[e.jsx(I,{className:"w-12 h-12 text-fg-muted opacity-30 mb-4"}),e.jsx("p",{className:"type-subheading text-fg-secondary mb-1",children:"Add a Room Server"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-8",children:"Choose how this device should operate."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[e.jsx(he,{icon:e.jsx(as,{className:"w-6 h-6"}),title:"Repeater + Room Server",description:"Keep forwarding packets and add group messaging.",onClick:()=>s("hybrid"),accent:"primary"}),e.jsx(he,{icon:e.jsx(De,{className:"w-6 h-6"}),title:"Dedicated Room Server",description:"Stop repeating. Focus entirely on room server duties.",onClick:()=>s("dedicated"),accent:"secondary"})]})]})}function ws({rooms:s,selected:t,onSelect:i,onAdd:a}){const r=a?e.jsx("button",{onClick:a,className:A("flex items-center justify-center px-2 py-1 rounded-md","text-fg-muted hover:text-fg-primary hover:bg-surface/60","transition-all duration-150"),title:"Add room server",children:e.jsx(os,{className:"w-4 h-4"})}):null;return s.length<=1?r:s.length<=3?e.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 rounded-lg bg-subtle-fill",children:[s.map(n=>e.jsx("button",{onClick:()=>i(n.room_name),className:A("px-3 py-1 rounded-md text-sm font-medium transition-all duration-150",n.room_name===t?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:n.room_name},n.room_name)),r]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ns,{value:t??"",onChange:i,children:s.map(n=>e.jsx(rs,{value:n.room_name,children:e.jsx(ls,{children:n.room_name})},n.room_name))}),r]})}function Cs(s){return s.settings??{}}function Ss(s){if(!s)return"";const t=s.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");return t?`${t}-room`:""}function fe({open:s,onClose:t,mode:i,identity:a,repeaterConfig:r,onCreate:n,onUpdate:c,onDelete:m,onSendAdvert:d}){var ae,ne,re,le;const o=i==="edit"&&a,x=`${s}-${(a==null?void 0:a.name)??""}-${i}`,[p,h]=l.useState(""),[g,j]=l.useState(""),[y,$]=l.useState(!1),[S,_]=l.useState(""),[k,R]=l.useState(""),[N,M]=l.useState(""),[w,T]=l.useState(""),[C,K]=l.useState(!1),[F,O]=l.useState(!1),[H,B]=l.useState(!1),[z,L]=l.useState(null),[J,f]=l.useState(x);if(x!==J)if(f(x),L(null),K(!1),O(!1),B(!1),o){const u=Cs(a);h(u.node_name??a.name),j(a.identity_key??""),$(!1),_(u.admin_password??""),R(u.guest_password??""),M(((ae=u.latitude)==null?void 0:ae.toString())??""),T(((ne=u.longitude)==null?void 0:ne.toString())??"")}else{const u=r;h(""),j(""),$(!1),_(""),R(""),M(((re=u==null?void 0:u.repeater)==null?void 0:re.latitude)!=null?u.repeater.latitude.toString():""),T(((le=u==null?void 0:u.repeater)==null?void 0:le.longitude)!=null?u.repeater.longitude.toString():"")}const v=l.useCallback(()=>{const u={};return p&&(u.node_name=p),S&&(u.admin_password=S),k&&(u.guest_password=k),N!==""&&(u.latitude=parseFloat(N)),w!==""&&(u.longitude=parseFloat(w)),u},[p,S,k,N,w]),Le=l.useCallback(async()=>{if(!p.trim()){L("Room name is required");return}K(!0),L(null);const u=o?a.name:Ss(p);let X;if(o)X=await c({name:a.name,settings:v()});else{const oe={name:u,type:"room_server",settings:v()};g.trim()&&(oe.identity_key=g.trim()),X=await n(oe)}K(!1),X?t():L("Failed to save. Check that the name is unique and passwords differ.")},[p,o,a,v,n,c,t]),Ee=l.useCallback(async()=>{if(!o)return;O(!0);const u=await m(a.name);O(!1),u&&t()},[o,a,m,t]),Pe=l.useCallback(async()=>{o&&(B(!0),await d(a.name),B(!1))},[o,a,d]);return e.jsxs(Ae,{open:s,onClose:t,size:"md",children:[e.jsx($e,{icon:o?void 0:e.jsx(js,{className:"w-5 h-5"}),title:o?"Edit Room Server":"Add Room Server",onClose:t}),e.jsx(Ke,{children:e.jsxs("div",{className:"space-y-5",children:[o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{color:a.registered?"green":"red",children:a.registered?"Active":"Inactive"}),a.identity_key&&e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",title:a.identity_key,children:["Key: ",a.identity_key.slice(0,16),"…"]})]}),e.jsxs(P,{children:[e.jsx(D,{title:"What people see on the mesh",children:"Room Name"}),e.jsx(E,{value:p,onChange:u=>h(u.target.value),placeholder:"Room Name"})]}),!o&&e.jsxs(P,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{title:"The unique hex public ID",children:["Identity Key ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx("button",{type:"button",onClick:()=>$(u=>!u),className:"type-data-xs text-fg-muted underline hover:text-fg-secondary",children:y?"Hide":"Show"})]}),y&&e.jsxs(e.Fragment,{children:[e.jsx(E,{value:g,onChange:u=>j(u.target.value),placeholder:"Leave empty to auto-generate"}),e.jsx(is,{children:"Leave empty to automatically generate a secure key"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(P,{children:[e.jsxs(D,{children:[e.jsx(Z,{className:"inline w-3.5 h-3.5 -mt-0.5 mr-1 text-fg-muted"}),"Latitude"]}),e.jsx(E,{type:"number",step:"any",value:N,onChange:u=>M(u.target.value),placeholder:"0"})]}),e.jsxs(P,{children:[e.jsxs(D,{children:[e.jsx(Z,{className:"inline w-3.5 h-3.5 -mt-0.5 mr-1 text-fg-muted"}),"Longitude"]}),e.jsx(E,{type:"number",step:"any",value:w,onChange:u=>T(u.target.value),placeholder:"0"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(P,{children:[e.jsxs(D,{title:"Full access to room server",children:["Admin Password ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(E,{type:"password",value:S,onChange:u=>_(u.target.value),placeholder:"None Set"})]}),e.jsxs(P,{children:[e.jsxs(D,{title:"Can post and read, but not administer the room",children:["Guest Password ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(E,{type:"password",value:k,onChange:u=>R(u.target.value),placeholder:"None Set"})]})]}),z&&e.jsx("p",{className:"type-data-xs text-sys-red",children:z})]})}),e.jsxs(Fe,{children:[o&&e.jsxs("div",{className:"flex items-center gap-2 mr-auto",children:[e.jsxs(b,{color:"danger",plain:!0,onClick:Ee,disabled:F,children:[e.jsx(Re,{"data-slot":"icon"}),F?"Deleting…":"Delete"]}),e.jsxs(b,{color:"primary",plain:!0,onClick:Pe,disabled:H,children:[e.jsx(we,{"data-slot":"icon"}),H?"Sending…":"Send Advert"]})]}),e.jsx(b,{plain:!0,onClick:t,children:"Cancel"}),e.jsx(b,{color:"primary",onClick:Le,disabled:C,children:C?"Saving…":o?"Save Changes":"Create"})]})]})}const Te=l.createContext(null),ge="room-tui";function je({children:s}){const[t,i]=l.useState(()=>localStorage.getItem(ge)!=="0"),a=l.useCallback(()=>{i(r=>{const n=!r;return localStorage.setItem(ge,n?"1":"0"),n})},[]);return e.jsx(Te.Provider,{value:{terminalMode:t,toggleTerminalMode:a},children:s})}function Q(){const s=l.useContext(Te);if(!s)throw new Error("useTerminalMode must be used within RoomTerminalProvider");return s}const ye=s=>s.author_pubkey==="server"||s.author_pubkey==="system";function ve({messages:s,onDelete:t,terminalMode:i,serverName:a}){const r=l.useRef(null),[n,c]=l.useState(!1),m=l.useMemo(()=>[...s].sort((x,p)=>x.post_timestamp-p.post_timestamp),[s]);l.useEffect(()=>{!n&&r.current&&(r.current.scrollTop=0)},[m.length,n]);const d=l.useCallback(()=>{r.current&&c(r.current.scrollTop<-100)},[]),o=l.useCallback(()=>{r.current&&r.current.scrollTo({top:0,behavior:"smooth"}),c(!1)},[]);return m.length===0?e.jsx("div",{className:`flex-1 flex flex-col items-center justify-center py-12 min-h-0${i?" font-mono":""}`,children:i?e.jsx("p",{className:"text-sm font-mono",style:{color:"var(--tui-accent)",opacity:.4},children:"> no messages in buffer_"}):e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"w-10 h-10 text-fg-muted opacity-20 mb-2"}),e.jsx("p",{className:"type-data-sm text-fg-muted",children:"No messages yet"})]})}):i?e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:r,onScroll:d,className:"h-full overflow-y-auto scroll-smooth p-4 font-mono text-sm leading-relaxed flex flex-col-reverse",children:e.jsx("div",{children:m.map(x=>{const p=ye(x),h=new Date(x.post_timestamp*1e3).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),g=p?"SYS":x.author_name||x.author_prefix,j=!p&&a&&g===a;return e.jsxs("div",{className:"group flex items-start gap-0 -mx-4 px-4 py-px",style:{"--tw-hover-bg":"var(--tui-hover-bg)"},onMouseEnter:y=>y.currentTarget.style.background="var(--tui-hover-bg)",onMouseLeave:y=>y.currentTarget.style.background="",children:[e.jsxs("span",{className:"select-none shrink-0",style:{color:"var(--tui-muted)"},children:["[",h,"]"]}),e.jsxs("span",{className:"mx-1.5 shrink-0",style:{color:j?"var(--tui-accent-local)":"var(--tui-accent)"},children:["<",g,">"]}),e.jsx("span",{style:{color:p?"var(--tui-system)":j?"var(--tui-body)":"var(--tui-accent)"},className:p?"italic":"",children:x.message_text}),e.jsx("button",{onClick:()=>t(x.id),className:"opacity-0 group-hover:opacity-100 ml-auto pl-2 shrink-0 transition-colors",style:{color:"var(--tui-muted)"},onMouseEnter:y=>y.currentTarget.style.color="var(--tui-danger)",onMouseLeave:y=>y.currentTarget.style.color="var(--tui-muted)",title:"Delete",children:"×"})]},x.id)})})}),n&&e.jsxs("button",{onClick:o,className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1.5 px-3 py-1 font-mono text-xs transition-colors duration-150",style:{background:"var(--tui-hover-bg)",border:"1px solid var(--tui-muted)",color:"var(--tui-accent)"},children:[e.jsx(ie,{className:"w-3 h-3"}),"↓ scroll"]})]}):e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:r,onScroll:d,className:"h-full overflow-y-auto scroll-smooth flex flex-col-reverse",children:e.jsx("div",{className:"p-4",children:m.map(x=>ye(x)?e.jsx(cs,{text:x.message_text},x.id):e.jsx(ds,{senderName:x.author_name||x.author_prefix,text:x.message_text,timestamp:x.post_timestamp,bubbleAccessory:e.jsx("button",{onClick:()=>t(x.id),className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150 p-1 text-fg-muted hover:text-sys-red flex-shrink-0",title:"Delete message",children:e.jsx(Re,{className:"w-3.5 h-3.5"})})},x.id))})}),n&&e.jsxs("button",{onClick:o,className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-surface/90 backdrop-blur-sm ring-1 ring-edge-subtle shadow-md text-fg-secondary hover:text-fg-primary transition-colors duration-150",children:[e.jsx(ie,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs",children:"New messages"})]})]})}function Ne({roomName:s,onSend:t,disabled:i,terminalMode:a}){const[r,n]=l.useState(""),[c,m]=l.useState(!1),d=l.useRef(null),o=l.useCallback(async()=>{var g;const p=r.trim();if(!p||c)return;m(!0);const h=await t(p);m(!1),h&&(n(""),(g=d.current)==null||g.focus())},[r,c,t]),x=l.useCallback(p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),o())},[o]);return a?e.jsxs("div",{className:"flex items-center gap-0 px-4 py-2 type-data-sm",children:[e.jsx("input",{ref:d,type:"text",value:r,onChange:p=>n(p.target.value),onKeyDown:x,placeholder:"type message...",disabled:i||c,className:"flex-1 bg-transparent outline-none ring-0 shadow-none border-none focus:outline-none focus:ring-0 font-mono tui-input",style:{color:"var(--tui-body)"}}),e.jsx("button",{onClick:o,disabled:!r.trim()||c||i,className:"transition-colors duration-100 px-1 font-mono text-xs disabled:opacity-30",style:{color:"var(--tui-accent)"},title:"Send",children:"[↵]"})]}):e.jsxs("div",{className:"flex items-center gap-2 p-3 border-t border-edge-subtle",children:[e.jsx("input",{ref:d,type:"text",value:r,onChange:p=>n(p.target.value),onKeyDown:x,placeholder:`Message ${s}…`,disabled:i||c,className:"flex-1 surface-input radius-inner px-3 py-2 type-body-sm text-fg-primary placeholder:text-fg-muted outline-none ring-focus"}),e.jsx("button",{onClick:o,disabled:!r.trim()||c||i,className:"p-2 rounded-lg text-sys-blue hover:bg-sys-blue/10 disabled:opacity-30 disabled:hover:bg-transparent transition-colors duration-150",title:"Send message",children:e.jsx(we,{className:"w-4.5 h-4.5"})})]})}function _s({selectedName:s,selectedIdentity:t,messages:i,onSend:a,onDelete:r,onClear:n}){var h;const{terminalMode:c,toggleTerminalMode:m}=Q(),[d,o]=l.useState(!1),x=((h=t==null?void 0:t.settings)==null?void 0:h.node_name)??s??void 0,p=l.useCallback(()=>{o(!1),n()},[n]);return c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[e.jsxs("div",{className:"card-terminal-header flex-shrink-0",children:[e.jsx("span",{className:"seven-seg-panel",children:e.jsx(ee,{text:"chat",minChars:7,size:24})}),e.jsx("div",{className:"card-terminal-ridge flex-1"}),e.jsxs("div",{className:"header-well",children:[e.jsx(W,{icon:e.jsx(pe,{className:"!w-5.5 !h-5.5 translate-y-px"}),onClick:m,title:"Exit terminal mode"}),i.length>0&&e.jsx(W,{icon:e.jsx("span",{className:"text-[13px] font-bold font-mono leading-none translate-y-px",children:"DEL"}),onClick:()=>o(!0),title:"Clear all messages",variant:"red",iconActiveColor:Oe.red})]})]}),e.jsx(q,{noPadding:!0,className:"flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",children:e.jsxs("div",{className:"card-terminal-well flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx(ve,{messages:i,onDelete:r,terminalMode:!0,serverName:x}),e.jsx("div",{className:"card-terminal-divider"}),s&&e.jsx(Ne,{roomName:s,onSend:a,disabled:!(t!=null&&t.registered),terminalMode:!0})]})})]}),e.jsx(xe,{isOpen:d,title:"Clear All Messages",message:`This will permanently delete all ${i.length} message${i.length===1?"":"s"} from this room. This cannot be undone.`,confirmLabel:"Clear Messages",variant:"danger",onConfirm:p,onCancel:()=>o(!1)})]}):e.jsxs(e.Fragment,{children:[e.jsxs(q,{noPadding:!0,className:"flex flex-col h-full overflow-hidden",children:[e.jsx(te,{listHeader:!0,icon:e.jsx(Me,{className:"icon-sm"}),title:"Messages",actions:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(b,{plain:!0,onClick:m,title:"Terminal mode",children:e.jsx(pe,{"data-slot":"icon",className:"!w-5 !h-5 translate-y-px"})}),i.length>0&&e.jsx(b,{plain:!0,onClick:()=>o(!0),title:"Clear all messages",children:e.jsx("span",{"data-slot":"icon",className:"text-[12px] font-bold font-mono leading-none translate-y-px text-sys-red",children:"DEL"})})]})}),e.jsx(ve,{messages:i,onDelete:r,terminalMode:!1,serverName:x}),s&&e.jsx(Ne,{roomName:s,onSend:a,disabled:!(t!=null&&t.registered),terminalMode:!1})]}),e.jsx(xe,{isOpen:d,title:"Clear All Messages",message:`This will permanently delete all ${i.length} message${i.length===1?"":"s"} from this room. This cannot be undone.`,confirmLabel:"Clear Messages",variant:"danger",onConfirm:p,onCancel:()=>o(!1)})]})}function Rs({pubkey:s,className:t}){const[i,a]=l.useState(!1),r=l.useCallback(async()=>{await Ce(s),a(!0),setTimeout(()=>a(!1),1500)},[s]);return e.jsxs("button",{onClick:r,title:i?"Copied!":"Copy public key",className:`inline-flex items-center gap-1 type-data-xs leading-tight text-fg-muted hover:text-fg-secondary transition-colors duration-150 cursor-copy ${t??""}`,children:[e.jsx("span",{className:"truncate min-w-0",children:s.slice(0,8)}),i&&e.jsx(G,{className:"w-2.5 h-2.5 text-sys-green flex-shrink-0"})]})}const Ms=l.memo(function({client:t,resolvedName:i,onRemove:a}){const r=t.name||i,n=t.unsynced_count===0,c=t.last_activity?new Date(t.last_activity*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never",{emoji:m,cleanName:d}=r?ms(r):{emoji:null,cleanName:t.pubkey_prefix},o=r?us(d):void 0,x=r?xs(r):t.pubkey_prefix.slice(0,2).toUpperCase();return e.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2.5 radius-inner row-hover transition-base",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:A("w-8 h-8 rounded-full flex items-center justify-center",o?"clay-avatar":"bg-sys-blue/12"),style:o?{"--avatar-color":o}:void 0,children:m?e.jsx("span",{className:"text-base leading-none",children:m}):e.jsx("span",{className:A("leading-none",o?"text-white text-[11px] font-bold tracking-tight":"text-sys-blue font-mono text-[11px]"),children:x})}),e.jsx("span",{className:`absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-sm ring-2 ring-surface ${n?"bg-sys-green":"bg-sys-indigo"}`})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[r?e.jsx("p",{className:"text-[13px] font-medium leading-tight text-fg-primary truncate",children:r}):e.jsx("p",{className:"font-mono text-[13px] leading-tight text-fg-primary truncate",children:t.pubkey_prefix}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[r&&e.jsx(Rs,{pubkey:t.pubkey}),r&&e.jsx("span",{className:"text-xs text-fg-muted/40",children:"·"}),e.jsxs("span",{className:"text-xs leading-tight text-fg-muted truncate",children:[!n&&e.jsxs("span",{className:"text-sys-indigo",children:[t.unsynced_count," unsynced · "]}),c]})]})]}),e.jsx("button",{onClick:()=>a(t.pubkey),className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150 p-1.5 -mr-1 rounded-md text-fg-muted hover:text-sys-red hover:bg-sys-red/8",title:"Remove client",children:e.jsx(Ns,{className:"w-3.5 h-3.5"})})]})});function be({clients:s,onRemove:t,messages:i,terminalMode:a}){const r=l.useMemo(()=>{const n=new Map;if(!i)return n;for(let c=i.length-1;c>=0;c--){const m=i[c];m.author_name&&m.author_pubkey&&m.author_pubkey!=="server"&&m.author_pubkey!=="system"&&n.set(m.author_pubkey,m.author_name)}return n},[i]);return s.length===0?a?e.jsx("p",{className:"type-data-sm text-left px-4 py-4",style:{color:"var(--tui-accent)"},children:"< NO CLIENTS CONNECTED >"}):e.jsx("p",{className:"type-data-xs text-fg-muted text-center py-4",children:"No clients connected"}):a?e.jsx("div",{className:"type-data-sm pt-2",children:s.map(n=>{const c=n.name||r.get(n.pubkey),m=n.unsynced_count===0,d=n.pubkey_prefix;return e.jsxs("div",{className:"group flex items-center gap-0 -mx-0 px-4 py-0.5",onMouseEnter:o=>o.currentTarget.style.background="var(--tui-hover-bg)",onMouseLeave:o=>o.currentTarget.style.background="",children:[e.jsx("span",{style:{color:m?"var(--tui-accent)":"var(--tui-warn)"},children:"■"}),e.jsx("span",{className:"ml-2 shrink-0",style:{color:"var(--tui-accent)"},children:c||d}),c&&e.jsxs("span",{className:"ml-1.5 shrink-0",style:{color:"var(--tui-accent)"},children:["[",d,"]"]}),!m&&e.jsxs("span",{className:"ml-1.5",style:{color:"var(--tui-warn)"},children:[n.unsynced_count,"unsync"]}),e.jsx("button",{onClick:()=>t(n.pubkey),className:"opacity-0 group-hover:opacity-100 ml-auto pl-2 shrink-0 transition-colors",style:{color:"var(--tui-muted)"},onMouseEnter:o=>o.currentTarget.style.color="var(--tui-danger)",onMouseLeave:o=>o.currentTarget.style.color="var(--tui-muted)",title:"Remove",children:"×"})]},n.pubkey)})}):e.jsx("div",{className:"space-y-0.5 pt-1",children:s.map(n=>e.jsx(Ms,{client:n,resolvedName:r.get(n.pubkey),onRemove:t},n.pubkey))})}function Ts({name:s,onSend:t}){const{terminalMode:i}=Q(),[a,r]=l.useState("idle"),n=l.useRef(),c=l.useCallback(async()=>{if(a==="sending")return;r("sending");const m=await t(s);r(m?"sent":"idle"),m&&(n.current=setTimeout(()=>r("idle"),2e3))},[s,t,a]);return l.useEffect(()=>()=>clearTimeout(n.current),[]),i?e.jsxs("button",{className:"btn-terminal",onClick:c,disabled:a==="sending",children:[a==="idle"&&"[ send_advert ]",a==="sending"&&"[ broadcasting... ]",a==="sent"&&"[ sent ✓ ]"]}):e.jsxs(b,{color:a==="sent"?"success":"primary",className:"w-full",onClick:c,disabled:a==="sending",children:[e.jsx(se,{"data-slot":"icon"}),a==="idle"&&"Send Advert",a==="sending"&&"Broadcasting…",a==="sent"&&"Advert Sent"]})}function V(s){return s.settings??{}}function ke({identity:s,onSendAdvert:t}){var c,m,d,o,x,p;const{terminalMode:i}=Q(),[a,r]=l.useState(!1),n=l.useCallback(async()=>{s!=null&&s.identity_key&&(await Ce(s.identity_key),r(!0),setTimeout(()=>r(!1),1500))},[s==null?void 0:s.identity_key]);return i?s?e.jsxs("div",{className:"space-y-1",children:[((c=s.settings)==null?void 0:c.node_name)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"node"}),e.jsx("span",{style:{color:"var(--tui-accent)"},children:s.settings.node_name})]}),(s.address||((m=s.runtime)==null?void 0:m.address))&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"addr"}),e.jsx("span",{style:{color:"var(--tui-accent)"},children:s.address||((d=s.runtime)==null?void 0:d.address)})]}),s.identity_key&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"key"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"truncate max-w-[140px]",style:{color:"var(--tui-accent)"},title:s.identity_key,children:[s.identity_key.slice(0,16),"…"]}),e.jsx("button",{type:"button",onClick:n,className:"text-xs",style:{color:"var(--tui-muted)"},children:a?"[copied ✓]":"[copy]"})]})]}),(()=>{var g,j;const h=V(s);return h.latitude!=null||h.longitude!=null?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"loc"}),e.jsxs("span",{style:{color:"var(--tui-accent)"},title:`${h.latitude??"—"}, ${h.longitude??"—"}`,children:[((g=h.latitude)==null?void 0:g.toFixed(4))??"—",", ",((j=h.longitude)==null?void 0:j.toFixed(4))??"—"]})]}):null})(),(()=>{const h=V(s);return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"pass"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{color:h.admin_password?"var(--tui-accent)":"var(--tui-muted)"},children:h.admin_password?"[✓ admin]":"[— admin]"}),e.jsx("span",{style:{color:h.guest_password?"var(--tui-accent)":"var(--tui-muted)"},children:h.guest_password?"[✓ guest]":"[— guest]"})]})]})})()]}):e.jsx("span",{style:{color:"var(--tui-muted)"},children:"no identity configured"}):e.jsxs("div",{className:"flex-shrink-0 border-t border-edge-subtle",children:[e.jsx(te,{listHeader:!0,icon:e.jsx(ps,{className:"icon-sm"}),title:"Room Info"}),s?e.jsxs("div",{className:"space-y-2 px-4 py-3",children:[((o=s.settings)==null?void 0:o.node_name)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Node"}),e.jsx("span",{className:"type-data-sm text-fg-primary",children:s.settings.node_name})]}),(s.address||((x=s.runtime)==null?void 0:x.address))&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Address"}),e.jsx("span",{className:"type-data-sm font-mono text-fg-primary",children:s.address||((p=s.runtime)==null?void 0:p.address)})]}),s.identity_key&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted flex items-center gap-1",title:"The unique hex public ID",children:[e.jsx(hs,{className:"w-3 h-3"}),"Key"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"type-data-sm font-mono text-fg-primary truncate max-w-[140px]",title:s.identity_key,children:[s.identity_key.slice(0,16),"…"]}),e.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center gap-0.5",children:e.jsx(U,{color:a?"green":"zinc",children:a?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-3 h-3"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-3 h-3"}),"Copy"]})})})]})]}),(()=>{var g,j;const h=V(s);return h.latitude!=null||h.longitude!=null?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted flex items-center gap-1",children:[e.jsx(Z,{className:"w-3 h-3"}),"Location"]}),e.jsxs("span",{className:"type-data-sm font-mono text-fg-primary",title:`${h.latitude??"—"}, ${h.longitude??"—"}`,children:[((g=h.latitude)==null?void 0:g.toFixed(4))??"—",", ",((j=h.longitude)==null?void 0:j.toFixed(4))??"—"]})]}):null})(),(()=>{const h=V(s);return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Passwords"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(U,{color:h.admin_password?"green":"zinc",children:[h.admin_password&&e.jsx(G,{className:"w-3 h-3"}),"Admin"]}),e.jsxs(U,{color:h.guest_password?"green":"zinc",children:[h.guest_password&&e.jsx(G,{className:"w-3 h-3"}),"Guest"]})]})]})})(),e.jsx("div",{className:"pt-3",children:e.jsx(Ts,{name:s.name,onSend:t})})]}):e.jsx("p",{className:"type-data-xs text-fg-muted text-center py-3",children:"No identity configured"})]})}function Ls({selectedIdentity:s,clients:t,messages:i,onSendAdvert:a}){const{terminalMode:r}=Q(),n=l.useCallback(async c=>{Se.setState(m=>({clients:m.clients.filter(d=>d.pubkey!==c)})),await ze({public_key:c})},[]);return r?e.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[s&&e.jsx("div",{className:"hidden lg:block",children:e.jsx("div",{className:"card-terminal-header flex-shrink-0",children:e.jsx("div",{className:"header-well flex-1",children:e.jsx(W,{icon:e.jsx(se,{}),onPress:()=>a(s.name),title:"Send room server advert",indicators:[{label:"ADVERTISE",trackPress:!0},{label:"ACTIVE",active:s.registered}]})})})}),e.jsxs("div",{className:"flex flex-col flex-1 min-h-0 gap-1.5",children:[e.jsx("div",{className:"card-terminal-header flex-shrink-0",children:e.jsx("span",{className:"seven-seg-panel",children:e.jsx(ee,{text:`OnLInE ${String(t.length).padStart(3,"0")}`,size:24})})}),e.jsx(q,{noPadding:!0,className:"!h-auto flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",children:e.jsx("div",{className:"card-terminal-well flex-1 min-h-0 overflow-y-auto",children:e.jsx(be,{clients:t,onRemove:n,messages:i,terminalMode:!0})})}),e.jsxs("div",{className:"card-terminal-header flex-shrink-0",children:[e.jsx("span",{className:"seven-seg-panel",children:e.jsx(ee,{text:`StAtUS ${s!=null&&s.registered?"On":"OFF"}`,size:24})}),s&&e.jsx("div",{className:"lg:hidden flex-1 flex min-w-0",children:e.jsx("div",{className:"header-well flex-1 !flex-shrink",children:e.jsx(W,{icon:e.jsx(se,{}),onPress:()=>a(s.name),title:"Send room server advert",className:"flex-row-reverse",indicators:[{label:"ACTIVE",active:s.registered},{label:"ADVERTISE",trackPress:!0}]})})})]}),e.jsx(q,{noPadding:!0,className:"!h-auto flex-shrink-0 overflow-hidden card-terminal",children:e.jsx("div",{className:"card-terminal-well px-4 py-3 type-data-sm",children:e.jsx(ke,{identity:s,onSendAdvert:a})})})]})]}):e.jsxs(q,{compact:!0,className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx(te,{listHeader:!0,icon:e.jsx(_e,{className:"icon-sm"}),title:"Clients",actions:t.length>0?e.jsx("span",{className:"type-data-xs text-fg-muted",children:t.length}):void 0}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsx(be,{clients:t,onRemove:n,messages:i,terminalMode:!1})}),e.jsx(ke,{identity:s,onSendAdvert:a})]})}function Zs(){const s=qe(),t=He(),i=Ve(),a=Ue(),r=Ge(),n=Ie(),c=We(),m=Ye(),d=Qe(),o=Je(),x=l.useMemo(()=>(d==null?void 0:d.neighbors)??{},[d==null?void 0:d.neighbors]),p=bs(x,o),h=l.useMemo(()=>n.map(f=>{if(f.name)return f;const v=p(f.pubkey);return v.name?{...f,name:v.name}:f}),[n,p]),g=l.useMemo(()=>r.map(f=>{if(f.author_name||f.author_pubkey==="server"||f.author_pubkey==="system")return f;const v=p(f.author_pubkey);return v.name?{...f,author_name:v.name}:f}),[r,p]),{selectRoom:j,postMessage:y,deleteMessage:$,clearMessages:S,createRoom:_,updateRoom:k,deleteRoom:R,sendAdvert:N,markAsRead:M,startActivePolling:w}=Se.getState(),[T,C]=l.useState(!1),[K,F]=l.useState("create"),[O,H]=l.useState("hybrid");l.useEffect(()=>{M()},[t,M]),l.useEffect(()=>w(),[w]);const B=l.useCallback(async f=>t?y({room_name:t,message:f,author_pubkey:"server"}):!1,[t,y]),z=l.useCallback((f="hybrid")=>{H(f),F("create"),C(!0)},[]),L=l.useCallback(()=>{F("edit"),C(!0)},[]),J=e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${i.total_messages} message${i.total_messages!==1?"s":""} in this room`,children:[e.jsx(Me,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:i.total_messages})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${i.total_clients} client${i.total_clients!==1?"s":""} connected`,children:[e.jsx(_e,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:i.total_clients})]})]}),e.jsx(ws,{rooms:s,selected:t,onSelect:j,onAdd:()=>z("hybrid")}),s.length>0&&e.jsx(b,{plain:!0,onClick:L,title:"Manage room server",children:e.jsx(Xe,{"data-slot":"icon"})})]});return s.length===0&&c.length===0&&!m?e.jsx(je,{children:e.jsxs(de,{children:[e.jsx(me,{title:"Room Server",icon:e.jsx(I,{})}),e.jsx(ks,{onCreateRoom:f=>z(f)}),e.jsx(fe,{open:T,onClose:()=>C(!1),mode:"create",repeaterConfig:d==null?void 0:d.config,onCreate:async f=>{const v=await _(f);return v&&O==="dedicated"&&(await ce.getState().setMode("monitor"),ce.getState().clearModeMutation()),v},onUpdate:k,onDelete:R,onSendAdvert:N})]})}):e.jsx(je,{children:e.jsxs(de,{children:[e.jsx(me,{title:"Room Server",icon:e.jsx(I,{}),controls:J}),e.jsx(Ze,{children:e.jsxs(es,{template:"hero-tall",className:"!h-[calc(100vh-11rem)] !min-h-[400px]",children:[e.jsx(ue,{span:12,lg:8,className:"h-full",children:e.jsx(_s,{selectedName:t,selectedIdentity:a,messages:g,onSend:B,onDelete:$,onClear:S})}),e.jsx(ue,{span:12,lg:4,className:"h-full",children:e.jsx(Ls,{selectedIdentity:a,clients:h,messages:g,onSendAdvert:N})})]})}),e.jsx(fe,{open:T,onClose:()=>C(!1),mode:K,identity:a,repeaterConfig:d==null?void 0:d.config,onCreate:_,onUpdate:k,onDelete:R,onSendAdvert:N})]})})}export{Zs as default}; + */const vs=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],Ns=I("user-x",vs);function bs(s,t){return l.useMemo(()=>{const a=new Map;for(const[n,c]of Object.entries(s)){const m=c.name||c.node_name||null,{type:d}=ss(c);a.set(n.toLowerCase(),{name:m,type:d})}const r=new Map;for(let n=t.length-1;n>=0;n--){const c=t[n];if(!c._advertSender)continue;const m=c._advertSender.toLowerCase();if(r.has(m))continue;const d=c._advertName??null,o=c._advertNodeType!=null?ts(c._advertNodeType):"companion";r.set(m,{name:d,type:o})}return function(c){const m=c.toLowerCase(),d=a.get(m);if(d!=null&&d.name)return d;const o=r.get(m);return o!=null&&o.name?o:d||o||{name:null,type:"companion"}}},[s,t])}function he({icon:s,title:t,description:i,onClick:a,accent:r}){return e.jsxs("button",{onClick:a,className:A("flex flex-col items-center gap-3 p-6 rounded-2xl text-center","ring-1 ring-edge-subtle hover:ring-2 transition-all duration-150","w-full max-w-[260px]",r==="primary"?"hover:ring-sys-blue hover:bg-sys-blue/5":"hover:ring-sys-indigo hover:bg-sys-indigo/5"),children:[e.jsx("div",{className:A("p-3 rounded-xl",r==="primary"?"bg-sys-blue/10 text-sys-blue":"bg-sys-indigo/10 text-sys-indigo"),children:s}),e.jsx("p",{className:"type-body-sm font-medium text-fg-primary",children:t}),e.jsx("p",{className:"type-data-xs text-fg-muted leading-relaxed",children:i})]})}function ks({onCreateRoom:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[e.jsx(W,{className:"w-12 h-12 text-fg-muted opacity-30 mb-4"}),e.jsx("p",{className:"type-subheading text-fg-secondary mb-1",children:"Add a Room Server"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-8",children:"Choose how this device should operate."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[e.jsx(he,{icon:e.jsx(as,{className:"w-6 h-6"}),title:"Repeater + Room Server",description:"Keep forwarding packets and add group messaging.",onClick:()=>s("hybrid"),accent:"primary"}),e.jsx(he,{icon:e.jsx(De,{className:"w-6 h-6"}),title:"Dedicated Room Server",description:"Stop repeating. Focus entirely on room server duties.",onClick:()=>s("dedicated"),accent:"secondary"})]})]})}function ws({rooms:s,selected:t,onSelect:i,onAdd:a}){const r=a?e.jsx("button",{onClick:a,className:A("flex items-center justify-center px-2 py-1 rounded-md","text-fg-muted hover:text-fg-primary hover:bg-surface/60","transition-all duration-150"),title:"Add room server",children:e.jsx(os,{className:"w-4 h-4"})}):null;return s.length<=1?r:s.length<=3?e.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 rounded-lg bg-subtle-fill",children:[s.map(n=>e.jsx("button",{onClick:()=>i(n.room_name),className:A("px-3 py-1 rounded-md text-sm font-medium transition-all duration-150",n.room_name===t?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:n.room_name},n.room_name)),r]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ns,{value:t??"",onChange:i,children:s.map(n=>e.jsx(rs,{value:n.room_name,children:e.jsx(ls,{children:n.room_name})},n.room_name))}),r]})}function Cs(s){return s.settings??{}}function Ss(s){if(!s)return"";const t=s.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");return t?`${t}-room`:""}function fe({open:s,onClose:t,mode:i,identity:a,repeaterConfig:r,onCreate:n,onUpdate:c,onDelete:m,onSendAdvert:d}){var ae,ne,re,le;const o=i==="edit"&&a,x=`${s}-${(a==null?void 0:a.name)??""}-${i}`,[p,h]=l.useState(""),[g,j]=l.useState(""),[y,$]=l.useState(!1),[S,_]=l.useState(""),[k,R]=l.useState(""),[N,M]=l.useState(""),[w,T]=l.useState(""),[C,K]=l.useState(!1),[F,O]=l.useState(!1),[H,B]=l.useState(!1),[z,L]=l.useState(null),[Q,f]=l.useState(x);if(x!==Q)if(f(x),L(null),K(!1),O(!1),B(!1),o){const u=Cs(a);h(u.node_name??a.name),j(a.identity_key??""),$(!1),_(u.admin_password??""),R(u.guest_password??""),M(((ae=u.latitude)==null?void 0:ae.toString())??""),T(((ne=u.longitude)==null?void 0:ne.toString())??"")}else{const u=r;h(""),j(""),$(!1),_(""),R(""),M(((re=u==null?void 0:u.repeater)==null?void 0:re.latitude)!=null?u.repeater.latitude.toString():""),T(((le=u==null?void 0:u.repeater)==null?void 0:le.longitude)!=null?u.repeater.longitude.toString():"")}const v=l.useCallback(()=>{const u={};return p&&(u.node_name=p),S&&(u.admin_password=S),k&&(u.guest_password=k),N!==""&&(u.latitude=parseFloat(N)),w!==""&&(u.longitude=parseFloat(w)),u},[p,S,k,N,w]),Le=l.useCallback(async()=>{if(!p.trim()){L("Room name is required");return}K(!0),L(null);const u=o?a.name:Ss(p);let X;if(o)X=await c({name:a.name,settings:v()});else{const oe={name:u,type:"room_server",settings:v()};g.trim()&&(oe.identity_key=g.trim()),X=await n(oe)}K(!1),X?t():L("Failed to save. Check that the name is unique and passwords differ.")},[p,o,a,v,n,c,t]),Ee=l.useCallback(async()=>{if(!o)return;O(!0);const u=await m(a.name);O(!1),u&&t()},[o,a,m,t]),Pe=l.useCallback(async()=>{o&&(B(!0),await d(a.name),B(!1))},[o,a,d]);return e.jsxs(Ae,{open:s,onClose:t,size:"md",children:[e.jsx($e,{icon:o?void 0:e.jsx(js,{className:"w-5 h-5"}),title:o?"Edit Room Server":"Add Room Server",onClose:t}),e.jsx(Ke,{children:e.jsxs("div",{className:"space-y-5",children:[o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{color:a.registered?"green":"red",children:a.registered?"Active":"Inactive"}),a.identity_key&&e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",title:a.identity_key,children:["Key: ",a.identity_key.slice(0,16),"…"]})]}),e.jsxs(P,{children:[e.jsx(D,{title:"What people see on the mesh",children:"Room Name"}),e.jsx(E,{value:p,onChange:u=>h(u.target.value),placeholder:"Room Name"})]}),!o&&e.jsxs(P,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{title:"The unique hex public ID",children:["Identity Key ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx("button",{type:"button",onClick:()=>$(u=>!u),className:"type-data-xs text-fg-muted underline hover:text-fg-secondary",children:y?"Hide":"Show"})]}),y&&e.jsxs(e.Fragment,{children:[e.jsx(E,{value:g,onChange:u=>j(u.target.value),placeholder:"Leave empty to auto-generate"}),e.jsx(is,{children:"Leave empty to automatically generate a secure key"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(P,{children:[e.jsxs(D,{children:[e.jsx(Z,{className:"inline w-3.5 h-3.5 -mt-0.5 mr-1 text-fg-muted"}),"Latitude"]}),e.jsx(E,{type:"number",step:"any",value:N,onChange:u=>M(u.target.value),placeholder:"0"})]}),e.jsxs(P,{children:[e.jsxs(D,{children:[e.jsx(Z,{className:"inline w-3.5 h-3.5 -mt-0.5 mr-1 text-fg-muted"}),"Longitude"]}),e.jsx(E,{type:"number",step:"any",value:w,onChange:u=>T(u.target.value),placeholder:"0"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(P,{children:[e.jsxs(D,{title:"Full access to room server",children:["Admin Password ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(E,{type:"password",value:S,onChange:u=>_(u.target.value),placeholder:"None Set"})]}),e.jsxs(P,{children:[e.jsxs(D,{title:"Can post and read, but not administer the room",children:["Guest Password ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(E,{type:"password",value:k,onChange:u=>R(u.target.value),placeholder:"None Set"})]})]}),z&&e.jsx("p",{className:"type-data-xs text-sys-red",children:z})]})}),e.jsxs(Fe,{children:[o&&e.jsxs("div",{className:"flex items-center gap-2 mr-auto",children:[e.jsxs(b,{color:"danger",plain:!0,onClick:Ee,disabled:F,children:[e.jsx(Re,{"data-slot":"icon"}),F?"Deleting…":"Delete"]}),e.jsxs(b,{color:"primary",plain:!0,onClick:Pe,disabled:H,children:[e.jsx(we,{"data-slot":"icon"}),H?"Sending…":"Send Advert"]})]}),e.jsx(b,{plain:!0,onClick:t,children:"Cancel"}),e.jsx(b,{color:"primary",onClick:Le,disabled:C,children:C?"Saving…":o?"Save Changes":"Create"})]})]})}const Te=l.createContext(null),ge="room-tui";function je({children:s}){const[t,i]=l.useState(()=>localStorage.getItem(ge)!=="0"),a=l.useCallback(()=>{i(r=>{const n=!r;return localStorage.setItem(ge,n?"1":"0"),n})},[]);return e.jsx(Te.Provider,{value:{terminalMode:t,toggleTerminalMode:a},children:s})}function J(){const s=l.useContext(Te);if(!s)throw new Error("useTerminalMode must be used within RoomTerminalProvider");return s}const ye=s=>s.author_pubkey==="server"||s.author_pubkey==="system";function ve({messages:s,onDelete:t,terminalMode:i,serverName:a}){const r=l.useRef(null),[n,c]=l.useState(!1),m=l.useMemo(()=>[...s].sort((x,p)=>x.post_timestamp-p.post_timestamp),[s]);l.useEffect(()=>{!n&&r.current&&(r.current.scrollTop=0)},[m.length,n]);const d=l.useCallback(()=>{r.current&&c(r.current.scrollTop<-100)},[]),o=l.useCallback(()=>{r.current&&r.current.scrollTo({top:0,behavior:"smooth"}),c(!1)},[]);return m.length===0?e.jsx("div",{className:`flex-1 flex flex-col items-center justify-center py-12 min-h-0${i?" font-mono":""}`,children:i?e.jsx("p",{className:"text-sm font-mono",style:{color:"var(--tui-accent)",opacity:.4},children:"> no messages in buffer_"}):e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-10 h-10 text-fg-muted opacity-20 mb-2"}),e.jsx("p",{className:"type-data-sm text-fg-muted",children:"No messages yet"})]})}):i?e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:r,onScroll:d,className:"h-full overflow-y-auto scroll-smooth p-4 font-mono text-sm leading-relaxed flex flex-col-reverse",children:e.jsx("div",{children:m.map(x=>{const p=ye(x),h=new Date(x.post_timestamp*1e3).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),g=p?"SYS":x.author_name||x.author_prefix,j=!p&&a&&g===a;return e.jsxs("div",{className:"group flex items-start gap-0 -mx-4 px-4 py-px",style:{"--tw-hover-bg":"var(--tui-hover-bg)"},onMouseEnter:y=>y.currentTarget.style.background="var(--tui-hover-bg)",onMouseLeave:y=>y.currentTarget.style.background="",children:[e.jsxs("span",{className:"select-none shrink-0",style:{color:"var(--tui-muted)"},children:["[",h,"]"]}),e.jsxs("span",{className:"mx-1.5 shrink-0",style:{color:j?"var(--tui-accent-local)":"var(--tui-accent)"},children:["<",g,">"]}),e.jsx("span",{style:{color:p?"var(--tui-system)":j?"var(--tui-body)":"var(--tui-accent)"},className:p?"italic":"",children:x.message_text}),e.jsx("button",{onClick:()=>t(x.id),className:"opacity-0 group-hover:opacity-100 ml-auto pl-2 shrink-0 transition-colors",style:{color:"var(--tui-muted)"},onMouseEnter:y=>y.currentTarget.style.color="var(--tui-danger)",onMouseLeave:y=>y.currentTarget.style.color="var(--tui-muted)",title:"Delete",children:"×"})]},x.id)})})}),n&&e.jsxs("button",{onClick:o,className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1.5 px-3 py-1 font-mono text-xs transition-colors duration-150",style:{background:"var(--tui-hover-bg)",border:"1px solid var(--tui-muted)",color:"var(--tui-accent)"},children:[e.jsx(ie,{className:"w-3 h-3"}),"↓ scroll"]})]}):e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:r,onScroll:d,className:"h-full overflow-y-auto scroll-smooth flex flex-col-reverse",children:e.jsx("div",{className:"p-4",children:m.map(x=>ye(x)?e.jsx(cs,{text:x.message_text},x.id):e.jsx(ds,{senderName:x.author_name||x.author_prefix,text:x.message_text,timestamp:x.post_timestamp,bubbleAccessory:e.jsx("button",{onClick:()=>t(x.id),className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150 p-1 text-fg-muted hover:text-sys-red flex-shrink-0",title:"Delete message",children:e.jsx(Re,{className:"w-3.5 h-3.5"})})},x.id))})}),n&&e.jsxs("button",{onClick:o,className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-surface/90 backdrop-blur-sm ring-1 ring-edge-subtle shadow-md text-fg-secondary hover:text-fg-primary transition-colors duration-150",children:[e.jsx(ie,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs",children:"New messages"})]})]})}function Ne({roomName:s,onSend:t,disabled:i,terminalMode:a}){const[r,n]=l.useState(""),[c,m]=l.useState(!1),d=l.useRef(null),o=l.useCallback(async()=>{var g;const p=r.trim();if(!p||c)return;m(!0);const h=await t(p);m(!1),h&&(n(""),(g=d.current)==null||g.focus())},[r,c,t]),x=l.useCallback(p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),o())},[o]);return a?e.jsxs("div",{className:"flex items-center gap-0 px-4 py-2 type-data-sm",children:[e.jsx("input",{ref:d,type:"text",value:r,onChange:p=>n(p.target.value),onKeyDown:x,placeholder:"type message...",disabled:i||c,className:"flex-1 bg-transparent outline-none ring-0 shadow-none border-none focus:outline-none focus:ring-0 font-mono tui-input",style:{color:"var(--tui-body)"}}),e.jsx("button",{onClick:o,disabled:!r.trim()||c||i,className:"transition-colors duration-100 px-1 font-mono text-xs disabled:opacity-30",style:{color:"var(--tui-accent)"},title:"Send",children:"[↵]"})]}):e.jsxs("div",{className:"flex items-center gap-2 p-3 border-t border-edge-subtle",children:[e.jsx("input",{ref:d,type:"text",value:r,onChange:p=>n(p.target.value),onKeyDown:x,placeholder:`Message ${s}…`,disabled:i||c,className:"flex-1 surface-input radius-inner px-3 py-2 type-body-sm text-fg-primary placeholder:text-fg-muted outline-none ring-focus"}),e.jsx("button",{onClick:o,disabled:!r.trim()||c||i,className:"p-2 rounded-lg text-sys-blue hover:bg-sys-blue/10 disabled:opacity-30 disabled:hover:bg-transparent transition-colors duration-150",title:"Send message",children:e.jsx(we,{className:"w-4.5 h-4.5"})})]})}function _s({selectedName:s,selectedIdentity:t,messages:i,onSend:a,onDelete:r,onClear:n}){var h;const{terminalMode:c,toggleTerminalMode:m}=J(),[d,o]=l.useState(!1),x=((h=t==null?void 0:t.settings)==null?void 0:h.node_name)??s??void 0,p=l.useCallback(()=>{o(!1),n()},[n]);return c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[e.jsxs("div",{className:"card-terminal-header flex-shrink-0",children:[e.jsx("span",{className:"seven-seg-panel",children:e.jsx(ee,{text:"chat",minChars:7,size:24})}),e.jsx("div",{className:"card-terminal-ridge flex-1"}),e.jsxs("div",{className:"header-well",children:[e.jsx(Y,{icon:e.jsx(pe,{className:"!w-5.5 !h-5.5 translate-y-px"}),onClick:m,title:"Exit terminal mode"}),i.length>0&&e.jsx(Y,{icon:e.jsx("span",{className:"text-[13px] font-bold font-mono leading-none translate-y-px",children:"DEL"}),onClick:()=>o(!0),title:"Clear all messages",variant:"red",iconActiveColor:Oe.red})]})]}),e.jsx(q,{noPadding:!0,className:"flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",children:e.jsxs("div",{className:"card-terminal-well flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx(ve,{messages:i,onDelete:r,terminalMode:!0,serverName:x}),e.jsx("div",{className:"card-terminal-divider"}),s&&e.jsx(Ne,{roomName:s,onSend:a,disabled:!(t!=null&&t.registered),terminalMode:!0})]})})]}),e.jsx(xe,{isOpen:d,title:"Clear All Messages",message:`This will permanently delete all ${i.length} message${i.length===1?"":"s"} from this room. This cannot be undone.`,confirmLabel:"Clear Messages",variant:"danger",onConfirm:p,onCancel:()=>o(!1)})]}):e.jsxs(e.Fragment,{children:[e.jsxs(q,{noPadding:!0,className:"flex flex-col h-full overflow-hidden",children:[e.jsx(te,{listHeader:!0,icon:e.jsx(Me,{className:"icon-sm"}),title:"Messages",actions:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(b,{plain:!0,onClick:m,title:"Terminal mode",children:e.jsx(pe,{"data-slot":"icon",className:"!w-5 !h-5 translate-y-px"})}),i.length>0&&e.jsx(b,{plain:!0,onClick:()=>o(!0),title:"Clear all messages",children:e.jsx("span",{"data-slot":"icon",className:"text-[12px] font-bold font-mono leading-none translate-y-px text-sys-red",children:"DEL"})})]})}),e.jsx(ve,{messages:i,onDelete:r,terminalMode:!1,serverName:x}),s&&e.jsx(Ne,{roomName:s,onSend:a,disabled:!(t!=null&&t.registered),terminalMode:!1})]}),e.jsx(xe,{isOpen:d,title:"Clear All Messages",message:`This will permanently delete all ${i.length} message${i.length===1?"":"s"} from this room. This cannot be undone.`,confirmLabel:"Clear Messages",variant:"danger",onConfirm:p,onCancel:()=>o(!1)})]})}function Rs({pubkey:s,className:t}){const[i,a]=l.useState(!1),r=l.useCallback(async()=>{await Ce(s),a(!0),setTimeout(()=>a(!1),1500)},[s]);return e.jsxs("button",{onClick:r,title:i?"Copied!":"Copy public key",className:`inline-flex items-center gap-1 type-data-xs leading-tight text-fg-muted hover:text-fg-secondary transition-colors duration-150 cursor-copy ${t??""}`,children:[e.jsx("span",{className:"truncate min-w-0",children:s.slice(0,8)}),i&&e.jsx(G,{className:"w-2.5 h-2.5 text-sys-green flex-shrink-0"})]})}const Ms=l.memo(function({client:t,resolvedName:i,onRemove:a}){const r=t.name||i,n=t.unsynced_count===0,c=t.last_activity?new Date(t.last_activity*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never",{emoji:m,cleanName:d}=r?ms(r):{emoji:null,cleanName:t.pubkey_prefix},o=r?us(d):void 0,x=r?xs(r):t.pubkey_prefix.slice(0,2).toUpperCase();return e.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2.5 radius-inner row-hover transition-base",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:A("w-8 h-8 rounded-full flex items-center justify-center",o?"clay-avatar":"bg-sys-blue/12"),style:o?{"--avatar-color":o}:void 0,children:m?e.jsx("span",{className:"text-base leading-none",children:m}):e.jsx("span",{className:A("leading-none",o?"text-white text-[11px] font-bold tracking-tight":"text-sys-blue font-mono text-[11px]"),children:x})}),e.jsx("span",{className:`absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-sm ring-2 ring-surface ${n?"bg-sys-green":"bg-sys-indigo"}`})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[r?e.jsx("p",{className:"text-[13px] font-medium leading-tight text-fg-primary truncate",children:r}):e.jsx("p",{className:"font-mono text-[13px] leading-tight text-fg-primary truncate",children:t.pubkey_prefix}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[r&&e.jsx(Rs,{pubkey:t.pubkey}),r&&e.jsx("span",{className:"text-xs text-fg-muted/40",children:"·"}),e.jsxs("span",{className:"text-xs leading-tight text-fg-muted truncate",children:[!n&&e.jsxs("span",{className:"text-sys-indigo",children:[t.unsynced_count," unsynced · "]}),c]})]})]}),e.jsx("button",{onClick:()=>a(t.pubkey),className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150 p-1.5 -mr-1 rounded-md text-fg-muted hover:text-sys-red hover:bg-sys-red/8",title:"Remove client",children:e.jsx(Ns,{className:"w-3.5 h-3.5"})})]})});function be({clients:s,onRemove:t,messages:i,terminalMode:a}){const r=l.useMemo(()=>{const n=new Map;if(!i)return n;for(let c=i.length-1;c>=0;c--){const m=i[c];m.author_name&&m.author_pubkey&&m.author_pubkey!=="server"&&m.author_pubkey!=="system"&&n.set(m.author_pubkey,m.author_name)}return n},[i]);return s.length===0?a?e.jsx("p",{className:"type-data-sm text-left px-4 py-4",style:{color:"var(--tui-accent)"},children:"< NO CLIENTS CONNECTED >"}):e.jsx("p",{className:"type-data-xs text-fg-muted text-center py-4",children:"No clients connected"}):a?e.jsx("div",{className:"type-data-sm pt-2",children:s.map(n=>{const c=n.name||r.get(n.pubkey),m=n.unsynced_count===0,d=n.pubkey_prefix;return e.jsxs("div",{className:"group flex items-center gap-0 -mx-0 px-4 py-0.5",onMouseEnter:o=>o.currentTarget.style.background="var(--tui-hover-bg)",onMouseLeave:o=>o.currentTarget.style.background="",children:[e.jsx("span",{style:{color:m?"var(--tui-accent)":"var(--tui-warn)"},children:"■"}),e.jsx("span",{className:"ml-2 shrink-0",style:{color:"var(--tui-accent)"},children:c||d}),c&&e.jsxs("span",{className:"ml-1.5 shrink-0",style:{color:"var(--tui-accent)"},children:["[",d,"]"]}),!m&&e.jsxs("span",{className:"ml-1.5",style:{color:"var(--tui-warn)"},children:[n.unsynced_count,"unsync"]}),e.jsx("button",{onClick:()=>t(n.pubkey),className:"opacity-0 group-hover:opacity-100 ml-auto pl-2 shrink-0 transition-colors",style:{color:"var(--tui-muted)"},onMouseEnter:o=>o.currentTarget.style.color="var(--tui-danger)",onMouseLeave:o=>o.currentTarget.style.color="var(--tui-muted)",title:"Remove",children:"×"})]},n.pubkey)})}):e.jsx("div",{className:"space-y-0.5 pt-1",children:s.map(n=>e.jsx(Ms,{client:n,resolvedName:r.get(n.pubkey),onRemove:t},n.pubkey))})}function Ts({name:s,onSend:t}){const{terminalMode:i}=J(),[a,r]=l.useState("idle"),n=l.useRef(),c=l.useCallback(async()=>{if(a==="sending")return;r("sending");const m=await t(s);r(m?"sent":"idle"),m&&(n.current=setTimeout(()=>r("idle"),2e3))},[s,t,a]);return l.useEffect(()=>()=>clearTimeout(n.current),[]),i?e.jsxs("button",{className:"btn-terminal",onClick:c,disabled:a==="sending",children:[a==="idle"&&"[ send_advert ]",a==="sending"&&"[ broadcasting... ]",a==="sent"&&"[ sent ✓ ]"]}):e.jsxs(b,{color:a==="sent"?"success":"primary",className:"w-full",onClick:c,disabled:a==="sending",children:[e.jsx(se,{"data-slot":"icon"}),a==="idle"&&"Send Advert",a==="sending"&&"Broadcasting…",a==="sent"&&"Advert Sent"]})}function V(s){return s.settings??{}}function ke({identity:s,onSendAdvert:t}){var c,m,d,o,x,p;const{terminalMode:i}=J(),[a,r]=l.useState(!1),n=l.useCallback(async()=>{s!=null&&s.identity_key&&(await Ce(s.identity_key),r(!0),setTimeout(()=>r(!1),1500))},[s==null?void 0:s.identity_key]);return i?s?e.jsxs("div",{className:"space-y-1",children:[((c=s.settings)==null?void 0:c.node_name)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"node"}),e.jsx("span",{style:{color:"var(--tui-accent)"},children:s.settings.node_name})]}),(s.address||((m=s.runtime)==null?void 0:m.address))&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"addr"}),e.jsx("span",{style:{color:"var(--tui-accent)"},children:s.address||((d=s.runtime)==null?void 0:d.address)})]}),s.identity_key&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"key"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"truncate max-w-[140px]",style:{color:"var(--tui-accent)"},title:s.identity_key,children:[s.identity_key.slice(0,16),"…"]}),e.jsx("button",{type:"button",onClick:n,className:"text-xs",style:{color:"var(--tui-muted)"},children:a?"[copied ✓]":"[copy]"})]})]}),(()=>{var g,j;const h=V(s);return h.latitude!=null||h.longitude!=null?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"loc"}),e.jsxs("span",{style:{color:"var(--tui-accent)"},title:`${h.latitude??"—"}, ${h.longitude??"—"}`,children:[((g=h.latitude)==null?void 0:g.toFixed(4))??"—",", ",((j=h.longitude)==null?void 0:j.toFixed(4))??"—"]})]}):null})(),(()=>{const h=V(s);return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"pass"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{color:h.admin_password?"var(--tui-accent)":"var(--tui-muted)"},children:h.admin_password?"[✓ admin]":"[— admin]"}),e.jsx("span",{style:{color:h.guest_password?"var(--tui-accent)":"var(--tui-muted)"},children:h.guest_password?"[✓ guest]":"[— guest]"})]})]})})()]}):e.jsx("span",{style:{color:"var(--tui-muted)"},children:"no identity configured"}):e.jsxs("div",{className:"flex-shrink-0 border-t border-edge-subtle",children:[e.jsx(te,{listHeader:!0,icon:e.jsx(ps,{className:"icon-sm"}),title:"Room Info"}),s?e.jsxs("div",{className:"space-y-2 px-4 py-3",children:[((o=s.settings)==null?void 0:o.node_name)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Node"}),e.jsx("span",{className:"type-data-sm text-fg-primary",children:s.settings.node_name})]}),(s.address||((x=s.runtime)==null?void 0:x.address))&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Address"}),e.jsx("span",{className:"type-data-sm font-mono text-fg-primary",children:s.address||((p=s.runtime)==null?void 0:p.address)})]}),s.identity_key&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted flex items-center gap-1",title:"The unique hex public ID",children:[e.jsx(hs,{className:"w-3 h-3"}),"Key"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"type-data-sm font-mono text-fg-primary truncate max-w-[140px]",title:s.identity_key,children:[s.identity_key.slice(0,16),"…"]}),e.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center gap-0.5",children:e.jsx(U,{color:a?"green":"zinc",children:a?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-3 h-3"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-3 h-3"}),"Copy"]})})})]})]}),(()=>{var g,j;const h=V(s);return h.latitude!=null||h.longitude!=null?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted flex items-center gap-1",children:[e.jsx(Z,{className:"w-3 h-3"}),"Location"]}),e.jsxs("span",{className:"type-data-sm font-mono text-fg-primary",title:`${h.latitude??"—"}, ${h.longitude??"—"}`,children:[((g=h.latitude)==null?void 0:g.toFixed(4))??"—",", ",((j=h.longitude)==null?void 0:j.toFixed(4))??"—"]})]}):null})(),(()=>{const h=V(s);return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Passwords"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(U,{color:h.admin_password?"green":"zinc",children:[h.admin_password&&e.jsx(G,{className:"w-3 h-3"}),"Admin"]}),e.jsxs(U,{color:h.guest_password?"green":"zinc",children:[h.guest_password&&e.jsx(G,{className:"w-3 h-3"}),"Guest"]})]})]})})(),e.jsx("div",{className:"pt-3",children:e.jsx(Ts,{name:s.name,onSend:t})})]}):e.jsx("p",{className:"type-data-xs text-fg-muted text-center py-3",children:"No identity configured"})]})}function Ls({selectedIdentity:s,clients:t,messages:i,onSendAdvert:a}){const{terminalMode:r}=J(),n=l.useCallback(async c=>{Se.setState(m=>({clients:m.clients.filter(d=>d.pubkey!==c)})),await ze({public_key:c})},[]);return r?e.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[s&&e.jsx("div",{className:"hidden lg:block",children:e.jsx("div",{className:"card-terminal-header flex-shrink-0",children:e.jsx("div",{className:"header-well flex-1",children:e.jsx(Y,{icon:e.jsx(se,{}),onPress:()=>a(s.name),title:"Send room server advert",indicators:[{label:"ADVERTISE",trackPress:!0},{label:"ACTIVE",active:s.registered}]})})})}),e.jsxs("div",{className:"flex flex-col flex-1 min-h-0 gap-1.5",children:[e.jsx("div",{className:"card-terminal-header flex-shrink-0",children:e.jsx("span",{className:"seven-seg-panel",children:e.jsx(ee,{text:`OnLInE ${String(t.length).padStart(3,"0")}`,size:24})})}),e.jsx(q,{noPadding:!0,className:"!h-auto flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",children:e.jsx("div",{className:"card-terminal-well flex-1 min-h-0 overflow-y-auto",children:e.jsx(be,{clients:t,onRemove:n,messages:i,terminalMode:!0})})}),e.jsxs("div",{className:"card-terminal-header flex-shrink-0",children:[e.jsx("span",{className:"seven-seg-panel",children:e.jsx(ee,{text:`StAtUS ${s!=null&&s.registered?"On":"OFF"}`,size:24})}),s&&e.jsx("div",{className:"lg:hidden flex-1 flex min-w-0",children:e.jsx("div",{className:"header-well flex-1 !flex-shrink",children:e.jsx(Y,{icon:e.jsx(se,{}),onPress:()=>a(s.name),title:"Send room server advert",className:"flex-row-reverse",indicators:[{label:"ACTIVE",active:s.registered},{label:"ADVERTISE",trackPress:!0}]})})})]}),e.jsx(q,{noPadding:!0,className:"!h-auto flex-shrink-0 overflow-hidden card-terminal",children:e.jsx("div",{className:"card-terminal-well px-4 py-3 type-data-sm",children:e.jsx(ke,{identity:s,onSendAdvert:a})})})]})]}):e.jsxs(q,{compact:!0,className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx(te,{listHeader:!0,icon:e.jsx(_e,{className:"icon-sm"}),title:"Clients",actions:t.length>0?e.jsx("span",{className:"type-data-xs text-fg-muted",children:t.length}):void 0}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsx(be,{clients:t,onRemove:n,messages:i,terminalMode:!1})}),e.jsx(ke,{identity:s,onSendAdvert:a})]})}function Zs(){const s=qe(),t=He(),i=Ve(),a=Ue(),r=Ge(),n=We(),c=Ye(),m=Ie(),d=Je(),o=Qe(),x=l.useMemo(()=>(d==null?void 0:d.neighbors)??{},[d==null?void 0:d.neighbors]),p=bs(x,o),h=l.useMemo(()=>n.map(f=>{if(f.name)return f;const v=p(f.pubkey);return v.name?{...f,name:v.name}:f}),[n,p]),g=l.useMemo(()=>r.map(f=>{if(f.author_name||f.author_pubkey==="server"||f.author_pubkey==="system")return f;const v=p(f.author_pubkey);return v.name?{...f,author_name:v.name}:f}),[r,p]),{selectRoom:j,postMessage:y,deleteMessage:$,clearMessages:S,createRoom:_,updateRoom:k,deleteRoom:R,sendAdvert:N,markAsRead:M,startActivePolling:w}=Se.getState(),[T,C]=l.useState(!1),[K,F]=l.useState("create"),[O,H]=l.useState("hybrid");l.useEffect(()=>{M()},[t,M]),l.useEffect(()=>w(),[w]);const B=l.useCallback(async f=>t?y({room_name:t,message:f,author_pubkey:"server"}):!1,[t,y]),z=l.useCallback((f="hybrid")=>{H(f),F("create"),C(!0)},[]),L=l.useCallback(()=>{F("edit"),C(!0)},[]),Q=e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${i.total_messages} message${i.total_messages!==1?"s":""} in this room`,children:[e.jsx(Me,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:i.total_messages})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${i.total_clients} client${i.total_clients!==1?"s":""} connected`,children:[e.jsx(_e,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:i.total_clients})]})]}),e.jsx(ws,{rooms:s,selected:t,onSelect:j,onAdd:()=>z("hybrid")}),s.length>0&&e.jsx(b,{plain:!0,onClick:L,title:"Manage room server",children:e.jsx(Xe,{"data-slot":"icon"})})]});return s.length===0&&c.length===0&&!m?e.jsx(je,{children:e.jsxs(de,{children:[e.jsx(me,{title:"Room Server",icon:e.jsx(W,{})}),e.jsx(ks,{onCreateRoom:f=>z(f)}),e.jsx(fe,{open:T,onClose:()=>C(!1),mode:"create",repeaterConfig:d==null?void 0:d.config,onCreate:async f=>{const v=await _(f);return v&&O==="dedicated"&&(await ce.getState().setMode("monitor"),ce.getState().clearModeMutation()),v},onUpdate:k,onDelete:R,onSendAdvert:N})]})}):e.jsx(je,{children:e.jsxs(de,{children:[e.jsx(me,{title:"Room Server",icon:e.jsx(W,{}),controls:Q}),e.jsx(Ze,{children:e.jsxs(es,{template:"hero-tall",className:"!h-[calc(100vh-11rem)] !min-h-[400px]",children:[e.jsx(ue,{span:12,lg:8,className:"h-full",children:e.jsx(_s,{selectedName:t,selectedIdentity:a,messages:g,onSend:B,onDelete:$,onClear:S})}),e.jsx(ue,{span:12,lg:4,className:"h-full",children:e.jsx(Ls,{selectedIdentity:a,clients:h,messages:g,onSendAdvert:N})})]})}),e.jsx(fe,{open:T,onClose:()=>C(!1),mode:K,identity:a,repeaterConfig:d==null?void 0:d.config,onCreate:_,onUpdate:k,onDelete:R,onSendAdvert:N})]})})}export{Zs as default}; diff --git a/frontend/dist/assets/Sessions-CB2LEa_r.js b/frontend/dist/assets/Sessions-ChDjzsGf.js similarity index 91% rename from frontend/dist/assets/Sessions-CB2LEa_r.js rename to frontend/dist/assets/Sessions-ChDjzsGf.js index 229bf10a..d586f3ef 100644 --- a/frontend/dist/assets/Sessions-CB2LEa_r.js +++ b/frontend/dist/assets/Sessions-ChDjzsGf.js @@ -1,4 +1,4 @@ -import{e as b,r as l,fk as U,fl as z,eg as V,j as e,B as g,a2 as M,a0 as Y,dV as J,bI as C,c as N,bY as Q,eL as Z,cU as W,cE as X,cs as ee,c3 as se}from"./index-C2xvS0Jd.js";import{C as ae}from"./ConfirmModal-eC-cl0ep.js";import{P as te,a as le,B as ie,C as P}from"./PageLayout-Cg7r5tdt.js";import{R as T,C as y}from"./Grid-kVOI-wJp.js";import{S as B}from"./shield-check-BB1TbeiZ.js";import{C as ne}from"./circle-question-mark-CF3fGjhH.js";import{S as ce}from"./shield-DvZvtyKV.js";import{A as re}from"./antenna-Dr-Egqv0.js";import{T as D}from"./trash-2-Def3YmfN.js";/** +import{e as b,r as l,fk as V,fl as z,eg as J,j as e,B as g,a2 as M,a0 as U,dV as Z,bJ as C,c as N,bZ as Q,eL as Y,cV as W,cF as X,ct as ee,c4 as se}from"./index-D33fcA3L.js";import{C as ae}from"./ConfirmModal-J2_Sxirm.js";import{P as te,a as le,B as ie,C as P}from"./PageLayout-CRN-E5xi.js";import{R as T,C as y}from"./Grid-DQYUnZsY.js";import{S as B}from"./shield-check-DOoXovft.js";import{C as ne}from"./circle-question-mark-CO80vHQp.js";import{S as ce}from"./shield-Ceq641wy.js";import{A as re}from"./antenna-rn7EByqR.js";import{T as D}from"./trash-2-CUY4NG5t.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -18,4 +18,4 @@ import{e as b,r as l,fk as U,fl as z,eg as V,j as e,B as g,a2 as M,a0 as Y,dV as * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const pe=[["path",{d:"m16 11 2 2 4-4",key:"9rsbq5"}],["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],fe=b("user-check",pe),ye=[{id:"overview",label:"Overview",icon:xe},{id:"clients",label:"Authenticated Clients",icon:fe},{id:"identities",label:"By Identity",icon:oe}];function E(s){return s?new Date(s*1e3).toLocaleString():"Never"}function je(s){if(!s)return"Never";const t=Date.now()-s*1e3,i=Math.floor(t/6e4),x=Math.floor(t/36e5),r=Math.floor(t/864e5);return i<1?"Just now":i<60?`${i}m ago`:x<24?`${x}h ago`:r<365?`${r}d ago`:`${Math.floor(r/365)}y ago`}function j({label:s,value:t,icon:i}){return e.jsxs(P,{neomorphic:!0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[i&&e.jsx("span",{className:"icon-sm text-icon-card-title",children:i}),e.jsx("span",{className:"type-micro",children:s})]}),e.jsx(W,{centered:!0,children:e.jsx("span",{className:"type-data-xl text-fg-primary font-mono font-normal tabular-nums",children:t})})]})}const $={repeater:{icon:re,color:"var(--sys-blue)"},room_server:{icon:ee,color:"var(--sys-pink)"},companion:{icon:X,color:"var(--sys-cyan)"}};function ge({identity:s}){const t=$[s.type]??$.repeater,i=t.icon;return e.jsxs("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-3",children:[e.jsx("span",{className:"icon-sm text-icon-card-title",children:e.jsx(i,{className:"w-4 h-4"})}),e.jsx("span",{className:"type-micro",children:s.name}),e.jsx(se,{copy:!0,size:"compact",truncate:[8,6],color:"text-fg-muted",children:s.hash}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined ml-auto",style:{"--data-box-accent":t.color},children:s.type})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Max Clients"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.max_clients})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Authenticated"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.authenticated_clients})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Admin Password"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",style:{"--data-box-color":s.has_admin_password?"var(--sys-green)":"var(--sys-red)"},children:s.has_admin_password?"✓ Set":"✗ Not Set"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Guest Password"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",style:{"--data-box-color":s.has_guest_password?"var(--sys-green)":"var(--sys-red)"},children:s.has_guest_password?"✓ Set":"✗ Not Set"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Read-Only Access"}),e.jsx("div",{className:N("data-box data-box-fill data-box-left",s.allow_read_only?"text-sys-green":"text-sys-red"),children:s.allow_read_only?"Allowed":"Disabled"})]})]})]})}function be({client:s,onRemove:t}){return e.jsx("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4 transition-base hover:bg-subtle-fill-strong",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 grid grid-cols-1 sm:grid-cols-5 gap-2 sm:gap-4 items-center",children:[e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Client"}),e.jsx("span",{className:"type-data-sm text-fg-primary font-mono truncate block",children:s.public_key})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Address"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-mono truncate block",children:s.address})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Identity"}),e.jsx("span",{className:"type-data-sm text-fg-primary block truncate",children:s.identity_name}),e.jsx("span",{className:"type-data-xs text-fg-muted block truncate",children:s.identity_hash})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Permissions"}),e.jsx("span",{className:N("type-data-xs px-2 py-0.5 rounded-full font-medium inline-block",s.permissions==="admin"?"bg-sys-green/15 text-sys-green":"bg-sys-amber/15 text-sys-amber"),children:s.permissions})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Last Activity"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:je(s.last_activity)})]})]}),e.jsxs(g,{color:"danger",outline:!0,onClick:t,className:"flex-shrink-0",children:[e.jsx(D,{"data-slot":"icon"}),"Remove"]})]})})}function Ne({client:s,onRemove:t}){return e.jsx("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4 transition-base hover:bg-subtle-fill-strong",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:N("type-data-xs px-2 py-0.5 rounded-full font-medium",s.permissions==="admin"?"bg-sys-green/15 text-sys-green":"bg-sys-amber/15 text-sys-amber"),children:s.permissions}),e.jsx("span",{className:"type-data-sm text-fg-primary font-mono truncate",children:s.public_key})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Address: "}),e.jsx("span",{className:"text-fg-primary/90 font-mono",children:s.address})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Identity: "}),e.jsxs("span",{className:"text-fg-primary/90",children:[s.identity_name," (",s.identity_hash,")"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Last Activity: "}),e.jsx("span",{className:"text-fg-primary/90",children:E(s.last_activity)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Last Login: "}),e.jsx("span",{className:"text-fg-primary/90",children:E(s.last_login_success)})]})]})]}),e.jsx(g,{color:"danger",outline:!0,onClick:t,className:"flex-shrink-0",children:e.jsx(D,{"data-slot":"icon"})})]})})}function Ie(){const[s,t]=l.useState("overview"),[i,x]=l.useState(!0),[r,S]=l.useState(!1),[h,v]=l.useState("idle"),[A,u]=l.useState(null),[w,K]=l.useState(null),[c,F]=l.useState([]),[d,H]=l.useState(null),[o,q]=l.useState(null),[n,p]=l.useState(null),[G,R]=l.useState(!1),k=(w==null?void 0:w.acls)??[],L=l.useMemo(()=>o?c.filter(a=>a.identity_name===o):c,[c,o]),f=l.useCallback(async()=>{u(null);try{const[a,m,_]=await Promise.all([U(),z(),V()]);a.success&&a.data&&K(a.data),m.success&&m.data&&F(m.data.clients||[]),_.success&&_.data&&H(_.data)}catch(a){u(a instanceof Error?a.message:"Failed to load session data")}},[]);l.useEffect(()=>{f().finally(()=>x(!1))},[f]);const I=async()=>{S(!0),v("loading"),await f(),S(!1),v("success"),setTimeout(()=>v("idle"),1500)},O=async()=>{if(n){R(!0);try{const a=await Z({public_key:n.publicKey,identity_hash:n.identityHash});a.success?await f():u(`Failed to remove client: ${a.error}`)}catch(a){u(a instanceof Error?a.message:"Failed to remove client")}finally{R(!1),p(null)}}};return e.jsxs(te,{children:[e.jsx(le,{title:"Sessions",icon:e.jsx(C,{}),controls:e.jsxs(g,{color:h==="success"?"success":"primary",outline:!0,onClick:I,disabled:r,children:[h==="loading"?e.jsx(M,{"data-slot":"icon",className:"animate-spin"}):h==="success"?e.jsx(Y,{"data-slot":"icon"}):e.jsx(J,{"data-slot":"icon"}),h==="success"?"Done":"Refresh"]}),subtitle:e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Manage authenticated clients and access control lists"})}),e.jsxs(ie,{children:[d&&e.jsxs(T,{template:"widget",children:[e.jsx(y,{span:6,md:3,children:e.jsx(j,{label:"Identities",value:d.total_identities,icon:e.jsx(C,{className:"w-4 h-4"})})}),e.jsx(y,{span:6,md:3,children:e.jsx(j,{label:"Authenticated",value:d.total_clients,icon:e.jsx(ue,{className:"w-4 h-4"})})}),e.jsx(y,{span:6,md:3,children:e.jsx(j,{label:"Admin",value:d.admin_clients,icon:e.jsx(B,{className:"w-4 h-4"})})}),e.jsx(y,{span:6,md:3,children:e.jsx(j,{label:"Guest",value:d.guest_clients,icon:e.jsx(ne,{className:"w-4 h-4"})})})]}),e.jsx(T,{template:"auto",children:e.jsxs(P,{neomorphic:!0,children:[e.jsx("div",{className:"flex flex-wrap gap-1 mb-5",children:e.jsx("div",{className:"toggle-group",children:ye.map(a=>{const m=s===a.id;return e.jsxs("button",{onClick:()=>t(a.id),className:N("toggle-group-item flex items-center gap-1.5",m&&"active"),children:[e.jsx(a.icon,{className:"w-3.5 h-3.5"}),a.label]},a.id)})})}),e.jsx("div",{className:"min-h-[300px]",children:i?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(M,{className:"w-6 h-6 animate-spin text-sys-blue mr-3"}),e.jsx("span",{className:"type-body text-fg-muted",children:"Loading session data..."})]}):A?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-sys-red/10 mx-auto mb-3 flex items-center justify-center",children:e.jsx(Q,{className:"w-6 h-6 text-sys-red"})}),e.jsx("p",{className:"type-body text-sys-red mb-2",children:"Failed to load session data"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:A}),e.jsx(g,{color:"primary",outline:!0,onClick:I,children:"Retry"})]}):e.jsxs(e.Fragment,{children:[s==="overview"&&e.jsx("div",{className:"space-y-4",children:k.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(B,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No identities configured"})]}):k.map(a=>e.jsx(ge,{identity:a},a.hash))}),s==="clients"&&e.jsxs("div",{className:"space-y-3",children:[c.length>0&&e.jsxs("div",{className:"hidden sm:grid grid-cols-5 gap-4 px-4 pb-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Client"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Address"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Identity"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Permissions"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Last Activity"})]}),c.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(C,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No authenticated clients"})]}):c.map(a=>e.jsx(be,{client:a,onRemove:()=>p({publicKey:a.public_key_full,identityHash:a.identity_hash,displayKey:a.public_key})},a.public_key_full))]}),s==="identities"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Filter by Identity"}),e.jsxs("select",{value:o??"",onChange:a=>q(a.target.value||null),className:"w-full sm:w-auto bg-subtle-fill border border-edge-subtle radius-inner px-4 py-2 type-data text-fg-primary focus:outline-none focus:border-sys-blue/50 transition-colors",children:[e.jsx("option",{value:"",children:"All Identities"}),k.map(a=>e.jsxs("option",{value:a.name,children:[a.name," (",a.authenticated_clients," clients)"]},a.name))]})]}),L.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(ce,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:o?"No clients for selected identity":"No clients found"})]}):e.jsx("div",{className:"space-y-3",children:L.map(a=>e.jsx(Ne,{client:a,onRemove:()=>p({publicKey:a.public_key_full,identityHash:a.identity_hash,displayKey:a.public_key})},a.public_key_full))})]})]})})]})})]}),e.jsx(ae,{isOpen:!!n,title:"Remove Client",message:`Are you sure you want to remove client '${n==null?void 0:n.displayKey}' from the ACL? This will disconnect the client.`,confirmLabel:G?"Removing...":"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:O,onCancel:()=>p(null)})]})}export{Ie as default}; + */const pe=[["path",{d:"m16 11 2 2 4-4",key:"9rsbq5"}],["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],fe=b("user-check",pe),ye=[{id:"overview",label:"Overview",icon:xe},{id:"clients",label:"Authenticated Clients",icon:fe},{id:"identities",label:"By Identity",icon:oe}];function $(s){return s?new Date(s*1e3).toLocaleString():"Never"}function je(s){if(!s)return"Never";const t=Date.now()-s*1e3,i=Math.floor(t/6e4),x=Math.floor(t/36e5),r=Math.floor(t/864e5);return i<1?"Just now":i<60?`${i}m ago`:x<24?`${x}h ago`:r<365?`${r}d ago`:`${Math.floor(r/365)}y ago`}function j({label:s,value:t,icon:i}){return e.jsxs(P,{neomorphic:!0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[i&&e.jsx("span",{className:"icon-sm text-icon-card-title",children:i}),e.jsx("span",{className:"type-micro",children:s})]}),e.jsx(W,{centered:!0,children:e.jsx("span",{className:"type-data-xl text-fg-primary font-mono font-normal tabular-nums",children:t})})]})}const E={repeater:{icon:re,color:"var(--sys-blue)"},room_server:{icon:ee,color:"var(--sys-pink)"},companion:{icon:X,color:"var(--sys-cyan)"}};function ge({identity:s}){const t=E[s.type]??E.repeater,i=t.icon;return e.jsxs("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-3",children:[e.jsx("span",{className:"icon-sm text-icon-card-title",children:e.jsx(i,{className:"w-4 h-4"})}),e.jsx("span",{className:"type-micro",children:s.name}),e.jsx(se,{copy:!0,size:"compact",truncate:[8,6],color:"text-fg-muted",children:s.hash}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined ml-auto",style:{"--data-box-accent":t.color},children:s.type})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Max Clients"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.max_clients})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Authenticated"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.authenticated_clients})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Admin Password"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",style:{"--data-box-color":s.has_admin_password?"var(--sys-green)":"var(--sys-red)"},children:s.has_admin_password?"✓ Set":"✗ Not Set"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Guest Password"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",style:{"--data-box-color":s.has_guest_password?"var(--sys-green)":"var(--sys-red)"},children:s.has_guest_password?"✓ Set":"✗ Not Set"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Read-Only Access"}),e.jsx("div",{className:N("data-box data-box-fill data-box-left",s.allow_read_only?"text-sys-green":"text-sys-red"),children:s.allow_read_only?"Allowed":"Disabled"})]})]})]})}function be({client:s,onRemove:t}){return e.jsx("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4 transition-base hover:bg-subtle-fill-strong",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 grid grid-cols-1 sm:grid-cols-5 gap-2 sm:gap-4 items-center",children:[e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Client"}),e.jsx("span",{className:"type-data-sm text-fg-primary font-mono truncate block",children:s.public_key})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Address"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-mono truncate block",children:s.address})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Identity"}),e.jsx("span",{className:"type-data-sm text-fg-primary block truncate",children:s.identity_name}),e.jsx("span",{className:"type-data-xs text-fg-muted block truncate",children:s.identity_hash})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Permissions"}),e.jsx("span",{className:N("type-data-xs px-2 py-0.5 rounded-full font-medium inline-block",s.permissions==="admin"?"bg-sys-green/15 text-sys-green":"bg-sys-amber/15 text-sys-amber"),children:s.permissions})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Last Activity"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:je(s.last_activity)})]})]}),e.jsxs(g,{color:"danger",outline:!0,onClick:t,className:"flex-shrink-0",children:[e.jsx(D,{"data-slot":"icon"}),"Remove"]})]})})}function Ne({client:s,onRemove:t}){return e.jsx("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4 transition-base hover:bg-subtle-fill-strong",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:N("type-data-xs px-2 py-0.5 rounded-full font-medium",s.permissions==="admin"?"bg-sys-green/15 text-sys-green":"bg-sys-amber/15 text-sys-amber"),children:s.permissions}),e.jsx("span",{className:"type-data-sm text-fg-primary font-mono truncate",children:s.public_key})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Address: "}),e.jsx("span",{className:"text-fg-primary/90 font-mono",children:s.address})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Identity: "}),e.jsxs("span",{className:"text-fg-primary/90",children:[s.identity_name," (",s.identity_hash,")"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Last Activity: "}),e.jsx("span",{className:"text-fg-primary/90",children:$(s.last_activity)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Last Login: "}),e.jsx("span",{className:"text-fg-primary/90",children:$(s.last_login_success)})]})]})]}),e.jsx(g,{color:"danger",outline:!0,onClick:t,className:"flex-shrink-0",children:e.jsx(D,{"data-slot":"icon"})})]})})}function Ie(){const[s,t]=l.useState("overview"),[i,x]=l.useState(!0),[r,S]=l.useState(!1),[h,v]=l.useState("idle"),[A,u]=l.useState(null),[w,F]=l.useState(null),[c,K]=l.useState([]),[d,H]=l.useState(null),[o,q]=l.useState(null),[n,p]=l.useState(null),[G,R]=l.useState(!1),k=(w==null?void 0:w.acls)??[],L=l.useMemo(()=>o?c.filter(a=>a.identity_name===o):c,[c,o]),f=l.useCallback(async()=>{u(null);try{const[a,m,_]=await Promise.all([V(),z(),J()]);a.success&&a.data&&F(a.data),m.success&&m.data&&K(m.data.clients||[]),_.success&&_.data&&H(_.data)}catch(a){u(a instanceof Error?a.message:"Failed to load session data")}},[]);l.useEffect(()=>{f().finally(()=>x(!1))},[f]);const I=async()=>{S(!0),v("loading"),await f(),S(!1),v("success"),setTimeout(()=>v("idle"),1500)},O=async()=>{if(n){R(!0);try{const a=await Y({public_key:n.publicKey,identity_hash:n.identityHash});a.success?await f():u(`Failed to remove client: ${a.error}`)}catch(a){u(a instanceof Error?a.message:"Failed to remove client")}finally{R(!1),p(null)}}};return e.jsxs(te,{children:[e.jsx(le,{title:"Sessions",icon:e.jsx(C,{}),controls:e.jsxs(g,{color:h==="success"?"success":"primary",outline:!0,onClick:I,disabled:r,children:[h==="loading"?e.jsx(M,{"data-slot":"icon",className:"animate-spin"}):h==="success"?e.jsx(U,{"data-slot":"icon"}):e.jsx(Z,{"data-slot":"icon"}),h==="success"?"Done":"Refresh"]}),subtitle:e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Manage authenticated clients and access control lists"})}),e.jsxs(ie,{children:[d&&e.jsxs(T,{template:"widget",children:[e.jsx(y,{span:6,md:3,children:e.jsx(j,{label:"Identities",value:d.total_identities,icon:e.jsx(C,{className:"w-4 h-4"})})}),e.jsx(y,{span:6,md:3,children:e.jsx(j,{label:"Authenticated",value:d.total_clients,icon:e.jsx(ue,{className:"w-4 h-4"})})}),e.jsx(y,{span:6,md:3,children:e.jsx(j,{label:"Admin",value:d.admin_clients,icon:e.jsx(B,{className:"w-4 h-4"})})}),e.jsx(y,{span:6,md:3,children:e.jsx(j,{label:"Guest",value:d.guest_clients,icon:e.jsx(ne,{className:"w-4 h-4"})})})]}),e.jsx(T,{template:"auto",children:e.jsxs(P,{neomorphic:!0,children:[e.jsx("div",{className:"flex flex-wrap gap-1 mb-5",children:e.jsx("div",{className:"toggle-group",children:ye.map(a=>{const m=s===a.id;return e.jsxs("button",{onClick:()=>t(a.id),className:N("toggle-group-item flex items-center gap-1.5",m&&"active"),children:[e.jsx(a.icon,{className:"w-3.5 h-3.5"}),a.label]},a.id)})})}),e.jsx("div",{className:"min-h-[300px]",children:i?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(M,{className:"w-6 h-6 animate-spin text-sys-blue mr-3"}),e.jsx("span",{className:"type-body text-fg-muted",children:"Loading session data..."})]}):A?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-sys-red/10 mx-auto mb-3 flex items-center justify-center",children:e.jsx(Q,{className:"w-6 h-6 text-sys-red"})}),e.jsx("p",{className:"type-body text-sys-red mb-2",children:"Failed to load session data"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:A}),e.jsx(g,{color:"primary",outline:!0,onClick:I,children:"Retry"})]}):e.jsxs(e.Fragment,{children:[s==="overview"&&e.jsx("div",{className:"space-y-4",children:k.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(B,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No identities configured"})]}):k.map(a=>e.jsx(ge,{identity:a},a.hash))}),s==="clients"&&e.jsxs("div",{className:"space-y-3",children:[c.length>0&&e.jsxs("div",{className:"hidden sm:grid grid-cols-5 gap-4 px-4 pb-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Client"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Address"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Identity"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Permissions"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Last Activity"})]}),c.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(C,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No authenticated clients"})]}):c.map(a=>e.jsx(be,{client:a,onRemove:()=>p({publicKey:a.public_key_full,identityHash:a.identity_hash,displayKey:a.public_key})},a.public_key_full))]}),s==="identities"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Filter by Identity"}),e.jsxs("select",{value:o??"",onChange:a=>q(a.target.value||null),className:"w-full sm:w-auto bg-subtle-fill border border-edge-subtle radius-inner px-4 py-2 type-data text-fg-primary focus:outline-none focus:border-sys-blue/50 transition-colors",children:[e.jsx("option",{value:"",children:"All Identities"}),k.map(a=>e.jsxs("option",{value:a.name,children:[a.name," (",a.authenticated_clients," clients)"]},a.name))]})]}),L.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(ce,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:o?"No clients for selected identity":"No clients found"})]}):e.jsx("div",{className:"space-y-3",children:L.map(a=>e.jsx(Ne,{client:a,onRemove:()=>p({publicKey:a.public_key_full,identityHash:a.identity_hash,displayKey:a.public_key})},a.public_key_full))})]})]})})]})})]}),e.jsx(ae,{isOpen:!!n,title:"Remove Client",message:`Are you sure you want to remove client '${n==null?void 0:n.displayKey}' from the ACL? This will disconnect the client.`,confirmLabel:G?"Removing...":"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:O,onCancel:()=>p(null)})]})}export{Ie as default}; diff --git a/frontend/dist/assets/SignalIndicator-DO8Lkax5.js b/frontend/dist/assets/SignalIndicator-DmWlnzMv.js similarity index 94% rename from frontend/dist/assets/SignalIndicator-DO8Lkax5.js rename to frontend/dist/assets/SignalIndicator-DmWlnzMv.js index 7f104705..384a5224 100644 --- a/frontend/dist/assets/SignalIndicator-DO8Lkax5.js +++ b/frontend/dist/assets/SignalIndicator-DmWlnzMv.js @@ -1,4 +1,4 @@ -import{e as l,r as m,c as i,j as r,go as j,dw as _,e8 as k}from"./index-C2xvS0Jd.js";/** +import{e as l,r as m,c as i,j as r,go as j,dx as _,e8 as k}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -8,7 +8,7 @@ import{e as l,r as m,c as i,j as r,go as j,dw as _,e8 as k}from"./index-C2xvS0Jd * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const w=[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}]],S=l("signal-low",w);/** + */const S=[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}]],w=l("signal-low",S);/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -23,4 +23,4 @@ import{e as l,r as m,c as i,j as r,go as j,dw as _,e8 as k}from"./index-C2xvS0Jd * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const B=[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]],R=l("signal",B),L={excellent:"color(display-p3 0.00 1.00 0.00)",good:"color(display-p3 0.55 0.90 0.15)",fair:"color(display-p3 1.00 0.85 0.00)",weak:"color(display-p3 1.00 0.55 0.15)",poor:"color(display-p3 1.00 0.20 0.20)"},E={excellent:"#4ADE80",good:"#A3E635",fair:"#FACC15",weak:"#FB923C",poor:"#EF4444"};function d(e){return e>=-90?"excellent":e>=-100?"good":e>=-110?"fair":e>=-120?"weak":"poor"}function F(e,t,a,s=0){const n=k(t,e,a,s);return n?I(n.finalGrade):d(e)}function I(e){switch(e){case"excellent":return"excellent";case"good":return"good";case"fair":return"fair";case"poor":return"weak";case"critical":return"poor"}}function O(e){switch(e){case"excellent":return"text-signal-excellent";case"good":return"text-signal-good";case"fair":return"text-signal-fair";case"weak":return"text-signal-poor";case"poor":return"text-signal-critical";default:return"text-fg-muted"}}function f(e,t,a=!0){return t?a?{backgroundColor:E[e],"--p3-color":L[e]}:{backgroundColor:"rgba(255, 255, 255, 0.25)"}:{backgroundColor:"rgba(255, 255, 255, 0.1)"}}function p(e,t=!0){return e&&t?"signal-bar-active":""}function G({rssi:e,className:t="w-4 h-4"}){const a=d(e),s=O(a),n=i(s,t);switch(a){case"excellent":return r.jsx(R,{className:n});case"good":return r.jsx(v,{className:n});case"fair":return r.jsx(A,{className:n});case"weak":return r.jsx(S,{className:n});case"poor":default:return r.jsx(b,{className:n})}}function $({rssi:e,snr:t,compact:a=!1,showValues:s=!0,radioConfig:n,nfPenalty:h=0,validated:c=!0}){const g=t!==void 0?F(e,t,n,h):d(e),x=4,u={excellent:4,good:3,fair:2,weak:1,poor:0}[g];return a?r.jsxs("div",{className:"flex items-center gap-1.5",children:[s&&r.jsx("span",{className:i("type-data-xs w-[32px] text-left",c?"text-fg-secondary":"text-fg-muted"),children:e}),r.jsx("div",{className:"flex items-center gap-[2px] h-3 w-[14px]",children:Array.from({length:x}).map((y,o)=>r.jsx("div",{className:i("w-[3px] h-full rounded-[1px] transition-colors",p(or.jsx("div",{className:i("w-[3px] h-full rounded-[1px] transition-colors",p(o=-90?"excellent":e>=-100?"good":e>=-110?"fair":e>=-120?"weak":"poor"}function F(e,t,a,s=0){const n=k(t,e,a,s);return n?I(n.finalGrade):d(e)}function I(e){switch(e){case"excellent":return"excellent";case"good":return"good";case"fair":return"fair";case"poor":return"weak";case"critical":return"poor"}}function O(e){switch(e){case"excellent":return"text-signal-excellent";case"good":return"text-signal-good";case"fair":return"text-signal-fair";case"weak":return"text-signal-poor";case"poor":return"text-signal-critical";default:return"text-fg-muted"}}function f(e,t,a=!0){return t?a?{backgroundColor:E[e],"--p3-color":L[e]}:{backgroundColor:"rgba(255, 255, 255, 0.25)"}:{backgroundColor:"rgba(255, 255, 255, 0.1)"}}function p(e,t=!0){return e&&t?"signal-bar-active":""}function G({rssi:e,className:t="w-4 h-4"}){const a=d(e),s=O(a),n=i(s,t);switch(a){case"excellent":return r.jsx(R,{className:n});case"good":return r.jsx(v,{className:n});case"fair":return r.jsx(A,{className:n});case"weak":return r.jsx(w,{className:n});case"poor":default:return r.jsx(b,{className:n})}}function $({rssi:e,snr:t,compact:a=!1,showValues:s=!0,radioConfig:n,nfPenalty:h=0,validated:c=!0}){const g=t!==void 0?F(e,t,n,h):d(e),x=4,u={excellent:4,good:3,fair:2,weak:1,poor:0}[g];return a?r.jsxs("div",{className:"flex items-center gap-1.5",children:[s&&r.jsx("span",{className:i("type-data-xs w-[32px] text-left",c?"text-fg-secondary":"text-fg-muted"),children:e}),r.jsx("div",{className:"flex items-center gap-[2px] h-3 w-[14px]",children:Array.from({length:x}).map((y,o)=>r.jsx("div",{className:i("w-[3px] h-full rounded-[1px] transition-colors",p(or.jsx("div",{className:i("w-[3px] h-full rounded-[1px] transition-colors",p(on in t?Ft(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var ke=(t,n,s)=>Ht(t,typeof n!="symbol"?n+"":n,s);import{e as Oe,r as l,j as e,G as Ve,c as mt,P as At,cF as _t,cG as qe,w as De,cH as Bt,V as Pe,cI as $t,cn as Re,cJ as zt,cK as Wt,x as Ut,at as Gt,cL as Vt,cM as qt,cN as Kt,cO as Xt,cP as Yt,cb as Zt,cQ as Ke,ce as Qt,cR as Jt,cS as es,a7 as Le,cT as ts,bY as dt,c3 as ss,af as Rt,ag as ns,cU as as,bK as rs,a6 as is,ac as ls,ab as os,Q as cs,aQ as ms,aR as ds,ad as us,aA as hs,cV as Xe,aj as xs,cW as ut,as as ps,aa as fs,cX as gs}from"./index-C2xvS0Jd.js";import{L as Ee}from"./layers-BICmdhXR.js";import{u as lt,h as ys,r as ot}from"./consumer-registry-DJyYnY6J.js";import{e as bs}from"./easing-2tSIucrJ.js";import{C as Ye}from"./compass-D_q1TimF.js";import{T as js,M as vs}from"./MqttModeBadge-DOXwpg3i.js";import{C as be,P as Ns,a as ks,B as ws}from"./PageLayout-Cg7r5tdt.js";import{A as Ze,D as ze}from"./DataValue-9iNfucjq.js";import{C as Ss}from"./CollisionExplorerModal-Du9NEbAu.js";import{H as ht}from"./hash-DjqT3oXN.js";import{L as We}from"./LightSparkline-Dtyxi9BD.js";import{A as Ms}from"./activity-BFfde9uG.js";import{c as Cs,a as As,A as _s}from"./AnalyzerFilterPanel-CckWnD46.js";import{useResolveSource as Rs}from"./usePipelineStore-Do-g28wv.js";import{R as Ae,C as Ie}from"./Grid-kVOI-wJp.js";import{S as Ts}from"./settings-2-OYYe3udS.js";import{N as Ls}from"./network-D80fXCJJ.js";import"./chevron-right-C9GG0xWI.js";import"./map-pin-CQk00ph2.js";import"./index-QCPybZMd.js";import"./index-wtt5rE5a.js";import"./maplibre-gl-C9QYi5T6.js";import"./BasemapLayer-DQCsZLc0.js";import"./share-2-DLfTr0kI.js";import"./node-types-BD70swWz.js";import"./circle-question-mark-CF3fGjhH.js";import"./funnel-DGVJFdsh.js";import"./search-DPGHPI2q.js";/** +var Ft=Object.defineProperty;var Ht=(t,n,s)=>n in t?Ft(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var ke=(t,n,s)=>Ht(t,typeof n!="symbol"?n+"":n,s);import{e as Oe,r as l,j as e,G as Ve,c as mt,P as At,cG as _t,cH as qe,w as De,cI as Bt,V as Pe,cJ as $t,co as Re,cK as zt,cL as Wt,x as Ut,at as Gt,cM as Vt,cN as qt,cO as Xt,cP as Kt,cQ as Yt,cc as Zt,cR as Xe,cf as Qt,cS as Jt,cT as es,a7 as Le,cU as ts,bZ as dt,c4 as ss,af as Rt,ag as ns,cV as as,bL as rs,a6 as is,ac as ls,ab as os,Q as cs,aR as ms,aS as ds,ad as us,aA as hs,cW as Ke,aj as xs,cX as ut,as as ps,aa as fs,cY as gs}from"./index-D33fcA3L.js";import{L as Ee}from"./layers-DguV5fdN.js";import{u as lt,h as ys,r as ot}from"./consumer-registry-DXaeZxMm.js";import{e as bs}from"./easing-D0twVjny.js";import{C as Ye}from"./compass-CncUthiD.js";import{T as js,M as vs}from"./MqttModeBadge-BtcQeS2v.js";import{C as be,P as Ns,a as ks,B as ws}from"./PageLayout-CRN-E5xi.js";import{A as Ze,D as ze}from"./DataValue-B0xdrk88.js";import{C as Ss}from"./CollisionExplorerModal-P8ZOhB65.js";import{H as ht}from"./hash-Ba9bZo8v.js";import{L as We}from"./LightSparkline-r3FtGEtW.js";import{A as Ms}from"./activity-D6ySIfuC.js";import{c as Cs,a as As,A as _s}from"./AnalyzerFilterPanel-Cq7b3I2L.js";import{useResolveSource as Rs}from"./usePipelineStore-DDHEHTlZ.js";import{R as Ae,C as Ie}from"./Grid-DQYUnZsY.js";import{S as Ts}from"./settings-2-C5Lvk9-M.js";import{N as Ls}from"./network-Btok3jeo.js";import"./chevron-right-D4kUPDBw.js";import"./map-pin-B_Rx-xpd.js";import"./index-5slIee7x.js";import"./index-DuiHY5wq.js";import"./maplibre-gl-B42P8ehE.js";import"./BasemapLayer-DhvtWc_h.js";import"./share-2-BAsDxZE2.js";import"./node-types-BoqnL0Eg.js";import"./circle-question-mark-CO80vHQp.js";import"./funnel-BBIwSMOb.js";import"./search-DN8guzpX.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -23,7 +23,7 @@ var Ft=Object.defineProperty;var Ht=(t,n,s)=>n in t?Ft(t,n,{enumerable:!0,config * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Hs=[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]],Bs=Oe("grip",Hs),Lt={useAbsoluteThresholds:!0,baselinePercentile:6,spikePercentile:50,baselineDbm:-107,spikeDbm:-100,mergeGapSeconds:45,minSequenceLength:16,similarityToleranceDbm:5};function Te(t,n){if(t.length===0)return 0;const s=n/100*(t.length-1),a=Math.floor(s),r=Math.ceil(s);return a===r?t[a]:t[a]+(t[r]-t[a])*(s-a)}function pt(t){if(t.length===0)return{median:0,p90:0,p95:0,p99:0,max:0,min:0};const n=[...t].sort((s,a)=>s-a);return{median:Te(n,50),p90:Te(n,90),p95:Te(n,95),p99:Te(n,99),max:n[n.length-1],min:n[0]}}function $s(t,n={}){const s={...Lt,...n};if(t.length<10)return{anomalies:[],thresholds:pt([]),totalSamples:t.length,anomalySamples:0};const a=t.map(j=>j.noise_floor_dbm),r=pt(a),o=[...a].sort((j,w)=>j-w);let i,u;s.useAbsoluteThresholds?(i=s.baselineDbm,u=s.spikeDbm):(i=Te(o,s.baselinePercentile),u=Te(o,s.spikePercentile));const h=[...t].sort((j,w)=>j.timestamp-w.timestamp),x=[];let c=null,p=0;for(const j of h)if(j.noise_floor_dbm>i&&j.noise_floor_dbm$+D,0)/c.values.length):(c.values.length>=s.minSequenceLength&&x.push(c),c={startTs:j.timestamp,endTs:j.timestamp,values:[j.noise_floor_dbm],timestamps:[j.timestamp],rollingAvg:j.noise_floor_dbm})}else c&&c.values.length>=s.minSequenceLength&&x.push(c),c=null;return c&&c.values.length>=s.minSequenceLength&&x.push(c),x.length===0?{anomalies:[],thresholds:r,totalSamples:t.length,anomalySamples:p,debug:{baselineCutoff:i,spikeCutoff:u,midBandSamples:p}}:{anomalies:x.map(j=>{const w=Math.max(...j.values),N=j.values.reduce((b,M)=>b+M,0)/j.values.length;return{startTs:j.startTs,endTs:j.endTs,peakValue:w,avgValue:N,severity:zs(N,i,u),sampleCount:j.values.length}}),thresholds:r,totalSamples:t.length,anomalySamples:p,debug:{baselineCutoff:i,spikeCutoff:u,midBandSamples:p}}}function zs(t,n,s){const a=s-n;if(a===0)return"moderate";const r=(t-n)/a;return r>.66?"critical":r>.33?"severe":"moderate"}const Ws=Object.entries(At).map(([t,n])=>{const s=parseInt(t,10);return{typeNum:s,key:`TYPE_${s}`,label:n}});function ct({sortedTypes:t,highlightedType:n,onTypeHover:s,aggregateShares:a,hoverData:r,overlayLines:o}){const i=l.useMemo(()=>{if(!r)return null;const x=new Map;for(const c of r.items)x.set(c.key,c.value);return x},[r]),u=i!==null,h=l.useMemo(()=>{const x=new Set(t.map(k=>k.key)),c=t.map(k=>({typeNum:k.typeNum,key:k.key,label:k.label})),p=Ws.filter(k=>!x.has(k.key));return[...c,...p]},[t]);return e.jsxs("div",{className:"flex-shrink-0 pt-2 sm:pt-3 mt-1 sm:mt-2 px-0 sm:pr-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mx-0 sm:ml-9 sm:mr-0 mb-1 sm:mb-1.5 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted",children:"Packet Types"}),u&&(r==null?void 0:r.timeLabel)&&e.jsx("span",{className:"text-sys-indigo tabular-nums",children:r.timeLabel})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-3 sm:gap-x-4 gap-y-1 type-data-xs mx-0 sm:ml-9 sm:mr-0",onMouseLeave:()=>s(null),children:[h.map(x=>{const c=Ve(x.typeNum),p=(i==null?void 0:i.get(x.key))??0,k=a.get(x.key)??0,j=u?p:k,w=j>1e-4,N=a.has(x.key),b=n===x.key,M=n&&!b||u&&p<=1e-4||!u&&!n&&!N;return e.jsxs("div",{className:mt("flex items-center gap-1.5 transition-opacity cursor-pointer hover:opacity-80",M&&"opacity-30"),onMouseEnter:()=>s(x.key),children:[e.jsx("div",{className:"shrink-0 w-3 h-3 rounded-xs",style:{backgroundColor:c}}),e.jsx("span",{className:"text-fg-secondary whitespace-nowrap",children:x.label}),w&&e.jsxs("span",{className:mt("tabular-nums",u?"text-fg-primary":"text-fg-muted"),children:[(j*100).toFixed(1),"%"]})]},x.key)}),o&&o.map(x=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"shrink-0 w-3 h-0.5 rounded-full",style:{backgroundColor:x.color,opacity:x.opacity??1}}),e.jsx("span",{className:"text-fg-secondary whitespace-nowrap",children:x.label})]},x.label))]})]})}const ft='ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',Us=2,Gs=3,Vs=32,qs=20,Ks=80;function gt(t,n,s,a,r){const o=t.reduce((x,c)=>x+c,0);if(o<=0||t.length===0)return[];const i=t.map((x,c)=>c).sort((x,c)=>t[c]-t[x]),u=i.map(x=>t[x]),h=new Array(t.length);return it(u,i,o,n,s,a,r,h),h}function it(t,n,s,a,r,o,i,u){if(t.length===0)return;if(t.length===1){u[n[0]]={x:a,y:r,w:o,h:i,index:n[0]};return}const h=o*i/s,x=o>=i,c=x?i:o;let p=0,k=1/0,j=0;for(let D=0;DX?F/X:X/F,v>X?v/X:X/v);if(y<=k)k=y,j=D+1,p=Z;else break}const w=c>0?p*h/c:0;let N=0;for(let D=0;D0?t[D]/p:0)*c;x?u[n[D]]={x:a,y:r+N,w,h:X,index:n[D]}:u[n[D]]={x:a+N,y:r,w:X,h:w,index:n[D]},N+=X}const b=t.slice(j),M=n.slice(j),$=s-p;x?it(b,M,$,a+w,r,o-w,i,u):it(b,M,$,a,r+w,o,i-w,u)}function yt(t,n,s,a,r,o){for(const i of n){const u=s[i.index];if(!u)continue;const h=Us*o,x=i.x*o+h/2,c=i.y*o+h/2,p=i.w*o-h,k=i.h*o-h;if(p<=0||k<=0)continue;const j=Ve(u.typeNum),w=r!==null&&r!==i.index;t.save(),t.globalAlpha=w?.4:1;const N=Gs*o;t.beginPath(),t.moveTo(x+N,c),t.lineTo(x+p-N,c),t.quadraticCurveTo(x+p,c,x+p,c+N),t.lineTo(x+p,c+k-N),t.quadraticCurveTo(x+p,c+k,x+p-N,c+k),t.lineTo(x+N,c+k),t.quadraticCurveTo(x,c+k,x,c+k-N),t.lineTo(x,c+N),t.quadraticCurveTo(x,c,x+N,c),t.closePath(),t.fillStyle=j,t.fill(),t.strokeStyle="rgba(0,0,0,0.2)",t.lineWidth=1*o,t.stroke();const b=4*o,M=i.w>36&&i.h>20,$=i.w>36&&i.h>32;if(M){const D=11*o;if($){const Z=a>0?u.size/a*100:0;t.font=`500 ${8*o}px ${ft}`,t.fillStyle="rgba(0,0,0,0.6)",t.textBaseline="alphabetic",t.textAlign="left",t.fillText(`${Z.toFixed(1)}%`,x+b,c+k-b-D)}t.font=`600 ${9*o}px ${ft}`,t.fillStyle="rgba(0,0,0,0.85)",t.textBaseline="alphabetic",t.textAlign="left",t.fillText(u.name,x+b,c+k-b)}t.restore()}}function Xs(t,n,s){for(const a of t)if(n>=a.x&&n<=a.x+a.w&&s>=a.y&&s<=a.y+a.h)return a.index;return null}function Ys({data:t,total:n,color:s,position:a,containerWidth:r,isAirtime:o}){if(!t||!a)return null;const i=(t.value/n*100).toFixed(1),u=160,c=r-a.x=6e4?`${(t/6e4).toFixed(1)}m`:t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function Zs({sortedTypes:t,aggregateShares:n,mode:s="share"}){var F,v,y;const[a,r]=l.useState(null),[o,i]=l.useState(null),[u,h]=l.useState(0),[x,c]=l.useState(null),p=l.useRef(null),k=l.useRef(null),j=l.useRef([]),w=s==="airtime",N=l.useMemo(()=>t.reduce((m,f)=>m+(w?f.totalAirtime:f.totalCount),0),[t,w]),b=l.useMemo(()=>t.map((m,f)=>({name:m.label,size:w?m.totalAirtime:m.totalCount,index:f,typeNum:m.typeNum,key:m.key})),[t,w]);l.useEffect(()=>{const m=k.current;if(!m)return;const f=m.parentElement;if(!f)return;const L=f.getBoundingClientRect(),G=L.width,g=L.height;if(G<=0||g<=0)return;const _=window.devicePixelRatio||1;m.width=Math.floor(G*_),m.height=Math.floor(g*_),m.style.width=`${G}px`,m.style.height=`${g}px`;const K=b.map(V=>V.size),re=gt(K,0,0,G,g);j.current=re;const te=m.getContext("2d");te&&(te.clearRect(0,0,m.width,m.height),yt(te,re,b,N,a,_))},[b,N,a]),l.useEffect(()=>{const m=p.current;if(!m)return;const f=new ResizeObserver(()=>{const L=k.current;if(!L)return;const G=m.getBoundingClientRect(),g=G.width,_=G.height;if(g<=0||_<=0)return;const K=window.devicePixelRatio||1;L.width=Math.floor(g*K),L.height=Math.floor(_*K),L.style.width=`${g}px`,L.style.height=`${_}px`;const re=b.map(Y=>Y.size),te=gt(re,0,0,g,_);j.current=te;const V=L.getContext("2d");V&&(V.clearRect(0,0,L.width,L.height),yt(V,te,b,N,a,K))});return f.observe(m),()=>f.disconnect()},[b,N]);const M=l.useCallback(m=>{const f=p.current;if(!f)return;const L=f.getBoundingClientRect(),G=m.clientX-L.left,g=m.clientY-L.top,_=Xs(j.current,G,g);r(_),_!==null?(h(L.width),i({x:G,y:g})):i(null)},[]),$=l.useCallback(()=>{r(null),i(null)},[]),D=l.useCallback(m=>{if(c(m),m){const f=b.findIndex(L=>L.key===m);r(f>=0?f:null)}else r(null)},[b]),Z=a!==null?{name:((F=b[a])==null?void 0:F.name)??"",value:((v=b[a])==null?void 0:v.size)??0}:null,X=a!==null?Ve((y=b[a])==null?void 0:y.typeNum):"";return t.length===0||N===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(Ee,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet type data available"})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 min-h-0 relative",children:e.jsxs("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:Vs,right:0,top:0,bottom:qs},ref:p,onMouseMove:M,onMouseLeave:$,children:[e.jsx("canvas",{ref:k,className:"absolute inset-0",style:{cursor:"default"}}),e.jsx(Ys,{data:Z,total:N,color:X,position:o,containerWidth:u,isAirtime:w})]})}),e.jsx("div",{style:{minHeight:Ks},children:e.jsx(ct,{sortedTypes:t,highlightedType:x,onTypeHover:D,aggregateShares:n})})]})}const Qe=32,Je=20,Qs=300;function _e(t){return t>=1e9?`${(t/1e9).toFixed(1)} Gb`:t>=1e6?`${(t/1e6).toFixed(1)} Mb`:t>=1e3?`${(t/1e3).toFixed(1)} Kb`:`${t.toFixed(0)} B`}function Js({packets:t,mode:n,startTs:s,endTs:a,radioConfig:r,bucketCount:o,lockedYMax:i,legendMinH:u}){const h=l.useMemo(()=>_t(),[]),x=h.blue,c=h.red,p=h.yellow,[k,j]=l.useState(null),{trendData:w,totals:N}=l.useMemo(()=>{if(t.length===0)return{trendData:[],totals:{rxBytes:0,txBytes:0,rxAirtime:0,txAirtime:0}};const v=a-s,y=Math.min(Math.ceil(v/Qs),o),m=v/y,f=[];let L=0,G=0,g=0,_=0;for(const C of t){const W=C.timestamp;if(W=a)continue;const H=qe(C),E=De(C,{spreadingFactor:r.sf,bandwidthHz:r.bw,codingRate:r.cr,preambleLength:r.preamble}),z={timestamp:W,rxAirtime:0,txAirtime:0,rxBytes:0,txBytes:0};C.transmitted?(z.txAirtime=E,z.txBytes=H,G+=H,_+=E):(z.rxAirtime=E,z.rxBytes=H,L+=H,g+=E),f.push(z)}f.sort((C,W)=>C.timestamp-W.timestamp);const K=new Float64Array(f.length+1),re=new Float64Array(f.length+1),te=new Float64Array(f.length+1),V=new Float64Array(f.length+1),Y=new Float64Array(f.length);for(let C=0;C{let W=0,H=Y.length;for(;W>>1;Y[E]0?q:null,tx:S>0?S:null})}else{const q=K[z]-K[E],S=re[z]-re[E],O=q/J*100,U=S/J*100;xe.push({timestamp:W,rx:O>0?O:null,tx:U>0?U:null})}}const P=2/31;let Q=null;return{trendData:xe.map(C=>{const W=C.rx;return W!==null&&W>0&&(Q===null?Q=W:Q=P*W+(1-P)*Q),{...C,rxSmooth:Q!==null&&Q>0?Q:null}}),totals:{rxBytes:L,txBytes:G,rxAirtime:g,txAirtime:_}}},[t,s,a,o,n,r]),b=l.useMemo(()=>{if(w.length===0)return n==="share"?100:10;let v=0;for(const m of w){const f=m.rx??0,L=m.tx??0;f>v&&(v=f),L>v&&(v=L)}const y=v*1.1;return n==="share"?y<=100?100:y<=500?Math.ceil(y/100)*100:y<=1e3?Math.ceil(y/200)*200:y<=5e3?Math.ceil(y/500)*500:y<=1e4?Math.ceil(y/1e3)*1e3:Math.ceil(y/5e3)*5e3:Math.max(1,Math.ceil(y))},[w,n]),M=i??b,$=l.useMemo(()=>{if(k!==null&&w[k]){const v=w[k],y=v.rx??0,m=v.tx??0;return n==="share"?{rx:_e(y),tx:_e(m),total:_e(y+m),isHovered:!0}:{rx:`${y.toFixed(2)}%`,tx:`${m.toFixed(2)}%`,total:`${(y+m).toFixed(2)}%`,isHovered:!0}}if(n==="share")return{rx:_e(N.rxBytes),tx:_e(N.txBytes),total:_e(N.rxBytes+N.txBytes),isHovered:!1};{let v=0,y=0,m=0;for(const G of w)(G.rx!==null||G.tx!==null)&&(v+=G.rx??0,y+=G.tx??0,m++);const f=m>0?v/m:0,L=m>0?y/m:0;return{rx:`${f.toFixed(2)}%`,tx:`${L.toFixed(2)}%`,total:`${(f+L).toFixed(2)}%`,isHovered:!1}}},[k,w,N,n]),D=l.useMemo(()=>{const v=a-s,y=v/3600;return[0,.25,.5,.75,1].map(f=>{const L=s+v*f,G=new Date(L*1e3),g=G.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),_=G.toLocaleDateString([],{weekday:"short"}),K=f===.25||f===.75;return{pct:f,label:y>=24?`${_} ${g}`:g,mobileHidden:K}})},[s,a]),Z=l.useCallback(v=>{j(v)},[]);if(w.length===0)return e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(Ee,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]});const X=l.useMemo(()=>n==="airtime"?M<=5?1:M<=10?2:M<=20?5:Math.ceil(M/5):M<=100?25:M<=500?100:M<=1e3?200:M<=5e3?1e3:M<=1e4?2e3:Math.ceil(M/5e3)*1e3,[M,n]),F=l.useMemo(()=>{const v=[];for(let y=0;y<=M;y+=X){const m=(1-y/M)*100;let f;n==="airtime"?f=`${y}%`:y>=1e6?f=`${(y/1e6).toFixed(1)}M`:y>=1e3?f=`${(y/1e3).toFixed(0)}K`:f=`${y}`,v.push({pos:m,label:f})}return v},[M,X,n]);return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:Qe,bottom:Je},children:F.map((v,y)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${v.pos}%`,transform:y===0?"translateY(-100%)":y===F.length-1?"none":"translateY(-50%)",right:0},children:v.label},y))}),e.jsx("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:Qe,right:0,top:0,bottom:Je},children:e.jsx(Bt,{data:w,yAxisMode:n==="share"?"share":"airtime",yMax:M,onHover:Z,startTs:s,endTs:a,externalAxes:!0})}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 flex items-center pointer-events-none",style:{left:Qe,height:Je,paddingTop:4},children:D.map((v,y)=>e.jsx("span",{className:`absolute type-data-xs text-fg-muted/60 tabular-nums ${v.mobileHidden?"hidden sm:inline":""}`,style:{left:`${v.pct*100}%`,transform:v.pct===0?"translateX(0)":v.pct===1?"translateX(-100%)":"translateX(-50%)"},children:v.label},y))})]}),e.jsxs("div",{className:"flex items-end justify-between pb-1",style:{minHeight:u},children:[e.jsxs("div",{className:"flex items-center gap-3 sm:gap-5 type-data-sm pl-2 sm:pl-11",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-4 sm:w-5 h-[2px] rounded-full",style:{backgroundColor:x}}),e.jsx("span",{className:"text-fg-secondary",children:"RX"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-4 sm:w-5 h-[2px] rounded-full",style:{backgroundColor:c}}),e.jsx("span",{className:"text-fg-secondary",children:"TX"})]}),e.jsxs("div",{className:"hidden sm:flex items-center gap-1.5",children:[e.jsx("div",{className:"w-5 h-[2px] rounded-full",style:{backgroundColor:p}}),e.jsx("span",{className:"text-fg-secondary",children:"Avg"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-8",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:$.rx}),e.jsx(Pe,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"RX"})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:$.tx}),e.jsx(Pe,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"TX"})]})]})]})]})}const jt=$t;class en{constructor(){ke(this,"worker",null);ke(this,"listeners",new Set);ke(this,"currentResult",null);ke(this,"isComputing",!1);ke(this,"debounceTimer",null);ke(this,"debounceMs",250);ke(this,"lastCacheKey",null)}ensureWorker(){if(this.worker)return this.worker;if(typeof window>"u")return null;try{this.worker=new Worker(new URL("/assets/bucketing.worker-D0TT0k8y.js",import.meta.url),{type:"module"}),this.worker.onmessage=n=>{this.handleWorkerMessage(n.data)},this.worker.onerror=n=>{console.error("[BucketingService] Worker error:",n),this.isComputing=!1,this.notifyListeners()}}catch(n){console.error("[BucketingService] Failed to initialize worker:",n)}return this.worker}handleWorkerMessage(n){if(this.isComputing=!1,n.type==="error"){this.currentResult=null,this.notifyListeners();return}const s=n.payload;this.currentResult={points:s.points,rawValues:s.rawValues,packetTypes:s.packetTypes,timestamps:s.timestamps,count:s.count,minTime:s.minTime,maxTime:s.maxTime,minValue:s.minValue,maxValue:s.maxValue,rawMinValue:s.rawMinValue,rawMaxValue:s.rawMaxValue,unit:"%",stats:{p5:s.p5,p50:s.p50,p95:s.p95,uniqueValues:s.uniqueValues,topValues:s.topValues}},this.notifyListeners()}notifyListeners(){for(const n of this.listeners)try{n(this.currentResult,this.isComputing)}catch(s){console.error("[BucketingService] Listener error:",s)}}isCacheHit(n){return!this.lastCacheKey||!this.currentResult?!1:this.lastCacheKey.startTs===n.startTs&&this.lastCacheKey.endTs===n.endTs&&this.lastCacheKey.mode===n.mode&&this.lastCacheKey.packetCount===n.packetCount}compute(n,s,a,r,o){if(n.length===0||!o){this.currentResult=null,this.notifyListeners();return}const i={startTs:s,endTs:a,mode:r,packetCount:n.length};this.isCacheHit(i)||(this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.computeInternal(n,s,a,r,o,i)},this.debounceMs))}computeInternal(n,s,a,r,o,i){const u=this.ensureWorker();if(!u)return;const h=n.length,x=new Float64Array(h),c=new Float64Array(h),p=new Uint16Array(h),k=new Uint8Array(h),j={spreadingFactor:o.sf,bandwidthHz:o.bw,codingRate:o.cr,preambleLength:o.preamble};for(let N=0;N{this.listeners.delete(n)}}clear(){this.currentResult=null,this.lastCacheKey=null,this.notifyListeners()}terminate(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.worker&&(this.worker.terminate(),this.worker=null),this.listeners.clear()}}const et=new en;function tn(t,n,s,a,r){const[o,i]=l.useState(()=>et.getResult());return l.useEffect(()=>et.subscribe(u=>{i(u)}),[]),l.useEffect(()=>{et.compute(t,n,s,a,r)},[t,n,s,a,r]),o}function sn({mode:t,packets:n,startTs:s,endTs:a,radioConfig:r,sortedTypes:o,aggregateShares:i,noiseFloorAnomalies:u,showNoiseFloorOverlay:h,overlayOpacity:x=.5,startLabel:c,endLabel:p,lockedYMax:k,legendMinH:j,dotSize:w,dotOpacity:N,channelGroups:b,channelToGroup:M,decodedMessages:$}){const[D,Z]=l.useState(null),[X,F]=l.useState(null),v=l.useMemo(()=>(a-s)/3600,[s,a]),y=l.useCallback(J=>{F(J)},[]),f=tn(n,s,a,t==="share"?"share":"airtime",r),[L,G]=l.useState(null),g=l.useCallback((J,P)=>{Z(J),G(P??null)},[]),_=l.useMemo(()=>{if(L===null||!f||f.count===0)return null;const J=s+L*(a-s);let P;v>=168?P=75:v>=72?P=35:v>=24?P=15:v>=3?P=10:P=5;const Q=P*60/2;return{start:J-Q,end:J+Q}},[L,f,s,a,v]),K=l.useMemo(()=>_?new Date((_.start+_.end)/2*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}):null,[_]),re=l.useMemo(()=>{if(D===null||!_)return null;const J=K??"",{start:P,end:Q}=_,ce=n.filter(q=>q.timestamp>=P&&q.timestamp({key:q.key,label:q.label,value:0,color:jt(q.typeNum)}))};const C=new Map,W=new Map;let H=0,E=0;for(const q of ce){const O=`TYPE_${q.type??q.payload_type??-1}`;if(C.set(O,(C.get(O)??0)+1),H++,r){const U=De(q,{spreadingFactor:r.sf,bandwidthHz:r.bw,codingRate:r.cr,preambleLength:r.preamble});W.set(O,(W.get(O)??0)+U),E+=U}}const z=o.map(q=>{let S;return t==="airtime"?S=E>0?(W.get(q.key)??0)/E:0:S=H>0?(C.get(q.key)??0)/H:0,{key:q.key,label:q.label,value:S,color:jt(q.typeNum)}});return{timestamp:(P+Q)/2,timeLabel:J,items:z}},[D,_,K,n,o,t,r]),te=t==="share",V=k??(f==null?void 0:f.maxValue)??(te?240:10),Y=l.useMemo(()=>{if(!te)return 5;const J=[10,20,25,50,100,200,250,500,1e3],P=V/4.5;for(const Q of J)if(Q>=P)return Q;return V>5e3?Math.ceil(P/1e3)*1e3:Math.ceil(P/100)*100},[V,te]),le=l.useMemo(()=>{const J=[];for(let P=0;P<=V;P+=Y){const Q=(1-P/V)*100;J.push({pos:Q,label:te?`${P}B`:`${P}%`})}return J},[V,Y,te]),xe=l.useMemo(()=>{var Q,ce;if(!b||b.length===0||!M||!$)return null;const J=a-s||1,P=b.map(C=>({xs:[],ys:[]}));for(const C of n){const W=C.timestamp;if(W=a||(C.type??C.payload_type)!==Re.GRP_TXT||!C.packet_hash)continue;const E=$.get(C.packet_hash),z=(ce=(Q=E==null?void 0:E.decoded)==null?void 0:Q.channelName)==null?void 0:ce.toLowerCase();if(!z)continue;const q=M.get(z);if(q===void 0)continue;const S=(W-s)/J,O=te?qe(C):.3;P[q].xs.push(S),P[q].ys.push(O)}return b.map((C,W)=>({label:C.label,color:C.color,xs:new Float32Array(P[W].xs),ys:new Float32Array(P[W].ys),count:P[W].xs.length})).filter(C=>C.count>0)},[n,b,M,$,s,a,te]);return!f||f.count===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(Ee,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:32,bottom:20},children:le.map((J,P)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${J.pos}%`,transform:P===0?"translateY(-100%)":P===le.length-1?"none":"translateY(-50%)",right:0},children:J.label},P))}),e.jsxs("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:32,right:0,top:0,bottom:20},children:[e.jsx(zt,{scatterData:f,yAxisMode:t==="share"?"share":"airtime",onHover:g,noiseFloorAnomalies:u,showNoiseFloorOverlay:h,overlayOpacity:x,highlightedType:X,timeRangeHours:v,yAxisMaxOverride:k,dotSize:w,dotOpacity:N,startTs:s,endTs:a,externalAxes:!0,channelGroupOverlays:xe}),K&&e.jsx("div",{className:"absolute top-1 right-1 px-2 py-0.5 bg-elevated/90 rounded type-data-xs text-sys-indigo pointer-events-none z-10",children:K})]}),c&&p&&e.jsxs("div",{className:"absolute left-0 right-0 bottom-0 flex justify-between pointer-events-none type-data-xs text-fg-muted/60",style:{left:32,height:20,paddingTop:4},children:[e.jsx("span",{children:c}),e.jsx("span",{children:p})]})]}),e.jsx("div",{style:{minHeight:j},children:e.jsx(ct,{sortedTypes:o,highlightedType:X,onTypeHover:y,aggregateShares:i,hoverData:re})})]})}function nn({mode:t,onChange:n}){return e.jsxs("div",{className:"toggle-group toggle-group-sm",children:[e.jsx("button",{onClick:()=>n("share"),className:`toggle-group-item ${t==="share"?"active":""}`,children:"Total"}),e.jsx("button",{onClick:()=>n("airtime"),className:`toggle-group-item ${t==="airtime"?"active":""}`,children:"Airtime"})]})}function an({smoothing:t,onChange:n}){return e.jsxs("div",{className:"toggle-group toggle-group-sm",children:[e.jsx("button",{onClick:()=>n("stats"),className:`toggle-group-item ${t==="stats"?"active":""}`,title:"Statistics view (scatter plot)",children:e.jsx(Bs,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("trend"),className:`toggle-group-item ${t==="trend"?"active":""}`,title:"Trend line chart",children:e.jsx(Tt,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("ema"),className:`toggle-group-item ${t==="ema"?"active":""}`,title:"Stacked area (moderate smoothing)",children:e.jsx(Ee,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("ultra"),className:`toggle-group-item ${t==="ultra"?"active":""}`,title:"Stacked area (heavy smoothing)",children:e.jsx(Wt,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("mosaic"),className:`toggle-group-item ${t==="mosaic"?"active":""}`,title:"Mosaic view (treemap)",children:e.jsx(Fs,{className:"w-3.5 h-3.5"})})]})}function rn({enabled:t,onChange:n,anomalyCount:s=0,showTuning:a=!1,onTuningChange:r}){return e.jsxs("div",{className:"relative inline-flex items-center gap-1",children:[t&&r&&e.jsx("button",{onClick:()=>r(!a),className:`toggle-group toggle-group-sm ${a?"active":""}`,title:a?"Hide tuning panel":"Show tuning panel",children:e.jsx("span",{className:`toggle-group-item ${a?"active":""}`,children:e.jsx(Ts,{className:"w-3.5 h-3.5"})})}),e.jsx("button",{onClick:()=>n(!t),className:`toggle-group toggle-group-sm ${t?"active":""}`,title:t?"Hide noise floor anomalies":"Show noise floor anomalies",children:e.jsx("span",{className:`toggle-group-item ${t?"active":""}`,children:e.jsx(Ps,{className:"w-3.5 h-3.5"})})}),s>0&&e.jsx("span",{className:"absolute -top-2 -right-2 min-w-[18px] h-[18px] px-1 rounded-full bg-sys-red text-white text-xs font-bold flex items-center justify-center pointer-events-none z-10",children:s>99?"99+":s})]})}function ln({enabled:t,onChange:n,channelName:s="#wardrive"}){const a=s.startsWith("#")?s:`#${s}`;return e.jsx("button",{onClick:()=>n(!t),className:`toggle-group toggle-group-sm ${t?"active":""}`,title:t?`Hide ${a} trendlines`:`Show ${a} trendlines`,children:e.jsxs("span",{className:`toggle-group-item ${t?"active":""}`,children:[e.jsx(Tt,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"ml-1 text-xs font-medium",children:a})]})})}const Dt=[{target:"PacketAnalyzer",fn:"type",minStage:1},{target:"PacketAnalyzer",fn:"airtime",minStage:1,when:ys}];ot(Dt);const Se=-100,Ge=new Map,vt=360,on=500,cn={sf:10,bw:25e4,cr:5,preamble:8},tt=32;function Nt(t,n){const s=new Date(t*1e3),a=i=>i.toString().padStart(2,"0"),r=`${a(s.getHours())}:${a(s.getMinutes())}`;return n<24?r:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][s.getMonth()]} ${s.getDate()} ${r}`}function mn(t){return t<=Se?"":At[t]??`TYPE_${t.toString(16).toUpperCase()}`}function kt(t){return Ge.get(t)??Ve(t)}function dn(t,n){const s=new Map;for(const r of t){const o=r.type??r.payload_type??-1,i=De(r,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble}),u=s.get(o)??{count:0,airtime:0};s.set(o,{count:u.count+1,airtime:u.airtime+i})}const a=[];for(const[r,o]of s)a.push({typeNum:r,key:`TYPE_${r}`,label:mn(r),totalCount:o.count,totalAirtime:o.airtime});return a.sort((r,o)=>o.totalCount-r.totalCount)}function un(t,n,s,a,r,o,i=0){const u=s-n,h=u/a,x=h*1e3,c=u/3600,p=n-i*h,k=s+i*h,j=a+2*i,w=[];for(let N=0;N=24?M.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):M.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),D={timestamp:b,time:$,counts:{},shares:{},airtimes:{},total:0,totalAirtime:0,bucketDurationMs:x};for(const Z of o)D.counts[Z.key]=0,D.airtimes[Z.key]=0;w.push(D)}for(const N of t){const b=N.timestamp;if(b=k)continue;const M=Math.min(Math.floor((b-p)/h),j-1),$=`TYPE_${N.type??N.payload_type??-1}`;w[M].counts[$]=(w[M].counts[$]??0)+1,w[M].total++;const D=De(N,{spreadingFactor:r.sf,bandwidthHz:r.bw,codingRate:r.cr,preambleLength:r.preamble});w[M].airtimes[$]=(w[M].airtimes[$]??0)+D,w[M].totalAirtime+=D}for(const N of w)for(const b of o)N.shares[b.key]=N.total>0?N.counts[b.key]/N.total*100:0;return{buckets:w,visibleStart:i,visibleEnd:i+a}}function hn(t,n){const s=t.length;if(s===0)return[];if(n<.5)return[...t];const a=Math.sqrt(12*n*n/3+1);let r=Math.floor(a);r%2===0&&r--;const o=r+2,i=(12*n*n-3*r*r-12*r-9)/(-4*r-4),u=Math.round(i),h=[u>0?r:o,u>1?r:o,u>2?r:o];let x=new Float32Array(t);const c=new Float32Array(s);for(const p of h){const k=(p-1)/2;xn(x,c,s,k);const j=x;x=c,c.set(j)}return Array.from(x)}function xn(t,n,s,a){const r=a*2+1;let o=0;for(let i=0;i<=a;i++)o+=t[Math.min(i,s-1)];for(let i=0;i=0&&(o-=t[h],i--),xnew Array(c).fill(0));for(let F=0;F0)for(let y=0;y0)for(let m=0;m0?M=w.map(F=>hn(F,N)):M=w.map(F=>pn(F,b));for(let F=0;F0){const y=1/v;for(let m=0;mvt?Math.ceil(k/vt):1,D=Math.ceil(k/$),Z=[];for(let F=0;F0){const g=1/L;for(let _=0;_=s)continue;const k=Math.min(Math.floor((p-n)/300),u-1);h[k]+=De(c,{spreadingFactor:r.sf,bandwidthHz:r.bw,codingRate:r.cr,preambleLength:r.preamble})}let x=0;for(let c=0;cx&&(x=p)}return Math.max(1,Math.ceil(x*1.1))}else{let h=0;for(const x of t){const c=x.timestamp;if(c=s)continue;const p=qe(x);p>h&&(h=p)}return h<=240?240:Math.ceil(h*1.1/50)*50}}function jn({packets:t,allPackets:n,startTs:s,endTs:a,parentStartTs:r,parentEndTs:o,bucketCount:i,radioConfig:u=cn,mode:h="share",smoothing:x="stats",noiseFloorAnomalies:c=null,showNoiseFloorOverlay:p=!1,overlayOpacity:k=.5,dotSize:j,dotOpacity:w,showChannelTrendlines:N=!1,channelGroups:b=[]}){lt(Dt);const M=Ut(),[$,D]=l.useState(null),[Z,X]=l.useState(null),F=Gt(S=>S.stableMessages),[v,y]=l.useState([]),m=l.useRef(null),f=l.useRef(0);l.useEffect(()=>{const S=Math.abs(t.length-f.current);if(S===0&&v.length>0)return;m.current&&clearTimeout(m.current);const O=S>100?50:on;return m.current=setTimeout(()=>{f.current=t.length,y(t)},O),()=>{m.current&&clearTimeout(m.current)}},[t,v.length]);const L=l.useMemo(()=>{const S=new Map;if(N){for(let O=0;O!N||b.length===0||L.size===0?v:v.map(S=>{var fe,je;if((S.type??S.payload_type)!==Re.GRP_TXT||!S.packet_hash)return S;const U=F.get(S.packet_hash),me=(je=(fe=U==null?void 0:U.decoded)==null?void 0:fe.channelName)==null?void 0:je.toLowerCase();if(!me)return S;const de=L.get(me);return de===void 0?S:{...S,type:Se-de}}),[v,N,b,L,F]),g=l.useMemo(()=>{var O;const S=dn(G,u);if(N){for(const U of S)if(U.typeNum<=Se){const me=-(U.typeNum-Se);U.label=((O=b[me])==null?void 0:O.label)??U.label}}return S},[G,u,N,b]),_=l.useMemo(()=>{if(x!=="ema"&&x!=="ultra")return 0;const O=(a-s)/i,{handleSize:U}=Et(x,O,i);return U},[x,s,a,i]),K=l.useMemo(()=>un(G,s,a,i,u,g,_),[G,s,a,i,u,g,_]),re=l.useMemo(()=>g.reduce((S,O)=>S+O.totalCount,0),[g]),te=l.useMemo(()=>g.reduce((S,O)=>S+O.totalAirtime,0),[g]),{sortedTypes:V,aggregateShares:Y}=l.useMemo(()=>{const S=new Map,O=h==="share"?re:te;if(O>0)for(const ie of g){const d=h==="share"?ie.totalCount:ie.totalAirtime;S.set(ie.key,d/O)}const U=g.filter(ie=>ie.typeNum>Se),me=g.filter(ie=>ie.typeNum<=Se),de=`TYPE_${Re.GRP_TXT}`,fe=me.reduce((ie,d)=>ie+(S.get(d.key)??0),S.get(de)??0);U.sort((ie,d)=>{const I=ie.typeNum===Re.GRP_TXT?fe:S.get(ie.key)??0;return(d.typeNum===Re.GRP_TXT?fe:S.get(d.key)??0)-I}),me.sort((ie,d)=>(S.get(d.key)??0)-(S.get(ie.key)??0));const je=U.findIndex(ie=>ie.typeNum===Re.GRP_TXT),we=je>=0?je+1:U.length;return{sortedTypes:[...U.slice(0,we),...me,...U.slice(we)],aggregateShares:S}},[g,re,te,h]),le=l.useMemo(()=>yn(K,h,V,x,s,a,i),[K,h,V,x,s,a,i]),xe=l.useCallback(S=>D(S),[]),J=l.useCallback(S=>X(S),[]),P=l.useCallback(S=>D(S),[]),Q=l.useMemo(()=>{if(Z===null||!le[Z])return null;const S=le[Z];return{timestamp:S.timestamp,timeLabel:S.time,items:V.map(O=>({key:O.key,label:O.label,value:S[O.key]??0,color:kt(O.typeNum)}))}},[Z,le,V]),ce=l.useMemo(()=>{const S=le.map(U=>U.timestamp),O=V.map(U=>({key:U.key,label:U.label,color:kt(U.typeNum),values:le.map(me=>me[U.key]??0)}));return{timestamps:S,series:O}},[le,V]),C=null,W=n&&r!==void 0&&o!==void 0&&(s!==r||a!==o),H=l.useMemo(()=>{if(!(!W||!n||r===void 0||o===void 0))return bn(n,r,o,h,u)},[W,n,r,o,h,u]);if(v.length===0)return t.length===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(Ee,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]}):null;if(x==="mosaic")return e.jsx(Zs,{sortedTypes:V,aggregateShares:Y,mode:h});const E=(a-s)/3600,z=Nt(s,E),q=Nt(a,E);return x==="stats"?e.jsx(sn,{mode:h,packets:v,startTs:s,endTs:a,radioConfig:u,sortedTypes:V,aggregateShares:Y,noiseFloorAnomalies:c,showNoiseFloorOverlay:p,overlayOpacity:k,startLabel:z,endLabel:q,lockedYMax:H,legendMinH:st,dotSize:j,dotOpacity:w,channelGroups:N?b:void 0,channelToGroup:L,decodedMessages:F}):x==="trend"?e.jsx(Js,{packets:v,mode:h,startTs:s,endTs:a,radioConfig:u,bucketCount:i,lockedYMax:H,legendMinH:st}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:tt,bottom:20},children:[0,20,40,60,80,100].map((S,O,U)=>e.jsxs("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${(1-S/100)*100}%`,transform:O===0?"translateY(-100%)":O===U.length-1?"none":"translateY(-50%)",right:0},children:[S,"%"]},S))}),e.jsx("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:tt,right:0,top:0,bottom:20},children:e.jsx(Vt,{timestamps:ce.timestamps,series:ce.series,highlightedKey:$,cursorColor:M.cursor,onHover:J,onSeriesHover:P,overlayLines:C,startTs:s,endTs:a,externalAxes:!0})}),e.jsxs("div",{className:"absolute left-0 right-0 bottom-0 flex justify-between pointer-events-none type-data-xs text-fg-muted/60",style:{left:tt,height:20,paddingTop:4},children:[e.jsx("span",{children:z}),e.jsx("span",{children:q})]})]}),e.jsx("div",{style:{minHeight:st},children:e.jsx(ct,{sortedTypes:V,highlightedType:$,onTypeHover:xe,aggregateShares:Y,hoverData:Q,overlayLines:C})})]})}const vn=l.memo(jn),nt={ZOOM_DURATION:400,BLINK_DURATION:600},he={PADDING:6,DOT_RADIUS:5,DOT_RADIUS_HOVERED:7,LOCAL_DOT_RADIUS:5,CARDINAL_FONT_SIZE:10,INTERCARDINAL_FONT_SIZE:9,LABEL_INSET:8,DATA_HEADROOM:1.08},Nn={"1x":1,"2x":2,"4x":4,"8x":8,"16x":16,"36x":36},wt=[1,5,10,25,50,100,150],kn=22.5,It=kn*Math.PI/180,St=Math.sin(It),Mt=Math.cos(It);function wn(t,n,s,a){const r=Math.PI/180,o=(a-n)*r,i=t*r,u=s*r,h=Math.sin(o)*Math.cos(u),x=Math.cos(i)*Math.sin(u)-Math.sin(i)*Math.cos(u)*Math.cos(o);return(Math.atan2(h,x)*180/Math.PI+360)%360}function Sn(t,n,s,a){const o=Math.PI/180,i=(s-t)*o,u=(a-n)*o,h=Math.sin(i/2)**2+Math.cos(t*o)*Math.cos(s*o)*Math.sin(u/2)**2;return 6371*2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h))}const Mn=[{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 Cn(t){var n;return((n=Mn.find(s=>t>=s.min))==null?void 0:n.label)??"Critical"}function Ct(t,n,s){const a=Qt(t,s);return n[a]||"#808080"}function An({neighbors:t,quickNeighbors:n,localLat:s,localLon:a,onStatsChange:r,title:o,badge:i,stats:u}){const[h,x]=l.useState(null),[c,p]=l.useState(new Set),[k,j]=l.useState({width:0,height:0}),[w,N]=l.useState("1x"),[b,M]=l.useState(1),$=l.useRef(null),D=l.useRef({}),Z=l.useRef(null),X=l.useRef(b);X.current=b;const F=qt(),v=Kt(),y=Xt(),m=Yt(),f=_t(),L=Zt(),G=m?y.primary:y.secondary,g=m?.15:.4,_=m?.08:.25,K=m?f.blue:y.primary;l.useEffect(()=>{const d=Z.current;if(!d)return;const I=new ResizeObserver(T=>{for(const B of T){const{width:se,height:ae}=B.contentRect;se>0&&ae>0&&j({width:se,height:ae})}});I.observe(d);const R=d.getBoundingClientRect();return R.width>0&&R.height>0&&j({width:R.width,height:R.height}),()=>I.disconnect()},[]);const re=l.useMemo(()=>{const d=new Set;if(n)for(const I of n)d.add(I.hash);return d},[n]),te=l.useMemo(()=>{const d=new Map;if(n)for(const I of n)d.set(I.hash,{snr:I.avgSnr,rssi:I.avgRssi});return d},[n]),{processedNeighbors:V,maxDistance:Y,totalNeighbors:le,zeroHopCount:xe}=l.useMemo(()=>{const d=[];for(const[T,B]of Object.entries(t)){if(!B.latitude||!B.longitude||B.latitude===0||B.longitude===0||!re.has(T))continue;const ae=wn(s,a,B.latitude,B.longitude),oe=Sn(s,a,B.latitude,B.longitude),ne=te.get(T);d.push({hash:T.slice(0,8),name:B.node_name||B.name||"Unknown",snr:(ne==null?void 0:ne.snr)??B.snr??null,rssi:(ne==null?void 0:ne.rssi)??B.rssi??null,bearing:ae,distance:oe,normalizedDistance:0,lastSeen:B.last_seen,isZeroHop:!0})}const R=(d.length>0?Math.max(...d.map(T=>T.distance)):0)*he.DATA_HEADROOM;return d.sort((T,B)=>(T.snr??-1/0)-(B.snr??-1/0)),{processedNeighbors:d,maxDistance:R,totalNeighbors:d.length,zeroHopCount:d.length}},[t,s,a,re,te]);l.useEffect(()=>{r==null||r({zeroHopCount:xe,totalCount:le,maxDistanceKm:Y})},[xe,le,Y]),l.useEffect(()=>{const d=Nn[w],I=X.current;$.current&&cancelAnimationFrame($.current);const R=performance.now(),T=B=>{const se=B-R,ae=Math.min(se/nt.ZOOM_DURATION,1),oe=bs(ae),ne=I+(d-I)*oe;M(ne),ae<1?$.current=requestAnimationFrame(T):$.current=null};return $.current=requestAnimationFrame(T),()=>{$.current&&cancelAnimationFrame($.current)}},[w]);const J=Y/b,P=l.useMemo(()=>wt.filter(d=>d<=J*1.1),[J]);l.useEffect(()=>{const d=[];for(const R of V){const T=D.current[R.hash];T!==void 0&&T!==R.lastSeen&&d.push(R.hash),D.current[R.hash]=R.lastSeen}if(d.length===0)return;queueMicrotask(()=>{p(R=>new Set([...R,...d]))});const I=setTimeout(()=>{p(R=>{const T=new Set(R);return d.forEach(B=>T.delete(B)),T})},nt.BLINK_DURATION);return()=>clearTimeout(I)},[V]);const Q=s!==0&&a!==0,ce=l.useMemo(()=>{const{width:d,height:I}=k,R=d/2,T=I/2,B=Math.min(d,I),se=Math.max(10,B/2-he.PADDING),ae=Math.max(10,se-he.LABEL_INSET);return{width:d,height:I,centerX:R,centerY:T,radius:ae,labelRadius:se}},[k]),{width:C,height:W,centerX:H,centerY:E,radius:z,labelRadius:q}=ce,S=l.useId(),O=l.useCallback((d,I)=>{const R=d*Math.PI/180;return{x:H+z*I*Math.sin(R),y:E-z*I*Math.cos(R)}},[H,E,z]),U=l.useCallback(d=>{const R={N:0,NE:45,E:90,SE:135,S:180,SW:225,W:270,NW:315}[d]*Math.PI/180;return{x:H+q*Math.sin(R),y:E-q*Math.cos(R)}},[H,E,q]),me=l.useCallback(d=>{x(d)},[]),de=l.useCallback(d=>{N(d)},[]),fe=l.useCallback(d=>Y<=0?0:d/Y*b,[Y,b]),je=d=>`${d}km`,we=28,Fe=l.useMemo(()=>{const d=[{x:H,y:E-q},{x:H+q*Math.SQRT1_2,y:E-q*Math.SQRT1_2}],I=P.map(T=>{const B=T/Y*b,se=H+z*B*St,ae=E-z*B*Mt;return{km:T,scale:B,lx:se,ly:ae}}).filter(T=>T.scale>=.02).sort((T,B)=>B.km-T.km),R=[];for(const T of I){const B=R.some(ae=>{const oe=ae.lx-T.lx,ne=ae.ly-T.ly;return Math.sqrt(oe*oe+ne*ne){const oe=ae.x-T.lx,ne=ae.y-T.ly;return Math.sqrt(oe*oe+ne*ne)0&&k.height>0;return Q?le===0?e.jsxs("div",{ref:Z,className:"flex flex-col items-center justify-center h-full text-fg-secondary",children:[e.jsx(Ye,{className:"w-8 h-8 mb-2 opacity-50"}),e.jsx("p",{children:"No nodes with location data"})]}):e.jsxs("div",{className:"flex h-full w-full overflow-visible",children:[e.jsxs("div",{ref:Z,className:"relative flex-1 min-w-0 h-full overflow-visible -ml-4 sm:-ml-5",children:[ie&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute depth-stroke-inset",style:{left:H-z-he.LABEL_INSET-4,top:E-z-he.LABEL_INSET-4,width:(z+he.LABEL_INSET)*2+8,height:(z+he.LABEL_INSET)*2+8,borderRadius:"50%",padding:4,boxSizing:"border-box",backgroundColor:m?"var(--zinc-925)":"var(--zinc-75)"}}),e.jsxs("svg",{width:C,height:W,className:"absolute inset-0 z-0",style:{overflow:"visible"},children:[e.jsxs("defs",{children:[e.jsx("style",{children:` + */const Hs=[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]],Bs=Oe("grip",Hs),Lt={useAbsoluteThresholds:!0,baselinePercentile:6,spikePercentile:50,baselineDbm:-107,spikeDbm:-100,mergeGapSeconds:45,minSequenceLength:16,similarityToleranceDbm:5};function Te(t,n){if(t.length===0)return 0;const s=n/100*(t.length-1),a=Math.floor(s),r=Math.ceil(s);return a===r?t[a]:t[a]+(t[r]-t[a])*(s-a)}function pt(t){if(t.length===0)return{median:0,p90:0,p95:0,p99:0,max:0,min:0};const n=[...t].sort((s,a)=>s-a);return{median:Te(n,50),p90:Te(n,90),p95:Te(n,95),p99:Te(n,99),max:n[n.length-1],min:n[0]}}function $s(t,n={}){const s={...Lt,...n};if(t.length<10)return{anomalies:[],thresholds:pt([]),totalSamples:t.length,anomalySamples:0};const a=t.map(j=>j.noise_floor_dbm),r=pt(a),o=[...a].sort((j,w)=>j-w);let i,u;s.useAbsoluteThresholds?(i=s.baselineDbm,u=s.spikeDbm):(i=Te(o,s.baselinePercentile),u=Te(o,s.spikePercentile));const h=[...t].sort((j,w)=>j.timestamp-w.timestamp),x=[];let c=null,p=0;for(const j of h)if(j.noise_floor_dbm>i&&j.noise_floor_dbm$+D,0)/c.values.length):(c.values.length>=s.minSequenceLength&&x.push(c),c={startTs:j.timestamp,endTs:j.timestamp,values:[j.noise_floor_dbm],timestamps:[j.timestamp],rollingAvg:j.noise_floor_dbm})}else c&&c.values.length>=s.minSequenceLength&&x.push(c),c=null;return c&&c.values.length>=s.minSequenceLength&&x.push(c),x.length===0?{anomalies:[],thresholds:r,totalSamples:t.length,anomalySamples:p,debug:{baselineCutoff:i,spikeCutoff:u,midBandSamples:p}}:{anomalies:x.map(j=>{const w=Math.max(...j.values),N=j.values.reduce((b,M)=>b+M,0)/j.values.length;return{startTs:j.startTs,endTs:j.endTs,peakValue:w,avgValue:N,severity:zs(N,i,u),sampleCount:j.values.length}}),thresholds:r,totalSamples:t.length,anomalySamples:p,debug:{baselineCutoff:i,spikeCutoff:u,midBandSamples:p}}}function zs(t,n,s){const a=s-n;if(a===0)return"moderate";const r=(t-n)/a;return r>.66?"critical":r>.33?"severe":"moderate"}const Ws=Object.entries(At).map(([t,n])=>{const s=parseInt(t,10);return{typeNum:s,key:`TYPE_${s}`,label:n}});function ct({sortedTypes:t,highlightedType:n,onTypeHover:s,aggregateShares:a,hoverData:r,overlayLines:o}){const i=l.useMemo(()=>{if(!r)return null;const x=new Map;for(const c of r.items)x.set(c.key,c.value);return x},[r]),u=i!==null,h=l.useMemo(()=>{const x=new Set(t.map(k=>k.key)),c=t.map(k=>({typeNum:k.typeNum,key:k.key,label:k.label})),p=Ws.filter(k=>!x.has(k.key));return[...c,...p]},[t]);return e.jsxs("div",{className:"flex-shrink-0 pt-2 sm:pt-3 mt-1 sm:mt-2 px-0 sm:pr-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mx-0 sm:ml-9 sm:mr-0 mb-1 sm:mb-1.5 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted",children:"Packet Types"}),u&&(r==null?void 0:r.timeLabel)&&e.jsx("span",{className:"text-sys-indigo tabular-nums",children:r.timeLabel})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-3 sm:gap-x-4 gap-y-1 type-data-xs mx-0 sm:ml-9 sm:mr-0",onMouseLeave:()=>s(null),children:[h.map(x=>{const c=Ve(x.typeNum),p=(i==null?void 0:i.get(x.key))??0,k=a.get(x.key)??0,j=u?p:k,w=j>1e-4,N=a.has(x.key),b=n===x.key,M=n&&!b||u&&p<=1e-4||!u&&!n&&!N;return e.jsxs("div",{className:mt("flex items-center gap-1.5 transition-opacity cursor-pointer hover:opacity-80",M&&"opacity-30"),onMouseEnter:()=>s(x.key),children:[e.jsx("div",{className:"shrink-0 w-3 h-3 rounded-xs",style:{backgroundColor:c}}),e.jsx("span",{className:"text-fg-secondary whitespace-nowrap",children:x.label}),w&&e.jsxs("span",{className:mt("tabular-nums",u?"text-fg-primary":"text-fg-muted"),children:[(j*100).toFixed(1),"%"]})]},x.key)}),o&&o.map(x=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"shrink-0 w-3 h-0.5 rounded-full",style:{backgroundColor:x.color,opacity:x.opacity??1}}),e.jsx("span",{className:"text-fg-secondary whitespace-nowrap",children:x.label})]},x.label))]})]})}const ft='ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',Us=2,Gs=3,Vs=32,qs=20,Xs=80;function gt(t,n,s,a,r){const o=t.reduce((x,c)=>x+c,0);if(o<=0||t.length===0)return[];const i=t.map((x,c)=>c).sort((x,c)=>t[c]-t[x]),u=i.map(x=>t[x]),h=new Array(t.length);return it(u,i,o,n,s,a,r,h),h}function it(t,n,s,a,r,o,i,u){if(t.length===0)return;if(t.length===1){u[n[0]]={x:a,y:r,w:o,h:i,index:n[0]};return}const h=o*i/s,x=o>=i,c=x?i:o;let p=0,k=1/0,j=0;for(let D=0;DK?F/K:K/F,v>K?v/K:K/v);if(y<=k)k=y,j=D+1,p=Z;else break}const w=c>0?p*h/c:0;let N=0;for(let D=0;D0?t[D]/p:0)*c;x?u[n[D]]={x:a,y:r+N,w,h:K,index:n[D]}:u[n[D]]={x:a+N,y:r,w:K,h:w,index:n[D]},N+=K}const b=t.slice(j),M=n.slice(j),$=s-p;x?it(b,M,$,a+w,r,o-w,i,u):it(b,M,$,a,r+w,o,i-w,u)}function yt(t,n,s,a,r,o){for(const i of n){const u=s[i.index];if(!u)continue;const h=Us*o,x=i.x*o+h/2,c=i.y*o+h/2,p=i.w*o-h,k=i.h*o-h;if(p<=0||k<=0)continue;const j=Ve(u.typeNum),w=r!==null&&r!==i.index;t.save(),t.globalAlpha=w?.4:1;const N=Gs*o;t.beginPath(),t.moveTo(x+N,c),t.lineTo(x+p-N,c),t.quadraticCurveTo(x+p,c,x+p,c+N),t.lineTo(x+p,c+k-N),t.quadraticCurveTo(x+p,c+k,x+p-N,c+k),t.lineTo(x+N,c+k),t.quadraticCurveTo(x,c+k,x,c+k-N),t.lineTo(x,c+N),t.quadraticCurveTo(x,c,x+N,c),t.closePath(),t.fillStyle=j,t.fill(),t.strokeStyle="rgba(0,0,0,0.2)",t.lineWidth=1*o,t.stroke();const b=4*o,M=i.w>36&&i.h>20,$=i.w>36&&i.h>32;if(M){const D=11*o;if($){const Z=a>0?u.size/a*100:0;t.font=`500 ${8*o}px ${ft}`,t.fillStyle="rgba(0,0,0,0.6)",t.textBaseline="alphabetic",t.textAlign="left",t.fillText(`${Z.toFixed(1)}%`,x+b,c+k-b-D)}t.font=`600 ${9*o}px ${ft}`,t.fillStyle="rgba(0,0,0,0.85)",t.textBaseline="alphabetic",t.textAlign="left",t.fillText(u.name,x+b,c+k-b)}t.restore()}}function Ks(t,n,s){for(const a of t)if(n>=a.x&&n<=a.x+a.w&&s>=a.y&&s<=a.y+a.h)return a.index;return null}function Ys({data:t,total:n,color:s,position:a,containerWidth:r,isAirtime:o}){if(!t||!a)return null;const i=(t.value/n*100).toFixed(1),u=160,c=r-a.x=6e4?`${(t/6e4).toFixed(1)}m`:t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function Zs({sortedTypes:t,aggregateShares:n,mode:s="share"}){var F,v,y;const[a,r]=l.useState(null),[o,i]=l.useState(null),[u,h]=l.useState(0),[x,c]=l.useState(null),p=l.useRef(null),k=l.useRef(null),j=l.useRef([]),w=s==="airtime",N=l.useMemo(()=>t.reduce((m,f)=>m+(w?f.totalAirtime:f.totalCount),0),[t,w]),b=l.useMemo(()=>t.map((m,f)=>({name:m.label,size:w?m.totalAirtime:m.totalCount,index:f,typeNum:m.typeNum,key:m.key})),[t,w]);l.useEffect(()=>{const m=k.current;if(!m)return;const f=m.parentElement;if(!f)return;const L=f.getBoundingClientRect(),G=L.width,g=L.height;if(G<=0||g<=0)return;const _=window.devicePixelRatio||1;m.width=Math.floor(G*_),m.height=Math.floor(g*_),m.style.width=`${G}px`,m.style.height=`${g}px`;const X=b.map(V=>V.size),re=gt(X,0,0,G,g);j.current=re;const te=m.getContext("2d");te&&(te.clearRect(0,0,m.width,m.height),yt(te,re,b,N,a,_))},[b,N,a]),l.useEffect(()=>{const m=p.current;if(!m)return;const f=new ResizeObserver(()=>{const L=k.current;if(!L)return;const G=m.getBoundingClientRect(),g=G.width,_=G.height;if(g<=0||_<=0)return;const X=window.devicePixelRatio||1;L.width=Math.floor(g*X),L.height=Math.floor(_*X),L.style.width=`${g}px`,L.style.height=`${_}px`;const re=b.map(Y=>Y.size),te=gt(re,0,0,g,_);j.current=te;const V=L.getContext("2d");V&&(V.clearRect(0,0,L.width,L.height),yt(V,te,b,N,a,X))});return f.observe(m),()=>f.disconnect()},[b,N]);const M=l.useCallback(m=>{const f=p.current;if(!f)return;const L=f.getBoundingClientRect(),G=m.clientX-L.left,g=m.clientY-L.top,_=Ks(j.current,G,g);r(_),_!==null?(h(L.width),i({x:G,y:g})):i(null)},[]),$=l.useCallback(()=>{r(null),i(null)},[]),D=l.useCallback(m=>{if(c(m),m){const f=b.findIndex(L=>L.key===m);r(f>=0?f:null)}else r(null)},[b]),Z=a!==null?{name:((F=b[a])==null?void 0:F.name)??"",value:((v=b[a])==null?void 0:v.size)??0}:null,K=a!==null?Ve((y=b[a])==null?void 0:y.typeNum):"";return t.length===0||N===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(Ee,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet type data available"})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 min-h-0 relative",children:e.jsxs("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:Vs,right:0,top:0,bottom:qs},ref:p,onMouseMove:M,onMouseLeave:$,children:[e.jsx("canvas",{ref:k,className:"absolute inset-0",style:{cursor:"default"}}),e.jsx(Ys,{data:Z,total:N,color:K,position:o,containerWidth:u,isAirtime:w})]})}),e.jsx("div",{style:{minHeight:Xs},children:e.jsx(ct,{sortedTypes:t,highlightedType:x,onTypeHover:D,aggregateShares:n})})]})}const Qe=32,Je=20,Qs=300;function _e(t){return t>=1e9?`${(t/1e9).toFixed(1)} Gb`:t>=1e6?`${(t/1e6).toFixed(1)} Mb`:t>=1e3?`${(t/1e3).toFixed(1)} Kb`:`${t.toFixed(0)} B`}function Js({packets:t,mode:n,startTs:s,endTs:a,radioConfig:r,bucketCount:o,lockedYMax:i,legendMinH:u}){const h=l.useMemo(()=>_t(),[]),x=h.blue,c=h.red,p=h.yellow,[k,j]=l.useState(null),{trendData:w,totals:N}=l.useMemo(()=>{if(t.length===0)return{trendData:[],totals:{rxBytes:0,txBytes:0,rxAirtime:0,txAirtime:0}};const v=a-s,y=Math.min(Math.ceil(v/Qs),o),m=v/y,f=[];let L=0,G=0,g=0,_=0;for(const C of t){const W=C.timestamp;if(W=a)continue;const H=qe(C),E=De(C,{spreadingFactor:r.sf,bandwidthHz:r.bw,codingRate:r.cr,preambleLength:r.preamble}),z={timestamp:W,rxAirtime:0,txAirtime:0,rxBytes:0,txBytes:0};C.transmitted?(z.txAirtime=E,z.txBytes=H,G+=H,_+=E):(z.rxAirtime=E,z.rxBytes=H,L+=H,g+=E),f.push(z)}f.sort((C,W)=>C.timestamp-W.timestamp);const X=new Float64Array(f.length+1),re=new Float64Array(f.length+1),te=new Float64Array(f.length+1),V=new Float64Array(f.length+1),Y=new Float64Array(f.length);for(let C=0;C{let W=0,H=Y.length;for(;W>>1;Y[E]0?q:null,tx:S>0?S:null})}else{const q=X[z]-X[E],S=re[z]-re[E],O=q/J*100,U=S/J*100;xe.push({timestamp:W,rx:O>0?O:null,tx:U>0?U:null})}}const P=2/31;let Q=null;return{trendData:xe.map(C=>{const W=C.rx;return W!==null&&W>0&&(Q===null?Q=W:Q=P*W+(1-P)*Q),{...C,rxSmooth:Q!==null&&Q>0?Q:null}}),totals:{rxBytes:L,txBytes:G,rxAirtime:g,txAirtime:_}}},[t,s,a,o,n,r]),b=l.useMemo(()=>{if(w.length===0)return n==="share"?100:10;let v=0;for(const m of w){const f=m.rx??0,L=m.tx??0;f>v&&(v=f),L>v&&(v=L)}const y=v*1.1;return n==="share"?y<=100?100:y<=500?Math.ceil(y/100)*100:y<=1e3?Math.ceil(y/200)*200:y<=5e3?Math.ceil(y/500)*500:y<=1e4?Math.ceil(y/1e3)*1e3:Math.ceil(y/5e3)*5e3:Math.max(1,Math.ceil(y))},[w,n]),M=i??b,$=l.useMemo(()=>{if(k!==null&&w[k]){const v=w[k],y=v.rx??0,m=v.tx??0;return n==="share"?{rx:_e(y),tx:_e(m),total:_e(y+m),isHovered:!0}:{rx:`${y.toFixed(2)}%`,tx:`${m.toFixed(2)}%`,total:`${(y+m).toFixed(2)}%`,isHovered:!0}}if(n==="share")return{rx:_e(N.rxBytes),tx:_e(N.txBytes),total:_e(N.rxBytes+N.txBytes),isHovered:!1};{let v=0,y=0,m=0;for(const G of w)(G.rx!==null||G.tx!==null)&&(v+=G.rx??0,y+=G.tx??0,m++);const f=m>0?v/m:0,L=m>0?y/m:0;return{rx:`${f.toFixed(2)}%`,tx:`${L.toFixed(2)}%`,total:`${(f+L).toFixed(2)}%`,isHovered:!1}}},[k,w,N,n]),D=l.useMemo(()=>{const v=a-s,y=v/3600;return[0,.25,.5,.75,1].map(f=>{const L=s+v*f,G=new Date(L*1e3),g=G.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),_=G.toLocaleDateString([],{weekday:"short"}),X=f===.25||f===.75;return{pct:f,label:y>=24?`${_} ${g}`:g,mobileHidden:X}})},[s,a]),Z=l.useCallback(v=>{j(v)},[]);if(w.length===0)return e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(Ee,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]});const K=l.useMemo(()=>n==="airtime"?M<=5?1:M<=10?2:M<=20?5:Math.ceil(M/5):M<=100?25:M<=500?100:M<=1e3?200:M<=5e3?1e3:M<=1e4?2e3:Math.ceil(M/5e3)*1e3,[M,n]),F=l.useMemo(()=>{const v=[];for(let y=0;y<=M;y+=K){const m=(1-y/M)*100;let f;n==="airtime"?f=`${y}%`:y>=1e6?f=`${(y/1e6).toFixed(1)}M`:y>=1e3?f=`${(y/1e3).toFixed(0)}K`:f=`${y}`,v.push({pos:m,label:f})}return v},[M,K,n]);return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:Qe,bottom:Je},children:F.map((v,y)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${v.pos}%`,transform:y===0?"translateY(-100%)":y===F.length-1?"none":"translateY(-50%)",right:0},children:v.label},y))}),e.jsx("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:Qe,right:0,top:0,bottom:Je},children:e.jsx(Bt,{data:w,yAxisMode:n==="share"?"share":"airtime",yMax:M,onHover:Z,startTs:s,endTs:a,externalAxes:!0})}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 flex items-center pointer-events-none",style:{left:Qe,height:Je,paddingTop:4},children:D.map((v,y)=>e.jsx("span",{className:`absolute type-data-xs text-fg-muted/60 tabular-nums ${v.mobileHidden?"hidden sm:inline":""}`,style:{left:`${v.pct*100}%`,transform:v.pct===0?"translateX(0)":v.pct===1?"translateX(-100%)":"translateX(-50%)"},children:v.label},y))})]}),e.jsxs("div",{className:"flex items-end justify-between pb-1",style:{minHeight:u},children:[e.jsxs("div",{className:"flex items-center gap-3 sm:gap-5 type-data-sm pl-2 sm:pl-11",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-4 sm:w-5 h-[2px] rounded-full",style:{backgroundColor:x}}),e.jsx("span",{className:"text-fg-secondary",children:"RX"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-4 sm:w-5 h-[2px] rounded-full",style:{backgroundColor:c}}),e.jsx("span",{className:"text-fg-secondary",children:"TX"})]}),e.jsxs("div",{className:"hidden sm:flex items-center gap-1.5",children:[e.jsx("div",{className:"w-5 h-[2px] rounded-full",style:{backgroundColor:p}}),e.jsx("span",{className:"text-fg-secondary",children:"Avg"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-8",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:$.rx}),e.jsx(Pe,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"RX"})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:$.tx}),e.jsx(Pe,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"TX"})]})]})]})]})}const jt=$t;class en{constructor(){ke(this,"worker",null);ke(this,"listeners",new Set);ke(this,"currentResult",null);ke(this,"isComputing",!1);ke(this,"debounceTimer",null);ke(this,"debounceMs",250);ke(this,"lastCacheKey",null)}ensureWorker(){if(this.worker)return this.worker;if(typeof window>"u")return null;try{this.worker=new Worker(new URL("/assets/bucketing.worker-D0TT0k8y.js",import.meta.url),{type:"module"}),this.worker.onmessage=n=>{this.handleWorkerMessage(n.data)},this.worker.onerror=n=>{console.error("[BucketingService] Worker error:",n),this.isComputing=!1,this.notifyListeners()}}catch(n){console.error("[BucketingService] Failed to initialize worker:",n)}return this.worker}handleWorkerMessage(n){if(this.isComputing=!1,n.type==="error"){this.currentResult=null,this.notifyListeners();return}const s=n.payload;this.currentResult={points:s.points,rawValues:s.rawValues,packetTypes:s.packetTypes,timestamps:s.timestamps,count:s.count,minTime:s.minTime,maxTime:s.maxTime,minValue:s.minValue,maxValue:s.maxValue,rawMinValue:s.rawMinValue,rawMaxValue:s.rawMaxValue,unit:"%",stats:{p5:s.p5,p50:s.p50,p95:s.p95,uniqueValues:s.uniqueValues,topValues:s.topValues}},this.notifyListeners()}notifyListeners(){for(const n of this.listeners)try{n(this.currentResult,this.isComputing)}catch(s){console.error("[BucketingService] Listener error:",s)}}isCacheHit(n){return!this.lastCacheKey||!this.currentResult?!1:this.lastCacheKey.startTs===n.startTs&&this.lastCacheKey.endTs===n.endTs&&this.lastCacheKey.mode===n.mode&&this.lastCacheKey.packetCount===n.packetCount}compute(n,s,a,r,o){if(n.length===0||!o){this.currentResult=null,this.notifyListeners();return}const i={startTs:s,endTs:a,mode:r,packetCount:n.length};this.isCacheHit(i)||(this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.computeInternal(n,s,a,r,o,i)},this.debounceMs))}computeInternal(n,s,a,r,o,i){const u=this.ensureWorker();if(!u)return;const h=n.length,x=new Float64Array(h),c=new Float64Array(h),p=new Uint16Array(h),k=new Uint8Array(h),j={spreadingFactor:o.sf,bandwidthHz:o.bw,codingRate:o.cr,preambleLength:o.preamble};for(let N=0;N{this.listeners.delete(n)}}clear(){this.currentResult=null,this.lastCacheKey=null,this.notifyListeners()}terminate(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.worker&&(this.worker.terminate(),this.worker=null),this.listeners.clear()}}const et=new en;function tn(t,n,s,a,r){const[o,i]=l.useState(()=>et.getResult());return l.useEffect(()=>et.subscribe(u=>{i(u)}),[]),l.useEffect(()=>{et.compute(t,n,s,a,r)},[t,n,s,a,r]),o}function sn({mode:t,packets:n,startTs:s,endTs:a,radioConfig:r,sortedTypes:o,aggregateShares:i,noiseFloorAnomalies:u,showNoiseFloorOverlay:h,overlayOpacity:x=.5,startLabel:c,endLabel:p,lockedYMax:k,legendMinH:j,dotSize:w,dotOpacity:N,channelGroups:b,channelToGroup:M,decodedMessages:$}){const[D,Z]=l.useState(null),[K,F]=l.useState(null),v=l.useMemo(()=>(a-s)/3600,[s,a]),y=l.useCallback(J=>{F(J)},[]),f=tn(n,s,a,t==="share"?"share":"airtime",r),[L,G]=l.useState(null),g=l.useCallback((J,P)=>{Z(J),G(P??null)},[]),_=l.useMemo(()=>{if(L===null||!f||f.count===0)return null;const J=s+L*(a-s);let P;v>=168?P=75:v>=72?P=35:v>=24?P=15:v>=3?P=10:P=5;const Q=P*60/2;return{start:J-Q,end:J+Q}},[L,f,s,a,v]),X=l.useMemo(()=>_?new Date((_.start+_.end)/2*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}):null,[_]),re=l.useMemo(()=>{if(D===null||!_)return null;const J=X??"",{start:P,end:Q}=_,ce=n.filter(q=>q.timestamp>=P&&q.timestamp({key:q.key,label:q.label,value:0,color:jt(q.typeNum)}))};const C=new Map,W=new Map;let H=0,E=0;for(const q of ce){const O=`TYPE_${q.type??q.payload_type??-1}`;if(C.set(O,(C.get(O)??0)+1),H++,r){const U=De(q,{spreadingFactor:r.sf,bandwidthHz:r.bw,codingRate:r.cr,preambleLength:r.preamble});W.set(O,(W.get(O)??0)+U),E+=U}}const z=o.map(q=>{let S;return t==="airtime"?S=E>0?(W.get(q.key)??0)/E:0:S=H>0?(C.get(q.key)??0)/H:0,{key:q.key,label:q.label,value:S,color:jt(q.typeNum)}});return{timestamp:(P+Q)/2,timeLabel:J,items:z}},[D,_,X,n,o,t,r]),te=t==="share",V=k??(f==null?void 0:f.maxValue)??(te?240:10),Y=l.useMemo(()=>{if(!te)return 5;const J=[10,20,25,50,100,200,250,500,1e3],P=V/4.5;for(const Q of J)if(Q>=P)return Q;return V>5e3?Math.ceil(P/1e3)*1e3:Math.ceil(P/100)*100},[V,te]),le=l.useMemo(()=>{const J=[];for(let P=0;P<=V;P+=Y){const Q=(1-P/V)*100;J.push({pos:Q,label:te?`${P}B`:`${P}%`})}return J},[V,Y,te]),xe=l.useMemo(()=>{var Q,ce;if(!b||b.length===0||!M||!$)return null;const J=a-s||1,P=b.map(C=>({xs:[],ys:[]}));for(const C of n){const W=C.timestamp;if(W=a||(C.type??C.payload_type)!==Re.GRP_TXT||!C.packet_hash)continue;const E=$.get(C.packet_hash),z=(ce=(Q=E==null?void 0:E.decoded)==null?void 0:Q.channelName)==null?void 0:ce.toLowerCase();if(!z)continue;const q=M.get(z);if(q===void 0)continue;const S=(W-s)/J,O=te?qe(C):.3;P[q].xs.push(S),P[q].ys.push(O)}return b.map((C,W)=>({label:C.label,color:C.color,xs:new Float32Array(P[W].xs),ys:new Float32Array(P[W].ys),count:P[W].xs.length})).filter(C=>C.count>0)},[n,b,M,$,s,a,te]);return!f||f.count===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(Ee,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:32,bottom:20},children:le.map((J,P)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${J.pos}%`,transform:P===0?"translateY(-100%)":P===le.length-1?"none":"translateY(-50%)",right:0},children:J.label},P))}),e.jsxs("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:32,right:0,top:0,bottom:20},children:[e.jsx(zt,{scatterData:f,yAxisMode:t==="share"?"share":"airtime",onHover:g,noiseFloorAnomalies:u,showNoiseFloorOverlay:h,overlayOpacity:x,highlightedType:K,timeRangeHours:v,yAxisMaxOverride:k,dotSize:w,dotOpacity:N,startTs:s,endTs:a,externalAxes:!0,channelGroupOverlays:xe}),X&&e.jsx("div",{className:"absolute top-1 right-1 px-2 py-0.5 bg-elevated/90 rounded type-data-xs text-sys-indigo pointer-events-none z-10",children:X})]}),c&&p&&e.jsxs("div",{className:"absolute left-0 right-0 bottom-0 flex justify-between pointer-events-none type-data-xs text-fg-muted/60",style:{left:32,height:20,paddingTop:4},children:[e.jsx("span",{children:c}),e.jsx("span",{children:p})]})]}),e.jsx("div",{style:{minHeight:j},children:e.jsx(ct,{sortedTypes:o,highlightedType:K,onTypeHover:y,aggregateShares:i,hoverData:re})})]})}function nn({mode:t,onChange:n}){return e.jsxs("div",{className:"toggle-group toggle-group-sm",children:[e.jsx("button",{onClick:()=>n("share"),className:`toggle-group-item ${t==="share"?"active":""}`,children:"Total"}),e.jsx("button",{onClick:()=>n("airtime"),className:`toggle-group-item ${t==="airtime"?"active":""}`,children:"Airtime"})]})}function an({smoothing:t,onChange:n}){return e.jsxs("div",{className:"toggle-group toggle-group-sm",children:[e.jsx("button",{onClick:()=>n("stats"),className:`toggle-group-item ${t==="stats"?"active":""}`,title:"Statistics view (scatter plot)",children:e.jsx(Bs,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("trend"),className:`toggle-group-item ${t==="trend"?"active":""}`,title:"Trend line chart",children:e.jsx(Tt,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("ema"),className:`toggle-group-item ${t==="ema"?"active":""}`,title:"Stacked area (moderate smoothing)",children:e.jsx(Ee,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("ultra"),className:`toggle-group-item ${t==="ultra"?"active":""}`,title:"Stacked area (heavy smoothing)",children:e.jsx(Wt,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("mosaic"),className:`toggle-group-item ${t==="mosaic"?"active":""}`,title:"Mosaic view (treemap)",children:e.jsx(Fs,{className:"w-3.5 h-3.5"})})]})}function rn({enabled:t,onChange:n,anomalyCount:s=0,showTuning:a=!1,onTuningChange:r}){return e.jsxs("div",{className:"relative inline-flex items-center gap-1",children:[t&&r&&e.jsx("button",{onClick:()=>r(!a),className:`toggle-group toggle-group-sm ${a?"active":""}`,title:a?"Hide tuning panel":"Show tuning panel",children:e.jsx("span",{className:`toggle-group-item ${a?"active":""}`,children:e.jsx(Ts,{className:"w-3.5 h-3.5"})})}),e.jsx("button",{onClick:()=>n(!t),className:`toggle-group toggle-group-sm ${t?"active":""}`,title:t?"Hide noise floor anomalies":"Show noise floor anomalies",children:e.jsx("span",{className:`toggle-group-item ${t?"active":""}`,children:e.jsx(Ps,{className:"w-3.5 h-3.5"})})}),s>0&&e.jsx("span",{className:"absolute -top-2 -right-2 min-w-[18px] h-[18px] px-1 rounded-full bg-sys-red text-white text-xs font-bold flex items-center justify-center pointer-events-none z-10",children:s>99?"99+":s})]})}function ln({enabled:t,onChange:n,channelName:s="#wardrive"}){const a=s.startsWith("#")?s:`#${s}`;return e.jsx("button",{onClick:()=>n(!t),className:`toggle-group toggle-group-sm ${t?"active":""}`,title:t?`Hide ${a} trendlines`:`Show ${a} trendlines`,children:e.jsxs("span",{className:`toggle-group-item ${t?"active":""}`,children:[e.jsx(Tt,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"ml-1 text-xs font-medium",children:a})]})})}const Dt=[{target:"PacketAnalyzer",fn:"type",minStage:1},{target:"PacketAnalyzer",fn:"airtime",minStage:1,when:ys}];ot(Dt);const Se=-100,Ge=new Map,vt=360,on=500,cn={sf:10,bw:25e4,cr:5,preamble:8},tt=32;function Nt(t,n){const s=new Date(t*1e3),a=i=>i.toString().padStart(2,"0"),r=`${a(s.getHours())}:${a(s.getMinutes())}`;return n<24?r:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][s.getMonth()]} ${s.getDate()} ${r}`}function mn(t){return t<=Se?"":At[t]??`TYPE_${t.toString(16).toUpperCase()}`}function kt(t){return Ge.get(t)??Ve(t)}function dn(t,n){const s=new Map;for(const r of t){const o=r.type??r.payload_type??-1,i=De(r,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble}),u=s.get(o)??{count:0,airtime:0};s.set(o,{count:u.count+1,airtime:u.airtime+i})}const a=[];for(const[r,o]of s)a.push({typeNum:r,key:`TYPE_${r}`,label:mn(r),totalCount:o.count,totalAirtime:o.airtime});return a.sort((r,o)=>o.totalCount-r.totalCount)}function un(t,n,s,a,r,o,i=0){const u=s-n,h=u/a,x=h*1e3,c=u/3600,p=n-i*h,k=s+i*h,j=a+2*i,w=[];for(let N=0;N=24?M.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):M.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),D={timestamp:b,time:$,counts:{},shares:{},airtimes:{},total:0,totalAirtime:0,bucketDurationMs:x};for(const Z of o)D.counts[Z.key]=0,D.airtimes[Z.key]=0;w.push(D)}for(const N of t){const b=N.timestamp;if(b=k)continue;const M=Math.min(Math.floor((b-p)/h),j-1),$=`TYPE_${N.type??N.payload_type??-1}`;w[M].counts[$]=(w[M].counts[$]??0)+1,w[M].total++;const D=De(N,{spreadingFactor:r.sf,bandwidthHz:r.bw,codingRate:r.cr,preambleLength:r.preamble});w[M].airtimes[$]=(w[M].airtimes[$]??0)+D,w[M].totalAirtime+=D}for(const N of w)for(const b of o)N.shares[b.key]=N.total>0?N.counts[b.key]/N.total*100:0;return{buckets:w,visibleStart:i,visibleEnd:i+a}}function hn(t,n){const s=t.length;if(s===0)return[];if(n<.5)return[...t];const a=Math.sqrt(12*n*n/3+1);let r=Math.floor(a);r%2===0&&r--;const o=r+2,i=(12*n*n-3*r*r-12*r-9)/(-4*r-4),u=Math.round(i),h=[u>0?r:o,u>1?r:o,u>2?r:o];let x=new Float32Array(t);const c=new Float32Array(s);for(const p of h){const k=(p-1)/2;xn(x,c,s,k);const j=x;x=c,c.set(j)}return Array.from(x)}function xn(t,n,s,a){const r=a*2+1;let o=0;for(let i=0;i<=a;i++)o+=t[Math.min(i,s-1)];for(let i=0;i=0&&(o-=t[h],i--),xnew Array(c).fill(0));for(let F=0;F0)for(let y=0;y0)for(let m=0;m0?M=w.map(F=>hn(F,N)):M=w.map(F=>pn(F,b));for(let F=0;F0){const y=1/v;for(let m=0;mvt?Math.ceil(k/vt):1,D=Math.ceil(k/$),Z=[];for(let F=0;F0){const g=1/L;for(let _=0;_=s)continue;const k=Math.min(Math.floor((p-n)/300),u-1);h[k]+=De(c,{spreadingFactor:r.sf,bandwidthHz:r.bw,codingRate:r.cr,preambleLength:r.preamble})}let x=0;for(let c=0;cx&&(x=p)}return Math.max(1,Math.ceil(x*1.1))}else{let h=0;for(const x of t){const c=x.timestamp;if(c=s)continue;const p=qe(x);p>h&&(h=p)}return h<=240?240:Math.ceil(h*1.1/50)*50}}function jn({packets:t,allPackets:n,startTs:s,endTs:a,parentStartTs:r,parentEndTs:o,bucketCount:i,radioConfig:u=cn,mode:h="share",smoothing:x="stats",noiseFloorAnomalies:c=null,showNoiseFloorOverlay:p=!1,overlayOpacity:k=.5,dotSize:j,dotOpacity:w,showChannelTrendlines:N=!1,channelGroups:b=[]}){lt(Dt);const M=Ut(),[$,D]=l.useState(null),[Z,K]=l.useState(null),F=Gt(S=>S.stableMessages),[v,y]=l.useState([]),m=l.useRef(null),f=l.useRef(0);l.useEffect(()=>{const S=Math.abs(t.length-f.current);if(S===0&&v.length>0)return;m.current&&clearTimeout(m.current);const O=S>100?50:on;return m.current=setTimeout(()=>{f.current=t.length,y(t)},O),()=>{m.current&&clearTimeout(m.current)}},[t,v.length]);const L=l.useMemo(()=>{const S=new Map;if(N){for(let O=0;O!N||b.length===0||L.size===0?v:v.map(S=>{var fe,je;if((S.type??S.payload_type)!==Re.GRP_TXT||!S.packet_hash)return S;const U=F.get(S.packet_hash),me=(je=(fe=U==null?void 0:U.decoded)==null?void 0:fe.channelName)==null?void 0:je.toLowerCase();if(!me)return S;const de=L.get(me);return de===void 0?S:{...S,type:Se-de}}),[v,N,b,L,F]),g=l.useMemo(()=>{var O;const S=dn(G,u);if(N){for(const U of S)if(U.typeNum<=Se){const me=-(U.typeNum-Se);U.label=((O=b[me])==null?void 0:O.label)??U.label}}return S},[G,u,N,b]),_=l.useMemo(()=>{if(x!=="ema"&&x!=="ultra")return 0;const O=(a-s)/i,{handleSize:U}=Et(x,O,i);return U},[x,s,a,i]),X=l.useMemo(()=>un(G,s,a,i,u,g,_),[G,s,a,i,u,g,_]),re=l.useMemo(()=>g.reduce((S,O)=>S+O.totalCount,0),[g]),te=l.useMemo(()=>g.reduce((S,O)=>S+O.totalAirtime,0),[g]),{sortedTypes:V,aggregateShares:Y}=l.useMemo(()=>{const S=new Map,O=h==="share"?re:te;if(O>0)for(const ie of g){const d=h==="share"?ie.totalCount:ie.totalAirtime;S.set(ie.key,d/O)}const U=g.filter(ie=>ie.typeNum>Se),me=g.filter(ie=>ie.typeNum<=Se),de=`TYPE_${Re.GRP_TXT}`,fe=me.reduce((ie,d)=>ie+(S.get(d.key)??0),S.get(de)??0);U.sort((ie,d)=>{const I=ie.typeNum===Re.GRP_TXT?fe:S.get(ie.key)??0;return(d.typeNum===Re.GRP_TXT?fe:S.get(d.key)??0)-I}),me.sort((ie,d)=>(S.get(d.key)??0)-(S.get(ie.key)??0));const je=U.findIndex(ie=>ie.typeNum===Re.GRP_TXT),we=je>=0?je+1:U.length;return{sortedTypes:[...U.slice(0,we),...me,...U.slice(we)],aggregateShares:S}},[g,re,te,h]),le=l.useMemo(()=>yn(X,h,V,x,s,a,i),[X,h,V,x,s,a,i]),xe=l.useCallback(S=>D(S),[]),J=l.useCallback(S=>K(S),[]),P=l.useCallback(S=>D(S),[]),Q=l.useMemo(()=>{if(Z===null||!le[Z])return null;const S=le[Z];return{timestamp:S.timestamp,timeLabel:S.time,items:V.map(O=>({key:O.key,label:O.label,value:S[O.key]??0,color:kt(O.typeNum)}))}},[Z,le,V]),ce=l.useMemo(()=>{const S=le.map(U=>U.timestamp),O=V.map(U=>({key:U.key,label:U.label,color:kt(U.typeNum),values:le.map(me=>me[U.key]??0)}));return{timestamps:S,series:O}},[le,V]),C=null,W=n&&r!==void 0&&o!==void 0&&(s!==r||a!==o),H=l.useMemo(()=>{if(!(!W||!n||r===void 0||o===void 0))return bn(n,r,o,h,u)},[W,n,r,o,h,u]);if(v.length===0)return t.length===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(Ee,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]}):null;if(x==="mosaic")return e.jsx(Zs,{sortedTypes:V,aggregateShares:Y,mode:h});const E=(a-s)/3600,z=Nt(s,E),q=Nt(a,E);return x==="stats"?e.jsx(sn,{mode:h,packets:v,startTs:s,endTs:a,radioConfig:u,sortedTypes:V,aggregateShares:Y,noiseFloorAnomalies:c,showNoiseFloorOverlay:p,overlayOpacity:k,startLabel:z,endLabel:q,lockedYMax:H,legendMinH:st,dotSize:j,dotOpacity:w,channelGroups:N?b:void 0,channelToGroup:L,decodedMessages:F}):x==="trend"?e.jsx(Js,{packets:v,mode:h,startTs:s,endTs:a,radioConfig:u,bucketCount:i,lockedYMax:H,legendMinH:st}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:tt,bottom:20},children:[0,20,40,60,80,100].map((S,O,U)=>e.jsxs("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${(1-S/100)*100}%`,transform:O===0?"translateY(-100%)":O===U.length-1?"none":"translateY(-50%)",right:0},children:[S,"%"]},S))}),e.jsx("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:tt,right:0,top:0,bottom:20},children:e.jsx(Vt,{timestamps:ce.timestamps,series:ce.series,highlightedKey:$,cursorColor:M.cursor,onHover:J,onSeriesHover:P,overlayLines:C,startTs:s,endTs:a,externalAxes:!0})}),e.jsxs("div",{className:"absolute left-0 right-0 bottom-0 flex justify-between pointer-events-none type-data-xs text-fg-muted/60",style:{left:tt,height:20,paddingTop:4},children:[e.jsx("span",{children:z}),e.jsx("span",{children:q})]})]}),e.jsx("div",{style:{minHeight:st},children:e.jsx(ct,{sortedTypes:V,highlightedType:$,onTypeHover:xe,aggregateShares:Y,hoverData:Q,overlayLines:C})})]})}const vn=l.memo(jn),nt={ZOOM_DURATION:400,BLINK_DURATION:600},he={PADDING:6,DOT_RADIUS:5,DOT_RADIUS_HOVERED:7,LOCAL_DOT_RADIUS:5,CARDINAL_FONT_SIZE:10,INTERCARDINAL_FONT_SIZE:9,LABEL_INSET:8,DATA_HEADROOM:1.08},Nn={"1x":1,"2x":2,"4x":4,"8x":8,"16x":16,"36x":36},wt=[1,5,10,25,50,100,150],kn=22.5,It=kn*Math.PI/180,St=Math.sin(It),Mt=Math.cos(It);function wn(t,n,s,a){const r=Math.PI/180,o=(a-n)*r,i=t*r,u=s*r,h=Math.sin(o)*Math.cos(u),x=Math.cos(i)*Math.sin(u)-Math.sin(i)*Math.cos(u)*Math.cos(o);return(Math.atan2(h,x)*180/Math.PI+360)%360}function Sn(t,n,s,a){const o=Math.PI/180,i=(s-t)*o,u=(a-n)*o,h=Math.sin(i/2)**2+Math.cos(t*o)*Math.cos(s*o)*Math.sin(u/2)**2;return 6371*2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h))}const Mn=[{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 Cn(t){var n;return((n=Mn.find(s=>t>=s.min))==null?void 0:n.label)??"Critical"}function Ct(t,n,s){const a=Qt(t,s);return n[a]||"#808080"}function An({neighbors:t,quickNeighbors:n,localLat:s,localLon:a,onStatsChange:r,title:o,badge:i,stats:u}){const[h,x]=l.useState(null),[c,p]=l.useState(new Set),[k,j]=l.useState({width:0,height:0}),[w,N]=l.useState("1x"),[b,M]=l.useState(1),$=l.useRef(null),D=l.useRef({}),Z=l.useRef(null),K=l.useRef(b);K.current=b;const F=qt(),v=Xt(),y=Kt(),m=Yt(),f=_t(),L=Zt(),G=m?y.primary:y.secondary,g=m?.15:.4,_=m?.08:.25,X=m?f.blue:y.primary;l.useEffect(()=>{const d=Z.current;if(!d)return;const I=new ResizeObserver(T=>{for(const B of T){const{width:se,height:ae}=B.contentRect;se>0&&ae>0&&j({width:se,height:ae})}});I.observe(d);const R=d.getBoundingClientRect();return R.width>0&&R.height>0&&j({width:R.width,height:R.height}),()=>I.disconnect()},[]);const re=l.useMemo(()=>{const d=new Set;if(n)for(const I of n)d.add(I.hash);return d},[n]),te=l.useMemo(()=>{const d=new Map;if(n)for(const I of n)d.set(I.hash,{snr:I.avgSnr,rssi:I.avgRssi});return d},[n]),{processedNeighbors:V,maxDistance:Y,totalNeighbors:le,zeroHopCount:xe}=l.useMemo(()=>{const d=[];for(const[T,B]of Object.entries(t)){if(!B.latitude||!B.longitude||B.latitude===0||B.longitude===0||!re.has(T))continue;const ae=wn(s,a,B.latitude,B.longitude),oe=Sn(s,a,B.latitude,B.longitude),ne=te.get(T);d.push({hash:T.slice(0,8),name:B.node_name||B.name||"Unknown",snr:(ne==null?void 0:ne.snr)??B.snr??null,rssi:(ne==null?void 0:ne.rssi)??B.rssi??null,bearing:ae,distance:oe,normalizedDistance:0,lastSeen:B.last_seen,isZeroHop:!0})}const R=(d.length>0?Math.max(...d.map(T=>T.distance)):0)*he.DATA_HEADROOM;return d.sort((T,B)=>(T.snr??-1/0)-(B.snr??-1/0)),{processedNeighbors:d,maxDistance:R,totalNeighbors:d.length,zeroHopCount:d.length}},[t,s,a,re,te]);l.useEffect(()=>{r==null||r({zeroHopCount:xe,totalCount:le,maxDistanceKm:Y})},[xe,le,Y]),l.useEffect(()=>{const d=Nn[w],I=K.current;$.current&&cancelAnimationFrame($.current);const R=performance.now(),T=B=>{const se=B-R,ae=Math.min(se/nt.ZOOM_DURATION,1),oe=bs(ae),ne=I+(d-I)*oe;M(ne),ae<1?$.current=requestAnimationFrame(T):$.current=null};return $.current=requestAnimationFrame(T),()=>{$.current&&cancelAnimationFrame($.current)}},[w]);const J=Y/b,P=l.useMemo(()=>wt.filter(d=>d<=J*1.1),[J]);l.useEffect(()=>{const d=[];for(const R of V){const T=D.current[R.hash];T!==void 0&&T!==R.lastSeen&&d.push(R.hash),D.current[R.hash]=R.lastSeen}if(d.length===0)return;queueMicrotask(()=>{p(R=>new Set([...R,...d]))});const I=setTimeout(()=>{p(R=>{const T=new Set(R);return d.forEach(B=>T.delete(B)),T})},nt.BLINK_DURATION);return()=>clearTimeout(I)},[V]);const Q=s!==0&&a!==0,ce=l.useMemo(()=>{const{width:d,height:I}=k,R=d/2,T=I/2,B=Math.min(d,I),se=Math.max(10,B/2-he.PADDING),ae=Math.max(10,se-he.LABEL_INSET);return{width:d,height:I,centerX:R,centerY:T,radius:ae,labelRadius:se}},[k]),{width:C,height:W,centerX:H,centerY:E,radius:z,labelRadius:q}=ce,S=l.useId(),O=l.useCallback((d,I)=>{const R=d*Math.PI/180;return{x:H+z*I*Math.sin(R),y:E-z*I*Math.cos(R)}},[H,E,z]),U=l.useCallback(d=>{const R={N:0,NE:45,E:90,SE:135,S:180,SW:225,W:270,NW:315}[d]*Math.PI/180;return{x:H+q*Math.sin(R),y:E-q*Math.cos(R)}},[H,E,q]),me=l.useCallback(d=>{x(d)},[]),de=l.useCallback(d=>{N(d)},[]),fe=l.useCallback(d=>Y<=0?0:d/Y*b,[Y,b]),je=d=>`${d}km`,we=28,Fe=l.useMemo(()=>{const d=[{x:H,y:E-q},{x:H+q*Math.SQRT1_2,y:E-q*Math.SQRT1_2}],I=P.map(T=>{const B=T/Y*b,se=H+z*B*St,ae=E-z*B*Mt;return{km:T,scale:B,lx:se,ly:ae}}).filter(T=>T.scale>=.02).sort((T,B)=>B.km-T.km),R=[];for(const T of I){const B=R.some(ae=>{const oe=ae.lx-T.lx,ne=ae.ly-T.ly;return Math.sqrt(oe*oe+ne*ne){const oe=ae.x-T.lx,ne=ae.y-T.ly;return Math.sqrt(oe*oe+ne*ne)0&&k.height>0;return Q?le===0?e.jsxs("div",{ref:Z,className:"flex flex-col items-center justify-center h-full text-fg-secondary",children:[e.jsx(Ye,{className:"w-8 h-8 mb-2 opacity-50"}),e.jsx("p",{children:"No nodes with location data"})]}):e.jsxs("div",{className:"flex h-full w-full overflow-visible",children:[e.jsxs("div",{ref:Z,className:"relative flex-1 min-w-0 h-full overflow-visible -ml-4 sm:-ml-5",children:[ie&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute depth-stroke-inset",style:{left:H-z-he.LABEL_INSET-4,top:E-z-he.LABEL_INSET-4,width:(z+he.LABEL_INSET)*2+8,height:(z+he.LABEL_INSET)*2+8,borderRadius:"50%",padding:4,boxSizing:"border-box",backgroundColor:m?"var(--zinc-925)":"var(--zinc-75)"}}),e.jsxs("svg",{width:C,height:W,className:"absolute inset-0 z-0",style:{overflow:"visible"},children:[e.jsxs("defs",{children:[e.jsx("style",{children:` @keyframes neighbor-blink-scale { 0%, 100% { transform: scale(1); @@ -38,4 +38,4 @@ var Ft=Object.defineProperty;var Ht=(t,n,s)=>n in t?Ft(t,n,{enumerable:!0,config transform-origin: center; animation: neighbor-blink-scale ${nt.BLINK_DURATION}ms ease-out forwards; } - `}),e.jsx("clipPath",{id:S,children:e.jsx("circle",{cx:H,cy:E,r:z})})]}),(()=>{const d=z+he.LABEL_INSET+12,I=m?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.15)",R=m?"rgba(59, 130, 246, 0.4)":"rgba(59, 130, 246, 0.5)",T=6,B=16,se=4,ae=[0,90,180,270],oe=[45,135,225,315];return e.jsxs("g",{className:"radar-frame","aria-hidden":"true",children:[e.jsx("circle",{cx:H,cy:E,r:d,fill:"none",stroke:I,strokeWidth:1,strokeDasharray:"2 6"}),oe.map(ne=>{const ue=ne*Math.PI/180,ge=Math.cos(ue),ye=Math.sin(ue),ve=d+se,Ne=d+se+B,He=H+ve*ye,Be=E-ve*ge,Me=H+Ne*ye,Ce=E-Ne*ge;return e.jsxs("g",{children:[e.jsx("line",{x1:He,y1:Be,x2:Me,y2:Ce,stroke:R,strokeWidth:1}),e.jsx("line",{x1:Me-4*ge,y1:Ce-4*ye,x2:Me+4*ge,y2:Ce+4*ye,stroke:R,strokeWidth:1})]},`corner-${ne}`)}),ae.map(ne=>{const ue=ne*Math.PI/180,ge=H+(d-T)*Math.sin(ue),ye=E-(d-T)*Math.cos(ue),ve=H+(d+2)*Math.sin(ue),Ne=E-(d+2)*Math.cos(ue);return e.jsx("line",{x1:ge,y1:ye,x2:ve,y2:Ne,stroke:I,strokeWidth:1},`tick-cardinal-${ne}`)}),oe.map(ne=>{const ue=ne*Math.PI/180,ge=H+(d-4)*Math.sin(ue),ye=E-(d-4)*Math.cos(ue),ve=H+(d+1)*Math.sin(ue),Ne=E-(d+1)*Math.cos(ue);return e.jsx("line",{x1:ge,y1:ye,x2:ve,y2:Ne,stroke:I,strokeWidth:1},`tick-intercardinal-${ne}`)})]})})(),(()=>{const d=z+he.LABEL_INSET+4,I=[0,...wt.map(R=>{const T=fe(R);return T<=0?0:Math.min(z*T,d)}),d];return I.slice(0,-1).map((R,T)=>{const B=I[T+1],se=B-R;return se<.5||T%2!==0?null:e.jsx("circle",{cx:H,cy:E,r:(B+R)/2,fill:"none",stroke:"var(--subtle-fill)",strokeWidth:se},`band-${T}`)})})(),P.map(d=>{const I=fe(d);if(I<.02)return null;const R=Fe.some(se=>se.km===d),T=H+z*I*St,B=E-z*I*Mt;return e.jsx("g",{children:R&&e.jsx("text",{x:T+4,y:B-2,textAnchor:"start",dominantBaseline:"auto",fill:y.secondary,fontSize:10,fontFamily:Ke,children:je(d)})},`ring-${d}`)}),["N","E","S","W"].map(d=>{const R={N:0,E:90,S:180,W:270}[d]*Math.PI/180;return e.jsx("line",{x1:H,y1:E,x2:H+z*Math.sin(R),y2:E-z*Math.cos(R),stroke:G,strokeOpacity:g,strokeWidth:1,strokeDasharray:"4 4"},d)}),["NE","SE","SW","NW"].map(d=>{const R={NE:45,SE:135,SW:225,NW:315}[d]*Math.PI/180;return e.jsx("line",{x1:H,y1:E,x2:H+z*Math.sin(R),y2:E-z*Math.cos(R),stroke:G,strokeOpacity:_,strokeWidth:1,strokeDasharray:"4 4"},`diag-${d}`)}),["N","E","S","W"].map(d=>{const I=U(d),R=d==="E"?"end":d==="W"?"start":"middle",T=d==="N"?"hanging":d==="S"?"auto":"middle";return e.jsx("text",{x:I.x,y:I.y,textAnchor:R,dominantBaseline:T,fill:K,fontSize:he.CARDINAL_FONT_SIZE,fontWeight:700,fontFamily:Ke,"aria-hidden":"true",children:d},d)}),["NE","SE","SW","NW"].map(d=>{const I=U(d),R=d==="NE"||d==="SE"?"end":"start",T=d==="NE"||d==="NW"?"hanging":"auto";return e.jsx("text",{x:I.x,y:I.y,textAnchor:R,dominantBaseline:T,fill:K,fontSize:he.INTERCARDINAL_FONT_SIZE,fontWeight:600,fontFamily:Ke,"aria-hidden":"true",children:d},d)}),e.jsx("circle",{cx:H,cy:E,r:he.LOCAL_DOT_RADIUS,fill:v.chart6,stroke:m?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.2)",strokeWidth:1,role:"img","aria-label":"Local node"}),e.jsx("g",{clipPath:`url(#${S})`,children:V.map(d=>{const I=Y>0?d.distance/Y*b:0;if(I>1)return null;const{x:R,y:T}=O(d.bearing,I),B=d.snr!==null?Ct(d.snr,F,L):"#808080",se=(h==null?void 0:h.hash)===d.hash,ae=c.has(d.hash),oe=he.DOT_RADIUS_HOVERED*1.5;return e.jsxs("g",{role:"img","aria-label":`${d.name}: ${d.distance.toFixed(1)}km ${d.bearing.toFixed(0)}°`,children:[ae&&e.jsx("circle",{cx:R,cy:T,r:oe,fill:"none",stroke:m?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.7)",strokeWidth:2,className:"neighbor-blink-ring"}),se&&e.jsx("circle",{cx:R,cy:T,r:oe,fill:B,opacity:.3}),e.jsx("circle",{cx:R,cy:T,r:se?he.DOT_RADIUS_HOVERED:he.DOT_RADIUS,fill:B,stroke:m?"rgba(0,0,0,0.5)":"rgba(0,0,0,0.25)",strokeWidth:1,style:{cursor:"pointer",transition:"r 0.15s"},onMouseEnter:()=>me(d),onMouseLeave:()=>me(null)})]},d.hash)})})]})]}),h&&e.jsxs("div",{className:"absolute bg-tooltip-bg border border-edge-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:[e.jsx("div",{className:"font-medium text-fg-primary",children:h.name}),e.jsx("div",{className:"type-data-xs text-fg-secondary",children:h.hash}),h.snr!==null?e.jsx("div",{className:"flex gap-3 mt-1 text-xs",children:e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"SNR:"})," ",e.jsxs("span",{className:"tabular-nums",style:{color:Ct(h.snr,F,L)},children:[h.snr.toFixed(1)," dB"]}),e.jsxs("span",{className:"text-fg-secondary ml-1",children:["(",Cn(h.snr),")"]})]})}):e.jsx("div",{className:"text-xs text-fg-secondary mt-1",children:"No SNR data"}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Distance:"})," ",e.jsxs("span",{className:"tabular-nums text-fg-primary",children:[h.distance.toFixed(2)," km"]})]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Bearing:"})," ",e.jsxs("span",{className:"tabular-nums text-fg-primary",children:[h.bearing.toFixed(0),"°"]})]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 px-1.5 pt-4 sm:pt-5 pb-2 flex-shrink-0 depth-raised radius-inset self-stretch",style:{width:"calc(100% / 6)"},children:[o&&e.jsxs("div",{className:"flex flex-col items-start gap-1 pb-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title",children:e.jsx(Ye,{className:"w-3.5 h-3.5"})}),i&&e.jsx(Pe,{color:"zinc",children:i})]}),e.jsx("span",{className:"type-micro text-left text-[10px] leading-tight px-1",children:o})]}),e.jsx("div",{className:"flex flex-col gap-1 flex-1",role:"group","aria-label":"Zoom level",children:["1x","2x","4x","8x","16x","36x"].map(d=>e.jsx("button",{onClick:()=>de(d),"aria-pressed":w===d,className:`flex flex-1 items-center justify-center min-w-[44px] sm:min-w-[32px] text-xs font-medium radius-inner depth-stroke-raised transition-colors ${w===d?"bg-sys-blue/20 text-sys-blue":"bg-subtle-fill/80 text-fg-secondary hover:bg-subtle-fill-strong hover:text-fg-primary"}`,children:d},d))})]})]}):e.jsxs("div",{ref:Z,className:"flex flex-col items-center justify-center h-full text-fg-secondary",children:[e.jsx(Ye,{className:"w-8 h-8 mb-2 opacity-50"}),e.jsx("p",{children:"Local node coordinates not configured"}),e.jsx("p",{className:"text-xs mt-1",children:"Set latitude/longitude in config to enable"})]})}const _n=l.memo(An),at={repeater:"var(--sys-blue)",companion:"var(--sys-cyan)",room_server:"var(--sys-indigo)"};function Rn(t){if(t.contact_type){const n=t.contact_type.toLowerCase();if(n==="repeater"||n==="rep")return"repeater";if(n==="room server"||n==="room_server"||n==="room"||n==="server")return"room_server";if(n==="companion"||n==="client"||n==="cli")return"companion"}return t.is_repeater?"repeater":"companion"}function Tn({neighbors:t,timeRangeLabel:n}){const s=l.useMemo(()=>{const a={repeater:0,companion:0,room_server:0};for(const i of Object.values(t)){const u=Rn(i);a[u]=(a[u]||0)+1}const r=Object.values(a).reduce((i,u)=>i+u,0);return{items:[{label:"Repeaters",count:a.repeater,percent:0,color:at.repeater},{label:"Companions",count:a.companion,percent:0,color:at.companion},{label:"Room Servers",count:a.room_server,percent:0,color:at.room_server}].map(i=>({...i,percent:r>0?i.count/r*100:0})).filter(i=>i.count>0).sort((i,u)=>u.count-i.count),total:r}},[t]);return s.total===0?e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted type-body-sm",children:"No neighbors discovered yet"}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex-1 flex flex-col justify-evenly",children:s.items.map(a=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-sm text-fg-secondary",children:a.label}),e.jsxs("span",{className:"type-data-sm text-fg-secondary tabular-nums",children:[a.count," ",e.jsxs("span",{className:"text-fg-secondary/60",children:["(",a.percent.toFixed(0),"%)"]})]})]}),e.jsx("div",{className:"h-2.5 bg-subtle-fill/80 overflow-hidden rounded-full depth-stroke-inset",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500 ease-out",style:{width:`${a.percent}%`,backgroundColor:a.color,minWidth:a.count>0?"4px":"0"}})})]},a.label))}),e.jsxs("div",{className:"mt-auto pt-2",children:[e.jsxs("div",{className:"data-box-label flex items-center gap-1.5",children:["Total Nodes",n&&e.jsx(Pe,{color:"zinc",children:n})]}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.total})]})]})}const Ln=l.memo(Tn);function rt({children:t,minHeight:n="100%",rootMargin:s="200px 0px",keepMounted:a=!0,className:r=""}){const o=l.useRef(null),[i,u]=l.useState(!1),[h,x]=l.useState(!1);l.useEffect(()=>{const p=o.current;if(!p)return;const k=new IntersectionObserver(([j])=>{const w=j.isIntersecting;x(w),w&&u(!0)},{rootMargin:s,threshold:0});return k.observe(p),()=>{k.disconnect()}},[s]);const c=h||a&&i;return e.jsx("div",{ref:o,className:`h-full w-full ${r}`,style:{minHeight:n},children:c?t:e.jsx("div",{className:"h-full w-full flex items-center justify-center text-fg-muted/50",children:e.jsx("div",{className:"animate-pulse text-xs",children:"Loading chart..."})})})}const Pt=[{target:"DisambiguationCard",fn:"disambiguation.collisions",minStage:2}];ot(Pt);const Dn=.9,En=.7,In=.5,Pn=10,On=25,Ue={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-sys-blue"},Fn={excellent:"bg-signal-excellent/10",good:"bg-signal-good/10",fair:"bg-signal-fair/10",poor:"bg-sys-blue/10"};function Hn(t){return t>=Dn?"excellent":t>=En?"good":t>=In?"fair":"poor"}function Bn(t){return t<=Pn?"excellent":t<=On?"good":"poor"}function $n(){lt(Pt);const t=Jt(),n=es(),[s,a]=l.useState(null),r=l.useCallback((c,p)=>{a({prefix:c,candidateHashes:p})},[]),o=l.useCallback(()=>{a(null)},[]);if(!n)return e.jsxs(be,{neomorphic:!0,children:[e.jsx(Le,{icon:e.jsx(ht,{}),title:"Prefix Conflicts"}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-fg-secondary",children:[e.jsx(ts,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"type-data-xs",children:"No topology data available"}),e.jsx("p",{className:"type-data-xs opacity-70",children:"Run deep analysis to see stats"})]})})]});const i=Hn(t.avgConfidence),u=Bn(t.collisionRate),h=i==="poor"||u==="poor"?"poor":i==="fair"||u==="fair"?"fair":i==="good"||u==="good"?"good":"excellent",x=h==="excellent"||h==="good"?xt:dt;return e.jsxs(be,{neomorphic:!0,className:"flex flex-col overflow-hidden",children:[e.jsx(Le,{icon:e.jsx(ht,{}),title:"Prefix Conflicts",badgeColor:"zinc",actions:h==="poor"?e.jsxs(Pe,{color:"red",children:[e.jsx(dt,{className:"w-3 h-3"}),"Needs Attention"]}):e.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${Fn[h]}`,children:[e.jsx(x,{className:`w-3.5 h-3.5 ${Ue[h]}`}),e.jsx("span",{className:`type-data-xs font-medium ${Ue[h]}`,children:h==="excellent"?"Excellent":h==="good"?"Good":"Fair"})]})}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-inset px-3 py-2.5 sm:py-3 cursor-help",title:"Total unique 2-character prefixes observed in packet paths.",children:[e.jsx("span",{className:"type-data-xl text-fg-primary",children:e.jsx(Ze,{value:t.totalPrefixes,priority:"low"})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Prefixes"})]}),e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-inset px-3 py-2.5 sm:py-3 cursor-help",title:"Prefixes that map to exactly one known node. No disambiguation needed.",children:[e.jsx("span",{className:"type-data-xl text-fg-primary",children:e.jsx(Ze,{value:t.unambiguousPrefixes,priority:"low"})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Unique"})]}),e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-inset px-3 py-2.5 sm:py-3 cursor-help",title:"Prefixes matching multiple known nodes. Click a prefix below to explore candidates.",children:[e.jsx("span",{className:`type-data-xl ${t.collisionPrefixes>0?"text-sys-blue":"text-fg-primary"}`,children:e.jsx(Ze,{value:t.collisionPrefixes,priority:"low"})}),e.jsx("span",{className:`type-micro mt-0.5 sm:mt-1 ${t.collisionPrefixes>0?"text-sys-blue":"text-fg-muted"}`,children:"Conflicts"})]})]}),t.highCollisionPrefixes.length>0&&e.jsxs("div",{className:"pt-3",children:[e.jsx("div",{className:"data-box-label",children:"Problem Prefixes"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 content-start",children:t.highCollisionPrefixes.map(({prefix:c,candidateCount:p,candidateHashes:k})=>e.jsxs("button",{type:"button",onClick:()=>r(c,k),className:"inline-flex items-center gap-0.5 group",title:`${p} candidates - click to explore`,children:[e.jsx(ss,{children:c}),e.jsxs("span",{className:"text-fg-muted type-data-xs group-hover:text-fg-secondary transition-colors",children:["×",p]})]},c))})]}),t.lowConfidencePrefixes.length===0&&t.collisionPrefixes===0&&e.jsx("div",{className:"flex-1 flex items-center",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xt,{className:"w-3.5 h-3.5 text-signal-excellent"}),e.jsx("span",{className:"type-data-xs text-signal-excellent",children:"All prefixes uniquely identified"})]})}),e.jsxs("div",{className:"flex gap-2 sm:gap-3 mt-auto pt-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Average confidence score across all disambiguated prefixes. Higher = more certain node identification.",children:[e.jsx("div",{className:"data-box-label",children:"Confidence"}),e.jsxs("div",{className:`data-box data-box-fill data-box-left ${Ue[i]}`,children:[(t.avgConfidence*100).toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Percentage of 2-character prefixes that match multiple known nodes. Lower is better.",children:[e.jsx("div",{className:"data-box-label",children:"Collisions"}),e.jsxs("div",{className:`data-box data-box-fill data-box-left ${Ue[u]}`,children:[t.collisionRate.toFixed(1),"%"]})]})]})]}),e.jsx(Ss,{isOpen:!!s,prefix:(s==null?void 0:s.prefix)||"",candidateHashes:(s==null?void 0:s.candidateHashes)||[],onClose:o})]})}const Ot=[{target:"PacketHealth",fn:"type",minStage:1},{target:"PacketHealth",fn:"duplicates",minStage:1}];ot(Ot);const pe=24;function zn(t,n,s,a){const r=Date.now()/1e3,o=n*60,i=r-o,u=o/pe,h=new Array(pe).fill(0),x=new Array(pe).fill(0),c=new Array(pe).fill(0),p=new Array(pe).fill(0),k=new Array(pe).fill(0),j=new Array(pe).fill(0);let w=0,N=0,b=0,M=0,$=0,D=0,Z=0;if(a&&a.length>0)for(const g of a){const _=g.timestamp;if(_r)continue;Z++;const K=Math.min(pe-1,Math.floor((_-i)/u));K>=0&&k[K]++}else if(s!=null&&s>0){Z=s;const g=s/pe;for(let _=0;_r)continue;w++;const K=Math.min(pe-1,Math.floor((_-i)/u));x[K]++,g.transmitted||g.packet_origin==="tx_forward"?(N++,h[K]++):g.is_duplicate||g.drop_reason==="Duplicate"?b++:g.drop_reason&&(M++,j[K]++),rs(g.route??g.route_type)&&($++,c[K]++),g._packetVersion===1&&(D++,p[K]++)}const X=Z,F=w+X,v=[],y=[],m=[],f=[],L=[];for(let g=0;g0?K/Y*100:0,timestamp:V}),y.push({count:Y>0?(te+re)/Y*100:0,timestamp:V}),m.push({count:Y>0?re/Y*100:0,timestamp:V}),f.push({count:_>0?c[g]/_*100:0,timestamp:V}),L.push({count:_>0?p[g]/_*100:0,timestamp:V})}const G=w-b;return{totalRx:w,uniqueRx:G,forwarded:N,duplicates:b,waste:M,efficiency:F>0?N/F*100:0,duplicateRate:F>0?b/F*100:0,wasteRate:F>0?(M+X)/F*100:0,sparkline:v,wasteSparkline:y,crcSparkline:m,transport:$,v2:D,transportSparkline:f,v2Sparkline:L}}function Wn({packets:t,rangeMinutes:n,rangeHours:s,timeRangeLabel:a,isLoaded:r=!0}){lt(Ot);const[o,i]=l.useState(null),[u,h]=l.useState(null),x=l.useCallback(async()=>{try{const k=await Rt(s);if(k.success&&k.data){i(k.data.count??k.data.history.length),h(k.data.history);return}const j=await ns(s);j.success&&j.data&&(i(j.data.count),h(null))}catch{}},[s]);l.useEffect(()=>{x()},[x]);const c=l.useMemo(()=>zn(t,n,o,u),[t,n,o,u]),p=c.totalRx>0;return e.jsx(be,{neomorphic:!0,isLoaded:r,skeletonType:"chart",children:r&&e.jsxs(e.Fragment,{children:[e.jsx(Le,{icon:e.jsx(Ms,{}),title:"Packet Health",badge:a,badgeColor:"zinc"}),e.jsx(as,{children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex gap-2 sm:gap-3 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 radius-inner depth-stroke-inset p-2 flex flex-col h-full cursor-help",title:"Total useless traffic: Software drops (e.g. empty, crypto) + Hardware CRC errors. Excludes duplicates.",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("div",{className:"data-box-label",children:"Discarded"}),e.jsx("div",{className:"data-box data-box-compact shrink-0 text-sys-indigo",children:p?`${c.wasteRate.toFixed(1)}%`:"—"})]}),e.jsx("div",{className:"flex-1 min-h-[20px] max-h-[28px] w-full",children:e.jsx(We,{data:c.wasteSparkline,width:9999,height:24,className:"w-full",color:"var(--sys-indigo)",invertScale:!0})})]}),e.jsxs("div",{className:"flex-1 min-w-0 radius-inner depth-stroke-inset p-2 flex flex-col h-full cursor-help",title:"Packets lost at the radio hardware level due to corruption or interference.",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("div",{className:"data-box-label flex items-center gap-1",children:"CRC Errors"}),e.jsx("div",{className:"data-box data-box-compact shrink-0 text-status-warning",children:o!==null?o:"—"})]}),e.jsx("div",{className:"flex-1 min-h-[20px] max-h-[28px] w-full",children:e.jsx(We,{data:c.crcSparkline,width:9999,height:24,className:"w-full",color:"var(--status-warning)",invertScale:!0})})]})]}),e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 radius-inner depth-stroke-inset p-2 flex flex-col h-full cursor-help",title:"Packets with Transport headers (reliable messaging)",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("div",{className:"data-box-label",children:"Transport"}),e.jsx("div",{className:"data-box data-box-compact shrink-0 text-sys-amber",children:p?e.jsxs(e.Fragment,{children:[e.jsx(ze,{children:c.transport}),e.jsx("span",{className:"punc-slash",children:"/"}),e.jsx(ze,{children:c.uniqueRx})]}):"—"})]}),e.jsx("div",{className:"flex-1 min-h-[20px] max-h-[28px] w-full",children:e.jsx(We,{data:c.transportSparkline,width:9999,height:24,className:"w-full",color:"var(--sys-amber)"})})]}),e.jsxs("div",{className:"flex-1 min-w-0 radius-inner depth-stroke-inset p-2 flex flex-col h-full cursor-help",title:"Packets using V2 protocol format",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("div",{className:"data-box-label",children:"V2"}),e.jsx("div",{className:"data-box data-box-compact shrink-0 text-sys-teal",children:p?e.jsxs(e.Fragment,{children:[e.jsx(ze,{children:c.v2}),e.jsx("span",{className:"punc-slash",children:"/"}),e.jsx(ze,{children:c.uniqueRx})]}):"—"})]}),e.jsx("div",{className:"flex-1 min-h-[20px] max-h-[28px] w-full",children:e.jsx(We,{data:c.v2Sparkline,width:9999,height:24,className:"w-full",color:"var(--sys-teal)"})})]})]}),e.jsxs("div",{className:"flex gap-2 sm:gap-3 mt-auto",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Redundant packets dropped because they were already received",children:[e.jsx("div",{className:"data-box-label",children:"Dupes"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:p?`${c.duplicateRate.toFixed(1)}%`:"—"})]}),e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Packets successfully retransmitted to extend the mesh",children:[e.jsx("div",{className:"data-box-label",children:"Forwarded"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:p?`${c.efficiency.toFixed(1)}%`:"—"})]})]})]})})]})})}function ja(){var I,R,T,B,se,ae,oe,ne,ue,ge,ye,ve,Ne,He,Be,Me,Ce;const t=is(),n=ls(),s=os(),a=cs(),r=ms(),o=ds(),i=t!==null&&r,u=l.useRef(!1);i&&!u.current&&(u.current=!0);const h=u.current,x=us(),c=hs(),[p,k]=l.useState([]),[j,w]=l.useState(null),[,N]=l.useState(null),[b]=l.useState(null),[M,$]=l.useState(()=>{const A=localStorage.getItem("statistics-view-mode");return A==="share"||A==="airtime"?A:"airtime"});l.useEffect(()=>{localStorage.setItem("statistics-view-mode",M)},[M]);const[D,Z]=l.useState(()=>{const A=localStorage.getItem("statistics-smoothing-mode");return["ema","ultra","mosaic","stats","trend"].includes(A)?A:"stats"});l.useEffect(()=>{localStorage.setItem("statistics-smoothing-mode",D)},[D]);const[X,F]=l.useState(!1),[v,y]=l.useState(!1),[m,f]=l.useState(Lt),[L,G]=l.useState(.5),[g,_]=l.useState(Cs),[K,re]=l.useState(.5),[te,V]=l.useState(85),[Y,le]=l.useState(()=>localStorage.getItem("statistics-channel-trendlines")==="true");l.useEffect(()=>{localStorage.setItem("statistics-channel-trendlines",Y.toString())},[Y]);const xe=[{label:"Wardrivers",channels:["wardrive","wardriving"],color:"var(--sys-red)"},{label:"Bots",channels:["volcano","meshai","bot","ai-bot","emergency","meshbud","test"],color:"#991B1B"}],J=l.useMemo(()=>({0:0,1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9})[x]??3,[x]),P=Xe[J].hours,Q=xs(P),ce=P*60,C=Xe[J],W=ut(P),H=o.isBackgroundLoading,E=l.useCallback(A=>{const $e={0:1,1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9,9:10}[A]??4;c($e)},[c]),z=l.useMemo(()=>{var ee;if(!((ee=t==null?void 0:t.config)!=null&&ee.radio))return null;const A=t.config.radio;return{sf:A.spreading_factor??10,bw:A.bandwidth??25e4,cr:A.coding_rate??5,preamble:A.preamble_length??8}},[(R=(I=t==null?void 0:t.config)==null?void 0:I.radio)==null?void 0:R.spreading_factor,(B=(T=t==null?void 0:t.config)==null?void 0:T.radio)==null?void 0:B.bandwidth,(ae=(se=t==null?void 0:t.config)==null?void 0:se.radio)==null?void 0:ae.coding_rate,(ne=(oe=t==null?void 0:t.config)==null?void 0:oe.radio)==null?void 0:ne.preamble_length]);l.useEffect(()=>{Rt(P).then(A=>{A.success&&A.data?k(A.data.history.map(ee=>ee.timestamp)):k([])})},[P]);const q=l.useMemo(()=>Q.length===0?{timestamps:[],values:[]}:{timestamps:Q.map(A=>A.timestamp),values:Q.map(A=>A.noise_floor_dbm)},[Q]),S=l.useMemo(()=>{if(Q.length<10)return{anomalies:[],debug:void 0};const A=$s(Q,m);return{anomalies:A.anomalies,debug:A.debug}},[Q,m]),O=S.anomalies,U=l.useMemo(()=>{const A=(t==null?void 0:t.neighbors)??{};return Object.fromEntries(Object.entries(A).filter(([ee])=>!n.has(ee)))},[t==null?void 0:t.neighbors,n]),me=l.useMemo(()=>{const A=Date.now()/1e3-P*3600;return Object.fromEntries(Object.entries(U).filter(([,ee])=>ee.last_seen>=A))},[U,P]),de=l.useMemo(()=>{const A=ce*60/W,ee=Math.floor(Date.now()/1e3),$e=Math.floor(ee/A)*A;return{start:$e-ce*60,end:$e}},[ce,W]),fe=g.timeStart??de.start,je=g.timeEnd??de.end,we=(je-fe)/3600,Fe=ut(we),ie=Rs(),d=l.useMemo(()=>As(a,g,ie,de),[a,g,ie,de]);return e.jsxs(Ns,{children:[e.jsx(ks,{title:"Statistics",icon:e.jsx(ps,{}),subtitle:e.jsx(vs,{}),controls:e.jsx(js,{ranges:Xe,selectedIndex:J,onSelect:E,isPending:H})}),b&&e.jsx(be,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:b})}),X&&v&&e.jsxs(be,{className:"border border-sys-indigo/30 bg-surface/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-label",children:"Anomaly Detection Tuning"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:["(",C.label,")"]})]}),e.jsx("button",{onClick:()=>f(A=>({...A,useAbsoluteThresholds:!A.useAbsoluteThresholds})),className:`type-data-xs px-2 py-1 rounded transition-colors ${m.useAbsoluteThresholds?"bg-sys-indigo/30 text-sys-indigo":"bg-elevated text-fg-muted hover:text-fg-secondary"}`,children:m.useAbsoluteThresholds?"Absolute dBm":"Percentile"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Baseline"}),e.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[((ge=(ue=S.debug)==null?void 0:ue.baselineCutoff)==null?void 0:ge.toFixed(1))??"—"," dBm"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Spike"}),e.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[((ve=(ye=S.debug)==null?void 0:ye.spikeCutoff)==null?void 0:ve.toFixed(1))??"—"," dBm"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Mid-band"}),e.jsx("span",{className:"ml-2 type-data-sm text-sys-indigo",children:((Ne=S.debug)==null?void 0:Ne.midBandSamples)??0})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Anomalies"}),e.jsx("span",{className:"ml-2 type-data-sm text-status-danger",children:O.length})]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-edge-subtle space-y-4",children:[m.useAbsoluteThresholds?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (",m.baselineDbm," dBm)"]}),e.jsx("input",{type:"range",min:"-120",max:"-60",value:m.baselineDbm,onChange:A=>f(ee=>({...ee,baselineDbm:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Spike (",m.spikeDbm," dBm)"]}),e.jsx("input",{type:"range",min:"-100",max:"-20",value:m.spikeDbm,onChange:A=>f(ee=>({...ee,spikeDbm:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",m.mergeGapSeconds,"s)"]}),e.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:m.mergeGapSeconds,onChange:A=>f(ee=>({...ee,mergeGapSeconds:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",m.minSequenceLength,")"]}),e.jsx("input",{type:"range",min:"2",max:"20",value:m.minSequenceLength,onChange:A=>f(ee=>({...ee,minSequenceLength:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",m.similarityToleranceDbm," dBm)"]}),e.jsx("input",{type:"range",min:"1",max:"15",value:m.similarityToleranceDbm,onChange:A=>f(ee=>({...ee,similarityToleranceDbm:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(L*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:L,onChange:A=>G(Number(A.target.value)),className:"w-full accent-sys-indigo"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (P",m.baselinePercentile,")"]}),e.jsx("input",{type:"range",min:"1",max:"50",value:m.baselinePercentile,onChange:A=>f(ee=>({...ee,baselinePercentile:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Spike (P",m.spikePercentile,")"]}),e.jsx("input",{type:"range",min:"50",max:"99",value:m.spikePercentile,onChange:A=>f(ee=>({...ee,spikePercentile:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",m.mergeGapSeconds,"s)"]}),e.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:m.mergeGapSeconds,onChange:A=>f(ee=>({...ee,mergeGapSeconds:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",m.minSequenceLength,")"]}),e.jsx("input",{type:"range",min:"2",max:"20",value:m.minSequenceLength,onChange:A=>f(ee=>({...ee,minSequenceLength:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",m.similarityToleranceDbm," dBm)"]}),e.jsx("input",{type:"range",min:"1",max:"15",value:m.similarityToleranceDbm,onChange:A=>f(ee=>({...ee,similarityToleranceDbm:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(L*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:L,onChange:A=>G(Number(A.target.value)),className:"w-full accent-sys-indigo"})]})]})]}),e.jsxs("div",{className:"mt-4 p-3 bg-elevated radius-inner",children:[e.jsx("div",{className:"type-micro mb-1",children:"Config output"}),e.jsxs("div",{className:"type-data-sm text-status-success",children:[m.useAbsoluteThresholds?`useAbsoluteThresholds: true, baselineDbm: ${m.baselineDbm}, spikeDbm: ${m.spikeDbm}`:`useAbsoluteThresholds: false, baselinePercentile: ${m.baselinePercentile}, spikePercentile: ${m.spikePercentile}`,", mergeGapSeconds: ",m.mergeGapSeconds,", minSequenceLength: ",m.minSequenceLength,", similarityToleranceDbm: ",m.similarityToleranceDbm]})]})]})]}),e.jsxs(ws,{ready:h,children:[e.jsx("div",{className:"sm:hidden",children:H&&e.jsx(Ae,{template:"auto",children:e.jsx(be,{className:"border border-sys-blue/30 bg-sys-blue/5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex h-3 w-3",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-sys-blue opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-sys-blue"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"type-body-sm text-fg-primary",children:["Loading ",C.label," data..."]}),o.loadProgress&&e.jsxs("p",{className:"type-data-xs text-fg-muted mt-0.5",children:[o.loadProgress.loaded.toLocaleString()," packets (",o.loadProgress.percent,"%)"]})]})]})})})}),e.jsxs(e.Fragment,{children:[e.jsx(Ae,{template:"hero-auto",children:e.jsx(be,{neomorphic:!0,skeletonType:"chart",children:h&&e.jsxs(e.Fragment,{children:[e.jsx(Le,{icon:e.jsx(Ee,{}),title:"Packet Analyzer",badge:C.label,badgeColor:"zinc",stackActionsOnMobile:!0,actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:[D==="stats"&&e.jsx(rn,{enabled:X,onChange:F,anomalyCount:O.length,showTuning:v,onTuningChange:y}),(D==="ema"||D==="ultra")&&M==="airtime"&&e.jsx(ln,{enabled:Y,onChange:le,channelName:xe.map(A=>A.label).join(" & ")}),e.jsx(an,{smoothing:D,onChange:Z}),e.jsx(nn,{mode:M,onChange:$})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(vn,{packets:d,allPackets:a,startTs:fe,endTs:je,parentStartTs:de.start,parentEndTs:de.end,bucketCount:Fe,radioConfig:z??void 0,mode:M,smoothing:D,noiseFloorAnomalies:O,showNoiseFloorOverlay:X,overlayOpacity:L,dotSize:K,dotOpacity:te/100,showChannelTrendlines:Y,channelGroups:xe})})]})})}),e.jsx(Ae,{template:"auto",className:"relative z-10",children:e.jsx(be,{neomorphic:!0,noPadding:!0,className:"overflow-visible",children:h&&e.jsx(_s,{parentStartTs:de.start,parentEndTs:de.end,neighbors:U,filter:g,onChange:_,...D==="stats"?{scatterDotSize:K,onScatterDotSizeChange:re,scatterOpacity:te,onScatterOpacityChange:V}:{}})})}),e.jsxs(Ae,{template:"panel",children:[e.jsx(Ie,{span:12,md:6,children:e.jsx(be,{neomorphic:!1,skeletonType:"chart",noPadding:h,className:"!bg-transparent !ring-0 !shadow-none !overflow-visible -mx-4 sm:mx-0 !px-0 !pr-0",children:h&&e.jsx(rt,{children:e.jsx(_n,{neighbors:me,quickNeighbors:s,localLat:((Be=(He=t==null?void 0:t.config)==null?void 0:He.repeater)==null?void 0:Be.latitude)??0,localLon:((Ce=(Me=t==null?void 0:t.config)==null?void 0:Me.repeater)==null?void 0:Ce.longitude)??0,onStatsChange:N,title:"Link Quality",badge:C.label})})})}),e.jsx(Ie,{span:12,md:6,children:e.jsx(be,{neomorphic:!0,skeletonType:"chart",children:h&&e.jsxs(e.Fragment,{children:[e.jsx(Le,{icon:e.jsx(Ls,{}),title:"Network Composition",badge:C.label,badgeColor:"zinc"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(rt,{children:e.jsx(Ln,{neighbors:me,timeRangeLabel:C.label})})})]})})})]}),e.jsxs(Ae,{template:"panel",children:[e.jsx(Ie,{span:12,md:6,children:e.jsx($n,{})}),e.jsx(Ie,{span:12,md:6,children:e.jsx(Wn,{packets:a,rangeMinutes:ce,rangeHours:P,timeRangeLabel:C.label})})]}),e.jsx(Ae,{template:"panel",children:e.jsx(Ie,{span:12,children:e.jsx(be,{neomorphic:!0,skeletonType:"chart",children:h&&e.jsxs(e.Fragment,{children:[e.jsx(Le,{icon:e.jsx(fs,{}),title:"NOISE FLOOR dBm",stackActionsOnMobile:!0,actions:j?e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["min ",e.jsx("span",{className:"data-box",children:j.min.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["avg ",e.jsx("span",{className:"data-box",children:j.avg.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["max ",e.jsx("span",{className:"data-box",children:j.max.toFixed(0)})]})]}):null}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(rt,{children:e.jsx(gs,{timestamps:q.timestamps,values:q.values,onStatsChange:w,crcTimestamps:p})})})]})})})})]})]})]})}export{ja as default}; + `}),e.jsx("clipPath",{id:S,children:e.jsx("circle",{cx:H,cy:E,r:z})})]}),(()=>{const d=z+he.LABEL_INSET+12,I=m?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.15)",R=m?"rgba(59, 130, 246, 0.4)":"rgba(59, 130, 246, 0.5)",T=6,B=16,se=4,ae=[0,90,180,270],oe=[45,135,225,315];return e.jsxs("g",{className:"radar-frame","aria-hidden":"true",children:[e.jsx("circle",{cx:H,cy:E,r:d,fill:"none",stroke:I,strokeWidth:1,strokeDasharray:"2 6"}),oe.map(ne=>{const ue=ne*Math.PI/180,ge=Math.cos(ue),ye=Math.sin(ue),ve=d+se,Ne=d+se+B,He=H+ve*ye,Be=E-ve*ge,Me=H+Ne*ye,Ce=E-Ne*ge;return e.jsxs("g",{children:[e.jsx("line",{x1:He,y1:Be,x2:Me,y2:Ce,stroke:R,strokeWidth:1}),e.jsx("line",{x1:Me-4*ge,y1:Ce-4*ye,x2:Me+4*ge,y2:Ce+4*ye,stroke:R,strokeWidth:1})]},`corner-${ne}`)}),ae.map(ne=>{const ue=ne*Math.PI/180,ge=H+(d-T)*Math.sin(ue),ye=E-(d-T)*Math.cos(ue),ve=H+(d+2)*Math.sin(ue),Ne=E-(d+2)*Math.cos(ue);return e.jsx("line",{x1:ge,y1:ye,x2:ve,y2:Ne,stroke:I,strokeWidth:1},`tick-cardinal-${ne}`)}),oe.map(ne=>{const ue=ne*Math.PI/180,ge=H+(d-4)*Math.sin(ue),ye=E-(d-4)*Math.cos(ue),ve=H+(d+1)*Math.sin(ue),Ne=E-(d+1)*Math.cos(ue);return e.jsx("line",{x1:ge,y1:ye,x2:ve,y2:Ne,stroke:I,strokeWidth:1},`tick-intercardinal-${ne}`)})]})})(),(()=>{const d=z+he.LABEL_INSET+4,I=[0,...wt.map(R=>{const T=fe(R);return T<=0?0:Math.min(z*T,d)}),d];return I.slice(0,-1).map((R,T)=>{const B=I[T+1],se=B-R;return se<.5||T%2!==0?null:e.jsx("circle",{cx:H,cy:E,r:(B+R)/2,fill:"none",stroke:"var(--subtle-fill)",strokeWidth:se},`band-${T}`)})})(),P.map(d=>{const I=fe(d);if(I<.02)return null;const R=Fe.some(se=>se.km===d),T=H+z*I*St,B=E-z*I*Mt;return e.jsx("g",{children:R&&e.jsx("text",{x:T+4,y:B-2,textAnchor:"start",dominantBaseline:"auto",fill:y.secondary,fontSize:10,fontFamily:Xe,children:je(d)})},`ring-${d}`)}),["N","E","S","W"].map(d=>{const R={N:0,E:90,S:180,W:270}[d]*Math.PI/180;return e.jsx("line",{x1:H,y1:E,x2:H+z*Math.sin(R),y2:E-z*Math.cos(R),stroke:G,strokeOpacity:g,strokeWidth:1,strokeDasharray:"4 4"},d)}),["NE","SE","SW","NW"].map(d=>{const R={NE:45,SE:135,SW:225,NW:315}[d]*Math.PI/180;return e.jsx("line",{x1:H,y1:E,x2:H+z*Math.sin(R),y2:E-z*Math.cos(R),stroke:G,strokeOpacity:_,strokeWidth:1,strokeDasharray:"4 4"},`diag-${d}`)}),["N","E","S","W"].map(d=>{const I=U(d),R=d==="E"?"end":d==="W"?"start":"middle",T=d==="N"?"hanging":d==="S"?"auto":"middle";return e.jsx("text",{x:I.x,y:I.y,textAnchor:R,dominantBaseline:T,fill:X,fontSize:he.CARDINAL_FONT_SIZE,fontWeight:700,fontFamily:Xe,"aria-hidden":"true",children:d},d)}),["NE","SE","SW","NW"].map(d=>{const I=U(d),R=d==="NE"||d==="SE"?"end":"start",T=d==="NE"||d==="NW"?"hanging":"auto";return e.jsx("text",{x:I.x,y:I.y,textAnchor:R,dominantBaseline:T,fill:X,fontSize:he.INTERCARDINAL_FONT_SIZE,fontWeight:600,fontFamily:Xe,"aria-hidden":"true",children:d},d)}),e.jsx("circle",{cx:H,cy:E,r:he.LOCAL_DOT_RADIUS,fill:v.chart6,stroke:m?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.2)",strokeWidth:1,role:"img","aria-label":"Local node"}),e.jsx("g",{clipPath:`url(#${S})`,children:V.map(d=>{const I=Y>0?d.distance/Y*b:0;if(I>1)return null;const{x:R,y:T}=O(d.bearing,I),B=d.snr!==null?Ct(d.snr,F,L):"#808080",se=(h==null?void 0:h.hash)===d.hash,ae=c.has(d.hash),oe=he.DOT_RADIUS_HOVERED*1.5;return e.jsxs("g",{role:"img","aria-label":`${d.name}: ${d.distance.toFixed(1)}km ${d.bearing.toFixed(0)}°`,children:[ae&&e.jsx("circle",{cx:R,cy:T,r:oe,fill:"none",stroke:m?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.7)",strokeWidth:2,className:"neighbor-blink-ring"}),se&&e.jsx("circle",{cx:R,cy:T,r:oe,fill:B,opacity:.3}),e.jsx("circle",{cx:R,cy:T,r:se?he.DOT_RADIUS_HOVERED:he.DOT_RADIUS,fill:B,stroke:m?"rgba(0,0,0,0.5)":"rgba(0,0,0,0.25)",strokeWidth:1,style:{cursor:"pointer",transition:"r 0.15s"},onMouseEnter:()=>me(d),onMouseLeave:()=>me(null)})]},d.hash)})})]})]}),h&&e.jsxs("div",{className:"absolute bg-tooltip-bg border border-edge-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:[e.jsx("div",{className:"font-medium text-fg-primary",children:h.name}),e.jsx("div",{className:"type-data-xs text-fg-secondary",children:h.hash}),h.snr!==null?e.jsx("div",{className:"flex gap-3 mt-1 text-xs",children:e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"SNR:"})," ",e.jsxs("span",{className:"tabular-nums",style:{color:Ct(h.snr,F,L)},children:[h.snr.toFixed(1)," dB"]}),e.jsxs("span",{className:"text-fg-secondary ml-1",children:["(",Cn(h.snr),")"]})]})}):e.jsx("div",{className:"text-xs text-fg-secondary mt-1",children:"No SNR data"}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Distance:"})," ",e.jsxs("span",{className:"tabular-nums text-fg-primary",children:[h.distance.toFixed(2)," km"]})]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Bearing:"})," ",e.jsxs("span",{className:"tabular-nums text-fg-primary",children:[h.bearing.toFixed(0),"°"]})]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 px-1.5 pt-4 sm:pt-5 pb-2 flex-shrink-0 depth-raised radius-inset self-stretch",style:{width:"calc(100% / 6)"},children:[o&&e.jsxs("div",{className:"flex flex-col items-start gap-1 pb-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title",children:e.jsx(Ye,{className:"w-3.5 h-3.5"})}),i&&e.jsx(Pe,{color:"zinc",children:i})]}),e.jsx("span",{className:"type-micro text-left text-[10px] leading-tight px-1",children:o})]}),e.jsx("div",{className:"flex flex-col gap-1 flex-1",role:"group","aria-label":"Zoom level",children:["1x","2x","4x","8x","16x","36x"].map(d=>e.jsx("button",{onClick:()=>de(d),"aria-pressed":w===d,className:`flex flex-1 items-center justify-center min-w-[44px] sm:min-w-[32px] text-xs font-medium radius-inner depth-stroke-raised transition-colors ${w===d?"bg-sys-blue/20 text-sys-blue":"bg-subtle-fill/80 text-fg-secondary hover:bg-subtle-fill-strong hover:text-fg-primary"}`,children:d},d))})]})]}):e.jsxs("div",{ref:Z,className:"flex flex-col items-center justify-center h-full text-fg-secondary",children:[e.jsx(Ye,{className:"w-8 h-8 mb-2 opacity-50"}),e.jsx("p",{children:"Local node coordinates not configured"}),e.jsx("p",{className:"text-xs mt-1",children:"Set latitude/longitude in config to enable"})]})}const _n=l.memo(An),at={repeater:"var(--sys-blue)",companion:"var(--sys-cyan)",room_server:"var(--sys-indigo)"};function Rn(t){if(t.contact_type){const n=t.contact_type.toLowerCase();if(n==="repeater"||n==="rep")return"repeater";if(n==="room server"||n==="room_server"||n==="room"||n==="server")return"room_server";if(n==="companion"||n==="client"||n==="cli")return"companion"}return t.is_repeater?"repeater":"companion"}function Tn({neighbors:t,timeRangeLabel:n}){const s=l.useMemo(()=>{const a={repeater:0,companion:0,room_server:0};for(const i of Object.values(t)){const u=Rn(i);a[u]=(a[u]||0)+1}const r=Object.values(a).reduce((i,u)=>i+u,0);return{items:[{label:"Repeaters",count:a.repeater,percent:0,color:at.repeater},{label:"Companions",count:a.companion,percent:0,color:at.companion},{label:"Room Servers",count:a.room_server,percent:0,color:at.room_server}].map(i=>({...i,percent:r>0?i.count/r*100:0})).filter(i=>i.count>0).sort((i,u)=>u.count-i.count),total:r}},[t]);return s.total===0?e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted type-body-sm",children:"No neighbors discovered yet"}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex-1 flex flex-col justify-evenly",children:s.items.map(a=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-sm text-fg-secondary",children:a.label}),e.jsxs("span",{className:"type-data-sm text-fg-secondary tabular-nums",children:[a.count," ",e.jsxs("span",{className:"text-fg-secondary/60",children:["(",a.percent.toFixed(0),"%)"]})]})]}),e.jsx("div",{className:"h-2.5 bg-subtle-fill/80 overflow-hidden rounded-full depth-stroke-inset",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500 ease-out",style:{width:`${a.percent}%`,backgroundColor:a.color,minWidth:a.count>0?"4px":"0"}})})]},a.label))}),e.jsxs("div",{className:"mt-auto pt-2",children:[e.jsxs("div",{className:"data-box-label flex items-center gap-1.5",children:["Total Nodes",n&&e.jsx(Pe,{color:"zinc",children:n})]}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.total})]})]})}const Ln=l.memo(Tn);function rt({children:t,minHeight:n="100%",rootMargin:s="200px 0px",keepMounted:a=!0,className:r=""}){const o=l.useRef(null),[i,u]=l.useState(!1),[h,x]=l.useState(!1);l.useEffect(()=>{const p=o.current;if(!p)return;const k=new IntersectionObserver(([j])=>{const w=j.isIntersecting;x(w),w&&u(!0)},{rootMargin:s,threshold:0});return k.observe(p),()=>{k.disconnect()}},[s]);const c=h||a&&i;return e.jsx("div",{ref:o,className:`h-full w-full ${r}`,style:{minHeight:n},children:c?t:e.jsx("div",{className:"h-full w-full flex items-center justify-center text-fg-muted/50",children:e.jsx("div",{className:"animate-pulse text-xs",children:"Loading chart..."})})})}const Pt=[{target:"DisambiguationCard",fn:"disambiguation.collisions",minStage:2}];ot(Pt);const Dn=.9,En=.7,In=.5,Pn=10,On=25,Ue={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-sys-blue"},Fn={excellent:"bg-signal-excellent/10",good:"bg-signal-good/10",fair:"bg-signal-fair/10",poor:"bg-sys-blue/10"};function Hn(t){return t>=Dn?"excellent":t>=En?"good":t>=In?"fair":"poor"}function Bn(t){return t<=Pn?"excellent":t<=On?"good":"poor"}function $n(){lt(Pt);const t=Jt(),n=es(),[s,a]=l.useState(null),r=l.useCallback((c,p)=>{a({prefix:c,candidateHashes:p})},[]),o=l.useCallback(()=>{a(null)},[]);if(!n)return e.jsxs(be,{neomorphic:!0,children:[e.jsx(Le,{icon:e.jsx(ht,{}),title:"Prefix Conflicts"}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-fg-secondary",children:[e.jsx(ts,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"type-data-xs",children:"No topology data available"}),e.jsx("p",{className:"type-data-xs opacity-70",children:"Run deep analysis to see stats"})]})})]});const i=Hn(t.avgConfidence),u=Bn(t.collisionRate),h=i==="poor"||u==="poor"?"poor":i==="fair"||u==="fair"?"fair":i==="good"||u==="good"?"good":"excellent",x=h==="excellent"||h==="good"?xt:dt;return e.jsxs(be,{neomorphic:!0,className:"flex flex-col overflow-hidden",children:[e.jsx(Le,{icon:e.jsx(ht,{}),title:"Prefix Conflicts",badgeColor:"zinc",actions:h==="poor"?e.jsxs(Pe,{color:"red",children:[e.jsx(dt,{className:"w-3 h-3"}),"Needs Attention"]}):e.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${Fn[h]}`,children:[e.jsx(x,{className:`w-3.5 h-3.5 ${Ue[h]}`}),e.jsx("span",{className:`type-data-xs font-medium ${Ue[h]}`,children:h==="excellent"?"Excellent":h==="good"?"Good":"Fair"})]})}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-inset px-3 py-2.5 sm:py-3 cursor-help",title:"Total unique 2-character prefixes observed in packet paths.",children:[e.jsx("span",{className:"type-data-xl text-fg-primary",children:e.jsx(Ze,{value:t.totalPrefixes,priority:"low"})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Prefixes"})]}),e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-inset px-3 py-2.5 sm:py-3 cursor-help",title:"Prefixes that map to exactly one known node. No disambiguation needed.",children:[e.jsx("span",{className:"type-data-xl text-fg-primary",children:e.jsx(Ze,{value:t.unambiguousPrefixes,priority:"low"})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Unique"})]}),e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-inset px-3 py-2.5 sm:py-3 cursor-help",title:"Prefixes matching multiple known nodes. Click a prefix below to explore candidates.",children:[e.jsx("span",{className:`type-data-xl ${t.collisionPrefixes>0?"text-sys-blue":"text-fg-primary"}`,children:e.jsx(Ze,{value:t.collisionPrefixes,priority:"low"})}),e.jsx("span",{className:`type-micro mt-0.5 sm:mt-1 ${t.collisionPrefixes>0?"text-sys-blue":"text-fg-muted"}`,children:"Conflicts"})]})]}),t.highCollisionPrefixes.length>0&&e.jsxs("div",{className:"pt-3",children:[e.jsx("div",{className:"data-box-label",children:"Problem Prefixes"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 content-start",children:t.highCollisionPrefixes.map(({prefix:c,candidateCount:p,candidateHashes:k})=>e.jsxs("button",{type:"button",onClick:()=>r(c,k),className:"inline-flex items-center gap-0.5 group",title:`${p} candidates - click to explore`,children:[e.jsx(ss,{children:c}),e.jsxs("span",{className:"text-fg-muted type-data-xs group-hover:text-fg-secondary transition-colors",children:["×",p]})]},c))})]}),t.lowConfidencePrefixes.length===0&&t.collisionPrefixes===0&&e.jsx("div",{className:"flex-1 flex items-center",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xt,{className:"w-3.5 h-3.5 text-signal-excellent"}),e.jsx("span",{className:"type-data-xs text-signal-excellent",children:"All prefixes uniquely identified"})]})}),e.jsxs("div",{className:"flex gap-2 sm:gap-3 mt-auto pt-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Average confidence score across all disambiguated prefixes. Higher = more certain node identification.",children:[e.jsx("div",{className:"data-box-label",children:"Confidence"}),e.jsxs("div",{className:`data-box data-box-fill data-box-left ${Ue[i]}`,children:[(t.avgConfidence*100).toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Percentage of 2-character prefixes that match multiple known nodes. Lower is better.",children:[e.jsx("div",{className:"data-box-label",children:"Collisions"}),e.jsxs("div",{className:`data-box data-box-fill data-box-left ${Ue[u]}`,children:[t.collisionRate.toFixed(1),"%"]})]})]})]}),e.jsx(Ss,{isOpen:!!s,prefix:(s==null?void 0:s.prefix)||"",candidateHashes:(s==null?void 0:s.candidateHashes)||[],onClose:o})]})}const Ot=[{target:"PacketHealth",fn:"type",minStage:1},{target:"PacketHealth",fn:"duplicates",minStage:1}];ot(Ot);const pe=24;function zn(t,n,s,a){const r=Date.now()/1e3,o=n*60,i=r-o,u=o/pe,h=new Array(pe).fill(0),x=new Array(pe).fill(0),c=new Array(pe).fill(0),p=new Array(pe).fill(0),k=new Array(pe).fill(0),j=new Array(pe).fill(0);let w=0,N=0,b=0,M=0,$=0,D=0,Z=0;if(a&&a.length>0)for(const g of a){const _=g.timestamp;if(_r)continue;Z++;const X=Math.min(pe-1,Math.floor((_-i)/u));X>=0&&k[X]++}else if(s!=null&&s>0){Z=s;const g=s/pe;for(let _=0;_r)continue;w++;const X=Math.min(pe-1,Math.floor((_-i)/u));x[X]++,g.transmitted||g.packet_origin==="tx_forward"?(N++,h[X]++):g.is_duplicate||g.drop_reason==="Duplicate"?b++:g.drop_reason&&(M++,j[X]++),rs(g.route??g.route_type)&&($++,c[X]++),g._packetVersion===1&&(D++,p[X]++)}const K=Z,F=w+K,v=[],y=[],m=[],f=[],L=[];for(let g=0;g0?X/Y*100:0,timestamp:V}),y.push({count:Y>0?(te+re)/Y*100:0,timestamp:V}),m.push({count:Y>0?re/Y*100:0,timestamp:V}),f.push({count:_>0?c[g]/_*100:0,timestamp:V}),L.push({count:_>0?p[g]/_*100:0,timestamp:V})}const G=w-b;return{totalRx:w,uniqueRx:G,forwarded:N,duplicates:b,waste:M,efficiency:F>0?N/F*100:0,duplicateRate:F>0?b/F*100:0,wasteRate:F>0?(M+K)/F*100:0,sparkline:v,wasteSparkline:y,crcSparkline:m,transport:$,v2:D,transportSparkline:f,v2Sparkline:L}}function Wn({packets:t,rangeMinutes:n,rangeHours:s,timeRangeLabel:a,isLoaded:r=!0}){lt(Ot);const[o,i]=l.useState(null),[u,h]=l.useState(null),x=l.useCallback(async()=>{try{const k=await Rt(s);if(k.success&&k.data){i(k.data.count??k.data.history.length),h(k.data.history);return}const j=await ns(s);j.success&&j.data&&(i(j.data.count),h(null))}catch{}},[s]);l.useEffect(()=>{x()},[x]);const c=l.useMemo(()=>zn(t,n,o,u),[t,n,o,u]),p=c.totalRx>0;return e.jsx(be,{neomorphic:!0,isLoaded:r,skeletonType:"chart",children:r&&e.jsxs(e.Fragment,{children:[e.jsx(Le,{icon:e.jsx(Ms,{}),title:"Packet Health",badge:a,badgeColor:"zinc"}),e.jsx(as,{children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex gap-2 sm:gap-3 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 radius-inner depth-stroke-inset p-2 flex flex-col h-full cursor-help",title:"Total useless traffic: Software drops (e.g. empty, crypto) + Hardware CRC errors. Excludes duplicates.",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("div",{className:"data-box-label",children:"Discarded"}),e.jsx("div",{className:"data-box data-box-compact shrink-0 text-sys-indigo",children:p?`${c.wasteRate.toFixed(1)}%`:"—"})]}),e.jsx("div",{className:"flex-1 min-h-[20px] max-h-[28px] w-full",children:e.jsx(We,{data:c.wasteSparkline,width:9999,height:24,className:"w-full",color:"var(--sys-indigo)",invertScale:!0})})]}),e.jsxs("div",{className:"flex-1 min-w-0 radius-inner depth-stroke-inset p-2 flex flex-col h-full cursor-help",title:"Packets lost at the radio hardware level due to corruption or interference.",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("div",{className:"data-box-label flex items-center gap-1",children:"CRC Errors"}),e.jsx("div",{className:"data-box data-box-compact shrink-0 text-status-warning",children:o!==null?o:"—"})]}),e.jsx("div",{className:"flex-1 min-h-[20px] max-h-[28px] w-full",children:e.jsx(We,{data:c.crcSparkline,width:9999,height:24,className:"w-full",color:"var(--status-warning)",invertScale:!0})})]})]}),e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 radius-inner depth-stroke-inset p-2 flex flex-col h-full cursor-help",title:"Packets with Transport headers (reliable messaging)",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("div",{className:"data-box-label",children:"Transport"}),e.jsx("div",{className:"data-box data-box-compact shrink-0 text-sys-amber",children:p?e.jsxs(e.Fragment,{children:[e.jsx(ze,{children:c.transport}),e.jsx("span",{className:"punc-slash",children:"/"}),e.jsx(ze,{children:c.uniqueRx})]}):"—"})]}),e.jsx("div",{className:"flex-1 min-h-[20px] max-h-[28px] w-full",children:e.jsx(We,{data:c.transportSparkline,width:9999,height:24,className:"w-full",color:"var(--sys-amber)"})})]}),e.jsxs("div",{className:"flex-1 min-w-0 radius-inner depth-stroke-inset p-2 flex flex-col h-full cursor-help",title:"Packets using V2 protocol format",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("div",{className:"data-box-label",children:"V2"}),e.jsx("div",{className:"data-box data-box-compact shrink-0 text-sys-teal",children:p?e.jsxs(e.Fragment,{children:[e.jsx(ze,{children:c.v2}),e.jsx("span",{className:"punc-slash",children:"/"}),e.jsx(ze,{children:c.uniqueRx})]}):"—"})]}),e.jsx("div",{className:"flex-1 min-h-[20px] max-h-[28px] w-full",children:e.jsx(We,{data:c.v2Sparkline,width:9999,height:24,className:"w-full",color:"var(--sys-teal)"})})]})]}),e.jsxs("div",{className:"flex gap-2 sm:gap-3 mt-auto",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Redundant packets dropped because they were already received",children:[e.jsx("div",{className:"data-box-label",children:"Dupes"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:p?`${c.duplicateRate.toFixed(1)}%`:"—"})]}),e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Packets successfully retransmitted to extend the mesh",children:[e.jsx("div",{className:"data-box-label",children:"Forwarded"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:p?`${c.efficiency.toFixed(1)}%`:"—"})]})]})]})})]})})}function ja(){var I,R,T,B,se,ae,oe,ne,ue,ge,ye,ve,Ne,He,Be,Me,Ce;const t=is(),n=ls(),s=os(),a=cs(),r=ms(),o=ds(),i=t!==null&&r,u=l.useRef(!1);i&&!u.current&&(u.current=!0);const h=u.current,x=us(),c=hs(),[p,k]=l.useState([]),[j,w]=l.useState(null),[,N]=l.useState(null),[b]=l.useState(null),[M,$]=l.useState(()=>{const A=localStorage.getItem("statistics-view-mode");return A==="share"||A==="airtime"?A:"airtime"});l.useEffect(()=>{localStorage.setItem("statistics-view-mode",M)},[M]);const[D,Z]=l.useState(()=>{const A=localStorage.getItem("statistics-smoothing-mode");return["ema","ultra","mosaic","stats","trend"].includes(A)?A:"stats"});l.useEffect(()=>{localStorage.setItem("statistics-smoothing-mode",D)},[D]);const[K,F]=l.useState(!1),[v,y]=l.useState(!1),[m,f]=l.useState(Lt),[L,G]=l.useState(.5),[g,_]=l.useState(Cs),[X,re]=l.useState(.5),[te,V]=l.useState(85),[Y,le]=l.useState(()=>localStorage.getItem("statistics-channel-trendlines")==="true");l.useEffect(()=>{localStorage.setItem("statistics-channel-trendlines",Y.toString())},[Y]);const xe=[{label:"Wardrivers",channels:["wardrive","wardriving"],color:"var(--sys-red)"},{label:"Bots",channels:["volcano","meshai","bot","ai-bot","emergency","meshbud","test"],color:"#991B1B"}],J=l.useMemo(()=>({0:0,1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9})[x]??3,[x]),P=Ke[J].hours,Q=xs(P),ce=P*60,C=Ke[J],W=ut(P),H=o.isBackgroundLoading,E=l.useCallback(A=>{const $e={0:1,1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9,9:10}[A]??4;c($e)},[c]),z=l.useMemo(()=>{var ee;if(!((ee=t==null?void 0:t.config)!=null&&ee.radio))return null;const A=t.config.radio;return{sf:A.spreading_factor??10,bw:A.bandwidth??25e4,cr:A.coding_rate??5,preamble:A.preamble_length??8}},[(R=(I=t==null?void 0:t.config)==null?void 0:I.radio)==null?void 0:R.spreading_factor,(B=(T=t==null?void 0:t.config)==null?void 0:T.radio)==null?void 0:B.bandwidth,(ae=(se=t==null?void 0:t.config)==null?void 0:se.radio)==null?void 0:ae.coding_rate,(ne=(oe=t==null?void 0:t.config)==null?void 0:oe.radio)==null?void 0:ne.preamble_length]);l.useEffect(()=>{Rt(P).then(A=>{A.success&&A.data?k(A.data.history.map(ee=>ee.timestamp)):k([])})},[P]);const q=l.useMemo(()=>Q.length===0?{timestamps:[],values:[]}:{timestamps:Q.map(A=>A.timestamp),values:Q.map(A=>A.noise_floor_dbm)},[Q]),S=l.useMemo(()=>{if(Q.length<10)return{anomalies:[],debug:void 0};const A=$s(Q,m);return{anomalies:A.anomalies,debug:A.debug}},[Q,m]),O=S.anomalies,U=l.useMemo(()=>{const A=(t==null?void 0:t.neighbors)??{};return Object.fromEntries(Object.entries(A).filter(([ee])=>!n.has(ee)))},[t==null?void 0:t.neighbors,n]),me=l.useMemo(()=>{const A=Date.now()/1e3-P*3600;return Object.fromEntries(Object.entries(U).filter(([,ee])=>ee.last_seen>=A))},[U,P]),de=l.useMemo(()=>{const A=ce*60/W,ee=Math.floor(Date.now()/1e3),$e=Math.floor(ee/A)*A;return{start:$e-ce*60,end:$e}},[ce,W]),fe=g.timeStart??de.start,je=g.timeEnd??de.end,we=(je-fe)/3600,Fe=ut(we),ie=Rs(),d=l.useMemo(()=>As(a,g,ie,de),[a,g,ie,de]);return e.jsxs(Ns,{children:[e.jsx(ks,{title:"Statistics",icon:e.jsx(ps,{}),subtitle:e.jsx(vs,{}),controls:e.jsx(js,{ranges:Ke,selectedIndex:J,onSelect:E,isPending:H})}),b&&e.jsx(be,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:b})}),K&&v&&e.jsxs(be,{className:"border border-sys-indigo/30 bg-surface/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-label",children:"Anomaly Detection Tuning"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:["(",C.label,")"]})]}),e.jsx("button",{onClick:()=>f(A=>({...A,useAbsoluteThresholds:!A.useAbsoluteThresholds})),className:`type-data-xs px-2 py-1 rounded transition-colors ${m.useAbsoluteThresholds?"bg-sys-indigo/30 text-sys-indigo":"bg-elevated text-fg-muted hover:text-fg-secondary"}`,children:m.useAbsoluteThresholds?"Absolute dBm":"Percentile"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Baseline"}),e.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[((ge=(ue=S.debug)==null?void 0:ue.baselineCutoff)==null?void 0:ge.toFixed(1))??"—"," dBm"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Spike"}),e.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[((ve=(ye=S.debug)==null?void 0:ye.spikeCutoff)==null?void 0:ve.toFixed(1))??"—"," dBm"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Mid-band"}),e.jsx("span",{className:"ml-2 type-data-sm text-sys-indigo",children:((Ne=S.debug)==null?void 0:Ne.midBandSamples)??0})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Anomalies"}),e.jsx("span",{className:"ml-2 type-data-sm text-status-danger",children:O.length})]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-edge-subtle space-y-4",children:[m.useAbsoluteThresholds?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (",m.baselineDbm," dBm)"]}),e.jsx("input",{type:"range",min:"-120",max:"-60",value:m.baselineDbm,onChange:A=>f(ee=>({...ee,baselineDbm:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Spike (",m.spikeDbm," dBm)"]}),e.jsx("input",{type:"range",min:"-100",max:"-20",value:m.spikeDbm,onChange:A=>f(ee=>({...ee,spikeDbm:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",m.mergeGapSeconds,"s)"]}),e.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:m.mergeGapSeconds,onChange:A=>f(ee=>({...ee,mergeGapSeconds:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",m.minSequenceLength,")"]}),e.jsx("input",{type:"range",min:"2",max:"20",value:m.minSequenceLength,onChange:A=>f(ee=>({...ee,minSequenceLength:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",m.similarityToleranceDbm," dBm)"]}),e.jsx("input",{type:"range",min:"1",max:"15",value:m.similarityToleranceDbm,onChange:A=>f(ee=>({...ee,similarityToleranceDbm:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(L*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:L,onChange:A=>G(Number(A.target.value)),className:"w-full accent-sys-indigo"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (P",m.baselinePercentile,")"]}),e.jsx("input",{type:"range",min:"1",max:"50",value:m.baselinePercentile,onChange:A=>f(ee=>({...ee,baselinePercentile:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Spike (P",m.spikePercentile,")"]}),e.jsx("input",{type:"range",min:"50",max:"99",value:m.spikePercentile,onChange:A=>f(ee=>({...ee,spikePercentile:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",m.mergeGapSeconds,"s)"]}),e.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:m.mergeGapSeconds,onChange:A=>f(ee=>({...ee,mergeGapSeconds:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",m.minSequenceLength,")"]}),e.jsx("input",{type:"range",min:"2",max:"20",value:m.minSequenceLength,onChange:A=>f(ee=>({...ee,minSequenceLength:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",m.similarityToleranceDbm," dBm)"]}),e.jsx("input",{type:"range",min:"1",max:"15",value:m.similarityToleranceDbm,onChange:A=>f(ee=>({...ee,similarityToleranceDbm:Number(A.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(L*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:L,onChange:A=>G(Number(A.target.value)),className:"w-full accent-sys-indigo"})]})]})]}),e.jsxs("div",{className:"mt-4 p-3 bg-elevated radius-inner",children:[e.jsx("div",{className:"type-micro mb-1",children:"Config output"}),e.jsxs("div",{className:"type-data-sm text-status-success",children:[m.useAbsoluteThresholds?`useAbsoluteThresholds: true, baselineDbm: ${m.baselineDbm}, spikeDbm: ${m.spikeDbm}`:`useAbsoluteThresholds: false, baselinePercentile: ${m.baselinePercentile}, spikePercentile: ${m.spikePercentile}`,", mergeGapSeconds: ",m.mergeGapSeconds,", minSequenceLength: ",m.minSequenceLength,", similarityToleranceDbm: ",m.similarityToleranceDbm]})]})]})]}),e.jsxs(ws,{ready:h,children:[e.jsx("div",{className:"sm:hidden",children:H&&e.jsx(Ae,{template:"auto",children:e.jsx(be,{className:"border border-sys-blue/30 bg-sys-blue/5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex h-3 w-3",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-sys-blue opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-sys-blue"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"type-body-sm text-fg-primary",children:["Loading ",C.label," data..."]}),o.loadProgress&&e.jsxs("p",{className:"type-data-xs text-fg-muted mt-0.5",children:[o.loadProgress.loaded.toLocaleString()," packets (",o.loadProgress.percent,"%)"]})]})]})})})}),e.jsxs(e.Fragment,{children:[e.jsx(Ae,{template:"hero-auto",children:e.jsx(be,{neomorphic:!0,skeletonType:"chart",children:h&&e.jsxs(e.Fragment,{children:[e.jsx(Le,{icon:e.jsx(Ee,{}),title:"Packet Analyzer",badge:C.label,badgeColor:"zinc",stackActionsOnMobile:!0,actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:[D==="stats"&&e.jsx(rn,{enabled:K,onChange:F,anomalyCount:O.length,showTuning:v,onTuningChange:y}),(D==="ema"||D==="ultra")&&M==="airtime"&&e.jsx(ln,{enabled:Y,onChange:le,channelName:xe.map(A=>A.label).join(" & ")}),e.jsx(an,{smoothing:D,onChange:Z}),e.jsx(nn,{mode:M,onChange:$})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(vn,{packets:d,allPackets:a,startTs:fe,endTs:je,parentStartTs:de.start,parentEndTs:de.end,bucketCount:Fe,radioConfig:z??void 0,mode:M,smoothing:D,noiseFloorAnomalies:O,showNoiseFloorOverlay:K,overlayOpacity:L,dotSize:X,dotOpacity:te/100,showChannelTrendlines:Y,channelGroups:xe})})]})})}),e.jsx(Ae,{template:"auto",className:"relative z-10",children:e.jsx(be,{neomorphic:!0,noPadding:!0,className:"overflow-visible",children:h&&e.jsx(_s,{parentStartTs:de.start,parentEndTs:de.end,neighbors:U,filter:g,onChange:_,...D==="stats"?{scatterDotSize:X,onScatterDotSizeChange:re,scatterOpacity:te,onScatterOpacityChange:V}:{}})})}),e.jsxs(Ae,{template:"panel",children:[e.jsx(Ie,{span:12,md:6,children:e.jsx(be,{neomorphic:!1,skeletonType:"chart",noPadding:h,className:"!bg-transparent !ring-0 !shadow-none !overflow-visible -mx-4 sm:mx-0 !px-0 !pr-0",children:h&&e.jsx(rt,{children:e.jsx(_n,{neighbors:me,quickNeighbors:s,localLat:((Be=(He=t==null?void 0:t.config)==null?void 0:He.repeater)==null?void 0:Be.latitude)??0,localLon:((Ce=(Me=t==null?void 0:t.config)==null?void 0:Me.repeater)==null?void 0:Ce.longitude)??0,onStatsChange:N,title:"Link Quality",badge:C.label})})})}),e.jsx(Ie,{span:12,md:6,children:e.jsx(be,{neomorphic:!0,skeletonType:"chart",children:h&&e.jsxs(e.Fragment,{children:[e.jsx(Le,{icon:e.jsx(Ls,{}),title:"Network Composition",badge:C.label,badgeColor:"zinc"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(rt,{children:e.jsx(Ln,{neighbors:me,timeRangeLabel:C.label})})})]})})})]}),e.jsxs(Ae,{template:"panel",children:[e.jsx(Ie,{span:12,md:6,children:e.jsx($n,{})}),e.jsx(Ie,{span:12,md:6,children:e.jsx(Wn,{packets:a,rangeMinutes:ce,rangeHours:P,timeRangeLabel:C.label})})]}),e.jsx(Ae,{template:"panel",children:e.jsx(Ie,{span:12,children:e.jsx(be,{neomorphic:!0,skeletonType:"chart",children:h&&e.jsxs(e.Fragment,{children:[e.jsx(Le,{icon:e.jsx(fs,{}),title:"NOISE FLOOR dBm",stackActionsOnMobile:!0,actions:j?e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["min ",e.jsx("span",{className:"data-box",children:j.min.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["avg ",e.jsx("span",{className:"data-box",children:j.avg.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["max ",e.jsx("span",{className:"data-box",children:j.max.toFixed(0)})]})]}):null}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(rt,{children:e.jsx(gs,{timestamps:q.timestamps,values:q.values,onStatsChange:w,crcTimestamps:p})})})]})})})})]})]})]})}export{ja as default}; diff --git a/frontend/dist/assets/System-C3tiCIme.js b/frontend/dist/assets/System-DDVQJuHy.js similarity index 95% rename from frontend/dist/assets/System-C3tiCIme.js rename to frontend/dist/assets/System-DDVQJuHy.js index 1c2b67bf..847824ca 100644 --- a/frontend/dist/assets/System-C3tiCIme.js +++ b/frontend/dist/assets/System-DDVQJuHy.js @@ -1,6 +1,6 @@ -import{e as ee,aJ as A,O as B,r as l,L as Z,j as e,dQ as z,c as F,bY as se,a7 as E,dR as te,dS as re,dT as ne,dU as ae,cF as oe,B as le,dV as ce,dW as ie,dX as G}from"./index-C2xvS0Jd.js";import{C as P,P as de,a as me,B as ue}from"./PageLayout-Cg7r5tdt.js";import{A as xe}from"./arrow-up-C0VG8Et4.js";import{N as fe}from"./network-D80fXCJJ.js";import{A as he}from"./arrow-down-4OY_dsXk.js";import{T as pe}from"./thermometer-CG3c-cKn.js";import{A as D}from"./activity-BFfde9uG.js";import{C as ge}from"./cpu-CUBKtjSm.js";import{R as H,C as $}from"./Grid-kVOI-wJp.js";/** +import{e as ee,aK as A,O as B,r as l,L as J,j as e,dQ as z,c as F,bZ as se,a7 as E,dR as te,dS as re,dT as ne,dU as ae,cG as oe,B as le,dV as ce,dW as ie,dX as G}from"./index-D33fcA3L.js";import{C as P,P as de,a as me,B as ue}from"./PageLayout-CRN-E5xi.js";import{A as xe}from"./arrow-up-C4DdHKHn.js";import{N as fe}from"./network-Btok3jeo.js";import{A as he}from"./arrow-down-BI9NpupK.js";import{T as pe}from"./thermometer-A8kLkazp.js";import{A as D}from"./activity-D6ySIfuC.js";import{C as ge}from"./cpu--k4RdYyx.js";import{R as H,C as $}from"./Grid-DQYUnZsY.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 ye=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],je=ee("hard-drive",ye),T=[{pos:0,color:A(B.purple)},{pos:.25,color:A(B.indigo)},{pos:.5,color:A(B.cyan)},{pos:.75,color:A(B.amber)},{pos:1,color:A(B.red)}];function we(s,t,o){const n=.45454545454545453,r=Math.pow(s.r/255,2.2),i=Math.pow(s.g/255,2.2),x=Math.pow(s.b/255,2.2),d=Math.pow(t.r/255,2.2),m=Math.pow(t.g/255,2.2),c=Math.pow(t.b/255,2.2);return{r:Math.round(Math.pow(r+o*(d-r),n)*255),g:Math.round(Math.pow(i+o*(m-i),n)*255),b:Math.round(Math.pow(x+o*(c-x),n)*255)}}function q(s){const t=Math.max(0,Math.min(1,s));let o=T[0],a=T[T.length-1];for(let i=0;i=T[i].pos&&t<=T[i+1].pos){o=T[i],a=T[i+1];break}const n=a.pos-o.pos,r=n>0?(t-o.pos)/n:0;return we(o.color,a.color,r)}const W=z.hero,be=36;function V(){const s=getComputedStyle(document.documentElement);return{fontFamily:s.getPropertyValue("--font-data").trim()||'"JetBrains Mono", ui-monospace, monospace',textPrimary:s.getPropertyValue("--text-primary").trim()||"#FFFFFF",textMuted:s.getPropertyValue("--text-muted").trim()||"#727272",gridColor:s.getPropertyValue("--chart-grid").trim()||"rgba(255, 255, 255, 0.06)"}}function Ne(s){const t=[],o=Math.max(0,W-s.length);for(let n=0;ni+(u+.5)*v,f=u=>{const y=Math.min(Math.max(u/100,0),1);return x+m*(1-y)};r.save(),r.strokeStyle=n.textPrimary,r.globalAlpha=.1,r.lineWidth=1*c,r.setLineDash([4*c,4*c]);for(const u of[25,50,75]){const y=Math.round(f(u))+.5;r.beginPath(),r.moveTo(Math.round(i),y),r.lineTo(Math.round(i+d),y),r.stroke()}r.restore(),r.save(),r.font=`bold ${10*c}px ${n.fontFamily}`,r.fillStyle=n.textMuted,r.textBaseline="middle",r.textAlign="left";const g=8*c;for(const u of[0,25,50,75,100]){const y=f(u),j=Math.max(x+g,Math.min(x+m-g,y));r.fillText(`${u}%`,4*c,j)}r.restore(),r.save();for(let u=0;u0){const u=t[p-1];u!=null&&u.time&&(r.textAlign="right",r.fillText(u.time,w(p-1),M))}r.restore()}function Me({data:s,cpuColor:t,memoryColor:o}){const a=l.useRef(null),n=l.useRef(null),r=l.useRef([]),i=l.useRef(t),x=l.useRef(o),d=l.useRef(null),m=l.useRef(s.length);l.useLayoutEffect(()=>{i.current=t,x.current=o}),l.useEffect(()=>{d.current=V()},[]);const c=l.useMemo(()=>Ne(s),[s]);l.useLayoutEffect(()=>{r.current=c},[c]);const p=l.useMemo(()=>{const f=c.map(h=>h.timestamp),g=new Array(c.length).fill(1);return[f,g]},[c]),v=l.useMemo(()=>({hooks:{draw:f=>{const g=d.current||V();ve(f,r.current,i.current,x.current,g)}}}),[]),w=l.useMemo(()=>({width:400,height:240,padding:[4,8,4,be],cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,100]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],plugins:[v]}),[v]);return l.useEffect(()=>{const f=a.current;if(!f||c.length===0)return;const g=m.current,h=s.length,b=Math.abs(h-g);if(!(!n.current||b>50||g>0&&b/g>.2)&&n.current){n.current.setData(p),m.current=h;return}n.current&&n.current.destroy();const R=f.getBoundingClientRect(),u=Math.floor(R.width)||400,y=Math.floor(R.height)||240,j=new Z({...w,width:u,height:y},p,f);return n.current=j,m.current=h,()=>{j.destroy(),n.current=null}},[w,p,c.length,s.length]),l.useEffect(()=>{const f=a.current;if(!f)return;const g=new ResizeObserver(h=>{const b=h[0];if(!b||!n.current)return;const{width:M,height:R}=b.contentRect;M>0&&R>0&&n.current.setSize({width:Math.floor(M),height:Math.floor(R)})});return g.observe(f),()=>{g.disconnect()}},[]),l.useEffect(()=>{n.current&&n.current.redraw()},[t,o,c]),s.length===0?e.jsx("div",{className:"flex-1 min-h-[180px] flex items-center justify-center text-fg-muted",children:"Collecting data..."}):e.jsx("div",{className:"relative flex-1 min-h-[180px]",children:e.jsx("div",{ref:a,className:"absolute inset-0 radius-inner overflow-hidden"})})}const Re=l.memo(Me),Ce=1024*1024;function Se(s,t,o,a,n){const r=s.ctx,{left:i,top:x,width:d,height:m}=s.bbox;if(d<=0||m<=0)return;const c=[...Array(Math.max(0,n-t.length)).fill(0),...t.slice(-n)],p=Math.max(...c,1),v=c.length,w=d/v,f=m*.03;r.save();for(let g=0;g{i.current=s,x.current=t,d.current=o,m.current=a});const c=l.useMemo(()=>{const w=Array.from({length:a},(g,h)=>h),f=new Array(a).fill(1);return[w,f]},[a]),p=l.useMemo(()=>({hooks:{draw:w=>{Se(w,i.current,x.current,d.current,m.current)}}}),[]),v=l.useMemo(()=>({width:400,height:40,padding:[0,0,0,0],legend:{show:!1},cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1,label:""}],plugins:[p]}),[p]);return l.useEffect(()=>{const w=n.current;if(!w)return;r.current&&r.current.destroy();const f=w.getBoundingClientRect(),g=Math.floor(f.width)||400,h=Math.floor(f.height)||40,b=new Z({...v,width:g,height:h},c,w);return r.current=b,()=>{b.destroy(),r.current=null}},[v,c]),l.useEffect(()=>{const w=n.current;if(!w)return;const f=new ResizeObserver(g=>{const h=g[0];if(!h||!r.current)return;const{width:b,height:M}=h.contentRect;b>0&&M>0&&r.current.setSize({width:Math.floor(b),height:Math.floor(M)})});return f.observe(w),()=>{f.disconnect()}},[]),l.useEffect(()=>{r.current&&r.current.redraw()},[s,t,o]),e.jsx("div",{ref:n,className:"w-full h-full"})}const X=l.memo(_e),C={cold:30,normal:50,warm:65,hot:80},I={cpu:{warning:80,danger:95},memory:{warning:85,danger:95},temp:{warning:70,danger:85}},Te=[{threshold:C.cold,color:"var(--sys-cyan)"},{threshold:C.normal,color:"var(--sys-blue)"},{threshold:C.warm,color:"var(--sys-indigo)"},{threshold:C.hot,color:"var(--signal-poor)"}];function ke(s){return s{const d=s>0?x.pos/s*100:0;return`${x.color} ${Math.min(d,100)}%`}).join(", ")})`}function U(s,t){return s>=t.danger?"danger":s>=t.warning?"warning":"none"}function Ee(s){let t="none";for(const o of Object.values(s)){const a=U(o,I.temp);if(a==="danger")return"danger";a==="warning"&&(t="warning")}return t}function J(s){let t,o;s>=1024*1024*1024?(t=s/(1024*1024*1024),o="GB/s"):s>=1024*1024?(t=s/(1024*1024),o="MB/s"):s>=1024?(t=s/1024,o="KB/s"):(t=s,o="B/s");let a;return t>=100?a=t.toFixed(0):(t>=10,a=t.toFixed(1)),`${a} ${o}`}function L(s){return s>=1024*1024*1024?{value:(s/(1024*1024*1024)).toFixed(1),unit:"GiB"}:s>=1024*1024?{value:(s/(1024*1024)).toFixed(1),unit:"MiB"}:s>=1024?{value:(s/1024).toFixed(1),unit:"KiB"}:{value:String(s),unit:"B"}}const Y=l.memo(function({level:t}){return t==="none"?null:e.jsxs("span",{className:F("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",t==="danger"&&"bg-sys-red/20 text-sys-red",t==="warning"&&"bg-sys-indigo/20 text-sys-indigo"),children:[e.jsx(se,{className:"w-3 h-3"}),t==="danger"?"High":"Warn"]})}),Q=l.memo(function({value:t,max:o=100,width:a=10,color:n="primary"}){const r=Math.min(t/o,1),i=Math.round(r*a),x=a-i,d="■".repeat(i),m="·".repeat(x),c={primary:"text-sys-blue",secondary:"text-sys-indigo",success:"text-sys-green",danger:"text-sys-red"}[n];return e.jsxs("span",{className:"font-mono text-[10px] tracking-tight",children:[e.jsx("span",{className:c,children:d}),e.jsx("span",{className:"text-fg-muted/40",children:m})]})}),Ae=l.memo(function({index:t,usage:o}){const a=o>90?"danger":o>70?"secondary":"primary";return e.jsxs("div",{className:"flex items-center gap-1 type-data-xs",children:[e.jsxs("span",{className:"text-fg-muted w-5",children:["C",t]}),e.jsx(Q,{value:o,width:8,color:a}),e.jsxs("span",{className:F("w-7 text-right tabular-nums",o>90?"text-sys-red":o>70?"text-sys-indigo":"text-sys-green"),children:[o.toFixed(0),"%"]})]})}),Be=l.memo(function({pid:t,name:o,cpu:a,mem:n,isTopCpu:r=!1,isTopMem:i=!1}){return e.jsxs("div",{className:"flex items-center gap-2 py-1 type-data-sm hover:bg-subtle-fill -mx-1 px-1 rounded",children:[e.jsx("span",{className:"text-fg-muted w-10 sm:w-14 tabular-nums",children:t}),e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:o}),e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx(Q,{value:a,max:100,width:6,color:a>50?"danger":a>20?"secondary":"success"})}),e.jsx("span",{className:F("w-10 sm:w-12 text-right tabular-nums",r?"text-fg-primary":a>50?"text-sys-red":a>20?"text-sys-indigo":"text-fg-muted"),children:a.toFixed(1)}),e.jsx("span",{className:F("w-10 sm:w-12 text-right tabular-nums",i?"text-fg-primary":n>50?"text-sys-red":n>20?"text-sys-indigo":"text-fg-muted"),children:n.toFixed(1)})]})}),K=l.memo(function({value:t,label:o,min:a=20,max:n=100}){const r=Math.min(Math.max((t-a)/(n-a)*100,0),100),i=ke(t),x=n-a;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:o}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:i.text}),e.jsxs("span",{className:"data-box",children:[e.jsx("span",{className:i.color,children:t.toFixed(1)}),e.jsx("span",{className:"text-fg-primary",children:"°C"})]})]})]}),e.jsxs("div",{className:"relative h-3 rounded-full bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full transition-all duration-300 ease-out",style:{background:Pe(r,a,n),width:`${r}%`}}),e.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:Te.map(({threshold:d,color:m})=>{const c=(d-a)/x*100;return c<0||c>100?null:e.jsx("div",{className:"absolute w-px h-full",style:{left:`${c}%`,backgroundColor:m}},d)})})]})]})});l.memo(function({data:t,color:o,flipped:a=!1,fixedSlots:n}){const r=[...Array(Math.max(0,n-t.length)).fill(0),...t.slice(-n)],i=Math.max(...r,1),x=r.map(d=>d===0?0:Math.max(d/i*100,3));return e.jsx("div",{className:"w-full h-full flex items-end",style:{transform:a?"scaleY(-1)":void 0},children:x.map((d,m)=>e.jsx("div",{className:"flex-1 min-w-0",style:{height:d>0?`${d}%`:"0%",backgroundColor:d>0?o:"transparent"}},m))})});function Fe({networkHistory:s,txRate:t,rxRate:o,totalBytesSent:a,totalBytesRecv:n,cpuColor:r,memoryColor:i,networkSlots:x}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(fe,{}),title:"Network",actions:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xe,{className:"w-3.5 h-3.5",style:{color:i}}),e.jsx("span",{className:"data-box-label !mb-0",style:{color:i},children:"TX"}),e.jsx("span",{className:"data-box",children:J(t)})]})}),e.jsxs("div",{className:"flex flex-col h-[120px]",children:[e.jsx("div",{className:"h-[60px]",children:e.jsx(X,{data:s.map((d,m,c)=>{if(m===0)return 0;const p=(d.timestamp-c[m-1].timestamp)/1e3;return p>0?(d.bytesSent-c[m-1].bytesSent)/p:0}),color:i,fixedSlots:x})}),e.jsx("div",{className:"h-[60px]",children:e.jsx(X,{data:s.map((d,m,c)=>{if(m===0)return 0;const p=(d.timestamp-c[m-1].timestamp)/1e3;return p>0?(d.bytesRecv-c[m-1].bytesRecv)/p:0}),color:r,flipped:!0,fixedSlots:x})})]}),e.jsxs("div",{className:"pt-2 flex flex-wrap justify-between items-center gap-2 type-data-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"data-box-label !mb-0",children:"Total"}),e.jsxs("span",{className:"data-box",children:[e.jsx("span",{style:{color:i},children:L(a).value})," ",e.jsx("span",{className:"text-fg-muted",children:L(a).unit})]}),e.jsxs("span",{className:"data-box",children:[e.jsx("span",{style:{color:r},children:L(n).value})," ",e.jsx("span",{className:"text-fg-muted",children:L(n).unit})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(he,{className:"w-3.5 h-3.5",style:{color:r}}),e.jsx("span",{className:"data-box-label !mb-0",style:{color:r},children:"RX"}),e.jsx("span",{className:"data-box",children:J(o)})]})]})]})}const He=l.memo(Fe);function $e({temperatures:s}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(pe,{}),title:"Temperature",actions:s&&e.jsx(Y,{level:Ee(s)})}),e.jsx("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:s&&Object.keys(s).length>0?e.jsxs("div",{className:"space-y-3",children:[s.cpu_thermal!==void 0&&e.jsx(K,{value:s.cpu_thermal,label:"CPU",min:20,max:100}),Object.entries(s).filter(([t])=>t!=="cpu_thermal").slice(0,2).map(([t,o])=>e.jsx(K,{value:o,label:t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),min:20,max:100},t))]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-sm",children:[e.jsx(D,{className:"w-4 h-4 mr-2"}),"No sensors"]})})]})}const Le=l.memo($e);function De({usagePercent:s,used:t,available:o,memoryColor:a}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(D,{}),title:"Memory",actions:e.jsxs("span",{className:"data-box",style:{"--data-box-color":a},children:[s.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${s}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-s}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"data-box",children:[(t/(1024*1024)).toFixed(0)," MB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Avail"}),e.jsxs("span",{className:"data-box",style:{"--data-box-color":"var(--fg-muted)"},children:[(o/(1024*1024)).toFixed(0)," MB"]})]})]})]})]})}const Oe=l.memo(De);function Ie({usagePercent:s,used:t,free:o,cpuColor:a}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(je,{}),title:"Disk",actions:e.jsxs("span",{className:"data-box",style:{"--data-box-color":a},children:[s.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${s}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-s}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"data-box",children:[(t/(1024*1024*1024)).toFixed(1)," GB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Free"}),e.jsxs("span",{className:"data-box",style:{"--data-box-color":"var(--fg-muted)"},children:[(o/(1024*1024*1024)).toFixed(1)," GB"]})]})]})]})]})}const Ue=l.memo(Ie);function Ye({processes:s}){if(s.length===0)return null;const t=s.slice(0,10),o=Math.max(...t.map(n=>n.cpu_percent)),a=Math.max(...t.map(n=>n.memory_percent));return e.jsx(P,{neomorphic:!0,noPadding:!0,children:e.jsxs("div",{className:"px-4 py-3",children:[e.jsx(E,{icon:e.jsx(D,{}),title:"Processes"}),e.jsxs("div",{className:"flex items-center gap-2 py-1.5 type-data-sm text-fg-muted",children:[e.jsx("span",{className:"w-10 sm:w-14",children:"PID"}),e.jsx("span",{className:"flex-1",children:"Program"}),e.jsx("span",{className:"hidden sm:block w-[52px]"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"CPU%"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"MEM%"})]}),t.map(n=>e.jsx(Be,{pid:n.pid,name:n.name,cpu:n.cpu_percent,mem:n.memory_percent,isTopCpu:n.cpu_percent===o&&o>0,isTopMem:n.memory_percent===a&&a>0},n.pid))]})})}const ze=l.memo(Ye),Ge=z.hero;function We(){const[s,t]=l.useState(typeof window<"u"?window.matchMedia("(max-width: 767px)").matches:!1);return l.useEffect(()=>{const o=window.matchMedia("(max-width: 767px)");t(o.matches);const a=n=>t(n.matches);return o.addEventListener("change",a),()=>o.removeEventListener("change",a)},[]),s?z.hero:40}function ts(){var y;const s=te(),t=re(),o=ne(),a=ae(),[n,r]=l.useState([]),[i,x]=l.useState(!1),[d,m]=l.useState([]),[c,p]=l.useState(0),[v,w]=l.useState(0),f=l.useRef(null),g=oe(),h=g.blue,b=g.amber,M=We();l.useEffect(()=>{if(!s)return;const j=Date.now(),N={timestamp:j,bytesRecv:s.network.bytes_recv,bytesSent:s.network.bytes_sent};if(f.current){const S=(j-f.current.timestamp)/1e3;if(S>0){const _=(N.bytesRecv-f.current.bytesRecv)/S,k=(N.bytesSent-f.current.bytesSent)/S;_>=0&&k>=0&&(p(_),w(k))}}f.current=N,m(S=>[...S,N].slice(-Ge))},[s]);const R=5e3;l.useEffect(()=>{let j=!0;const N=async()=>{var k;const _=await G();j&&_.success&&((k=_.data)!=null&&k.processes)&&r(_.data.processes)};N();const S=setInterval(N,R);return()=>{j=!1,clearInterval(S)}},[]);const u=async()=>{var N;x(!0),await o();const j=await G();j.success&&((N=j.data)!=null&&N.processes)&&r(j.data.processes),x(!1)};return e.jsxs(de,{children:[e.jsx(me,{title:"System Stats",icon:e.jsx(ge,{}),controls:e.jsxs(le,{color:"muted",onClick:u,disabled:i,children:[e.jsx(ce,{"data-slot":"icon",className:F(i&&"animate-spin")}),"Refresh"]})}),e.jsxs(ue,{ready:!!s,children:[t&&e.jsx(P,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:t})}),e.jsx(H,{template:"hero",children:e.jsxs(P,{neomorphic:!0,className:"pb-2 sm:pb-3",children:[e.jsx(E,{icon:e.jsx(D,{}),title:"System Resources",stackActionsOnMobile:!0,actions:s&&e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-wrap",children:[((y=s.system)==null?void 0:y.uptime)&&e.jsx("span",{className:"data-box",children:ie(s.system.uptime)}),e.jsx(Y,{level:U(s.cpu.usage_percent,I.cpu)}),e.jsx(Y,{level:U(s.memory.usage_percent,I.memory)}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"data-box-label !mb-0",children:"CPU"}),e.jsxs("span",{className:"data-box",style:{"--data-box-color":h},children:[s.cpu.usage_percent.toFixed(0),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"data-box-label !mb-0",children:"MEM"}),e.jsxs("span",{className:"data-box",style:{"--data-box-color":b},children:[s.memory.usage_percent.toFixed(0),"%"]})]})]})}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e.jsx(Re,{data:a,cpuColor:h,memoryColor:b})}),s.cpu.per_core_percent&&s.cpu.per_core_percent.length>0&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-x-3 gap-y-0.5",children:s.cpu.per_core_percent.map((j,N)=>e.jsx(Ae,{index:N,usage:j},N))})})]})]})}),s&&e.jsxs(e.Fragment,{children:[e.jsxs(H,{template:"compact",children:[e.jsx($,{span:12,md:6,children:e.jsx(He,{networkHistory:d,txRate:v,rxRate:c,totalBytesSent:s.network.bytes_sent,totalBytesRecv:s.network.bytes_recv,cpuColor:h,memoryColor:b,networkSlots:M})}),e.jsx($,{span:12,md:6,children:e.jsx(Le,{temperatures:s.temperatures})})]}),e.jsxs(H,{template:"compact",children:[e.jsx($,{span:12,sm:6,children:e.jsx(Oe,{usagePercent:s.memory.usage_percent,used:s.memory.used,available:s.memory.available,memoryColor:b})}),e.jsx($,{span:12,sm:6,children:e.jsx(Ue,{usagePercent:s.disk.usage_percent,used:s.disk.used,free:s.disk.free,cpuColor:h})})]}),e.jsx(H,{template:"auto",children:e.jsx(ze,{processes:n})})]})]})]})}export{ts as default}; + */const ye=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],je=ee("hard-drive",ye),T=[{pos:0,color:A(B.purple)},{pos:.25,color:A(B.indigo)},{pos:.5,color:A(B.cyan)},{pos:.75,color:A(B.amber)},{pos:1,color:A(B.red)}];function we(s,t,o){const n=.45454545454545453,r=Math.pow(s.r/255,2.2),i=Math.pow(s.g/255,2.2),x=Math.pow(s.b/255,2.2),d=Math.pow(t.r/255,2.2),m=Math.pow(t.g/255,2.2),c=Math.pow(t.b/255,2.2);return{r:Math.round(Math.pow(r+o*(d-r),n)*255),g:Math.round(Math.pow(i+o*(m-i),n)*255),b:Math.round(Math.pow(x+o*(c-x),n)*255)}}function q(s){const t=Math.max(0,Math.min(1,s));let o=T[0],a=T[T.length-1];for(let i=0;i=T[i].pos&&t<=T[i+1].pos){o=T[i],a=T[i+1];break}const n=a.pos-o.pos,r=n>0?(t-o.pos)/n:0;return we(o.color,a.color,r)}const W=z.hero,be=36;function V(){const s=getComputedStyle(document.documentElement);return{fontFamily:s.getPropertyValue("--font-data").trim()||'"JetBrains Mono", ui-monospace, monospace',textPrimary:s.getPropertyValue("--text-primary").trim()||"#FFFFFF",textMuted:s.getPropertyValue("--text-muted").trim()||"#727272",gridColor:s.getPropertyValue("--chart-grid").trim()||"rgba(255, 255, 255, 0.06)"}}function Ne(s){const t=[],o=Math.max(0,W-s.length);for(let n=0;ni+(u+.5)*v,f=u=>{const y=Math.min(Math.max(u/100,0),1);return x+m*(1-y)};r.save(),r.strokeStyle=n.textPrimary,r.globalAlpha=.1,r.lineWidth=1*c,r.setLineDash([4*c,4*c]);for(const u of[25,50,75]){const y=Math.round(f(u))+.5;r.beginPath(),r.moveTo(Math.round(i),y),r.lineTo(Math.round(i+d),y),r.stroke()}r.restore(),r.save(),r.font=`bold ${10*c}px ${n.fontFamily}`,r.fillStyle=n.textMuted,r.textBaseline="middle",r.textAlign="left";const g=8*c;for(const u of[0,25,50,75,100]){const y=f(u),j=Math.max(x+g,Math.min(x+m-g,y));r.fillText(`${u}%`,4*c,j)}r.restore(),r.save();for(let u=0;u0){const u=t[p-1];u!=null&&u.time&&(r.textAlign="right",r.fillText(u.time,w(p-1),M))}r.restore()}function Me({data:s,cpuColor:t,memoryColor:o}){const a=l.useRef(null),n=l.useRef(null),r=l.useRef([]),i=l.useRef(t),x=l.useRef(o),d=l.useRef(null),m=l.useRef(s.length);l.useLayoutEffect(()=>{i.current=t,x.current=o}),l.useEffect(()=>{d.current=V()},[]);const c=l.useMemo(()=>Ne(s),[s]);l.useLayoutEffect(()=>{r.current=c},[c]);const p=l.useMemo(()=>{const f=c.map(h=>h.timestamp),g=new Array(c.length).fill(1);return[f,g]},[c]),v=l.useMemo(()=>({hooks:{draw:f=>{const g=d.current||V();ve(f,r.current,i.current,x.current,g)}}}),[]),w=l.useMemo(()=>({width:400,height:240,padding:[4,8,4,be],cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,100]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],plugins:[v]}),[v]);return l.useEffect(()=>{const f=a.current;if(!f||c.length===0)return;const g=m.current,h=s.length,b=Math.abs(h-g);if(!(!n.current||b>50||g>0&&b/g>.2)&&n.current){n.current.setData(p),m.current=h;return}n.current&&n.current.destroy();const R=f.getBoundingClientRect(),u=Math.floor(R.width)||400,y=Math.floor(R.height)||240,j=new J({...w,width:u,height:y},p,f);return n.current=j,m.current=h,()=>{j.destroy(),n.current=null}},[w,p,c.length,s.length]),l.useEffect(()=>{const f=a.current;if(!f)return;const g=new ResizeObserver(h=>{const b=h[0];if(!b||!n.current)return;const{width:M,height:R}=b.contentRect;M>0&&R>0&&n.current.setSize({width:Math.floor(M),height:Math.floor(R)})});return g.observe(f),()=>{g.disconnect()}},[]),l.useEffect(()=>{n.current&&n.current.redraw()},[t,o,c]),s.length===0?e.jsx("div",{className:"flex-1 min-h-[180px] flex items-center justify-center text-fg-muted",children:"Collecting data..."}):e.jsx("div",{className:"relative flex-1 min-h-[180px]",children:e.jsx("div",{ref:a,className:"absolute inset-0 radius-inner overflow-hidden"})})}const Re=l.memo(Me),Ce=1024*1024;function Se(s,t,o,a,n){const r=s.ctx,{left:i,top:x,width:d,height:m}=s.bbox;if(d<=0||m<=0)return;const c=[...Array(Math.max(0,n-t.length)).fill(0),...t.slice(-n)],p=Math.max(...c,1),v=c.length,w=d/v,f=m*.03;r.save();for(let g=0;g{i.current=s,x.current=t,d.current=o,m.current=a});const c=l.useMemo(()=>{const w=Array.from({length:a},(g,h)=>h),f=new Array(a).fill(1);return[w,f]},[a]),p=l.useMemo(()=>({hooks:{draw:w=>{Se(w,i.current,x.current,d.current,m.current)}}}),[]),v=l.useMemo(()=>({width:400,height:40,padding:[0,0,0,0],legend:{show:!1},cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1,label:""}],plugins:[p]}),[p]);return l.useEffect(()=>{const w=n.current;if(!w)return;r.current&&r.current.destroy();const f=w.getBoundingClientRect(),g=Math.floor(f.width)||400,h=Math.floor(f.height)||40,b=new J({...v,width:g,height:h},c,w);return r.current=b,()=>{b.destroy(),r.current=null}},[v,c]),l.useEffect(()=>{const w=n.current;if(!w)return;const f=new ResizeObserver(g=>{const h=g[0];if(!h||!r.current)return;const{width:b,height:M}=h.contentRect;b>0&&M>0&&r.current.setSize({width:Math.floor(b),height:Math.floor(M)})});return f.observe(w),()=>{f.disconnect()}},[]),l.useEffect(()=>{r.current&&r.current.redraw()},[s,t,o]),e.jsx("div",{ref:n,className:"w-full h-full"})}const X=l.memo(_e),C={cold:30,normal:50,warm:65,hot:80},I={cpu:{warning:80,danger:95},memory:{warning:85,danger:95},temp:{warning:70,danger:85}},Te=[{threshold:C.cold,color:"var(--sys-cyan)"},{threshold:C.normal,color:"var(--sys-blue)"},{threshold:C.warm,color:"var(--sys-indigo)"},{threshold:C.hot,color:"var(--signal-poor)"}];function ke(s){return s{const d=s>0?x.pos/s*100:0;return`${x.color} ${Math.min(d,100)}%`}).join(", ")})`}function U(s,t){return s>=t.danger?"danger":s>=t.warning?"warning":"none"}function Ee(s){let t="none";for(const o of Object.values(s)){const a=U(o,I.temp);if(a==="danger")return"danger";a==="warning"&&(t="warning")}return t}function K(s){let t,o;s>=1024*1024*1024?(t=s/(1024*1024*1024),o="GB/s"):s>=1024*1024?(t=s/(1024*1024),o="MB/s"):s>=1024?(t=s/1024,o="KB/s"):(t=s,o="B/s");let a;return t>=100?a=t.toFixed(0):(t>=10,a=t.toFixed(1)),`${a} ${o}`}function L(s){return s>=1024*1024*1024?{value:(s/(1024*1024*1024)).toFixed(1),unit:"GiB"}:s>=1024*1024?{value:(s/(1024*1024)).toFixed(1),unit:"MiB"}:s>=1024?{value:(s/1024).toFixed(1),unit:"KiB"}:{value:String(s),unit:"B"}}const Y=l.memo(function({level:t}){return t==="none"?null:e.jsxs("span",{className:F("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",t==="danger"&&"bg-sys-red/20 text-sys-red",t==="warning"&&"bg-sys-indigo/20 text-sys-indigo"),children:[e.jsx(se,{className:"w-3 h-3"}),t==="danger"?"High":"Warn"]})}),Q=l.memo(function({value:t,max:o=100,width:a=10,color:n="primary"}){const r=Math.min(t/o,1),i=Math.round(r*a),x=a-i,d="■".repeat(i),m="·".repeat(x),c={primary:"text-sys-blue",secondary:"text-sys-indigo",success:"text-sys-green",danger:"text-sys-red"}[n];return e.jsxs("span",{className:"font-mono text-[10px] tracking-tight",children:[e.jsx("span",{className:c,children:d}),e.jsx("span",{className:"text-fg-muted/40",children:m})]})}),Ae=l.memo(function({index:t,usage:o}){const a=o>90?"danger":o>70?"secondary":"primary";return e.jsxs("div",{className:"flex items-center gap-1 type-data-xs",children:[e.jsxs("span",{className:"text-fg-muted w-5",children:["C",t]}),e.jsx(Q,{value:o,width:8,color:a}),e.jsxs("span",{className:F("w-7 text-right tabular-nums",o>90?"text-sys-red":o>70?"text-sys-indigo":"text-sys-green"),children:[o.toFixed(0),"%"]})]})}),Be=l.memo(function({pid:t,name:o,cpu:a,mem:n,isTopCpu:r=!1,isTopMem:i=!1}){return e.jsxs("div",{className:"flex items-center gap-2 py-1 type-data-sm hover:bg-subtle-fill -mx-1 px-1 rounded",children:[e.jsx("span",{className:"text-fg-muted w-10 sm:w-14 tabular-nums",children:t}),e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:o}),e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx(Q,{value:a,max:100,width:6,color:a>50?"danger":a>20?"secondary":"success"})}),e.jsx("span",{className:F("w-10 sm:w-12 text-right tabular-nums",r?"text-fg-primary":a>50?"text-sys-red":a>20?"text-sys-indigo":"text-fg-muted"),children:a.toFixed(1)}),e.jsx("span",{className:F("w-10 sm:w-12 text-right tabular-nums",i?"text-fg-primary":n>50?"text-sys-red":n>20?"text-sys-indigo":"text-fg-muted"),children:n.toFixed(1)})]})}),Z=l.memo(function({value:t,label:o,min:a=20,max:n=100}){const r=Math.min(Math.max((t-a)/(n-a)*100,0),100),i=ke(t),x=n-a;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:o}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:i.text}),e.jsxs("span",{className:"data-box",children:[e.jsx("span",{className:i.color,children:t.toFixed(1)}),e.jsx("span",{className:"text-fg-primary",children:"°C"})]})]})]}),e.jsxs("div",{className:"relative h-3 rounded-full bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full transition-all duration-300 ease-out",style:{background:Pe(r,a,n),width:`${r}%`}}),e.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:Te.map(({threshold:d,color:m})=>{const c=(d-a)/x*100;return c<0||c>100?null:e.jsx("div",{className:"absolute w-px h-full",style:{left:`${c}%`,backgroundColor:m}},d)})})]})]})});l.memo(function({data:t,color:o,flipped:a=!1,fixedSlots:n}){const r=[...Array(Math.max(0,n-t.length)).fill(0),...t.slice(-n)],i=Math.max(...r,1),x=r.map(d=>d===0?0:Math.max(d/i*100,3));return e.jsx("div",{className:"w-full h-full flex items-end",style:{transform:a?"scaleY(-1)":void 0},children:x.map((d,m)=>e.jsx("div",{className:"flex-1 min-w-0",style:{height:d>0?`${d}%`:"0%",backgroundColor:d>0?o:"transparent"}},m))})});function Fe({networkHistory:s,txRate:t,rxRate:o,totalBytesSent:a,totalBytesRecv:n,cpuColor:r,memoryColor:i,networkSlots:x}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(fe,{}),title:"Network",actions:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xe,{className:"w-3.5 h-3.5",style:{color:i}}),e.jsx("span",{className:"data-box-label !mb-0",style:{color:i},children:"TX"}),e.jsx("span",{className:"data-box",children:K(t)})]})}),e.jsxs("div",{className:"flex flex-col h-[120px]",children:[e.jsx("div",{className:"h-[60px]",children:e.jsx(X,{data:s.map((d,m,c)=>{if(m===0)return 0;const p=(d.timestamp-c[m-1].timestamp)/1e3;return p>0?(d.bytesSent-c[m-1].bytesSent)/p:0}),color:i,fixedSlots:x})}),e.jsx("div",{className:"h-[60px]",children:e.jsx(X,{data:s.map((d,m,c)=>{if(m===0)return 0;const p=(d.timestamp-c[m-1].timestamp)/1e3;return p>0?(d.bytesRecv-c[m-1].bytesRecv)/p:0}),color:r,flipped:!0,fixedSlots:x})})]}),e.jsxs("div",{className:"pt-2 flex flex-wrap justify-between items-center gap-2 type-data-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"data-box-label !mb-0",children:"Total"}),e.jsxs("span",{className:"data-box",children:[e.jsx("span",{style:{color:i},children:L(a).value})," ",e.jsx("span",{className:"text-fg-muted",children:L(a).unit})]}),e.jsxs("span",{className:"data-box",children:[e.jsx("span",{style:{color:r},children:L(n).value})," ",e.jsx("span",{className:"text-fg-muted",children:L(n).unit})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(he,{className:"w-3.5 h-3.5",style:{color:r}}),e.jsx("span",{className:"data-box-label !mb-0",style:{color:r},children:"RX"}),e.jsx("span",{className:"data-box",children:K(o)})]})]})]})}const He=l.memo(Fe);function $e({temperatures:s}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(pe,{}),title:"Temperature",actions:s&&e.jsx(Y,{level:Ee(s)})}),e.jsx("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:s&&Object.keys(s).length>0?e.jsxs("div",{className:"space-y-3",children:[s.cpu_thermal!==void 0&&e.jsx(Z,{value:s.cpu_thermal,label:"CPU",min:20,max:100}),Object.entries(s).filter(([t])=>t!=="cpu_thermal").slice(0,2).map(([t,o])=>e.jsx(Z,{value:o,label:t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),min:20,max:100},t))]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-sm",children:[e.jsx(D,{className:"w-4 h-4 mr-2"}),"No sensors"]})})]})}const Le=l.memo($e);function De({usagePercent:s,used:t,available:o,memoryColor:a}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(D,{}),title:"Memory",actions:e.jsxs("span",{className:"data-box",style:{"--data-box-color":a},children:[s.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${s}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-s}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"data-box",children:[(t/(1024*1024)).toFixed(0)," MB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Avail"}),e.jsxs("span",{className:"data-box",style:{"--data-box-color":"var(--fg-muted)"},children:[(o/(1024*1024)).toFixed(0)," MB"]})]})]})]})]})}const Oe=l.memo(De);function Ie({usagePercent:s,used:t,free:o,cpuColor:a}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(je,{}),title:"Disk",actions:e.jsxs("span",{className:"data-box",style:{"--data-box-color":a},children:[s.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${s}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-s}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"data-box",children:[(t/(1024*1024*1024)).toFixed(1)," GB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Free"}),e.jsxs("span",{className:"data-box",style:{"--data-box-color":"var(--fg-muted)"},children:[(o/(1024*1024*1024)).toFixed(1)," GB"]})]})]})]})]})}const Ue=l.memo(Ie);function Ye({processes:s}){if(s.length===0)return null;const t=s.slice(0,10),o=Math.max(...t.map(n=>n.cpu_percent)),a=Math.max(...t.map(n=>n.memory_percent));return e.jsx(P,{neomorphic:!0,noPadding:!0,children:e.jsxs("div",{className:"px-4 py-3",children:[e.jsx(E,{icon:e.jsx(D,{}),title:"Processes"}),e.jsxs("div",{className:"flex items-center gap-2 py-1.5 type-data-sm text-fg-muted",children:[e.jsx("span",{className:"w-10 sm:w-14",children:"PID"}),e.jsx("span",{className:"flex-1",children:"Program"}),e.jsx("span",{className:"hidden sm:block w-[52px]"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"CPU%"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"MEM%"})]}),t.map(n=>e.jsx(Be,{pid:n.pid,name:n.name,cpu:n.cpu_percent,mem:n.memory_percent,isTopCpu:n.cpu_percent===o&&o>0,isTopMem:n.memory_percent===a&&a>0},n.pid))]})})}const ze=l.memo(Ye),Ge=z.hero;function We(){const[s,t]=l.useState(typeof window<"u"?window.matchMedia("(max-width: 767px)").matches:!1);return l.useEffect(()=>{const o=window.matchMedia("(max-width: 767px)");t(o.matches);const a=n=>t(n.matches);return o.addEventListener("change",a),()=>o.removeEventListener("change",a)},[]),s?z.hero:40}function ts(){var y;const s=te(),t=re(),o=ne(),a=ae(),[n,r]=l.useState([]),[i,x]=l.useState(!1),[d,m]=l.useState([]),[c,p]=l.useState(0),[v,w]=l.useState(0),f=l.useRef(null),g=oe(),h=g.blue,b=g.amber,M=We();l.useEffect(()=>{if(!s)return;const j=Date.now(),N={timestamp:j,bytesRecv:s.network.bytes_recv,bytesSent:s.network.bytes_sent};if(f.current){const S=(j-f.current.timestamp)/1e3;if(S>0){const _=(N.bytesRecv-f.current.bytesRecv)/S,k=(N.bytesSent-f.current.bytesSent)/S;_>=0&&k>=0&&(p(_),w(k))}}f.current=N,m(S=>[...S,N].slice(-Ge))},[s]);const R=5e3;l.useEffect(()=>{let j=!0;const N=async()=>{var k;const _=await G();j&&_.success&&((k=_.data)!=null&&k.processes)&&r(_.data.processes)};N();const S=setInterval(N,R);return()=>{j=!1,clearInterval(S)}},[]);const u=async()=>{var N;x(!0),await o();const j=await G();j.success&&((N=j.data)!=null&&N.processes)&&r(j.data.processes),x(!1)};return e.jsxs(de,{children:[e.jsx(me,{title:"System Stats",icon:e.jsx(ge,{}),controls:e.jsxs(le,{color:"muted",onClick:u,disabled:i,children:[e.jsx(ce,{"data-slot":"icon",className:F(i&&"animate-spin")}),"Refresh"]})}),e.jsxs(ue,{ready:!!s,children:[t&&e.jsx(P,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:t})}),e.jsx(H,{template:"hero",children:e.jsxs(P,{neomorphic:!0,className:"pb-2 sm:pb-3",children:[e.jsx(E,{icon:e.jsx(D,{}),title:"System Resources",stackActionsOnMobile:!0,actions:s&&e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-wrap",children:[((y=s.system)==null?void 0:y.uptime)&&e.jsx("span",{className:"data-box",children:ie(s.system.uptime)}),e.jsx(Y,{level:U(s.cpu.usage_percent,I.cpu)}),e.jsx(Y,{level:U(s.memory.usage_percent,I.memory)}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"data-box-label !mb-0",children:"CPU"}),e.jsxs("span",{className:"data-box",style:{"--data-box-color":h},children:[s.cpu.usage_percent.toFixed(0),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"data-box-label !mb-0",children:"MEM"}),e.jsxs("span",{className:"data-box",style:{"--data-box-color":b},children:[s.memory.usage_percent.toFixed(0),"%"]})]})]})}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e.jsx(Re,{data:a,cpuColor:h,memoryColor:b})}),s.cpu.per_core_percent&&s.cpu.per_core_percent.length>0&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-x-3 gap-y-0.5",children:s.cpu.per_core_percent.map((j,N)=>e.jsx(Ae,{index:N,usage:j},N))})})]})]})}),s&&e.jsxs(e.Fragment,{children:[e.jsxs(H,{template:"compact",children:[e.jsx($,{span:12,md:6,children:e.jsx(He,{networkHistory:d,txRate:v,rxRate:c,totalBytesSent:s.network.bytes_sent,totalBytesRecv:s.network.bytes_recv,cpuColor:h,memoryColor:b,networkSlots:M})}),e.jsx($,{span:12,md:6,children:e.jsx(Le,{temperatures:s.temperatures})})]}),e.jsxs(H,{template:"compact",children:[e.jsx($,{span:12,sm:6,children:e.jsx(Oe,{usagePercent:s.memory.usage_percent,used:s.memory.used,available:s.memory.available,memoryColor:b})}),e.jsx($,{span:12,sm:6,children:e.jsx(Ue,{usagePercent:s.disk.usage_percent,used:s.disk.used,free:s.disk.free,cpuColor:h})})]}),e.jsx(H,{template:"auto",children:e.jsx(ze,{processes:n})})]})]})]})}export{ts as default}; diff --git a/frontend/dist/assets/Terminal-CrgP7ye2.js b/frontend/dist/assets/Terminal-DLdeTxtN.js similarity index 97% rename from frontend/dist/assets/Terminal-CrgP7ye2.js rename to frontend/dist/assets/Terminal-DLdeTxtN.js index 41b1852a..895cc0db 100644 --- a/frontend/dist/assets/Terminal-CrgP7ye2.js +++ b/frontend/dist/assets/Terminal-DLdeTxtN.js @@ -1,4 +1,4 @@ -var Ua=Object.defineProperty;var ja=(e,t,s)=>t in e?Ua(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var D=(e,t,s)=>ja(e,typeof t!="symbol"?t+"":t,s);import{e as li,Z as is,O as ve,e4 as Ka,e5 as rt,e6 as ei,e7 as qa,e8 as xo,dt as ko,du as Va,X as Eo,e9 as Ga,ea as Xa,eb as Ya,cC as Ja,ec as Za,ct as Qa,t as Ro,ds as el,bR as tl,ed as sl,c8 as Bo,ee as ce,bJ as il,P as rl,c6 as nl,cu as xt,ef as ol,eg as al,eh as ll,ei as hl,dX as Ur,ej as vs,ek as Mo,el as Lo,em as Do,j as m,aC as To,aK as $o,dK as jr,aD as Ao,B as cl,r as U,d as fi,m as $s,en as Kr,eo as qr,cZ as dl,ep as ul,c as ti,eq as _l,er as fl,a6 as pl,es as ml,et as gl,eu as vl}from"./index-C2xvS0Jd.js";import{g as Sl,r as yl}from"./system-Cf6Lcq9I.js";import{P as bl,B as wl,C as Cl}from"./PageLayout-Cg7r5tdt.js";import{K as Po,S as xl}from"./KeycapButton-BVIaMPId.js";import{S as Vr}from"./search-DPGHPI2q.js";import{C as kl}from"./chevron-right-C9GG0xWI.js";import"./keycap-sfx-ByZp-njj.js";/** +var Ua=Object.defineProperty;var ja=(e,t,s)=>t in e?Ua(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var D=(e,t,s)=>ja(e,typeof t!="symbol"?t+"":t,s);import{e as li,Z as is,O as ve,e4 as Ka,e5 as rt,e6 as ei,e7 as qa,e8 as xo,du as ko,dv as Va,X as Eo,e9 as Ga,ea as Xa,eb as Ya,cD as Ja,ec as Za,cu as Qa,t as Ro,dt as el,bS as tl,ed as sl,c9 as Bo,ee as ce,bK as il,P as rl,c7 as nl,cv as xt,ef as ol,eg as al,eh as ll,ei as hl,dX as Ur,ej as vs,ek as Lo,el as Mo,em as Do,j as m,aC as To,aL as $o,aE as jr,aD as Ao,B as cl,r as U,d as fi,m as $s,en as Kr,eo as qr,c_ as dl,ep as ul,c as ti,eq as _l,er as fl,a6 as pl,es as ml,et as gl,eu as vl}from"./index-D33fcA3L.js";import{g as Sl,r as yl}from"./system-4FyMIaL1.js";import{P as bl,B as wl,C as Cl}from"./PageLayout-CRN-E5xi.js";import{K as Po,S as xl}from"./KeycapButton-xWUX1i8p.js";import{S as Vr}from"./search-DN8guzpX.js";import{C as kl}from"./chevron-right-D4kUPDBw.js";import"./keycap-sfx-ByZp-njj.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -13,7 +13,7 @@ var Ua=Object.defineProperty;var ja=(e,t,s)=>t in e?Ua(e,t,{enumerable:!0,config * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Ml=[["path",{d:"M20 5a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h2.5a1.5 1.5 0 0 1 1.2.6l.6.8a1.5 1.5 0 0 0 1.2.6z",key:"a4852j"}],["path",{d:"M3 8.268a2 2 0 0 0-1 1.738V19a2 2 0 0 0 2 2h11a2 2 0 0 0 1.732-1",key:"yxbcw3"}]],Ll=li("folders",Ml);/** + */const Ll=[["path",{d:"M20 5a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h2.5a1.5 1.5 0 0 1 1.2.6l.6.8a1.5 1.5 0 0 0 1.2.6z",key:"a4852j"}],["path",{d:"M3 8.268a2 2 0 0 0-1 1.738V19a2 2 0 0 0 2 2h11a2 2 0 0 0 1.732-1",key:"yxbcw3"}]],Ml=li("folders",Ll);/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -29,19 +29,19 @@ var Ua=Object.defineProperty;var ja=(e,t,s)=>t in e?Ua(e,t,{enumerable:!0,config * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var Io=Object.defineProperty,$l=Object.getOwnPropertyDescriptor,Al=(e,t)=>{for(var s in t)Io(e,s,{get:t[s],enumerable:!0})},pe=(e,t,s,i)=>{for(var r=i>1?void 0:i?$l(t,s):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(i?o(t,s,r):o(r))||r);return i&&r&&Io(t,s,r),r},$=(e,t)=>(s,i)=>t(s,i,e),Gr="Terminal input",Oi={get:()=>Gr,set:e=>Gr=e},Xr="Too much output to announce, navigate to rows manually to read",Fi={get:()=>Xr,set:e=>Xr=e};function Pl(e){return e.replace(/\r?\n/g,"\r")}function Nl(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Il(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Ol(e,t,s,i){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");Oo(r,t,s,i)}}function Oo(e,t,s,i){e=Pl(e),e=Nl(e,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function Fo(e,t,s){let i=s.getBoundingClientRect(),r=e.clientX-i.left-10,n=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Yr(e,t,s,i,r){Fo(e,t,s),r&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}function Ct(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function hi(e,t=0,s=e.length){let i="";for(let r=t;r65535?(n-=65536,i+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):i+=String.fromCharCode(n)}return i}var Fl=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[i++]=(this._interim-55296)*1024+n-56320+65536:(t[i++]=this._interim,t[i++]=n),this._interim=0}for(let n=r;n=s)return this._interim=o,i;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[i++]=(o-55296)*1024+a-56320+65536:(t[i++]=o,t[i++]=a);continue}o!==65279&&(t[i++]=o)}return i}},Hl=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let u=!1,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let _=0,p;for(;(p=this.interim[++_]&63)&&_<4;)f<<=6,f|=p;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,k=g-_;for(;l=s)return 0;if(p=e[l++],(p&192)!==128){l--,u=!0;break}else this.interim[_++]=p,f<<=6,f|=p&63}u||(g===2?f<128?l--:t[i++]=f:g===3?f<2048||f>=55296&&f<=57343||f===65279||(t[i++]=f):f<65536||f>1114111||(t[i++]=f)),this.interim.fill(0)}let c=s-4,d=l;for(;d=s)return this.interim[0]=r,i;if(n=e[d++],(n&192)!==128){d--;continue}if(h=(r&31)<<6|n&63,h<128){d--;continue}t[i++]=h}else if((r&240)===224){if(d>=s)return this.interim[0]=r,i;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,i;if(o=e[d++],(o&192)!==128){d--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[i++]=h}else if((r&248)===240){if(d>=s)return this.interim[0]=r,i;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,i;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,i;if(a=e[d++],(a&192)!==128){d--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;t[i++]=h}}return i}},Ho="",kt=" ",xs=class Wo{constructor(){this.fg=0,this.bg=0,this.extended=new si}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Wo;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},si=class zo{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new zo(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ze=class Uo extends xs{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new si,this.combinedData=""}static fromCharData(t){let s=new Uo;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ct(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let i=t[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Jr="di$target",Hi="di$dependencies",pi=new Map;function Wl(e){return e[Hi]||[]}function Le(e){if(pi.has(e))return pi.get(e);let t=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");zl(t,s,r)};return t._id=e,pi.set(e,t),t}function zl(e,t,s){t[Jr]===t?t[Hi].push({id:e,index:s}):(t[Hi]=[{id:e,index:s}],t[Jr]=t)}var Fe=Le("BufferService"),jo=Le("CoreMouseService"),Ft=Le("CoreService"),Ul=Le("CharsetService"),Rr=Le("InstantiationService"),Ko=Le("LogService"),He=Le("OptionsService"),qo=Le("OscLinkService"),jl=Le("UnicodeService"),ks=Le("DecorationService"),Wi=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var c;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,n=new Ze,o=s.getTrimmedLength(),a=-1,h=-1,l=!1;for(let d=0;dr?r.activate(p,g,f):Kl(p,g),hover:(p,g)=>{var k;return(k=r==null?void 0:r.hover)==null?void 0:k.call(r,p,g,f)},leave:(p,g)=>{var k;return(k=r==null?void 0:r.leave)==null?void 0:k.call(r,p,g,f)}})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=d,a=n.extended.urlId):(h=-1,a=-1)}}t(i)}};Wi=pe([$(0,Fe),$(1,He),$(2,qo)],Wi);function Kl(e,t){if(confirm(`Do you want to navigate to ${t}? + */var Io=Object.defineProperty,$l=Object.getOwnPropertyDescriptor,Al=(e,t)=>{for(var s in t)Io(e,s,{get:t[s],enumerable:!0})},pe=(e,t,s,i)=>{for(var r=i>1?void 0:i?$l(t,s):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(i?o(t,s,r):o(r))||r);return i&&r&&Io(t,s,r),r},$=(e,t)=>(s,i)=>t(s,i,e),Gr="Terminal input",Oi={get:()=>Gr,set:e=>Gr=e},Xr="Too much output to announce, navigate to rows manually to read",Fi={get:()=>Xr,set:e=>Xr=e};function Pl(e){return e.replace(/\r?\n/g,"\r")}function Nl(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Il(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Ol(e,t,s,i){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");Oo(r,t,s,i)}}function Oo(e,t,s,i){e=Pl(e),e=Nl(e,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function Fo(e,t,s){let i=s.getBoundingClientRect(),r=e.clientX-i.left-10,n=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Yr(e,t,s,i,r){Fo(e,t,s),r&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}function Ct(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function hi(e,t=0,s=e.length){let i="";for(let r=t;r65535?(n-=65536,i+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):i+=String.fromCharCode(n)}return i}var Fl=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[i++]=(this._interim-55296)*1024+n-56320+65536:(t[i++]=this._interim,t[i++]=n),this._interim=0}for(let n=r;n=s)return this._interim=o,i;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[i++]=(o-55296)*1024+a-56320+65536:(t[i++]=o,t[i++]=a);continue}o!==65279&&(t[i++]=o)}return i}},Hl=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let u=!1,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let _=0,p;for(;(p=this.interim[++_]&63)&&_<4;)f<<=6,f|=p;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,k=g-_;for(;l=s)return 0;if(p=e[l++],(p&192)!==128){l--,u=!0;break}else this.interim[_++]=p,f<<=6,f|=p&63}u||(g===2?f<128?l--:t[i++]=f:g===3?f<2048||f>=55296&&f<=57343||f===65279||(t[i++]=f):f<65536||f>1114111||(t[i++]=f)),this.interim.fill(0)}let c=s-4,d=l;for(;d=s)return this.interim[0]=r,i;if(n=e[d++],(n&192)!==128){d--;continue}if(h=(r&31)<<6|n&63,h<128){d--;continue}t[i++]=h}else if((r&240)===224){if(d>=s)return this.interim[0]=r,i;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,i;if(o=e[d++],(o&192)!==128){d--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[i++]=h}else if((r&248)===240){if(d>=s)return this.interim[0]=r,i;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,i;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,i;if(a=e[d++],(a&192)!==128){d--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;t[i++]=h}}return i}},Ho="",kt=" ",xs=class Wo{constructor(){this.fg=0,this.bg=0,this.extended=new si}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Wo;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},si=class zo{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new zo(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ze=class Uo extends xs{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new si,this.combinedData=""}static fromCharData(t){let s=new Uo;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ct(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let i=t[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Jr="di$target",Hi="di$dependencies",pi=new Map;function Wl(e){return e[Hi]||[]}function Me(e){if(pi.has(e))return pi.get(e);let t=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");zl(t,s,r)};return t._id=e,pi.set(e,t),t}function zl(e,t,s){t[Jr]===t?t[Hi].push({id:e,index:s}):(t[Hi]=[{id:e,index:s}],t[Jr]=t)}var Fe=Me("BufferService"),jo=Me("CoreMouseService"),Ft=Me("CoreService"),Ul=Me("CharsetService"),Rr=Me("InstantiationService"),Ko=Me("LogService"),He=Me("OptionsService"),qo=Me("OscLinkService"),jl=Me("UnicodeService"),ks=Me("DecorationService"),Wi=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var c;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,n=new Ze,o=s.getTrimmedLength(),a=-1,h=-1,l=!1;for(let d=0;dr?r.activate(p,g,f):Kl(p,g),hover:(p,g)=>{var k;return(k=r==null?void 0:r.hover)==null?void 0:k.call(r,p,g,f)},leave:(p,g)=>{var k;return(k=r==null?void 0:r.leave)==null?void 0:k.call(r,p,g,f)}})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=d,a=n.extended.urlId):(h=-1,a=-1)}}t(i)}};Wi=pe([$(0,Fe),$(1,He),$(2,qo)],Wi);function Kl(e,t){if(confirm(`Do you want to navigate to ${t}? -WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var ci=Le("CharSizeService"),pt=Le("CoreBrowserService"),Br=Le("MouseService"),mt=Le("RenderService"),ql=Le("SelectionService"),Vo=Le("CharacterJoinerService"),es=Le("ThemeService"),Go=Le("LinkProviderService"),Vl=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Zr.isErrorNoTelemetry(e)?new Zr(e.message+` +WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var ci=Me("CharSizeService"),pt=Me("CoreBrowserService"),Br=Me("MouseService"),mt=Me("RenderService"),ql=Me("SelectionService"),Vo=Me("CharacterJoinerService"),es=Me("ThemeService"),Go=Me("LinkProviderService"),Vl=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Zr.isErrorNoTelemetry(e)?new Zr(e.message+` `+e.stack):new Error(e.message+` -`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Gl=new Vl;function zs(e){Xl(e)||Gl.onUnexpectedError(e)}var zi="Canceled";function Xl(e){return e instanceof Yl?!0:e instanceof Error&&e.name===zi&&e.message===zi}var Yl=class extends Error{constructor(){super(zi),this.name=this.message}};function Jl(e){return new Error(`Illegal argument: ${e}`)}var Zr=class Ui extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Ui)return t;let s=new Ui;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},ji=class Xo extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Xo.prototype)}};function Ke(e,t=0){return e[e.length-(1+t)]}var Zl;(e=>{function t(n){return n<0}e.isLessThan=t;function s(n){return n<=0}e.isLessThanOrEqual=s;function i(n){return n>0}e.isGreaterThan=i;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Zl||(Zl={}));function Ql(e,t){let s=this,i=!1,r;return function(){return i||(i=!0,t||(r=e.apply(s,arguments))),r}}var Yo;(e=>{function t(T){return T&&typeof T=="object"&&typeof T[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*r(T){yield T}e.single=r;function n(T){return t(T)?T:r(T)}e.wrap=n;function o(T){return T||s}e.from=o;function*a(T){for(let N=T.length-1;N>=0;N--)yield T[N]}e.reverse=a;function h(T){return!T||T[Symbol.iterator]().next().done===!0}e.isEmpty=h;function l(T){return T[Symbol.iterator]().next().value}e.first=l;function c(T,N){let H=0;for(let Z of T)if(N(Z,H++))return!0;return!1}e.some=c;function d(T,N){for(let H of T)if(N(H))return H}e.find=d;function*u(T,N){for(let H of T)N(H)&&(yield H)}e.filter=u;function*f(T,N){let H=0;for(let Z of T)yield N(Z,H++)}e.map=f;function*_(T,N){let H=0;for(let Z of T)yield*N(Z,H++)}e.flatMap=_;function*p(...T){for(let N of T)yield*N}e.concat=p;function g(T,N,H){let Z=H;for(let me of T)Z=N(Z,me);return Z}e.reduce=g;function*k(T,N,H=T.length){for(N<0&&(N+=T.length),H<0?H+=T.length:H>T.length&&(H=T.length);N1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function eh(...e){return ae(()=>It(e))}function ae(e){return{dispose:Ql(()=>{e()})}}var Jo=class Zo{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{It(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Zo.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Jo.DISABLE_DISPOSED_WARNING=!1;var Et=Jo,X=class{constructor(){this._store=new Et,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};X.None=Object.freeze({dispose(){}});var Zt=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},ft=typeof window=="object"?window:globalThis,Ki=class qi{constructor(t){this.element=t,this.next=qi.Undefined,this.prev=qi.Undefined}};Ki.Undefined=new Ki(void 0);var le=Ki,Qr=class{constructor(){this._first=le.Undefined,this._last=le.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===le.Undefined}clear(){let e=this._first;for(;e!==le.Undefined;){let t=e.next;e.prev=le.Undefined,e.next=le.Undefined,e=t}this._first=le.Undefined,this._last=le.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new le(e);if(this._first===le.Undefined)this._first=s,this._last=s;else if(t){let r=this._last;this._last=s,s.prev=r,r.next=s}else{let r=this._first;this._first=s,s.next=r,r.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==le.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==le.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==le.Undefined&&e.next!==le.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===le.Undefined&&e.next===le.Undefined?(this._first=le.Undefined,this._last=le.Undefined):e.next===le.Undefined?(this._last=this._last.prev,this._last.next=le.Undefined):e.prev===le.Undefined&&(this._first=this._first.next,this._first.prev=le.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==le.Undefined;)yield e.element,e=e.next}},th=globalThis.performance&&typeof globalThis.performance.now=="function",sh=class Qo{static create(t){return new Qo(t)}constructor(t){this._now=th&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Te;(e=>{e.None=()=>X.None;function t(P,S){return d(P,()=>{},0,void 0,!0,void 0,S)}e.defer=t;function s(P){return(S,M=null,C)=>{let L=!1,I;return I=P(R=>{if(!L)return I?I.dispose():L=!0,S.call(M,R)},null,C),L&&I.dispose(),I}}e.once=s;function i(P,S,M){return l((C,L=null,I)=>P(R=>C.call(L,S(R)),null,I),M)}e.map=i;function r(P,S,M){return l((C,L=null,I)=>P(R=>{S(R),C.call(L,R)},null,I),M)}e.forEach=r;function n(P,S,M){return l((C,L=null,I)=>P(R=>S(R)&&C.call(L,R),null,I),M)}e.filter=n;function o(P){return P}e.signal=o;function a(...P){return(S,M=null,C)=>{let L=eh(...P.map(I=>I(R=>S.call(M,R))));return c(L,C)}}e.any=a;function h(P,S,M,C){let L=M;return i(P,I=>(L=S(L,I),L),C)}e.reduce=h;function l(P,S){let M,C={onWillAddFirstListener(){M=P(L.fire,L)},onDidRemoveLastListener(){M==null||M.dispose()}},L=new x(C);return S==null||S.add(L),L.event}function c(P,S){return S instanceof Array?S.push(P):S&&S.add(P),P}function d(P,S,M=100,C=!1,L=!1,I,R){let V,ee,Se,$e=0,Ne,re={leakWarningThreshold:I,onWillAddFirstListener(){V=P(We=>{$e++,ee=S(ee,We),C&&!Se&&(Ge.fire(ee),ee=void 0),Ne=()=>{let ut=ee;ee=void 0,Se=void 0,(!C||$e>1)&&Ge.fire(ut),$e=0},typeof M=="number"?(clearTimeout(Se),Se=setTimeout(Ne,M)):Se===void 0&&(Se=0,queueMicrotask(Ne))})},onWillRemoveListener(){L&&$e>0&&(Ne==null||Ne())},onDidRemoveLastListener(){Ne=void 0,V.dispose()}},Ge=new x(re);return R==null||R.add(Ge),Ge.event}e.debounce=d;function u(P,S=0,M){return e.debounce(P,(C,L)=>C?(C.push(L),C):[L],S,void 0,!0,void 0,M)}e.accumulate=u;function f(P,S=(C,L)=>C===L,M){let C=!0,L;return n(P,I=>{let R=C||!S(I,L);return C=!1,L=I,R},M)}e.latch=f;function _(P,S,M){return[e.filter(P,S,M),e.filter(P,C=>!S(C),M)]}e.split=_;function p(P,S=!1,M=[],C){let L=M.slice(),I=P(ee=>{L?L.push(ee):V.fire(ee)});C&&C.add(I);let R=()=>{L==null||L.forEach(ee=>V.fire(ee)),L=null},V=new x({onWillAddFirstListener(){I||(I=P(ee=>V.fire(ee)),C&&C.add(I))},onDidAddFirstListener(){L&&(S?setTimeout(R):R())},onDidRemoveLastListener(){I&&I.dispose(),I=null}});return C&&C.add(V),V.event}e.buffer=p;function g(P,S){return(M,C,L)=>{let I=S(new q);return P(function(R){let V=I.evaluate(R);V!==k&&M.call(C,V)},void 0,L)}}e.chain=g;let k=Symbol("HaltChainable");class q{constructor(){this.steps=[]}map(S){return this.steps.push(S),this}forEach(S){return this.steps.push(M=>(S(M),M)),this}filter(S){return this.steps.push(M=>S(M)?M:k),this}reduce(S,M){let C=M;return this.steps.push(L=>(C=S(C,L),C)),this}latch(S=(M,C)=>M===C){let M=!0,C;return this.steps.push(L=>{let I=M||!S(L,C);return M=!1,C=L,I?L:k}),this}evaluate(S){for(let M of this.steps)if(S=M(S),S===k)break;return S}}function F(P,S,M=C=>C){let C=(...V)=>R.fire(M(...V)),L=()=>P.on(S,C),I=()=>P.removeListener(S,C),R=new x({onWillAddFirstListener:L,onDidRemoveLastListener:I});return R.event}e.fromNodeEventEmitter=F;function T(P,S,M=C=>C){let C=(...V)=>R.fire(M(...V)),L=()=>P.addEventListener(S,C),I=()=>P.removeEventListener(S,C),R=new x({onWillAddFirstListener:L,onDidRemoveLastListener:I});return R.event}e.fromDOMEventEmitter=T;function N(P){return new Promise(S=>s(P)(S))}e.toPromise=N;function H(P){let S=new x;return P.then(M=>{S.fire(M)},()=>{S.fire(void 0)}).finally(()=>{S.dispose()}),S.event}e.fromPromise=H;function Z(P,S){return P(M=>S.fire(M))}e.forward=Z;function me(P,S,M){return S(M),P(C=>S(C))}e.runAndSubscribe=me;class Y{constructor(S,M){this._observable=S,this._counter=0,this._hasChanged=!1;let C={onWillAddFirstListener:()=>{S.addObserver(this)},onDidRemoveLastListener:()=>{S.removeObserver(this)}};this.emitter=new x(C),M&&M.add(this.emitter)}beginUpdate(S){this._counter++}handlePossibleChange(S){}handleChange(S,M){this._hasChanged=!0}endUpdate(S){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function oe(P,S){return new Y(P,S).emitter.event}e.fromObservable=oe;function J(P){return(S,M,C)=>{let L=0,I=!1,R={beginUpdate(){L++},endUpdate(){L--,L===0&&(P.reportChanges(),I&&(I=!1,S.call(M)))},handlePossibleChange(){},handleChange(){I=!0}};P.addObserver(R),P.reportChanges();let V={dispose(){P.removeObserver(R)}};return C instanceof Et?C.add(V):Array.isArray(C)&&C.push(V),V}}e.fromObservableLight=J})(Te||(Te={}));var Vi=class Gi{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Gi._idPool++}`,Gi.all.add(this)}start(t){this._stopWatch=new sh,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Vi.all=new Set,Vi._idPool=0;var ih=Vi,rh=-1,ea=class ta{constructor(t,s,i=(ta._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let i=this.threshold;if(i<=0||s{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,r]of this._stacks)(!t||s{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Gl=new Vl;function zs(e){Xl(e)||Gl.onUnexpectedError(e)}var zi="Canceled";function Xl(e){return e instanceof Yl?!0:e instanceof Error&&e.name===zi&&e.message===zi}var Yl=class extends Error{constructor(){super(zi),this.name=this.message}};function Jl(e){return new Error(`Illegal argument: ${e}`)}var Zr=class Ui extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Ui)return t;let s=new Ui;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},ji=class Xo extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Xo.prototype)}};function Ke(e,t=0){return e[e.length-(1+t)]}var Zl;(e=>{function t(n){return n<0}e.isLessThan=t;function s(n){return n<=0}e.isLessThanOrEqual=s;function i(n){return n>0}e.isGreaterThan=i;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Zl||(Zl={}));function Ql(e,t){let s=this,i=!1,r;return function(){return i||(i=!0,t||(r=e.apply(s,arguments))),r}}var Yo;(e=>{function t(T){return T&&typeof T=="object"&&typeof T[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*r(T){yield T}e.single=r;function n(T){return t(T)?T:r(T)}e.wrap=n;function o(T){return T||s}e.from=o;function*a(T){for(let N=T.length-1;N>=0;N--)yield T[N]}e.reverse=a;function h(T){return!T||T[Symbol.iterator]().next().done===!0}e.isEmpty=h;function l(T){return T[Symbol.iterator]().next().value}e.first=l;function c(T,N){let H=0;for(let Z of T)if(N(Z,H++))return!0;return!1}e.some=c;function d(T,N){for(let H of T)if(N(H))return H}e.find=d;function*u(T,N){for(let H of T)N(H)&&(yield H)}e.filter=u;function*f(T,N){let H=0;for(let Z of T)yield N(Z,H++)}e.map=f;function*_(T,N){let H=0;for(let Z of T)yield*N(Z,H++)}e.flatMap=_;function*p(...T){for(let N of T)yield*N}e.concat=p;function g(T,N,H){let Z=H;for(let me of T)Z=N(Z,me);return Z}e.reduce=g;function*k(T,N,H=T.length){for(N<0&&(N+=T.length),H<0?H+=T.length:H>T.length&&(H=T.length);N1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function eh(...e){return ae(()=>It(e))}function ae(e){return{dispose:Ql(()=>{e()})}}var Jo=class Zo{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{It(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Zo.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Jo.DISABLE_DISPOSED_WARNING=!1;var Et=Jo,X=class{constructor(){this._store=new Et,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};X.None=Object.freeze({dispose(){}});var Zt=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},ft=typeof window=="object"?window:globalThis,Ki=class qi{constructor(t){this.element=t,this.next=qi.Undefined,this.prev=qi.Undefined}};Ki.Undefined=new Ki(void 0);var le=Ki,Qr=class{constructor(){this._first=le.Undefined,this._last=le.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===le.Undefined}clear(){let e=this._first;for(;e!==le.Undefined;){let t=e.next;e.prev=le.Undefined,e.next=le.Undefined,e=t}this._first=le.Undefined,this._last=le.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new le(e);if(this._first===le.Undefined)this._first=s,this._last=s;else if(t){let r=this._last;this._last=s,s.prev=r,r.next=s}else{let r=this._first;this._first=s,s.next=r,r.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==le.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==le.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==le.Undefined&&e.next!==le.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===le.Undefined&&e.next===le.Undefined?(this._first=le.Undefined,this._last=le.Undefined):e.next===le.Undefined?(this._last=this._last.prev,this._last.next=le.Undefined):e.prev===le.Undefined&&(this._first=this._first.next,this._first.prev=le.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==le.Undefined;)yield e.element,e=e.next}},th=globalThis.performance&&typeof globalThis.performance.now=="function",sh=class Qo{static create(t){return new Qo(t)}constructor(t){this._now=th&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Te;(e=>{e.None=()=>X.None;function t(P,S){return d(P,()=>{},0,void 0,!0,void 0,S)}e.defer=t;function s(P){return(S,L=null,C)=>{let M=!1,I;return I=P(R=>{if(!M)return I?I.dispose():M=!0,S.call(L,R)},null,C),M&&I.dispose(),I}}e.once=s;function i(P,S,L){return l((C,M=null,I)=>P(R=>C.call(M,S(R)),null,I),L)}e.map=i;function r(P,S,L){return l((C,M=null,I)=>P(R=>{S(R),C.call(M,R)},null,I),L)}e.forEach=r;function n(P,S,L){return l((C,M=null,I)=>P(R=>S(R)&&C.call(M,R),null,I),L)}e.filter=n;function o(P){return P}e.signal=o;function a(...P){return(S,L=null,C)=>{let M=eh(...P.map(I=>I(R=>S.call(L,R))));return c(M,C)}}e.any=a;function h(P,S,L,C){let M=L;return i(P,I=>(M=S(M,I),M),C)}e.reduce=h;function l(P,S){let L,C={onWillAddFirstListener(){L=P(M.fire,M)},onDidRemoveLastListener(){L==null||L.dispose()}},M=new x(C);return S==null||S.add(M),M.event}function c(P,S){return S instanceof Array?S.push(P):S&&S.add(P),P}function d(P,S,L=100,C=!1,M=!1,I,R){let V,ee,Se,$e=0,Ne,re={leakWarningThreshold:I,onWillAddFirstListener(){V=P(We=>{$e++,ee=S(ee,We),C&&!Se&&(Ge.fire(ee),ee=void 0),Ne=()=>{let ut=ee;ee=void 0,Se=void 0,(!C||$e>1)&&Ge.fire(ut),$e=0},typeof L=="number"?(clearTimeout(Se),Se=setTimeout(Ne,L)):Se===void 0&&(Se=0,queueMicrotask(Ne))})},onWillRemoveListener(){M&&$e>0&&(Ne==null||Ne())},onDidRemoveLastListener(){Ne=void 0,V.dispose()}},Ge=new x(re);return R==null||R.add(Ge),Ge.event}e.debounce=d;function u(P,S=0,L){return e.debounce(P,(C,M)=>C?(C.push(M),C):[M],S,void 0,!0,void 0,L)}e.accumulate=u;function f(P,S=(C,M)=>C===M,L){let C=!0,M;return n(P,I=>{let R=C||!S(I,M);return C=!1,M=I,R},L)}e.latch=f;function _(P,S,L){return[e.filter(P,S,L),e.filter(P,C=>!S(C),L)]}e.split=_;function p(P,S=!1,L=[],C){let M=L.slice(),I=P(ee=>{M?M.push(ee):V.fire(ee)});C&&C.add(I);let R=()=>{M==null||M.forEach(ee=>V.fire(ee)),M=null},V=new x({onWillAddFirstListener(){I||(I=P(ee=>V.fire(ee)),C&&C.add(I))},onDidAddFirstListener(){M&&(S?setTimeout(R):R())},onDidRemoveLastListener(){I&&I.dispose(),I=null}});return C&&C.add(V),V.event}e.buffer=p;function g(P,S){return(L,C,M)=>{let I=S(new q);return P(function(R){let V=I.evaluate(R);V!==k&&L.call(C,V)},void 0,M)}}e.chain=g;let k=Symbol("HaltChainable");class q{constructor(){this.steps=[]}map(S){return this.steps.push(S),this}forEach(S){return this.steps.push(L=>(S(L),L)),this}filter(S){return this.steps.push(L=>S(L)?L:k),this}reduce(S,L){let C=L;return this.steps.push(M=>(C=S(C,M),C)),this}latch(S=(L,C)=>L===C){let L=!0,C;return this.steps.push(M=>{let I=L||!S(M,C);return L=!1,C=M,I?M:k}),this}evaluate(S){for(let L of this.steps)if(S=L(S),S===k)break;return S}}function F(P,S,L=C=>C){let C=(...V)=>R.fire(L(...V)),M=()=>P.on(S,C),I=()=>P.removeListener(S,C),R=new x({onWillAddFirstListener:M,onDidRemoveLastListener:I});return R.event}e.fromNodeEventEmitter=F;function T(P,S,L=C=>C){let C=(...V)=>R.fire(L(...V)),M=()=>P.addEventListener(S,C),I=()=>P.removeEventListener(S,C),R=new x({onWillAddFirstListener:M,onDidRemoveLastListener:I});return R.event}e.fromDOMEventEmitter=T;function N(P){return new Promise(S=>s(P)(S))}e.toPromise=N;function H(P){let S=new x;return P.then(L=>{S.fire(L)},()=>{S.fire(void 0)}).finally(()=>{S.dispose()}),S.event}e.fromPromise=H;function Z(P,S){return P(L=>S.fire(L))}e.forward=Z;function me(P,S,L){return S(L),P(C=>S(C))}e.runAndSubscribe=me;class Y{constructor(S,L){this._observable=S,this._counter=0,this._hasChanged=!1;let C={onWillAddFirstListener:()=>{S.addObserver(this)},onDidRemoveLastListener:()=>{S.removeObserver(this)}};this.emitter=new x(C),L&&L.add(this.emitter)}beginUpdate(S){this._counter++}handlePossibleChange(S){}handleChange(S,L){this._hasChanged=!0}endUpdate(S){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function oe(P,S){return new Y(P,S).emitter.event}e.fromObservable=oe;function J(P){return(S,L,C)=>{let M=0,I=!1,R={beginUpdate(){M++},endUpdate(){M--,M===0&&(P.reportChanges(),I&&(I=!1,S.call(L)))},handlePossibleChange(){},handleChange(){I=!0}};P.addObserver(R),P.reportChanges();let V={dispose(){P.removeObserver(R)}};return C instanceof Et?C.add(V):Array.isArray(C)&&C.push(V),V}}e.fromObservableLight=J})(Te||(Te={}));var Vi=class Gi{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Gi._idPool++}`,Gi.all.add(this)}start(t){this._stopWatch=new sh,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Vi.all=new Set,Vi._idPool=0;var ih=Vi,rh=-1,ea=class ta{constructor(t,s,i=(ta._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let i=this.threshold;if(i<=0||s{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,r]of this._stacks)(!t||s{var a,h,l,c,d;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],_=new lh(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((a=this._options)==null?void 0:a.onListenerError)||zs)(_),X.None}if(this._disposed)return X.None;s&&(t=t.bind(s));let r=new mi(t),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=oh.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof mi?(this._deliveryQueue??(this._deliveryQueue=new uh),this._listeners=[this._listeners,r]):this._listeners.push(r):((l=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||l.call(h,this),this._listeners=r,(d=(c=this._options)==null?void 0:c.onDidAddFirstListener)==null||d.call(c,this)),this._size++;let o=ae(()=>{n==null||n(),this._removeListener(r)});return i instanceof Et?i.add(o):Array.isArray(i)&&i.push(o),o}),this._event}_removeListener(t){var n,o,a,h;if((o=(n=this._options)==null?void 0:n.onWillRemoveListener)==null||o.call(n,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(a=this._options)==null?void 0:a.onDidRemoveLastListener)==null||h.call(a,this),this._size=0;return}let s=this._listeners,i=s.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,s[i]=void 0;let r=this._deliveryQueue.current===this;if(this._size*ch<=s.length){let l=0;for(let c=0;c0}},uh=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Xi=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new x,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new x,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Xi.INSTANCE=new Xi;var Mr=Xi;function _h(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}Mr.INSTANCE.onDidChangeZoomLevel;function fh(e){return Mr.INSTANCE.getZoomFactor(e)}Mr.INSTANCE.onDidChangeFullscreen;var ts=typeof navigator=="object"?navigator.userAgent:"",Yi=ts.indexOf("Firefox")>=0,ph=ts.indexOf("AppleWebKit")>=0,Lr=ts.indexOf("Chrome")>=0,mh=!Lr&&ts.indexOf("Safari")>=0;ts.indexOf("Electron/")>=0;ts.indexOf("Android")>=0;var gi=!1;if(typeof ft.matchMedia=="function"){let e=ft.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=ft.matchMedia("(display-mode: fullscreen)");gi=e.matches,_h(ft,e,({matches:s})=>{gi&&t.matches||(gi=s)})}var Gt="en",Ji=!1,Zi=!1,Us=!1,ia=!1,As,js=Gt,en=Gt,gh,tt,Nt=globalThis,De,bo;typeof Nt.vscode<"u"&&typeof Nt.vscode.process<"u"?De=Nt.vscode.process:typeof process<"u"&&typeof((bo=process==null?void 0:process.versions)==null?void 0:bo.node)=="string"&&(De=process);var wo,vh=typeof((wo=De==null?void 0:De.versions)==null?void 0:wo.electron)=="string",Sh=vh&&(De==null?void 0:De.type)==="renderer",Co;if(typeof De=="object"){Ji=De.platform==="win32",Zi=De.platform==="darwin",Us=De.platform==="linux",Us&&De.env.SNAP&&De.env.SNAP_REVISION,De.env.CI||De.env.BUILD_ARTIFACTSTAGINGDIRECTORY,As=Gt,js=Gt;let e=De.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);As=t.userLocale,en=t.osLocale,js=t.resolvedLanguage||Gt,gh=(Co=t.languagePack)==null?void 0:Co.translationsConfigFile}catch{}ia=!0}else typeof navigator=="object"&&!Sh?(tt=navigator.userAgent,Ji=tt.indexOf("Windows")>=0,Zi=tt.indexOf("Macintosh")>=0,(tt.indexOf("Macintosh")>=0||tt.indexOf("iPad")>=0||tt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Us=tt.indexOf("Linux")>=0,(tt==null?void 0:tt.indexOf("Mobi"))>=0,js=globalThis._VSCODE_NLS_LANGUAGE||Gt,As=navigator.language.toLowerCase(),en=As):console.error("Unable to resolve platform.");var ra=Ji,ct=Zi,yh=Us,tn=ia,dt=tt,vt=js,bh;(e=>{function t(){return vt}e.value=t;function s(){return vt.length===2?vt==="en":vt.length>=3?vt[0]==="e"&&vt[1]==="n"&&vt[2]==="-":!1}e.isDefaultVariant=s;function i(){return vt==="en"}e.isDefault=i})(bh||(bh={}));var wh=typeof Nt.postMessage=="function"&&!Nt.importScripts;(()=>{if(wh){let e=[];Nt.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i{let i=++t;e.push({id:i,callback:s}),Nt.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var Ch=!!(dt&&dt.indexOf("Chrome")>=0);dt&&dt.indexOf("Firefox")>=0;!Ch&&dt&&dt.indexOf("Safari")>=0;dt&&dt.indexOf("Edg/")>=0;dt&&dt.indexOf("Android")>=0;var Ut=typeof navigator=="object"?navigator:{};tn||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ut&&Ut.clipboard&&Ut.clipboard.writeText,tn||Ut&&Ut.clipboard&&Ut.clipboard.readText;var Dr=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},vi=new Dr,sn=new Dr,rn=new Dr,xh=new Array(230),na;(e=>{function t(a){return vi.keyCodeToStr(a)}e.toString=t;function s(a){return vi.strToKeyCode(a)}e.fromString=s;function i(a){return sn.keyCodeToStr(a)}e.toUserSettingsUS=i;function r(a){return rn.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function n(a){return sn.strToKeyCode(a)||rn.strToKeyCode(a)}e.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return vi.keyCodeToStr(a)}e.toElectronAccelerator=o})(na||(na={}));var kh=class oa{constructor(t,s,i,r,n){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof oa&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${s}${i}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Eh([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Eh=class{constructor(e){if(e.length===0)throw Jl("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t{function t(s){return s===e.None||s===e.Cancelled||s instanceof Ph?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Te.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:aa})})(Ah||(Ah={}));var Ph=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?aa:(this._emitter||(this._emitter=new x),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Tr=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new ji("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new ji("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Nh=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new ji("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=ae(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Ih;(e=>{async function t(i){let r,n=await Promise.all(i.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function s(i){return new Promise(async(r,n)=>{try{await i(r,n)}catch(o){n(o)}})}e.withAsyncBody=s})(Ih||(Ih={}));var ln=class Ye{static fromArray(t){return new Ye(s=>{s.emitMany(t)})}static fromPromise(t){return new Ye(async s=>{s.emitMany(await t)})}static fromPromises(t){return new Ye(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new Ye(async s=>{await Promise.all(t.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new x,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new Ye(async i=>{for await(let r of t)i.emitOne(s(r))})}map(t){return Ye.map(this,t)}static filter(t,s){return new Ye(async i=>{for await(let r of t)s(r)&&i.emitOne(r)})}filter(t){return Ye.filter(this,t)}static coalesce(t){return Ye.filter(t,s=>!!s)}coalesce(){return Ye.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return Ye.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};ln.EMPTY=ln.fromArray([]);var{getWindow:ht,getWindowId:Oh,onDidRegisterWindow:Fh}=(function(){let e=new Map,t={window:ft,disposables:new Et};e.set(ft.vscodeWindowId,t);let s=new x,i=new x,r=new x;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:i.event,registerWindow(o){if(e.has(o.vscodeWindowId))return X.None;let a=new Et,h={window:o,disposables:a.add(new Et)};return e.set(o.vscodeWindowId,h),a.add(ae(()=>{e.delete(o.vscodeWindowId),i.fire(o)})),a.add(j(o,Ee.BEFORE_UNLOAD,()=>{r.fire(o)})),s.fire(h),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var l;let a=o;if((l=a==null?void 0:a.ownerDocument)!=null&&l.defaultView)return a.ownerDocument.defaultView.window;let h=o;return h!=null&&h.view?h.view.window:ft},getDocument(o){return ht(o).document}}})(),Hh=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function j(e,t,s,i){return new Hh(e,t,s,i)}var hn=function(e,t,s,i){return j(e,t,s,i)},$r,Wh=class extends Nh{constructor(e){super(),this.defaultTarget=e&&ht(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},cn=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){zs(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,r=n=>{s.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),i.set(n,!0);o.length>0;)o.sort(cn.sort),o.shift().execute();i.set(n,!1)};$r=(n,o,a=0)=>{let h=Oh(n),l=new cn(o,a),c=e.get(h);return c||(c=[],e.set(h,c)),c.push(l),s.get(h)||(s.set(h,!0),n.requestAnimationFrame(()=>r(h))),l}})();function zh(e){let t=e.getBoundingClientRect(),s=ht(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Ee={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Uh=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=ze(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=ze(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=ze(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=ze(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=ze(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=ze(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=ze(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=ze(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=ze(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=ze(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=ze(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=ze(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=ze(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=ze(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function ze(e){return typeof e=="number"?`${e}px`:e}function Ss(e){return new Uh(e)}var la=class{constructor(){this._hooks=new Et,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(ae(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=ht(e)}this._hooks.add(j(n,Ee.POINTER_MOVE,o=>{if(o.buttons!==s){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(j(n,Ee.POINTER_UP,o=>this.stopMonitoring(!0)))}};function jh(e,t,s){let i=null,r=null;if(typeof s.value=="function"?(i="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",r=s.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;s[i]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var lt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(lt||(lt={}));var us=class Ae extends X{constructor(){super(),this.dispatched=!1,this.targets=new Qr,this.ignoreTargets=new Qr,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Te.runAndSubscribe(Fh,({window:t,disposables:s})=>{s.add(j(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(j(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(j(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:ft,disposables:this._store}))}static addTarget(t){if(!Ae.isTouchDevice())return X.None;Ae.INSTANCE||(Ae.INSTANCE=new Ae);let s=Ae.INSTANCE.targets.push(t);return ae(s)}static ignoreTarget(t){if(!Ae.isTouchDevice())return X.None;Ae.INSTANCE||(Ae.INSTANCE=new Ae);let s=Ae.INSTANCE.ignoreTargets.push(t);return ae(s)}static isTouchDevice(){return"ontouchstart"in ft||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,r=t.targetTouches.length;i=Ae.HOLD_DELAY&&Math.abs(h.initialPageX-Ke(h.rollingPageX))<30&&Math.abs(h.initialPageY-Ke(h.rollingPageY))<30){let c=this.newGestureEvent(lt.Contextmenu,h.initialTarget);c.pageX=Ke(h.rollingPageX),c.pageY=Ke(h.rollingPageY),this.dispatchEvent(c)}else if(r===1){let c=Ke(h.rollingPageX),d=Ke(h.rollingPageY),u=Ke(h.rollingTimestamps)-h.rollingTimestamps[0],f=c-h.rollingPageX[0],_=d-h.rollingPageY[0],p=[...this.targets].filter(g=>h.initialTarget instanceof Node&&g.contains(h.initialTarget));this.inertia(t,p,i,Math.abs(f)/u,f>0?1:-1,c,Math.abs(_)/u,_>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(lt.End,h.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===lt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>Ae.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===lt.Change||t.type===lt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==i;)r++,n=n.parentElement;s.push([r,i])}s.sort((i,r)=>i[0]-r[0]);for(let[i,r]of s)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,r,n,o,a,h,l){this.handle=$r(t,()=>{let c=Date.now(),d=c-i,u=0,f=0,_=!0;r+=Ae.SCROLL_FRICTION*d,a+=Ae.SCROLL_FRICTION*d,r>0&&(_=!1,u=n*r*d),a>0&&(_=!1,f=h*a*d);let p=this.newGestureEvent(lt.Change);p.translationX=u,p.translationY=f,s.forEach(g=>g.dispatchEvent(p)),_||this.inertia(t,s,c,r,n,o+u,a,h,l+f)})}onTouchMove(t){let s=Date.now();for(let i=0,r=t.changedTouches.length;i3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};us.SCROLL_FRICTION=-.005,us.HOLD_DELAY=700,us.CLEAR_TAP_COUNT_TIME=400,pe([jh],us,"isTouchDevice",1);var Kh=us,Ar=class extends X{onclick(e,t){this._register(j(e,Ee.CLICK,s=>t(new Ps(ht(e),s))))}onmousedown(e,t){this._register(j(e,Ee.MOUSE_DOWN,s=>t(new Ps(ht(e),s))))}onmouseover(e,t){this._register(j(e,Ee.MOUSE_OVER,s=>t(new Ps(ht(e),s))))}onmouseleave(e,t){this._register(j(e,Ee.MOUSE_LEAVE,s=>t(new Ps(ht(e),s))))}onkeydown(e,t){this._register(j(e,Ee.KEY_DOWN,s=>t(new nn(s))))}onkeyup(e,t){this._register(j(e,Ee.KEY_UP,s=>t(new nn(s))))}oninput(e,t){this._register(j(e,Ee.INPUT,t))}onblur(e,t){this._register(j(e,Ee.BLUR,t))}onfocus(e,t){this._register(j(e,Ee.FOCUS,t))}onchange(e,t){this._register(j(e,Ee.CHANGE,t))}ignoreGesture(e){return Kh.ignoreTarget(e)}},dn=11,qh=class extends Ar{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=dn+"px",this.domNode.style.height=dn+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new la),this._register(hn(this.bgDomNode,Ee.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(hn(this.domNode,Ee.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Wh),this._pointerdownScheduleRepeatTimer=this._register(new Tr)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ht(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Vh=class Qi{constructor(t,s,i,r,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,s<0&&(s=0),r+s>i&&(r=i-s),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new Qi(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Qi(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let i=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:h}}},Gh=class extends X{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new x),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Vh(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var i;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new _n(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=_n.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},un=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function Si(e,t){let s=t-e;return function(i){return e+s*Jh(i)}}function Xh(e,t,s){return function(i){return i2.5*i){let r,n;return t{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},Qh=140,ha=class extends Ar{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Zh(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new la),this._shouldRender=!0,this.domNode=Ss(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(j(this.domNode.domNode,Ee.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new qh(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=Ss(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(j(this.slider.domNode,Ee.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);s<=r&&r<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let r=zh(this.domNode.domNode);t=e.pageX-r.left,s=e.pageY-r.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-s);if(ra&&o>Qh){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},ca=class tr{constructor(t,s,i,r,n,o){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new tr(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,r,n){let o=Math.max(0,i-t),a=Math.max(0,o-2*s),h=r>0&&r>i;if(!h)return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(i*a/r))),c=(a-l)/(r-i),d=n*c;return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:c,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=tr._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(s.deltaX),a=Math.abs(s.deltaY),h=Math.max(Math.min(r,o),1),l=Math.max(Math.min(n,a),1),c=Math.max(r,o),d=Math.max(n,a);c%h===0&&d%l===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};sr.INSTANCE=new sr;var rc=sr,nc=class extends Ar{constructor(e,t,s){super(),this._onScroll=this._register(new x),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new x),this.onWillScroll=this._onWillScroll.event,this._options=ac(t),this._scrollable=s,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let i={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new tc(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new ec(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Ss(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ss(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ss(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Tr),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=It(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,ct&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new an(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=It(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new an(s))};this._mouseWheelToDispose.push(j(this._listenOnDomNode,Ee.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=rc.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let a=!ct&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),l={};if(n){let c=fn*n,d=h.scrollTop-(c<0?Math.floor(c):Math.ceil(c));this._verticalScrollbar.writeScrollPosition(l,d)}if(o){let c=fn*o,d=h.scrollLeft-(c<0?Math.floor(c):Math.ceil(c));this._horizontalScrollbar.writeScrollPosition(l,d)}l=this._scrollable.validateScrollPosition(l),(h.scrollLeft!==l.scrollLeft||h.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",r=t?" top":"",n=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),sc)}},oc=class extends nc{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function ac(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,ct&&(t.className+=" mac"),t}var ir=class extends X{constructor(e,t,s,i,r,n,o,a){super(),this._bufferService=s,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new x),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Gh({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>$r(i.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new oc(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(l=>{this._scrollableElement.updateOptions({handleMouseWheel:!(l&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Te.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ae(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ae(()=>this._styleElement.remove())),this._register(Te.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(` +`))}},ah=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},lh=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},hh=0,mi=class{constructor(e){this.value=e,this.id=hh++}},ch=2,dh,x=class{constructor(t){var s,i,r,n;this._size=0,this._options=t,this._leakageMon=(s=this._options)!=null&&s.leakWarningThreshold?new nh((t==null?void 0:t.onListenerError)??zs,((i=this._options)==null?void 0:i.leakWarningThreshold)??rh):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new ih(this._options._profName):void 0,this._deliveryQueue=(n=this._options)==null?void 0:n.deliveryQueue}dispose(){var t,s,i,r;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(s=this._options)==null?void 0:s.onDidRemoveLastListener)==null||i.call(s),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(t,s,i)=>{var a,h,l,c,d;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],_=new lh(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((a=this._options)==null?void 0:a.onListenerError)||zs)(_),X.None}if(this._disposed)return X.None;s&&(t=t.bind(s));let r=new mi(t),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=oh.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof mi?(this._deliveryQueue??(this._deliveryQueue=new uh),this._listeners=[this._listeners,r]):this._listeners.push(r):((l=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||l.call(h,this),this._listeners=r,(d=(c=this._options)==null?void 0:c.onDidAddFirstListener)==null||d.call(c,this)),this._size++;let o=ae(()=>{n==null||n(),this._removeListener(r)});return i instanceof Et?i.add(o):Array.isArray(i)&&i.push(o),o}),this._event}_removeListener(t){var n,o,a,h;if((o=(n=this._options)==null?void 0:n.onWillRemoveListener)==null||o.call(n,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(a=this._options)==null?void 0:a.onDidRemoveLastListener)==null||h.call(a,this),this._size=0;return}let s=this._listeners,i=s.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,s[i]=void 0;let r=this._deliveryQueue.current===this;if(this._size*ch<=s.length){let l=0;for(let c=0;c0}},uh=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Xi=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new x,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new x,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Xi.INSTANCE=new Xi;var Lr=Xi;function _h(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}Lr.INSTANCE.onDidChangeZoomLevel;function fh(e){return Lr.INSTANCE.getZoomFactor(e)}Lr.INSTANCE.onDidChangeFullscreen;var ts=typeof navigator=="object"?navigator.userAgent:"",Yi=ts.indexOf("Firefox")>=0,ph=ts.indexOf("AppleWebKit")>=0,Mr=ts.indexOf("Chrome")>=0,mh=!Mr&&ts.indexOf("Safari")>=0;ts.indexOf("Electron/")>=0;ts.indexOf("Android")>=0;var gi=!1;if(typeof ft.matchMedia=="function"){let e=ft.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=ft.matchMedia("(display-mode: fullscreen)");gi=e.matches,_h(ft,e,({matches:s})=>{gi&&t.matches||(gi=s)})}var Gt="en",Ji=!1,Zi=!1,Us=!1,ia=!1,As,js=Gt,en=Gt,gh,tt,Nt=globalThis,De,bo;typeof Nt.vscode<"u"&&typeof Nt.vscode.process<"u"?De=Nt.vscode.process:typeof process<"u"&&typeof((bo=process==null?void 0:process.versions)==null?void 0:bo.node)=="string"&&(De=process);var wo,vh=typeof((wo=De==null?void 0:De.versions)==null?void 0:wo.electron)=="string",Sh=vh&&(De==null?void 0:De.type)==="renderer",Co;if(typeof De=="object"){Ji=De.platform==="win32",Zi=De.platform==="darwin",Us=De.platform==="linux",Us&&De.env.SNAP&&De.env.SNAP_REVISION,De.env.CI||De.env.BUILD_ARTIFACTSTAGINGDIRECTORY,As=Gt,js=Gt;let e=De.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);As=t.userLocale,en=t.osLocale,js=t.resolvedLanguage||Gt,gh=(Co=t.languagePack)==null?void 0:Co.translationsConfigFile}catch{}ia=!0}else typeof navigator=="object"&&!Sh?(tt=navigator.userAgent,Ji=tt.indexOf("Windows")>=0,Zi=tt.indexOf("Macintosh")>=0,(tt.indexOf("Macintosh")>=0||tt.indexOf("iPad")>=0||tt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Us=tt.indexOf("Linux")>=0,(tt==null?void 0:tt.indexOf("Mobi"))>=0,js=globalThis._VSCODE_NLS_LANGUAGE||Gt,As=navigator.language.toLowerCase(),en=As):console.error("Unable to resolve platform.");var ra=Ji,ct=Zi,yh=Us,tn=ia,dt=tt,vt=js,bh;(e=>{function t(){return vt}e.value=t;function s(){return vt.length===2?vt==="en":vt.length>=3?vt[0]==="e"&&vt[1]==="n"&&vt[2]==="-":!1}e.isDefaultVariant=s;function i(){return vt==="en"}e.isDefault=i})(bh||(bh={}));var wh=typeof Nt.postMessage=="function"&&!Nt.importScripts;(()=>{if(wh){let e=[];Nt.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i{let i=++t;e.push({id:i,callback:s}),Nt.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var Ch=!!(dt&&dt.indexOf("Chrome")>=0);dt&&dt.indexOf("Firefox")>=0;!Ch&&dt&&dt.indexOf("Safari")>=0;dt&&dt.indexOf("Edg/")>=0;dt&&dt.indexOf("Android")>=0;var Ut=typeof navigator=="object"?navigator:{};tn||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ut&&Ut.clipboard&&Ut.clipboard.writeText,tn||Ut&&Ut.clipboard&&Ut.clipboard.readText;var Dr=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},vi=new Dr,sn=new Dr,rn=new Dr,xh=new Array(230),na;(e=>{function t(a){return vi.keyCodeToStr(a)}e.toString=t;function s(a){return vi.strToKeyCode(a)}e.fromString=s;function i(a){return sn.keyCodeToStr(a)}e.toUserSettingsUS=i;function r(a){return rn.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function n(a){return sn.strToKeyCode(a)||rn.strToKeyCode(a)}e.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return vi.keyCodeToStr(a)}e.toElectronAccelerator=o})(na||(na={}));var kh=class oa{constructor(t,s,i,r,n){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof oa&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${s}${i}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Eh([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Eh=class{constructor(e){if(e.length===0)throw Jl("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t{function t(s){return s===e.None||s===e.Cancelled||s instanceof Ph?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Te.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:aa})})(Ah||(Ah={}));var Ph=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?aa:(this._emitter||(this._emitter=new x),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Tr=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new ji("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new ji("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Nh=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new ji("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=ae(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Ih;(e=>{async function t(i){let r,n=await Promise.all(i.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function s(i){return new Promise(async(r,n)=>{try{await i(r,n)}catch(o){n(o)}})}e.withAsyncBody=s})(Ih||(Ih={}));var ln=class Ye{static fromArray(t){return new Ye(s=>{s.emitMany(t)})}static fromPromise(t){return new Ye(async s=>{s.emitMany(await t)})}static fromPromises(t){return new Ye(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new Ye(async s=>{await Promise.all(t.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new x,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new Ye(async i=>{for await(let r of t)i.emitOne(s(r))})}map(t){return Ye.map(this,t)}static filter(t,s){return new Ye(async i=>{for await(let r of t)s(r)&&i.emitOne(r)})}filter(t){return Ye.filter(this,t)}static coalesce(t){return Ye.filter(t,s=>!!s)}coalesce(){return Ye.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return Ye.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};ln.EMPTY=ln.fromArray([]);var{getWindow:ht,getWindowId:Oh,onDidRegisterWindow:Fh}=(function(){let e=new Map,t={window:ft,disposables:new Et};e.set(ft.vscodeWindowId,t);let s=new x,i=new x,r=new x;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:i.event,registerWindow(o){if(e.has(o.vscodeWindowId))return X.None;let a=new Et,h={window:o,disposables:a.add(new Et)};return e.set(o.vscodeWindowId,h),a.add(ae(()=>{e.delete(o.vscodeWindowId),i.fire(o)})),a.add(j(o,Ee.BEFORE_UNLOAD,()=>{r.fire(o)})),s.fire(h),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var l;let a=o;if((l=a==null?void 0:a.ownerDocument)!=null&&l.defaultView)return a.ownerDocument.defaultView.window;let h=o;return h!=null&&h.view?h.view.window:ft},getDocument(o){return ht(o).document}}})(),Hh=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function j(e,t,s,i){return new Hh(e,t,s,i)}var hn=function(e,t,s,i){return j(e,t,s,i)},$r,Wh=class extends Nh{constructor(e){super(),this.defaultTarget=e&&ht(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},cn=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){zs(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,r=n=>{s.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),i.set(n,!0);o.length>0;)o.sort(cn.sort),o.shift().execute();i.set(n,!1)};$r=(n,o,a=0)=>{let h=Oh(n),l=new cn(o,a),c=e.get(h);return c||(c=[],e.set(h,c)),c.push(l),s.get(h)||(s.set(h,!0),n.requestAnimationFrame(()=>r(h))),l}})();function zh(e){let t=e.getBoundingClientRect(),s=ht(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Ee={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Uh=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=ze(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=ze(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=ze(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=ze(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=ze(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=ze(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=ze(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=ze(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=ze(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=ze(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=ze(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=ze(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=ze(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=ze(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function ze(e){return typeof e=="number"?`${e}px`:e}function Ss(e){return new Uh(e)}var la=class{constructor(){this._hooks=new Et,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(ae(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=ht(e)}this._hooks.add(j(n,Ee.POINTER_MOVE,o=>{if(o.buttons!==s){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(j(n,Ee.POINTER_UP,o=>this.stopMonitoring(!0)))}};function jh(e,t,s){let i=null,r=null;if(typeof s.value=="function"?(i="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",r=s.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;s[i]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var lt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(lt||(lt={}));var us=class Ae extends X{constructor(){super(),this.dispatched=!1,this.targets=new Qr,this.ignoreTargets=new Qr,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Te.runAndSubscribe(Fh,({window:t,disposables:s})=>{s.add(j(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(j(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(j(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:ft,disposables:this._store}))}static addTarget(t){if(!Ae.isTouchDevice())return X.None;Ae.INSTANCE||(Ae.INSTANCE=new Ae);let s=Ae.INSTANCE.targets.push(t);return ae(s)}static ignoreTarget(t){if(!Ae.isTouchDevice())return X.None;Ae.INSTANCE||(Ae.INSTANCE=new Ae);let s=Ae.INSTANCE.ignoreTargets.push(t);return ae(s)}static isTouchDevice(){return"ontouchstart"in ft||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,r=t.targetTouches.length;i=Ae.HOLD_DELAY&&Math.abs(h.initialPageX-Ke(h.rollingPageX))<30&&Math.abs(h.initialPageY-Ke(h.rollingPageY))<30){let c=this.newGestureEvent(lt.Contextmenu,h.initialTarget);c.pageX=Ke(h.rollingPageX),c.pageY=Ke(h.rollingPageY),this.dispatchEvent(c)}else if(r===1){let c=Ke(h.rollingPageX),d=Ke(h.rollingPageY),u=Ke(h.rollingTimestamps)-h.rollingTimestamps[0],f=c-h.rollingPageX[0],_=d-h.rollingPageY[0],p=[...this.targets].filter(g=>h.initialTarget instanceof Node&&g.contains(h.initialTarget));this.inertia(t,p,i,Math.abs(f)/u,f>0?1:-1,c,Math.abs(_)/u,_>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(lt.End,h.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===lt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>Ae.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===lt.Change||t.type===lt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==i;)r++,n=n.parentElement;s.push([r,i])}s.sort((i,r)=>i[0]-r[0]);for(let[i,r]of s)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,r,n,o,a,h,l){this.handle=$r(t,()=>{let c=Date.now(),d=c-i,u=0,f=0,_=!0;r+=Ae.SCROLL_FRICTION*d,a+=Ae.SCROLL_FRICTION*d,r>0&&(_=!1,u=n*r*d),a>0&&(_=!1,f=h*a*d);let p=this.newGestureEvent(lt.Change);p.translationX=u,p.translationY=f,s.forEach(g=>g.dispatchEvent(p)),_||this.inertia(t,s,c,r,n,o+u,a,h,l+f)})}onTouchMove(t){let s=Date.now();for(let i=0,r=t.changedTouches.length;i3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};us.SCROLL_FRICTION=-.005,us.HOLD_DELAY=700,us.CLEAR_TAP_COUNT_TIME=400,pe([jh],us,"isTouchDevice",1);var Kh=us,Ar=class extends X{onclick(e,t){this._register(j(e,Ee.CLICK,s=>t(new Ps(ht(e),s))))}onmousedown(e,t){this._register(j(e,Ee.MOUSE_DOWN,s=>t(new Ps(ht(e),s))))}onmouseover(e,t){this._register(j(e,Ee.MOUSE_OVER,s=>t(new Ps(ht(e),s))))}onmouseleave(e,t){this._register(j(e,Ee.MOUSE_LEAVE,s=>t(new Ps(ht(e),s))))}onkeydown(e,t){this._register(j(e,Ee.KEY_DOWN,s=>t(new nn(s))))}onkeyup(e,t){this._register(j(e,Ee.KEY_UP,s=>t(new nn(s))))}oninput(e,t){this._register(j(e,Ee.INPUT,t))}onblur(e,t){this._register(j(e,Ee.BLUR,t))}onfocus(e,t){this._register(j(e,Ee.FOCUS,t))}onchange(e,t){this._register(j(e,Ee.CHANGE,t))}ignoreGesture(e){return Kh.ignoreTarget(e)}},dn=11,qh=class extends Ar{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=dn+"px",this.domNode.style.height=dn+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new la),this._register(hn(this.bgDomNode,Ee.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(hn(this.domNode,Ee.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Wh),this._pointerdownScheduleRepeatTimer=this._register(new Tr)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ht(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Vh=class Qi{constructor(t,s,i,r,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,s<0&&(s=0),r+s>i&&(r=i-s),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new Qi(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Qi(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let i=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:h}}},Gh=class extends X{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new x),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Vh(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var i;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new _n(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=_n.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},un=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function Si(e,t){let s=t-e;return function(i){return e+s*Jh(i)}}function Xh(e,t,s){return function(i){return i2.5*i){let r,n;return t{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},Qh=140,ha=class extends Ar{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Zh(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new la),this._shouldRender=!0,this.domNode=Ss(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(j(this.domNode.domNode,Ee.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new qh(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=Ss(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(j(this.slider.domNode,Ee.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);s<=r&&r<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let r=zh(this.domNode.domNode);t=e.pageX-r.left,s=e.pageY-r.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-s);if(ra&&o>Qh){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},ca=class tr{constructor(t,s,i,r,n,o){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new tr(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,r,n){let o=Math.max(0,i-t),a=Math.max(0,o-2*s),h=r>0&&r>i;if(!h)return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(i*a/r))),c=(a-l)/(r-i),d=n*c;return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:c,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=tr._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(s.deltaX),a=Math.abs(s.deltaY),h=Math.max(Math.min(r,o),1),l=Math.max(Math.min(n,a),1),c=Math.max(r,o),d=Math.max(n,a);c%h===0&&d%l===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};sr.INSTANCE=new sr;var rc=sr,nc=class extends Ar{constructor(e,t,s){super(),this._onScroll=this._register(new x),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new x),this.onWillScroll=this._onWillScroll.event,this._options=ac(t),this._scrollable=s,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let i={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new tc(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new ec(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Ss(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ss(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ss(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Tr),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=It(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,ct&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new an(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=It(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new an(s))};this._mouseWheelToDispose.push(j(this._listenOnDomNode,Ee.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=rc.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let a=!ct&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),l={};if(n){let c=fn*n,d=h.scrollTop-(c<0?Math.floor(c):Math.ceil(c));this._verticalScrollbar.writeScrollPosition(l,d)}if(o){let c=fn*o,d=h.scrollLeft-(c<0?Math.floor(c):Math.ceil(c));this._horizontalScrollbar.writeScrollPosition(l,d)}l=this._scrollable.validateScrollPosition(l),(h.scrollLeft!==l.scrollLeft||h.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",r=t?" top":"",n=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),sc)}},oc=class extends nc{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function ac(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,ct&&(t.className+=" mac"),t}var ir=class extends X{constructor(e,t,s,i,r,n,o,a){super(),this._bufferService=s,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new x),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Gh({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>$r(i.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new oc(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(l=>{this._scrollableElement.updateOptions({handleMouseWheel:!(l&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Te.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ae(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ae(()=>this._styleElement.remove())),this._register(Te.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(` `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(l=>this._handleScroll(l)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};ir=pe([$(2,Fe),$(3,pt),$(4,jo),$(5,es),$(6,He),$(7,mt)],ir);var rr=class extends X{constructor(e,t,s,i,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=i,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(n=>this._removeDecoration(n))),this._register(ae(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var i;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((i=e==null?void 0:e.options)==null?void 0:i.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};rr=pe([$(1,Fe),$(2,pt),$(3,ks),$(4,mt)],rr);var lc=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ot={full:0,left:0,center:0,right:0},St={full:0,left:0,center:0,right:0},rs={full:0,left:0,center:0,right:0},ii=class extends X{constructor(e,t,s,i,r,n,o,a){var l;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=i,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new lc,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(l=this._viewportElement.parentElement)==null||l.insertBefore(this._canvas,this._viewportElement),this._register(ae(()=>{var c;return(c=this._canvas)==null?void 0:c.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);St.full=this._canvas.width,St.left=e,St.center=t,St.right=e,this._refreshDrawHeightConstants(),rs.full=1,rs.left=1,rs.center=1+St.left,rs.right=1+St.left+St.center}_refreshDrawHeightConstants(){ot.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);ot.left=t,ot.center=t,ot.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ot.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ot.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ot.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ot.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(rs[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ot[e.position||"full"]/2),St[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ot[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};ii=pe([$(2,Fe),$(3,ks),$(4,mt),$(5,He),$(6,es),$(7,pt)],ii);var v;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=` -`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(v||(v={}));var Ks;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(Ks||(Ks={}));var da;(e=>e.ST=`${v.ESC}\\`)(da||(da={}));var nr=class{constructor(e,t,s,i,r,n){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.lengththis.updateCompositionElements(!0),0)}}};nr=pe([$(2,Fe),$(3,He),$(4,Ft),$(5,mt)],nr);var Re=0,Be=0,Me=0,fe=0,pn={css:"#00000000",rgba:0},be;(e=>{function t(r,n,o,a){return a!==void 0?`#${Tt(r)}${Tt(n)}${Tt(o)}${Tt(a)}`:`#${Tt(r)}${Tt(n)}${Tt(o)}`}e.toCss=t;function s(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=s;function i(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=i})(be||(be={}));var ne;(e=>{function t(h,l){if(fe=(l.rgba&255)/255,fe===1)return{css:l.css,rgba:l.rgba};let c=l.rgba>>24&255,d=l.rgba>>16&255,u=l.rgba>>8&255,f=h.rgba>>24&255,_=h.rgba>>16&255,p=h.rgba>>8&255;Re=f+Math.round((c-f)*fe),Be=_+Math.round((d-_)*fe),Me=p+Math.round((u-p)*fe);let g=be.toCss(Re,Be,Me),k=be.toRgba(Re,Be,Me);return{css:g,rgba:k}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function i(h,l,c){let d=qs.ensureContrastRatio(h.rgba,l.rgba,c);if(d)return be.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=i;function r(h){let l=(h.rgba|255)>>>0;return[Re,Be,Me]=qs.toChannels(l),{css:be.toCss(Re,Be,Me),rgba:l}}e.opaque=r;function n(h,l){return fe=Math.round(l*255),[Re,Be,Me]=qs.toChannels(h.rgba),{css:be.toCss(Re,Be,Me,fe),rgba:be.toRgba(Re,Be,Me,fe)}}e.opacity=n;function o(h,l){return fe=h.rgba&255,n(h,fe*l/255)}e.multiplyOpacity=o;function a(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=a})(ne||(ne={}));var he;(e=>{let t,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Re=parseInt(r.slice(1,2).repeat(2),16),Be=parseInt(r.slice(2,3).repeat(2),16),Me=parseInt(r.slice(3,4).repeat(2),16),be.toColor(Re,Be,Me);case 5:return Re=parseInt(r.slice(1,2).repeat(2),16),Be=parseInt(r.slice(2,3).repeat(2),16),Me=parseInt(r.slice(3,4).repeat(2),16),fe=parseInt(r.slice(4,5).repeat(2),16),be.toColor(Re,Be,Me,fe);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Re=parseInt(n[1]),Be=parseInt(n[2]),Me=parseInt(n[3]),fe=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),be.toColor(Re,Be,Me,fe);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Re,Be,Me,fe]=t.getImageData(0,0,1,1).data,fe!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:be.toRgba(Re,Be,Me,fe),css:r}}e.toColor=i})(he||(he={}));var Ie;(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,r,n){let o=i/255,a=r/255,h=n/255,l=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return l*.2126+c*.7152+d*.0722}e.relativeLuminance2=s})(Ie||(Ie={}));var qs;(e=>{function t(o,a){if(fe=(a&255)/255,fe===1)return a;let h=a>>24&255,l=a>>16&255,c=a>>8&255,d=o>>24&255,u=o>>16&255,f=o>>8&255;return Re=d+Math.round((h-d)*fe),Be=u+Math.round((l-u)*fe),Me=f+Math.round((c-f)*fe),be.toRgba(Re,Be,Me)}e.blend=t;function s(o,a,h){let l=Ie.relativeLuminance(o>>8),c=Ie.relativeLuminance(a>>8);if(_t(l,c)>8));if(_>8));return _>g?f:p}return f}let d=r(o,a,h),u=_t(l,Ie.relativeLuminance(d>>8));if(u>8));return u>_?d:f}return d}}e.ensureContrastRatio=s;function i(o,a,h){let l=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,f=a>>16&255,_=a>>8&255,p=_t(Ie.relativeLuminance2(u,f,_),Ie.relativeLuminance2(l,c,d));for(;p0||f>0||_>0);)u-=Math.max(0,Math.ceil(u*.1)),f-=Math.max(0,Math.ceil(f*.1)),_-=Math.max(0,Math.ceil(_*.1)),p=_t(Ie.relativeLuminance2(u,f,_),Ie.relativeLuminance2(l,c,d));return(u<<24|f<<16|_<<8|255)>>>0}e.reduceLuminance=i;function r(o,a,h){let l=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,f=a>>16&255,_=a>>8&255,p=_t(Ie.relativeLuminance2(u,f,_),Ie.relativeLuminance2(l,c,d));for(;p>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(qs||(qs={}));function Tt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function _t(e,t){return e1){let c=this._getJoinedRanges(i,o,n,t,r);for(let d=0;d1){let l=this._getJoinedRanges(i,o,n,t,r);for(let c=0;c=oe,I=S,R=this._workCell;if(u.length>0&&S===u[0][0]&&L){let O=u.shift(),K=this._isCellInSelection(O[0],t);for(q=O[0]+1;q=O[1]),L?(C=!0,R=new hc(this._workCell,e.translateToString(!0,O[0],O[1]),O[1]-O[0]),I=O[1]-1,M=R.getWidth()):oe=O[1]}let V=this._isCellInSelection(S,t),ee=s&&S===n,Se=P&&S>=l&&S<=c,$e=!1;this._decorationService.forEachDecorationAtCell(S,t,void 0,O=>{$e=!0});let Ne=R.getChars()||kt;if(Ne===" "&&(R.isUnderline()||R.isOverline())&&(Ne=" "),Y=M*a-h.get(Ne,R.isBold(),R.isItalic()),!p)p=this._document.createElement("span");else if(g&&(V&&me||!V&&!me&&R.bg===F)&&(V&&me&&f.selectionForeground||R.fg===T)&&R.extended.ext===N&&Se===H&&Y===Z&&!ee&&!C&&!$e&&L){R.isInvisible()?k+=kt:k+=Ne,g++;continue}else g&&(p.textContent=k),p=this._document.createElement("span"),g=0,k="";if(F=R.bg,T=R.fg,N=R.extended.ext,H=Se,Z=Y,me=V,C&&n>=S&&n<=I&&(n=S),!this._coreService.isCursorHidden&&ee&&this._coreService.isCursorInitialized){if(J.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&J.push("xterm-cursor-blink"),J.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":J.push("xterm-cursor-outline");break;case"block":J.push("xterm-cursor-block");break;case"bar":J.push("xterm-cursor-bar");break;case"underline":J.push("xterm-cursor-underline");break}}if(R.isBold()&&J.push("xterm-bold"),R.isItalic()&&J.push("xterm-italic"),R.isDim()&&J.push("xterm-dim"),R.isInvisible()?k=kt:k=R.getChars()||kt,R.isUnderline()&&(J.push(`xterm-underline-${R.extended.underlineStyle}`),k===" "&&(k=" "),!R.isUnderlineColorDefault()))if(R.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${xs.toColorRGB(R.getUnderlineColor()).join(",")})`;else{let O=R.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&R.isBold()&&O<8&&(O+=8),p.style.textDecorationColor=f.ansi[O].css}R.isOverline()&&(J.push("xterm-overline"),k===" "&&(k=" ")),R.isStrikethrough()&&J.push("xterm-strikethrough"),Se&&(p.style.textDecoration="underline");let re=R.getFgColor(),Ge=R.getFgColorMode(),We=R.getBgColor(),ut=R.getBgColorMode(),ss=!!R.isInverse();if(ss){let O=re;re=We,We=O;let K=Ge;Ge=ut,ut=K}let nt,E,A=!1;this._decorationService.forEachDecorationAtCell(S,t,void 0,O=>{O.options.layer!=="top"&&A||(O.backgroundColorRGB&&(ut=50331648,We=O.backgroundColorRGB.rgba>>8&16777215,nt=O.backgroundColorRGB),O.foregroundColorRGB&&(Ge=50331648,re=O.foregroundColorRGB.rgba>>8&16777215,E=O.foregroundColorRGB),A=O.options.layer==="top")}),!A&&V&&(nt=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque,We=nt.rgba>>8&16777215,ut=50331648,A=!0,f.selectionForeground&&(Ge=50331648,re=f.selectionForeground.rgba>>8&16777215,E=f.selectionForeground)),A&&J.push("xterm-decoration-top");let W;switch(ut){case 16777216:case 33554432:W=f.ansi[We],J.push(`xterm-bg-${We}`);break;case 50331648:W=be.toColor(We>>16,We>>8&255,We&255),this._addStyle(p,`background-color:#${mn((We>>>0).toString(16),"0",6)}`);break;case 0:default:ss?(W=f.foreground,J.push("xterm-bg-257")):W=f.background}switch(nt||R.isDim()&&(nt=ne.multiplyOpacity(W,.5)),Ge){case 16777216:case 33554432:R.isBold()&&re<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(re+=8),this._applyMinimumContrast(p,W,f.ansi[re],R,nt,void 0)||J.push(`xterm-fg-${re}`);break;case 50331648:let O=be.toColor(re>>16&255,re>>8&255,re&255);this._applyMinimumContrast(p,W,O,R,nt,E)||this._addStyle(p,`color:#${mn(re.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(p,W,f.foreground,R,nt,E)||ss&&J.push("xterm-fg-257")}J.length&&(p.className=J.join(" "),J.length=0),!ee&&!C&&!$e&&L?g++:p.textContent=k,Y!==this.defaultSpacing&&(p.style.letterSpacing=`${Y}px`),d.push(p),S=I}return p&&g&&(p.textContent=k),d}_applyMinimumContrast(e,t,s,i,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||uc(i.getCode()))return!1;let o=this._getContrastCache(i),a;if(!r&&!n&&(a=o.getColor(t.rgba,s.rgba)),a===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);a=ne.ensureContrastRatio(r||t,n||s,h),o.setColor((r||t).rgba,(n||s).rgba,a??null)}return a?(this._addStyle(e,`color:${a.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t=s[0]&&e=s[0]}};or=pe([$(1,Vo),$(2,He),$(3,pt),$(4,Ft),$(5,ks),$(6,es)],or);function mn(e,t,s){for(;e.length0&&(this._flat[i]=o),o}let r=e;t&&(r+="B"),s&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),s&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},pc=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=s[1]-r,a=Math.max(n,0),h=Math.min(o,e.rows-1);if(a>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s=this.startCol&&t=this.startCol):!1}};function mc(){return new pc}var yi="xterm-dom-renderer-owner-",Xe="xterm-rows",Is="xterm-fg-",gn="xterm-bg-",ns="xterm-focus",Os="xterm-selection",gc=1,ar=class extends X{constructor(e,t,s,i,r,n,o,a,h,l,c,d,u,f){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=h,this._optionsService=l,this._bufferService=c,this._coreService=d,this._coreBrowserService=u,this._themeService=f,this._terminalClass=gc++,this._rowElements=[],this._selectionRenderModel=mc(),this.onRequestRedraw=this._register(new x).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Xe),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Os),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=_c(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(_=>this._injectCss(_))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(or,document),this._element.classList.add(yi+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(_=>this._handleLinkHover(_))),this._register(this._linkifier2.onHideLinkUnderline(_=>this._handleLinkLeave(_))),this._register(ae(()=>{this._element.classList.remove(yi+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new fc(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Xe} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Xe} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Xe} .xterm-dim { color: ${ne.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Xe}.${ns} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Xe}.${ns} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Xe}.${ns} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Xe} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Xe} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Xe} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Xe} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Xe} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Os} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Os} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Os} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Is}${n} { color: ${o.css}; }${this._terminalSelector} .${Is}${n}.xterm-dim { color: ${ne.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${gn}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Is}257 { color: ${ne.opaque(e.background).css}; }${this._terminalSelector} .${Is}257.xterm-dim { color: ${ne.multiplyOpacity(ne.opaque(e.background),.5).css}; }${this._terminalSelector} .${gn}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(ns),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ns),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];a.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],o-n+1))}else{let h=i===n?e[0]:0,l=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,h,l));let c=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,c)),n!==o){let d=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,s,i=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(s-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,i=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let l=h+s.ydisp,c=this._rowElements[h],d=s.lines.get(l);if(!c||!d)break;c.replaceChildren(...this._rowFactory.createRow(d,l,l===i,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${yi}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,i,r,n){s<0&&(e=0),i<0&&(t=0);let o=this._bufferService.rows-1;s=Math.max(Math.min(s,o),0),i=Math.max(Math.min(i,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,h=a.ybase+a.y,l=Math.min(a.x,r-1),c=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,u=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=s;f<=i;++f){let _=f+a.ydisp,p=this._rowElements[f],g=a.lines.get(_);if(!p||!g)break;p.replaceChildren(...this._rowFactory.createRow(g,_,_===h,d,u,l,c,this.dimensions.css.cell.width,this._widthCache,n?f===s?e:0:-1,n?(f===i?t:r)-1:-1))}}};ar=pe([$(7,Rr),$(8,ci),$(9,He),$(10,Fe),$(11,Ft),$(12,pt),$(13,es)],ar);var lr=class extends X{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new x),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Sc(this._optionsService))}catch{this._measureStrategy=this._register(new vc(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};lr=pe([$(2,He)],lr);var ua=class extends X{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},vc=class extends ua{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Sc=class extends ua{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},yc=class extends X{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new bc(this._window)),this._onDprChange=this._register(new x),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new x),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(Te.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(j(this._textarea,"focus",()=>this._isFocused=!0)),this._register(j(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},bc=class extends X{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Zt),this._onDprChange=this._register(new x),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ae(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=j(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},wc=class extends X{constructor(){super(),this.linkProviders=[],this._register(ae(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Pr(e,t,s){let i=s.getBoundingClientRect(),r=e.getComputedStyle(s),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-i.left-n,t.clientY-i.top-o]}function Cc(e,t,s,i,r,n,o,a,h){if(!n)return;let l=Pr(e,t,s);if(l)return l[0]=Math.ceil((l[0]+(h?o/2:0))/o),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),i+(h?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}var hr=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,r){return Cc(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let s=Pr(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};hr=pe([$(0,mt),$(1,ci)],hr);var xc=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},_a={};Al(_a,{getSafariVersion:()=>Ec,isChromeOS:()=>ga,isFirefox:()=>fa,isIpad:()=>Rc,isIphone:()=>Bc,isLegacyEdge:()=>kc,isLinux:()=>Nr,isMac:()=>ni,isNode:()=>di,isSafari:()=>pa,isWindows:()=>ma});var di=typeof process<"u"&&"title"in process,Es=di?"node":navigator.userAgent,Rs=di?"node":navigator.platform,fa=Es.includes("Firefox"),kc=Es.includes("Edge"),pa=/^((?!chrome|android).)*safari/i.test(Es);function Ec(){if(!pa)return 0;let e=Es.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ni=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Rs),Rc=Rs==="iPad",Bc=Rs==="iPhone",ma=["Windows","Win16","Win32","WinCE"].includes(Rs),Nr=Rs.indexOf("Linux")>=0,ga=/\bCrOS\b/.test(Es),va=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ir){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=r}this.clear()}},Mc=class extends va{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Lc=class extends va{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},oi=!di&&"requestIdleCallback"in window?Lc:Mc,Dc=class{constructor(){this._queue=new oi}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},cr=class extends X{constructor(e,t,s,i,r,n,o,a,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new Zt),this._pausedResizeTask=new Dc,this._observerDisposable=this._register(new Zt),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new x),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new x),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new x),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new x),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new xc((l,c)=>this._renderRows(l,c),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Tc(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ae(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var l;return(l=this._renderer.value)==null?void 0:l.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(l=>this._registerIntersectionObserver(l,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=ae(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var i;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};cr=pe([$(2,He),$(3,ci),$(4,Ft),$(5,ks),$(6,Fe),$(7,pt),$(8,es)],cr);var Tc=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function $c(e,t,s,i){let r=s.buffer.x,n=s.buffer.y;if(!s.buffer.hasScrollback)return Nc(r,n,e,t,s,i)+ui(n,t,s,i)+Ic(r,n,e,t,s,i);let o;if(n===t)return o=r>e?"D":"C",bs(Math.abs(r-e),ys(o,i));o=n>t?"D":"C";let a=Math.abs(n-t),h=Pc(n>t?e:r,s)+(a-1)*s.cols+1+Ac(n>t?r:e);return bs(h,ys(o,i))}function Ac(e,t){return e-1}function Pc(e,t){return t.cols-e}function Nc(e,t,s,i,r,n){return ui(t,i,r,n).length===0?"":bs(ya(e,t,e,t-Ot(t,r),!1,r).length,ys("D",n))}function ui(e,t,s,i){let r=e-Ot(e,s),n=t-Ot(t,s),o=Math.abs(r-n)-Oc(e,t,s);return bs(o,ys(Sa(e,t),i))}function Ic(e,t,s,i,r,n){let o;ui(t,i,r,n).length>0?o=i-Ot(i,r):o=t;let a=i,h=Fc(e,t,s,i,r,n);return bs(ya(e,o,s,a,h==="C",r).length,ys(h,n))}function Oc(e,t,s){var o;let i=0,r=e-Ot(e,s),n=t-Ot(t,s);for(let a=0;a=0&&e0?o=i-Ot(i,r):o=t,e=s&&ot?"A":"B"}function ya(e,t,s,i,r,n){let o=e,a=t,h="";for(;(o!==s||a!==i)&&a>=0&&an.cols-1?(h+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(h+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return h+n.buffer.translateBufferLineToString(a,!1,e,o)}function ys(e,t){let s=t?"O":"[";return v.ESC+s+e}function bs(e,t){e=Math.floor(e);let s="";for(let i=0;ithis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function vn(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var bi=50,Wc=15,zc=50,Uc=500,jc=" ",Kc=new RegExp(jc,"g"),dr=class extends X{constructor(e,t,s,i,r,n,o,a,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ze,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new x),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new x),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new x),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new x),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=l=>this._handleMouseMove(l),this._mouseUpListener=l=>this._handleMouseUp(l),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(l=>this._handleTrim(l)),this._register(this._bufferService.buffers.onBufferActivate(l=>this._handleBufferActivate(l))),this.enable(),this._model=new Hc(this._bufferService),this._activeSelectionMode=0,this._register(ae(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(l=>{l.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]r.replace(Kc," ")).join(ma?`\r +`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(v||(v={}));var Ks;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(Ks||(Ks={}));var da;(e=>e.ST=`${v.ESC}\\`)(da||(da={}));var nr=class{constructor(e,t,s,i,r,n){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.lengththis.updateCompositionElements(!0),0)}}};nr=pe([$(2,Fe),$(3,He),$(4,Ft),$(5,mt)],nr);var Re=0,Be=0,Le=0,fe=0,pn={css:"#00000000",rgba:0},be;(e=>{function t(r,n,o,a){return a!==void 0?`#${Tt(r)}${Tt(n)}${Tt(o)}${Tt(a)}`:`#${Tt(r)}${Tt(n)}${Tt(o)}`}e.toCss=t;function s(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=s;function i(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=i})(be||(be={}));var ne;(e=>{function t(h,l){if(fe=(l.rgba&255)/255,fe===1)return{css:l.css,rgba:l.rgba};let c=l.rgba>>24&255,d=l.rgba>>16&255,u=l.rgba>>8&255,f=h.rgba>>24&255,_=h.rgba>>16&255,p=h.rgba>>8&255;Re=f+Math.round((c-f)*fe),Be=_+Math.round((d-_)*fe),Le=p+Math.round((u-p)*fe);let g=be.toCss(Re,Be,Le),k=be.toRgba(Re,Be,Le);return{css:g,rgba:k}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function i(h,l,c){let d=qs.ensureContrastRatio(h.rgba,l.rgba,c);if(d)return be.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=i;function r(h){let l=(h.rgba|255)>>>0;return[Re,Be,Le]=qs.toChannels(l),{css:be.toCss(Re,Be,Le),rgba:l}}e.opaque=r;function n(h,l){return fe=Math.round(l*255),[Re,Be,Le]=qs.toChannels(h.rgba),{css:be.toCss(Re,Be,Le,fe),rgba:be.toRgba(Re,Be,Le,fe)}}e.opacity=n;function o(h,l){return fe=h.rgba&255,n(h,fe*l/255)}e.multiplyOpacity=o;function a(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=a})(ne||(ne={}));var he;(e=>{let t,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Re=parseInt(r.slice(1,2).repeat(2),16),Be=parseInt(r.slice(2,3).repeat(2),16),Le=parseInt(r.slice(3,4).repeat(2),16),be.toColor(Re,Be,Le);case 5:return Re=parseInt(r.slice(1,2).repeat(2),16),Be=parseInt(r.slice(2,3).repeat(2),16),Le=parseInt(r.slice(3,4).repeat(2),16),fe=parseInt(r.slice(4,5).repeat(2),16),be.toColor(Re,Be,Le,fe);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Re=parseInt(n[1]),Be=parseInt(n[2]),Le=parseInt(n[3]),fe=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),be.toColor(Re,Be,Le,fe);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Re,Be,Le,fe]=t.getImageData(0,0,1,1).data,fe!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:be.toRgba(Re,Be,Le,fe),css:r}}e.toColor=i})(he||(he={}));var Ie;(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,r,n){let o=i/255,a=r/255,h=n/255,l=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return l*.2126+c*.7152+d*.0722}e.relativeLuminance2=s})(Ie||(Ie={}));var qs;(e=>{function t(o,a){if(fe=(a&255)/255,fe===1)return a;let h=a>>24&255,l=a>>16&255,c=a>>8&255,d=o>>24&255,u=o>>16&255,f=o>>8&255;return Re=d+Math.round((h-d)*fe),Be=u+Math.round((l-u)*fe),Le=f+Math.round((c-f)*fe),be.toRgba(Re,Be,Le)}e.blend=t;function s(o,a,h){let l=Ie.relativeLuminance(o>>8),c=Ie.relativeLuminance(a>>8);if(_t(l,c)>8));if(_>8));return _>g?f:p}return f}let d=r(o,a,h),u=_t(l,Ie.relativeLuminance(d>>8));if(u>8));return u>_?d:f}return d}}e.ensureContrastRatio=s;function i(o,a,h){let l=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,f=a>>16&255,_=a>>8&255,p=_t(Ie.relativeLuminance2(u,f,_),Ie.relativeLuminance2(l,c,d));for(;p0||f>0||_>0);)u-=Math.max(0,Math.ceil(u*.1)),f-=Math.max(0,Math.ceil(f*.1)),_-=Math.max(0,Math.ceil(_*.1)),p=_t(Ie.relativeLuminance2(u,f,_),Ie.relativeLuminance2(l,c,d));return(u<<24|f<<16|_<<8|255)>>>0}e.reduceLuminance=i;function r(o,a,h){let l=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,f=a>>16&255,_=a>>8&255,p=_t(Ie.relativeLuminance2(u,f,_),Ie.relativeLuminance2(l,c,d));for(;p>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(qs||(qs={}));function Tt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function _t(e,t){return e1){let c=this._getJoinedRanges(i,o,n,t,r);for(let d=0;d1){let l=this._getJoinedRanges(i,o,n,t,r);for(let c=0;c=oe,I=S,R=this._workCell;if(u.length>0&&S===u[0][0]&&M){let O=u.shift(),K=this._isCellInSelection(O[0],t);for(q=O[0]+1;q=O[1]),M?(C=!0,R=new hc(this._workCell,e.translateToString(!0,O[0],O[1]),O[1]-O[0]),I=O[1]-1,L=R.getWidth()):oe=O[1]}let V=this._isCellInSelection(S,t),ee=s&&S===n,Se=P&&S>=l&&S<=c,$e=!1;this._decorationService.forEachDecorationAtCell(S,t,void 0,O=>{$e=!0});let Ne=R.getChars()||kt;if(Ne===" "&&(R.isUnderline()||R.isOverline())&&(Ne=" "),Y=L*a-h.get(Ne,R.isBold(),R.isItalic()),!p)p=this._document.createElement("span");else if(g&&(V&&me||!V&&!me&&R.bg===F)&&(V&&me&&f.selectionForeground||R.fg===T)&&R.extended.ext===N&&Se===H&&Y===Z&&!ee&&!C&&!$e&&M){R.isInvisible()?k+=kt:k+=Ne,g++;continue}else g&&(p.textContent=k),p=this._document.createElement("span"),g=0,k="";if(F=R.bg,T=R.fg,N=R.extended.ext,H=Se,Z=Y,me=V,C&&n>=S&&n<=I&&(n=S),!this._coreService.isCursorHidden&&ee&&this._coreService.isCursorInitialized){if(J.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&J.push("xterm-cursor-blink"),J.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":J.push("xterm-cursor-outline");break;case"block":J.push("xterm-cursor-block");break;case"bar":J.push("xterm-cursor-bar");break;case"underline":J.push("xterm-cursor-underline");break}}if(R.isBold()&&J.push("xterm-bold"),R.isItalic()&&J.push("xterm-italic"),R.isDim()&&J.push("xterm-dim"),R.isInvisible()?k=kt:k=R.getChars()||kt,R.isUnderline()&&(J.push(`xterm-underline-${R.extended.underlineStyle}`),k===" "&&(k=" "),!R.isUnderlineColorDefault()))if(R.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${xs.toColorRGB(R.getUnderlineColor()).join(",")})`;else{let O=R.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&R.isBold()&&O<8&&(O+=8),p.style.textDecorationColor=f.ansi[O].css}R.isOverline()&&(J.push("xterm-overline"),k===" "&&(k=" ")),R.isStrikethrough()&&J.push("xterm-strikethrough"),Se&&(p.style.textDecoration="underline");let re=R.getFgColor(),Ge=R.getFgColorMode(),We=R.getBgColor(),ut=R.getBgColorMode(),ss=!!R.isInverse();if(ss){let O=re;re=We,We=O;let K=Ge;Ge=ut,ut=K}let nt,E,A=!1;this._decorationService.forEachDecorationAtCell(S,t,void 0,O=>{O.options.layer!=="top"&&A||(O.backgroundColorRGB&&(ut=50331648,We=O.backgroundColorRGB.rgba>>8&16777215,nt=O.backgroundColorRGB),O.foregroundColorRGB&&(Ge=50331648,re=O.foregroundColorRGB.rgba>>8&16777215,E=O.foregroundColorRGB),A=O.options.layer==="top")}),!A&&V&&(nt=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque,We=nt.rgba>>8&16777215,ut=50331648,A=!0,f.selectionForeground&&(Ge=50331648,re=f.selectionForeground.rgba>>8&16777215,E=f.selectionForeground)),A&&J.push("xterm-decoration-top");let W;switch(ut){case 16777216:case 33554432:W=f.ansi[We],J.push(`xterm-bg-${We}`);break;case 50331648:W=be.toColor(We>>16,We>>8&255,We&255),this._addStyle(p,`background-color:#${mn((We>>>0).toString(16),"0",6)}`);break;case 0:default:ss?(W=f.foreground,J.push("xterm-bg-257")):W=f.background}switch(nt||R.isDim()&&(nt=ne.multiplyOpacity(W,.5)),Ge){case 16777216:case 33554432:R.isBold()&&re<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(re+=8),this._applyMinimumContrast(p,W,f.ansi[re],R,nt,void 0)||J.push(`xterm-fg-${re}`);break;case 50331648:let O=be.toColor(re>>16&255,re>>8&255,re&255);this._applyMinimumContrast(p,W,O,R,nt,E)||this._addStyle(p,`color:#${mn(re.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(p,W,f.foreground,R,nt,E)||ss&&J.push("xterm-fg-257")}J.length&&(p.className=J.join(" "),J.length=0),!ee&&!C&&!$e&&M?g++:p.textContent=k,Y!==this.defaultSpacing&&(p.style.letterSpacing=`${Y}px`),d.push(p),S=I}return p&&g&&(p.textContent=k),d}_applyMinimumContrast(e,t,s,i,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||uc(i.getCode()))return!1;let o=this._getContrastCache(i),a;if(!r&&!n&&(a=o.getColor(t.rgba,s.rgba)),a===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);a=ne.ensureContrastRatio(r||t,n||s,h),o.setColor((r||t).rgba,(n||s).rgba,a??null)}return a?(this._addStyle(e,`color:${a.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t=s[0]&&e=s[0]}};or=pe([$(1,Vo),$(2,He),$(3,pt),$(4,Ft),$(5,ks),$(6,es)],or);function mn(e,t,s){for(;e.length0&&(this._flat[i]=o),o}let r=e;t&&(r+="B"),s&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),s&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},pc=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=s[1]-r,a=Math.max(n,0),h=Math.min(o,e.rows-1);if(a>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s=this.startCol&&t=this.startCol):!1}};function mc(){return new pc}var yi="xterm-dom-renderer-owner-",Xe="xterm-rows",Is="xterm-fg-",gn="xterm-bg-",ns="xterm-focus",Os="xterm-selection",gc=1,ar=class extends X{constructor(e,t,s,i,r,n,o,a,h,l,c,d,u,f){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=h,this._optionsService=l,this._bufferService=c,this._coreService=d,this._coreBrowserService=u,this._themeService=f,this._terminalClass=gc++,this._rowElements=[],this._selectionRenderModel=mc(),this.onRequestRedraw=this._register(new x).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Xe),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Os),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=_c(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(_=>this._injectCss(_))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(or,document),this._element.classList.add(yi+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(_=>this._handleLinkHover(_))),this._register(this._linkifier2.onHideLinkUnderline(_=>this._handleLinkLeave(_))),this._register(ae(()=>{this._element.classList.remove(yi+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new fc(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Xe} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Xe} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Xe} .xterm-dim { color: ${ne.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Xe}.${ns} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Xe}.${ns} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Xe}.${ns} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Xe} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Xe} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Xe} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Xe} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Xe} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Os} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Os} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Os} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Is}${n} { color: ${o.css}; }${this._terminalSelector} .${Is}${n}.xterm-dim { color: ${ne.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${gn}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Is}257 { color: ${ne.opaque(e.background).css}; }${this._terminalSelector} .${Is}257.xterm-dim { color: ${ne.multiplyOpacity(ne.opaque(e.background),.5).css}; }${this._terminalSelector} .${gn}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(ns),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ns),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];a.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],o-n+1))}else{let h=i===n?e[0]:0,l=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,h,l));let c=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,c)),n!==o){let d=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,s,i=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(s-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,i=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let l=h+s.ydisp,c=this._rowElements[h],d=s.lines.get(l);if(!c||!d)break;c.replaceChildren(...this._rowFactory.createRow(d,l,l===i,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${yi}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,i,r,n){s<0&&(e=0),i<0&&(t=0);let o=this._bufferService.rows-1;s=Math.max(Math.min(s,o),0),i=Math.max(Math.min(i,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,h=a.ybase+a.y,l=Math.min(a.x,r-1),c=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,u=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=s;f<=i;++f){let _=f+a.ydisp,p=this._rowElements[f],g=a.lines.get(_);if(!p||!g)break;p.replaceChildren(...this._rowFactory.createRow(g,_,_===h,d,u,l,c,this.dimensions.css.cell.width,this._widthCache,n?f===s?e:0:-1,n?(f===i?t:r)-1:-1))}}};ar=pe([$(7,Rr),$(8,ci),$(9,He),$(10,Fe),$(11,Ft),$(12,pt),$(13,es)],ar);var lr=class extends X{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new x),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Sc(this._optionsService))}catch{this._measureStrategy=this._register(new vc(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};lr=pe([$(2,He)],lr);var ua=class extends X{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},vc=class extends ua{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Sc=class extends ua{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},yc=class extends X{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new bc(this._window)),this._onDprChange=this._register(new x),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new x),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(Te.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(j(this._textarea,"focus",()=>this._isFocused=!0)),this._register(j(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},bc=class extends X{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Zt),this._onDprChange=this._register(new x),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ae(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=j(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},wc=class extends X{constructor(){super(),this.linkProviders=[],this._register(ae(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Pr(e,t,s){let i=s.getBoundingClientRect(),r=e.getComputedStyle(s),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-i.left-n,t.clientY-i.top-o]}function Cc(e,t,s,i,r,n,o,a,h){if(!n)return;let l=Pr(e,t,s);if(l)return l[0]=Math.ceil((l[0]+(h?o/2:0))/o),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),i+(h?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}var hr=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,r){return Cc(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let s=Pr(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};hr=pe([$(0,mt),$(1,ci)],hr);var xc=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},_a={};Al(_a,{getSafariVersion:()=>Ec,isChromeOS:()=>ga,isFirefox:()=>fa,isIpad:()=>Rc,isIphone:()=>Bc,isLegacyEdge:()=>kc,isLinux:()=>Nr,isMac:()=>ni,isNode:()=>di,isSafari:()=>pa,isWindows:()=>ma});var di=typeof process<"u"&&"title"in process,Es=di?"node":navigator.userAgent,Rs=di?"node":navigator.platform,fa=Es.includes("Firefox"),kc=Es.includes("Edge"),pa=/^((?!chrome|android).)*safari/i.test(Es);function Ec(){if(!pa)return 0;let e=Es.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ni=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Rs),Rc=Rs==="iPad",Bc=Rs==="iPhone",ma=["Windows","Win16","Win32","WinCE"].includes(Rs),Nr=Rs.indexOf("Linux")>=0,ga=/\bCrOS\b/.test(Es),va=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ir){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=r}this.clear()}},Lc=class extends va{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Mc=class extends va{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},oi=!di&&"requestIdleCallback"in window?Mc:Lc,Dc=class{constructor(){this._queue=new oi}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},cr=class extends X{constructor(e,t,s,i,r,n,o,a,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new Zt),this._pausedResizeTask=new Dc,this._observerDisposable=this._register(new Zt),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new x),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new x),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new x),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new x),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new xc((l,c)=>this._renderRows(l,c),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Tc(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ae(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var l;return(l=this._renderer.value)==null?void 0:l.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(l=>this._registerIntersectionObserver(l,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=ae(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var i;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};cr=pe([$(2,He),$(3,ci),$(4,Ft),$(5,ks),$(6,Fe),$(7,pt),$(8,es)],cr);var Tc=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function $c(e,t,s,i){let r=s.buffer.x,n=s.buffer.y;if(!s.buffer.hasScrollback)return Nc(r,n,e,t,s,i)+ui(n,t,s,i)+Ic(r,n,e,t,s,i);let o;if(n===t)return o=r>e?"D":"C",bs(Math.abs(r-e),ys(o,i));o=n>t?"D":"C";let a=Math.abs(n-t),h=Pc(n>t?e:r,s)+(a-1)*s.cols+1+Ac(n>t?r:e);return bs(h,ys(o,i))}function Ac(e,t){return e-1}function Pc(e,t){return t.cols-e}function Nc(e,t,s,i,r,n){return ui(t,i,r,n).length===0?"":bs(ya(e,t,e,t-Ot(t,r),!1,r).length,ys("D",n))}function ui(e,t,s,i){let r=e-Ot(e,s),n=t-Ot(t,s),o=Math.abs(r-n)-Oc(e,t,s);return bs(o,ys(Sa(e,t),i))}function Ic(e,t,s,i,r,n){let o;ui(t,i,r,n).length>0?o=i-Ot(i,r):o=t;let a=i,h=Fc(e,t,s,i,r,n);return bs(ya(e,o,s,a,h==="C",r).length,ys(h,n))}function Oc(e,t,s){var o;let i=0,r=e-Ot(e,s),n=t-Ot(t,s);for(let a=0;a=0&&e0?o=i-Ot(i,r):o=t,e=s&&ot?"A":"B"}function ya(e,t,s,i,r,n){let o=e,a=t,h="";for(;(o!==s||a!==i)&&a>=0&&an.cols-1?(h+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(h+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return h+n.buffer.translateBufferLineToString(a,!1,e,o)}function ys(e,t){let s=t?"O":"[";return v.ESC+s+e}function bs(e,t){e=Math.floor(e);let s="";for(let i=0;ithis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function vn(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var bi=50,Wc=15,zc=50,Uc=500,jc=" ",Kc=new RegExp(jc,"g"),dr=class extends X{constructor(e,t,s,i,r,n,o,a,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ze,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new x),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new x),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new x),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new x),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=l=>this._handleMouseMove(l),this._mouseUpListener=l=>this._handleMouseUp(l),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(l=>this._handleTrim(l)),this._register(this._bufferService.buffers.onBufferActivate(l=>this._handleBufferActivate(l))),this.enable(),this._model=new Hc(this._bufferService),this._activeSelectionMode=0,this._register(ae(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(l=>{l.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]r.replace(Kc," ")).join(ma?`\r `:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Nr&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var r,n;let s=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=vn(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Pr(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-bi),bi),t/=bi,t/Math.abs(t)+Math.round(t*(Wc-1)))}shouldForceSelection(e){return ni?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),zc)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(ni&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let r=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&t!==i&&(s+=r-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),h=a,l=e[0]-a,c=0,d=0,u=0,f=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;h1&&(f+=q-1,h+=q-1);g>0&&a>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let F=this._workCell.getChars().length;this._workCell.getWidth()===0?(c++,g--):F>1&&(u+=F-1,a-=F-1),a--,g--}for(;k1&&(f+=F-1,h+=F-1),h++,k++}}h++;let _=a+l-c+u,p=Math.min(this._bufferService.cols,h-a+c+d-u-f);if(!(!t&&o.slice(a,h).trim()==="")){if(s&&_===0&&n.getCodePoint(0)!==32){let g=r.lines.get(e[1]-1);if(g&&n.isWrapped&&g.getCodePoint(this._bufferService.cols-1)!==32){let k=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(k){let q=this._bufferService.cols-k.start;_-=q,p+=q}}}if(i&&_+p===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let g=r.lines.get(e[1]+1);if(g!=null&&g.isWrapped&&g.getCodePoint(0)!==32){let k=this._getWordAt([0,e[1]+1],!1,!1,!0);k&&(p+=k.length)}}return{start:_,length:p}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=vn(s,this._bufferService.cols)}};dr=pe([$(3,Fe),$(4,Ft),$(5,Br),$(6,He),$(7,mt),$(8,pt)],dr);var Sn=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},yn=class{constructor(){this._color=new Sn,this._css=new Sn}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ce=Object.freeze((()=>{let e=[he.toColor("#2e3436"),he.toColor("#cc0000"),he.toColor("#4e9a06"),he.toColor("#c4a000"),he.toColor("#3465a4"),he.toColor("#75507b"),he.toColor("#06989a"),he.toColor("#d3d7cf"),he.toColor("#555753"),he.toColor("#ef2929"),he.toColor("#8ae234"),he.toColor("#fce94f"),he.toColor("#729fcf"),he.toColor("#ad7fa8"),he.toColor("#34e2e2"),he.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],r=t[s/6%6|0],n=t[s%6];e.push({css:be.toCss(i,r,n),rgba:be.toRgba(i,r,n)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:be.toCss(i,i,i),rgba:be.toRgba(i,i,i)})}return e})()),$t=he.toColor("#ffffff"),_s=he.toColor("#000000"),bn=he.toColor("#ffffff"),wn=_s,os={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},qc=$t,ur=class extends X{constructor(e){super(),this._optionsService=e,this._contrastCache=new yn,this._halfContrastCache=new yn,this._onChangeColors=this._register(new x),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:$t,background:_s,cursor:bn,cursorAccent:wn,selectionForeground:void 0,selectionBackgroundTransparent:os,selectionBackgroundOpaque:ne.blend(_s,os),selectionInactiveBackgroundTransparent:os,selectionInactiveBackgroundOpaque:ne.blend(_s,os),scrollbarSliderBackground:ne.opacity($t,.2),scrollbarSliderHoverBackground:ne.opacity($t,.4),scrollbarSliderActiveBackground:ne.opacity($t,.5),overviewRulerBorder:$t,ansi:Ce.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Q(e.foreground,$t),t.background=Q(e.background,_s),t.cursor=ne.blend(t.background,Q(e.cursor,bn)),t.cursorAccent=ne.blend(t.background,Q(e.cursorAccent,wn)),t.selectionBackgroundTransparent=Q(e.selectionBackground,os),t.selectionBackgroundOpaque=ne.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Q(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ne.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Q(e.selectionForeground,pn):void 0,t.selectionForeground===pn&&(t.selectionForeground=void 0),ne.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ne.opacity(t.selectionBackgroundTransparent,.3)),ne.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ne.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Q(e.scrollbarSliderBackground,ne.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Q(e.scrollbarSliderHoverBackground,ne.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Q(e.scrollbarSliderActiveBackground,ne.opacity(t.foreground,.5)),t.overviewRulerBorder=Q(e.overviewRulerBorder,qc),t.ansi=Ce.slice(),t.ansi[0]=Q(e.black,Ce[0]),t.ansi[1]=Q(e.red,Ce[1]),t.ansi[2]=Q(e.green,Ce[2]),t.ansi[3]=Q(e.yellow,Ce[3]),t.ansi[4]=Q(e.blue,Ce[4]),t.ansi[5]=Q(e.magenta,Ce[5]),t.ansi[6]=Q(e.cyan,Ce[6]),t.ansi[7]=Q(e.white,Ce[7]),t.ansi[8]=Q(e.brightBlack,Ce[8]),t.ansi[9]=Q(e.brightRed,Ce[9]),t.ansi[10]=Q(e.brightGreen,Ce[10]),t.ansi[11]=Q(e.brightYellow,Ce[11]),t.ansi[12]=Q(e.brightBlue,Ce[12]),t.ansi[13]=Q(e.brightMagenta,Ce[13]),t.ansi[14]=Q(e.brightCyan,Ce[14]),t.ansi[15]=Q(e.brightWhite,Ce[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;in.index-o.index),i=[];for(let n of s){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);i.push(o)}let r=s.length>0?s[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...i)}},Xc={trace:0,debug:1,info:2,warn:3,error:4,off:5},Yc="xterm.js: ",_r=class extends X{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Xc[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;ithis._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=t-1;r>=0;r--)this.set(e+r+s,this.get(e+r));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*G+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*G+0]=t|2097152|s[2]<<22):this._data[t*G+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*G+0]>>22}hasWidth(t){return this._data[t*G+0]&12582912}getFg(t){return this._data[t*G+1]}getBg(t){return this._data[t*G+2]}hasContent(t){return this._data[t*G+0]&4194303}getCodePoint(t){let s=this._data[t*G+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*G+0]&2097152}getString(t){let s=this._data[t*G+0];return s&2097152?this._combined[t]:s&2097151?Ct(s&2097151):""}isProtected(t){return this._data[t*G+2]&536870912}loadCell(t,s){return Fs=t*G,s.content=this._data[Fs+0],s.fg=this._data[Fs+1],s.bg=this._data[Fs+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*G+0]=s.content,this._data[t*G+1]=s.fg,this._data[t*G+2]=s.bg}setCellFromCodepoint(t,s,i,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*G+0]=s|i<<22,this._data[t*G+1]=r.fg,this._data[t*G+2]=r.bg}addCodepointToCell(t,s,i){let r=this._data[t*G+0];r&2097152?this._combined[t]+=Ct(s):r&2097151?(this._combined[t]=Ct(r&2097151)+Ct(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[t*G+0]=r}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s=0;--n)this.setCell(t+s+n,this.loadCell(t+n,r));for(let n=0;nthis.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let r=new Uint32Array(i);r.set(this._data),this._data=r}for(let r=this.length;r=t&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o=t&&delete this._extendedAttrs[a]}}return this.length=t,i*4*wi=0;--t)if(this._data[t*G+0]&4194303)return t+(this._data[t*G+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*G+0]&4194303||this._data[t*G+2]&50331648)return t+(this._data[t*G+0]>>22);return 0}copyCellsFrom(t,s,i,r,n){let o=t._data;if(n)for(let h=r-1;h>=0;h--){for(let l=0;l=s&&(this._combined[l-s+i]=t._combined[l])}}translateToString(t,s,i,r){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;s>22||1}return r&&r.push(s),n}};function Jc(e,t,s,i,r,n){let o=[];for(let a=0;a=a&&i0&&(g>d||c[g].getTrimmedLength()===0);g--)p++;p>0&&(o.push(a+c.length-p),o.push(p)),a+=c.length-1}return o}function Zc(e,t){let s=[],i=0,r=t[i],n=0;for(let o=0;ows(e,l,t)).reduce((h,l)=>h+l),n=0,o=0,a=0;for(;ah&&(n-=h,o++);let l=e[o].getWidth(n-1)===2;l&&n--;let c=l?s-1:s;i.push(c),a+=c}return i}function ws(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,r=e[t+1].getWidth(0)===2;return i&&r?s-1:s}var wa=class Ca{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Ca._nextId++,this._onDispose=this.register(new x),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),It(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};wa._nextId=1;var td=wa,ke={},At=ke.B;ke[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};ke.A={"#":"£"};ke.B=void 0;ke[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};ke.C=ke[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ke.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};ke.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};ke.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};ke.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};ke.E=ke[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};ke.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};ke.H=ke[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ke["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var xn=4294967295,kn=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=ye.clone(),this.savedCharset=At,this.markers=[],this._nullCell=Ze.fromCharData([0,Ho,1,0]),this._whitespaceCell=Ze.fromCharData([0,kt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new oi,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Cn(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new si),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new si),this._whitespaceCell}getBlankLine(e,t){return new fs(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&exn?xn:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=ye);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Cn(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(ye),i=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new fs(e,s)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=Jc(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(ye),s);if(i.length>0){let r=Zc(this.lines,i);Qc(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(ye),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let h=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),h.unshift(a);if(!s){let F=this.ybase+this.y;if(F>=o&&F0&&(r.push({start:o+h.length+n,newLines:f}),n+=f.length),h.push(...f);let _=c.length-1,p=c[_];p===0&&(_--,p=c[_]);let g=h.length-d-1,k=l;for(;g>=0;){let F=Math.min(k,p);if(h[_]===void 0)break;if(h[_].copyCellsFrom(h[g],k-F,p-F,F,!0),p-=F,p===0&&(_--,p=c[_]),k-=F,k===0){g--;let T=Math.max(g,0);k=ws(h,T,this._cols)}}for(let F=0;F0;)this.ybase===0?this.y0){let o=[],a=[];for(let p=0;p=0;p--)if(d&&d.start>l+u){for(let g=d.newLines.length-1;g>=0;g--)this.lines.set(p--,d.newLines[g]);p++,o.push({index:l+1,amount:d.newLines.length}),u+=d.newLines.length,d=r[++c]}else this.lines.set(p,a[l--]);let f=0;for(let p=o.length-1;p>=0;p--)o[p].index+=f,this.lines.onInsertEmitter.fire(o[p]),f+=o[p].amount;let _=Math.max(0,h+n-this.lines.maxLength);_>0&&this.lines.onTrimEmitter.fire(_)}}translateBufferLineToString(e,t,s=0,i){let r=this.lines.get(e);return r?r.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.lines.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},sd=class extends X{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new x),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new kn(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new kn(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},xa=2,ka=1,fr=class extends X{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new x),this.onResize=this._onResize.event,this._onScroll=this._register(new x),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,xa),this.rows=Math.max(e.rawOptions.rows||0,ka),this.buffers=this._register(new sd(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let r=s.ybase+s.scrollTop,n=s.ybase+s.scrollBottom;if(s.scrollTop===0){let o=s.lines.isFull;n===s.lines.length-1?o?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(n+1,0,i.clone()),o?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let o=n-r+1;s.lines.shiftElements(r+1,o-1,-1),s.lines.set(n,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};fr=pe([$(0,He)],fr);var jt={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:ni,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},id=["normal","bold","100","200","300","400","500","600","700","800","900"],rd=class extends X{constructor(e){super(),this._onOptionChange=this._register(new x),this.onOptionChange=this._onOptionChange.event;let t={...jt};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ae(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in jt))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in jt))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=jt[e]),!nd(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=jt[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=id.includes(t)?t:jt[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function nd(e){return e==="block"||e==="underline"||e==="bar"}function ps(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&ps(e[i],t-1);return s}var En=Object.freeze({insertMode:!1}),Rn=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),pr=class extends X{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new x),this.onData=this._onData.event,this._onUserInput=this._register(new x),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new x),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new x),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ps(En),this.decPrivateModes=ps(Rn)}reset(){this.modes=ps(En),this.decPrivateModes=ps(Rn)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};pr=pe([$(0,Fe),$(1,Ko),$(2,He)],pr);var Bn={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Ci(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var xi=String.fromCharCode,Mn={DEFAULT:e=>{let t=[Ci(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${xi(t[0])}${xi(t[1])}${xi(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ci(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ci(e,!0)};${e.x};${e.y}${t}`}},mr=class extends X{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new x),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(Bn))this.addProtocol(i,Bn[i]);for(let i of Object.keys(Mn))this.addEncoding(i,Mn[i]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};mr=pe([$(0,Fe),$(1,Ft),$(2,He)],mr);var ki=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],od=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],xe;function ad(e,t){let s=0,i=t.length-1,r;if(et[i][1])return!1;for(;i>=s;)if(r=s+i>>1,e>t[r][1])s=r+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let r=Pt.extractWidth(t);r===0?i=!1:r>s&&(s=r)}return Pt.createPropertyValue(0,s,i)}},Pt=class Vs{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new x,this.onChange=this._onChange.event;let t=new ld;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,i=0,r=t.length;for(let n=0;n=r)return s+this.wcwidth(o);let l=t.charCodeAt(n);56320<=l&&l<=57343?o=(o-55296)*1024+l-56320+65536:s+=this.wcwidth(l)}let a=this.charProperties(o,i),h=Vs.extractWidth(a);Vs.extractShouldJoin(a)&&(h-=Vs.extractWidth(i)),s+=h,i=a}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},hd=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Ln(e){var i;let t=(i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:i.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var as=2147483647,cd=256,Ea=class gr{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>cd)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new gr;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i>8,r=this._subParamsIdx[s]&255;r-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,r))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>as?as:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>as?as:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s>8,r=this._subParamsIdx[s]&255;r-i>0&&(t[s]=this._subParams.slice(i,r))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,r=i[s-1];i[s-1]=~r?Math.min(r*10+t,as):t}},ls=[],dd=class{constructor(){this._state=0,this._active=ls,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ls}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ls,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ls,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",hi(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=ls,this._id=-1,this._state=0}}},qe=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=hi(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},hs=[],ud=class{constructor(){this._handlers=Object.create(null),this._active=hs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=hs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=hs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||hs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",hi(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=hs,this._ident=0}},ms=new Ea;ms.addParam(0);var Dn=class{constructor(e){this._handler=e,this._data="",this._params=ms,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ms,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=hi(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=ms,this._data="",this._hitLimit=!1,s));return this._params=ms,this._data="",this._hitLimit=!1,t}},_d=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let r=0;rh),s=(a,h)=>t.slice(a,h),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let n=s(0,14),o;e.setDefault(1,0),e.addMany(i,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(s(128,144),o,3,0),e.addMany(s(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Je,0,2,0),e.add(Je,8,5,8),e.add(Je,6,0,6),e.add(Je,11,0,11),e.add(Je,13,13,13),e})(),pd=class extends X{constructor(e=fd){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Ea,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ae(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new dd),this._dcsParser=this._register(new ud),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;rn||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,i,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=r}parse(e,t,s){let i=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(o=a[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(o=a[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(i!==24&&i!==26,s),o)return o;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],o=this._oscParser.end(i!==24&&i!==26,s),o)return o;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=n;a>4){case 2:for(let u=a+1;;++u){if(u>=t||(i=e[u])<32||i>126&&i=t||(i=e[u])<32||i>126&&i=t||(i=e[u])<32||i>126&&i=t||(i=e[u])<32||i>126&&i=0&&(o=h[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(3,h,l,r,a),o;l<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++a47&&i<60);a--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let c=this._escHandlers[this._collect<<8|i],d=c?c.length-1:-1;for(;d>=0&&(o=c[d](),o!==!0);d--)if(o instanceof Promise)return this._preserveStack(4,c,d,r,a),o;d<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let u=a+1;;++u)if(u>=t||(i=e[u])===24||i===26||i===27||i>127&&i=t||(i=e[u])<32||i>127&&i>4:n>>8}return i}}function Ei(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function vd(e,t=16){let[s,i,r]=e;return`rgb:${Ei(s,t)}/${Ei(i,t)}/${Ei(r,t)}`}var Sd={"(":0,")":1,"*":2,"+":3,"-":1,".":2},yt=131072,$n=10;function An(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Pn=5e3,Nn=0,yd=class extends X{constructor(e,t,s,i,r,n,o,a,h=new pd){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Fl,this._utf8Decoder=new Hl,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=ye.clone(),this._eraseAttrDataInternal=ye.clone(),this._onRequestBell=this._register(new x),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new x),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new x),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new x),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new x),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new x),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new x),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new x),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new x),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new x),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new x),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new x),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new x),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new vr(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,c)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:c.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,c,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:c,data:d})}),this._parser.setDcsHandlerFallback((l,c,d)=>{c==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:c,payload:d})}),this._parser.setPrintHandler((l,c,d)=>this.print(l,c,d)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(v.BEL,()=>this.bell()),this._parser.setExecuteHandler(v.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(v.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(v.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(v.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(v.BS,()=>this.backspace()),this._parser.setExecuteHandler(v.HT,()=>this.tab()),this._parser.setExecuteHandler(v.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(v.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ks.IND,()=>this.index()),this._parser.setExecuteHandler(Ks.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ks.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new qe(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new qe(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new qe(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new qe(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new qe(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new qe(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new qe(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new qe(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new qe(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new qe(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new qe(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new qe(l=>this.restoreCursorColor(l))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let l in ke)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Dn((l,c)=>this.requestStatusString(l,c)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),Pn))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Pn} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>yt&&(n=this._parseStack.position+yt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(l=>l.charCodeAt(0)):e),this._parseBuffer.lengthyt)for(let l=n;l0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let u=this._parser.precedingJoinState;for(let f=t;fa){if(h){let k=d,q=this._activeBuffer.x-g;for(this._activeBuffer.x=g,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),g>0&&d instanceof fs&&d.copyCellsFrom(k,q,0,g,!1);q=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);continue}if(l&&(d.insertCells(this._activeBuffer.x,r-g,this._activeBuffer.getNullCell(c)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,c)),d.setCellFromCodepoint(this._activeBuffer.x++,i,r,c),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c)}this._parser.precedingJoinState=u,this._activeBuffer.x0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>An(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Dn(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new qe(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var i;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&i.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let h=a;for(let l=1;l0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(v.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(v.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(v.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(v.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(v.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(p[p.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",p[p.SET=1]="SET",p[p.RESET=2]="RESET",p[p.PERMANENTLY_SET=3]="PERMANENTLY_SET",p[p.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:h}=this._bufferService,{active:l,alt:c}=a,d=this._optionsService.rawOptions,u=(p,g)=>(o.triggerDataEvent(`${v.ESC}[${t?"":"?"}${p};${g}$y`),!0),f=p=>p?1:2,_=e.params[0];return t?_===2?u(_,4):_===4?u(_,f(o.modes.insertMode)):_===12?u(_,3):_===20?u(_,f(d.convertEol)):u(_,0):_===1?u(_,f(i.applicationCursorKeys)):_===3?u(_,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):_===6?u(_,f(i.origin)):_===7?u(_,f(i.wraparound)):_===8?u(_,3):_===9?u(_,f(r==="X10")):_===12?u(_,f(d.cursorBlink)):_===25?u(_,f(!o.isCursorHidden)):_===45?u(_,f(i.reverseWraparound)):_===66?u(_,f(i.applicationKeypad)):_===67?u(_,4):_===1e3?u(_,f(r==="VT200")):_===1002?u(_,f(r==="DRAG")):_===1003?u(_,f(r==="ANY")):_===1004?u(_,f(i.sendFocus)):_===1005?u(_,4):_===1006?u(_,f(n==="SGR")):_===1015?u(_,4):_===1016?u(_,f(n==="SGR_PIXELS")):_===1048?u(_,1):_===47||_===1047||_===1049?u(_,f(l===c)):_===2004?u(_,f(i.bracketedPasteMode)):_===2026?u(_,f(i.synchronizedOutput)):u(_,0)}_updateAttrColor(e,t,s,i,r){return t===2?(e|=50331648,e&=-16777216,e|=xs.fromColorRGB([s,i,r])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],r=0,n=0;do{if(i[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do i[1]===5&&(r=1),i[n+a+1+r]=o[a];while(++a=2||i[1]===2&&n+r>=5)break;i[1]&&(r=1)}while(++n+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=ye.fg,e.bg=ye.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,i=this._curAttrData;for(let r=0;r=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=ye.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=ye.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(e,r,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=ye.fg&16777215,i.bg&=-67108864,i.bg|=ye.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${v.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${v.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${v.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=ye.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!An(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${v.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>$n&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>$n&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),r=s.shift();if(/^\d+$/.exec(i)){let n=parseInt(i);if(In(n))if(r==="?")t.push({type:0,index:n});else{let o=Tn(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,r=s.findIndex(n=>n.startsWith("id="));return r!==-1&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let i=0;i=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=Tn(s[i]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let i=0;i=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=ye.clone(),this._eraseAttrDataInternal=ye.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ze;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${v.ESC}${o}${v.ESC}\\`),!0),i=this._bufferService.buffer,r=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},vr=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Nn=e,e=t,t=Nn),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};vr=pe([$(0,Fe)],vr);function In(e){return 0<=e&&e<256}var bd=5e7,On=12,wd=50,Cd=class extends X{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new x),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>bd)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],r=this._action(i,t);if(r){let o=a=>performance.now()-s>=On?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(s,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=On)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>wd&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Sr=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(h,a)),this._dataByLinkId.set(h.id,h),h.id}let s=e,i=this._getEntryIdKey(s),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Sr=pe([$(0,Fe)],Sr);var Fn=!1,xd=class extends X{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Zt),this._onBinary=this._register(new x),this.onBinary=this._onBinary.event,this._onData=this._register(new x),this.onData=this._onData.event,this._onLineFeed=this._register(new x),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new x),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new x),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new x),this._instantiationService=new Gc,this.optionsService=this._register(new rd(e)),this._instantiationService.setService(He,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(fr)),this._instantiationService.setService(Fe,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(_r)),this._instantiationService.setService(Ko,this._logService),this.coreService=this._register(this._instantiationService.createInstance(pr)),this._instantiationService.setService(Ft,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(mr)),this._instantiationService.setService(jo,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Pt)),this._instantiationService.setService(jl,this.unicodeService),this._charsetService=this._instantiationService.createInstance(hd),this._instantiationService.setService(Ul,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Sr),this._instantiationService.setService(qo,this._oscLinkService),this._inputHandler=this._register(new yd(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Te.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Te.forward(this._bufferService.onResize,this._onResize)),this._register(Te.forward(this.coreService.onData,this._onData)),this._register(Te.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Cd((t,s)=>this._inputHandler.parse(t,s))),this._register(Te.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new x),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Fn&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Fn=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,xa),t=Math.max(t,ka),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Ln.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Ln(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ae(()=>{for(let t of e)t.dispose()})}}},kd={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function Ed(e,t,s,i){var o;let r={type:0,cancel:!1,key:void 0},n=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key=v.ESC+"OA":r.key=v.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=v.ESC+"OD":r.key=v.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=v.ESC+"OC":r.key=v.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=v.ESC+"OB":r.key=v.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":v.DEL,e.altKey&&(r.key=v.ESC+r.key);break;case 9:if(e.shiftKey){r.key=v.ESC+"[Z";break}r.key=v.HT,r.cancel=!0;break;case 13:r.key=e.altKey?v.ESC+v.CR:v.CR,r.cancel=!0;break;case 27:r.key=v.ESC,e.altKey&&(r.key=v.ESC+v.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"D":t?r.key=v.ESC+"OD":r.key=v.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"C":t?r.key=v.ESC+"OC":r.key=v.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"A":t?r.key=v.ESC+"OA":r.key=v.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"B":t?r.key=v.ESC+"OB":r.key=v.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=v.ESC+"[2~");break;case 46:n?r.key=v.ESC+"[3;"+(n+1)+"~":r.key=v.ESC+"[3~";break;case 36:n?r.key=v.ESC+"[1;"+(n+1)+"H":t?r.key=v.ESC+"OH":r.key=v.ESC+"[H";break;case 35:n?r.key=v.ESC+"[1;"+(n+1)+"F":t?r.key=v.ESC+"OF":r.key=v.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=v.ESC+"[5;"+(n+1)+"~":r.key=v.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=v.ESC+"[6;"+(n+1)+"~":r.key=v.ESC+"[6~";break;case 112:n?r.key=v.ESC+"[1;"+(n+1)+"P":r.key=v.ESC+"OP";break;case 113:n?r.key=v.ESC+"[1;"+(n+1)+"Q":r.key=v.ESC+"OQ";break;case 114:n?r.key=v.ESC+"[1;"+(n+1)+"R":r.key=v.ESC+"OR";break;case 115:n?r.key=v.ESC+"[1;"+(n+1)+"S":r.key=v.ESC+"OS";break;case 116:n?r.key=v.ESC+"[15;"+(n+1)+"~":r.key=v.ESC+"[15~";break;case 117:n?r.key=v.ESC+"[17;"+(n+1)+"~":r.key=v.ESC+"[17~";break;case 118:n?r.key=v.ESC+"[18;"+(n+1)+"~":r.key=v.ESC+"[18~";break;case 119:n?r.key=v.ESC+"[19;"+(n+1)+"~":r.key=v.ESC+"[19~";break;case 120:n?r.key=v.ESC+"[20;"+(n+1)+"~":r.key=v.ESC+"[20~";break;case 121:n?r.key=v.ESC+"[21;"+(n+1)+"~":r.key=v.ESC+"[21~";break;case 122:n?r.key=v.ESC+"[23;"+(n+1)+"~":r.key=v.ESC+"[23~";break;case 123:n?r.key=v.ESC+"[24;"+(n+1)+"~":r.key=v.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=v.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=v.DEL:e.keyCode===219?r.key=v.ESC:e.keyCode===220?r.key=v.FS:e.keyCode===221&&(r.key=v.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let a=(o=kd[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)r.key=v.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(h);e.shiftKey&&(l=l.toUpperCase()),r.key=v.ESC+l}else if(e.keyCode===32)r.key=v.ESC+(e.ctrlKey?v.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=v.ESC+h,r.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=v.US),e.key==="@"&&(r.key=v.NUL));break}return r}var ge=0,Rd=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new oi,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new oi,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((r,n)=>this._getKey(r)-this._getKey(n)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let r=0;r=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[r]=e[t],t++):i[r]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ge=this._search(t),ge===-1)||this._getKey(this._array[ge])!==t)return!1;do if(this._array[ge]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ge),!0;while(++ger-n),t=0,s=new Array(this._array.length-e.length),i=0;for(let r=0;r0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ge=this._search(e),!(ge<0||ge>=this._array.length)&&this._getKey(this._array[ge])===e))do yield this._array[ge];while(++ge=this._array.length)&&this._getKey(this._array[ge])===e))do t(this._array[ge]);while(++ge=t;){let i=t+s>>1,r=this._getKey(this._array[i]);if(r>e)s=i-1;else if(r0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},Ri=0,Hn=0,Bd=class extends X{constructor(){super(),this._decorations=new Rd(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new x),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new x),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ae(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Md(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let i=0,r=0;for(let n of this._decorations.getKeyIterator(t))i=n.options.x??0,r=i+(n.options.width??1),e>=i&&e{Ri=r.options.x??0,Hn=Ri+(r.options.width??1),e>=Ri&&e=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=i-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Wn=20,ai=class extends X{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;nthis._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Dd(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Nr&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var r,n;let s=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=vn(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Pr(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-bi),bi),t/=bi,t/Math.abs(t)+Math.round(t*(Wc-1)))}shouldForceSelection(e){return ni?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),zc)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(ni&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let r=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&t!==i&&(s+=r-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),h=a,l=e[0]-a,c=0,d=0,u=0,f=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;h1&&(f+=q-1,h+=q-1);g>0&&a>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let F=this._workCell.getChars().length;this._workCell.getWidth()===0?(c++,g--):F>1&&(u+=F-1,a-=F-1),a--,g--}for(;k1&&(f+=F-1,h+=F-1),h++,k++}}h++;let _=a+l-c+u,p=Math.min(this._bufferService.cols,h-a+c+d-u-f);if(!(!t&&o.slice(a,h).trim()==="")){if(s&&_===0&&n.getCodePoint(0)!==32){let g=r.lines.get(e[1]-1);if(g&&n.isWrapped&&g.getCodePoint(this._bufferService.cols-1)!==32){let k=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(k){let q=this._bufferService.cols-k.start;_-=q,p+=q}}}if(i&&_+p===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let g=r.lines.get(e[1]+1);if(g!=null&&g.isWrapped&&g.getCodePoint(0)!==32){let k=this._getWordAt([0,e[1]+1],!1,!1,!0);k&&(p+=k.length)}}return{start:_,length:p}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=vn(s,this._bufferService.cols)}};dr=pe([$(3,Fe),$(4,Ft),$(5,Br),$(6,He),$(7,mt),$(8,pt)],dr);var Sn=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},yn=class{constructor(){this._color=new Sn,this._css=new Sn}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ce=Object.freeze((()=>{let e=[he.toColor("#2e3436"),he.toColor("#cc0000"),he.toColor("#4e9a06"),he.toColor("#c4a000"),he.toColor("#3465a4"),he.toColor("#75507b"),he.toColor("#06989a"),he.toColor("#d3d7cf"),he.toColor("#555753"),he.toColor("#ef2929"),he.toColor("#8ae234"),he.toColor("#fce94f"),he.toColor("#729fcf"),he.toColor("#ad7fa8"),he.toColor("#34e2e2"),he.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],r=t[s/6%6|0],n=t[s%6];e.push({css:be.toCss(i,r,n),rgba:be.toRgba(i,r,n)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:be.toCss(i,i,i),rgba:be.toRgba(i,i,i)})}return e})()),$t=he.toColor("#ffffff"),_s=he.toColor("#000000"),bn=he.toColor("#ffffff"),wn=_s,os={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},qc=$t,ur=class extends X{constructor(e){super(),this._optionsService=e,this._contrastCache=new yn,this._halfContrastCache=new yn,this._onChangeColors=this._register(new x),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:$t,background:_s,cursor:bn,cursorAccent:wn,selectionForeground:void 0,selectionBackgroundTransparent:os,selectionBackgroundOpaque:ne.blend(_s,os),selectionInactiveBackgroundTransparent:os,selectionInactiveBackgroundOpaque:ne.blend(_s,os),scrollbarSliderBackground:ne.opacity($t,.2),scrollbarSliderHoverBackground:ne.opacity($t,.4),scrollbarSliderActiveBackground:ne.opacity($t,.5),overviewRulerBorder:$t,ansi:Ce.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Q(e.foreground,$t),t.background=Q(e.background,_s),t.cursor=ne.blend(t.background,Q(e.cursor,bn)),t.cursorAccent=ne.blend(t.background,Q(e.cursorAccent,wn)),t.selectionBackgroundTransparent=Q(e.selectionBackground,os),t.selectionBackgroundOpaque=ne.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Q(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ne.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Q(e.selectionForeground,pn):void 0,t.selectionForeground===pn&&(t.selectionForeground=void 0),ne.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ne.opacity(t.selectionBackgroundTransparent,.3)),ne.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ne.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Q(e.scrollbarSliderBackground,ne.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Q(e.scrollbarSliderHoverBackground,ne.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Q(e.scrollbarSliderActiveBackground,ne.opacity(t.foreground,.5)),t.overviewRulerBorder=Q(e.overviewRulerBorder,qc),t.ansi=Ce.slice(),t.ansi[0]=Q(e.black,Ce[0]),t.ansi[1]=Q(e.red,Ce[1]),t.ansi[2]=Q(e.green,Ce[2]),t.ansi[3]=Q(e.yellow,Ce[3]),t.ansi[4]=Q(e.blue,Ce[4]),t.ansi[5]=Q(e.magenta,Ce[5]),t.ansi[6]=Q(e.cyan,Ce[6]),t.ansi[7]=Q(e.white,Ce[7]),t.ansi[8]=Q(e.brightBlack,Ce[8]),t.ansi[9]=Q(e.brightRed,Ce[9]),t.ansi[10]=Q(e.brightGreen,Ce[10]),t.ansi[11]=Q(e.brightYellow,Ce[11]),t.ansi[12]=Q(e.brightBlue,Ce[12]),t.ansi[13]=Q(e.brightMagenta,Ce[13]),t.ansi[14]=Q(e.brightCyan,Ce[14]),t.ansi[15]=Q(e.brightWhite,Ce[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;in.index-o.index),i=[];for(let n of s){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);i.push(o)}let r=s.length>0?s[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...i)}},Xc={trace:0,debug:1,info:2,warn:3,error:4,off:5},Yc="xterm.js: ",_r=class extends X{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Xc[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;ithis._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=t-1;r>=0;r--)this.set(e+r+s,this.get(e+r));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*G+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*G+0]=t|2097152|s[2]<<22):this._data[t*G+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*G+0]>>22}hasWidth(t){return this._data[t*G+0]&12582912}getFg(t){return this._data[t*G+1]}getBg(t){return this._data[t*G+2]}hasContent(t){return this._data[t*G+0]&4194303}getCodePoint(t){let s=this._data[t*G+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*G+0]&2097152}getString(t){let s=this._data[t*G+0];return s&2097152?this._combined[t]:s&2097151?Ct(s&2097151):""}isProtected(t){return this._data[t*G+2]&536870912}loadCell(t,s){return Fs=t*G,s.content=this._data[Fs+0],s.fg=this._data[Fs+1],s.bg=this._data[Fs+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*G+0]=s.content,this._data[t*G+1]=s.fg,this._data[t*G+2]=s.bg}setCellFromCodepoint(t,s,i,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*G+0]=s|i<<22,this._data[t*G+1]=r.fg,this._data[t*G+2]=r.bg}addCodepointToCell(t,s,i){let r=this._data[t*G+0];r&2097152?this._combined[t]+=Ct(s):r&2097151?(this._combined[t]=Ct(r&2097151)+Ct(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[t*G+0]=r}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s=0;--n)this.setCell(t+s+n,this.loadCell(t+n,r));for(let n=0;nthis.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let r=new Uint32Array(i);r.set(this._data),this._data=r}for(let r=this.length;r=t&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o=t&&delete this._extendedAttrs[a]}}return this.length=t,i*4*wi=0;--t)if(this._data[t*G+0]&4194303)return t+(this._data[t*G+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*G+0]&4194303||this._data[t*G+2]&50331648)return t+(this._data[t*G+0]>>22);return 0}copyCellsFrom(t,s,i,r,n){let o=t._data;if(n)for(let h=r-1;h>=0;h--){for(let l=0;l=s&&(this._combined[l-s+i]=t._combined[l])}}translateToString(t,s,i,r){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;s>22||1}return r&&r.push(s),n}};function Jc(e,t,s,i,r,n){let o=[];for(let a=0;a=a&&i0&&(g>d||c[g].getTrimmedLength()===0);g--)p++;p>0&&(o.push(a+c.length-p),o.push(p)),a+=c.length-1}return o}function Zc(e,t){let s=[],i=0,r=t[i],n=0;for(let o=0;ows(e,l,t)).reduce((h,l)=>h+l),n=0,o=0,a=0;for(;ah&&(n-=h,o++);let l=e[o].getWidth(n-1)===2;l&&n--;let c=l?s-1:s;i.push(c),a+=c}return i}function ws(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,r=e[t+1].getWidth(0)===2;return i&&r?s-1:s}var wa=class Ca{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Ca._nextId++,this._onDispose=this.register(new x),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),It(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};wa._nextId=1;var td=wa,ke={},At=ke.B;ke[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};ke.A={"#":"£"};ke.B=void 0;ke[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};ke.C=ke[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ke.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};ke.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};ke.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};ke.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};ke.E=ke[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};ke.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};ke.H=ke[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ke["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var xn=4294967295,kn=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=ye.clone(),this.savedCharset=At,this.markers=[],this._nullCell=Ze.fromCharData([0,Ho,1,0]),this._whitespaceCell=Ze.fromCharData([0,kt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new oi,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Cn(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new si),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new si),this._whitespaceCell}getBlankLine(e,t){return new fs(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&exn?xn:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=ye);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Cn(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(ye),i=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new fs(e,s)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=Jc(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(ye),s);if(i.length>0){let r=Zc(this.lines,i);Qc(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(ye),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let h=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),h.unshift(a);if(!s){let F=this.ybase+this.y;if(F>=o&&F0&&(r.push({start:o+h.length+n,newLines:f}),n+=f.length),h.push(...f);let _=c.length-1,p=c[_];p===0&&(_--,p=c[_]);let g=h.length-d-1,k=l;for(;g>=0;){let F=Math.min(k,p);if(h[_]===void 0)break;if(h[_].copyCellsFrom(h[g],k-F,p-F,F,!0),p-=F,p===0&&(_--,p=c[_]),k-=F,k===0){g--;let T=Math.max(g,0);k=ws(h,T,this._cols)}}for(let F=0;F0;)this.ybase===0?this.y0){let o=[],a=[];for(let p=0;p=0;p--)if(d&&d.start>l+u){for(let g=d.newLines.length-1;g>=0;g--)this.lines.set(p--,d.newLines[g]);p++,o.push({index:l+1,amount:d.newLines.length}),u+=d.newLines.length,d=r[++c]}else this.lines.set(p,a[l--]);let f=0;for(let p=o.length-1;p>=0;p--)o[p].index+=f,this.lines.onInsertEmitter.fire(o[p]),f+=o[p].amount;let _=Math.max(0,h+n-this.lines.maxLength);_>0&&this.lines.onTrimEmitter.fire(_)}}translateBufferLineToString(e,t,s=0,i){let r=this.lines.get(e);return r?r.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.lines.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},sd=class extends X{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new x),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new kn(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new kn(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},xa=2,ka=1,fr=class extends X{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new x),this.onResize=this._onResize.event,this._onScroll=this._register(new x),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,xa),this.rows=Math.max(e.rawOptions.rows||0,ka),this.buffers=this._register(new sd(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let r=s.ybase+s.scrollTop,n=s.ybase+s.scrollBottom;if(s.scrollTop===0){let o=s.lines.isFull;n===s.lines.length-1?o?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(n+1,0,i.clone()),o?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let o=n-r+1;s.lines.shiftElements(r+1,o-1,-1),s.lines.set(n,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};fr=pe([$(0,He)],fr);var jt={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:ni,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},id=["normal","bold","100","200","300","400","500","600","700","800","900"],rd=class extends X{constructor(e){super(),this._onOptionChange=this._register(new x),this.onOptionChange=this._onOptionChange.event;let t={...jt};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ae(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in jt))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in jt))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=jt[e]),!nd(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=jt[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=id.includes(t)?t:jt[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function nd(e){return e==="block"||e==="underline"||e==="bar"}function ps(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&ps(e[i],t-1);return s}var En=Object.freeze({insertMode:!1}),Rn=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),pr=class extends X{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new x),this.onData=this._onData.event,this._onUserInput=this._register(new x),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new x),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new x),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ps(En),this.decPrivateModes=ps(Rn)}reset(){this.modes=ps(En),this.decPrivateModes=ps(Rn)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};pr=pe([$(0,Fe),$(1,Ko),$(2,He)],pr);var Bn={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Ci(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var xi=String.fromCharCode,Ln={DEFAULT:e=>{let t=[Ci(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${xi(t[0])}${xi(t[1])}${xi(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ci(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ci(e,!0)};${e.x};${e.y}${t}`}},mr=class extends X{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new x),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(Bn))this.addProtocol(i,Bn[i]);for(let i of Object.keys(Ln))this.addEncoding(i,Ln[i]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};mr=pe([$(0,Fe),$(1,Ft),$(2,He)],mr);var ki=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],od=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],xe;function ad(e,t){let s=0,i=t.length-1,r;if(et[i][1])return!1;for(;i>=s;)if(r=s+i>>1,e>t[r][1])s=r+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let r=Pt.extractWidth(t);r===0?i=!1:r>s&&(s=r)}return Pt.createPropertyValue(0,s,i)}},Pt=class Vs{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new x,this.onChange=this._onChange.event;let t=new ld;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,i=0,r=t.length;for(let n=0;n=r)return s+this.wcwidth(o);let l=t.charCodeAt(n);56320<=l&&l<=57343?o=(o-55296)*1024+l-56320+65536:s+=this.wcwidth(l)}let a=this.charProperties(o,i),h=Vs.extractWidth(a);Vs.extractShouldJoin(a)&&(h-=Vs.extractWidth(i)),s+=h,i=a}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},hd=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Mn(e){var i;let t=(i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:i.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var as=2147483647,cd=256,Ea=class gr{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>cd)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new gr;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i>8,r=this._subParamsIdx[s]&255;r-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,r))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>as?as:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>as?as:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s>8,r=this._subParamsIdx[s]&255;r-i>0&&(t[s]=this._subParams.slice(i,r))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,r=i[s-1];i[s-1]=~r?Math.min(r*10+t,as):t}},ls=[],dd=class{constructor(){this._state=0,this._active=ls,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ls}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ls,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ls,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",hi(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=ls,this._id=-1,this._state=0}}},qe=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=hi(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},hs=[],ud=class{constructor(){this._handlers=Object.create(null),this._active=hs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=hs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=hs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||hs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",hi(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=hs,this._ident=0}},ms=new Ea;ms.addParam(0);var Dn=class{constructor(e){this._handler=e,this._data="",this._params=ms,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ms,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=hi(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=ms,this._data="",this._hitLimit=!1,s));return this._params=ms,this._data="",this._hitLimit=!1,t}},_d=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let r=0;rh),s=(a,h)=>t.slice(a,h),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let n=s(0,14),o;e.setDefault(1,0),e.addMany(i,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(s(128,144),o,3,0),e.addMany(s(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Je,0,2,0),e.add(Je,8,5,8),e.add(Je,6,0,6),e.add(Je,11,0,11),e.add(Je,13,13,13),e})(),pd=class extends X{constructor(e=fd){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Ea,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ae(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new dd),this._dcsParser=this._register(new ud),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;rn||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,i,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=r}parse(e,t,s){let i=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(o=a[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(o=a[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(i!==24&&i!==26,s),o)return o;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],o=this._oscParser.end(i!==24&&i!==26,s),o)return o;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=n;a>4){case 2:for(let u=a+1;;++u){if(u>=t||(i=e[u])<32||i>126&&i=t||(i=e[u])<32||i>126&&i=t||(i=e[u])<32||i>126&&i=t||(i=e[u])<32||i>126&&i=0&&(o=h[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(3,h,l,r,a),o;l<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++a47&&i<60);a--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let c=this._escHandlers[this._collect<<8|i],d=c?c.length-1:-1;for(;d>=0&&(o=c[d](),o!==!0);d--)if(o instanceof Promise)return this._preserveStack(4,c,d,r,a),o;d<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let u=a+1;;++u)if(u>=t||(i=e[u])===24||i===26||i===27||i>127&&i=t||(i=e[u])<32||i>127&&i>4:n>>8}return i}}function Ei(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function vd(e,t=16){let[s,i,r]=e;return`rgb:${Ei(s,t)}/${Ei(i,t)}/${Ei(r,t)}`}var Sd={"(":0,")":1,"*":2,"+":3,"-":1,".":2},yt=131072,$n=10;function An(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Pn=5e3,Nn=0,yd=class extends X{constructor(e,t,s,i,r,n,o,a,h=new pd){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Fl,this._utf8Decoder=new Hl,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=ye.clone(),this._eraseAttrDataInternal=ye.clone(),this._onRequestBell=this._register(new x),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new x),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new x),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new x),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new x),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new x),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new x),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new x),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new x),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new x),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new x),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new x),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new x),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new vr(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,c)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:c.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,c,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:c,data:d})}),this._parser.setDcsHandlerFallback((l,c,d)=>{c==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:c,payload:d})}),this._parser.setPrintHandler((l,c,d)=>this.print(l,c,d)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(v.BEL,()=>this.bell()),this._parser.setExecuteHandler(v.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(v.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(v.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(v.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(v.BS,()=>this.backspace()),this._parser.setExecuteHandler(v.HT,()=>this.tab()),this._parser.setExecuteHandler(v.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(v.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ks.IND,()=>this.index()),this._parser.setExecuteHandler(Ks.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ks.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new qe(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new qe(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new qe(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new qe(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new qe(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new qe(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new qe(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new qe(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new qe(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new qe(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new qe(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new qe(l=>this.restoreCursorColor(l))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let l in ke)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Dn((l,c)=>this.requestStatusString(l,c)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),Pn))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Pn} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>yt&&(n=this._parseStack.position+yt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(l=>l.charCodeAt(0)):e),this._parseBuffer.lengthyt)for(let l=n;l0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let u=this._parser.precedingJoinState;for(let f=t;fa){if(h){let k=d,q=this._activeBuffer.x-g;for(this._activeBuffer.x=g,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),g>0&&d instanceof fs&&d.copyCellsFrom(k,q,0,g,!1);q=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);continue}if(l&&(d.insertCells(this._activeBuffer.x,r-g,this._activeBuffer.getNullCell(c)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,c)),d.setCellFromCodepoint(this._activeBuffer.x++,i,r,c),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c)}this._parser.precedingJoinState=u,this._activeBuffer.x0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>An(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Dn(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new qe(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var i;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&i.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let h=a;for(let l=1;l0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(v.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(v.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(v.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(v.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(v.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(p[p.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",p[p.SET=1]="SET",p[p.RESET=2]="RESET",p[p.PERMANENTLY_SET=3]="PERMANENTLY_SET",p[p.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:h}=this._bufferService,{active:l,alt:c}=a,d=this._optionsService.rawOptions,u=(p,g)=>(o.triggerDataEvent(`${v.ESC}[${t?"":"?"}${p};${g}$y`),!0),f=p=>p?1:2,_=e.params[0];return t?_===2?u(_,4):_===4?u(_,f(o.modes.insertMode)):_===12?u(_,3):_===20?u(_,f(d.convertEol)):u(_,0):_===1?u(_,f(i.applicationCursorKeys)):_===3?u(_,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):_===6?u(_,f(i.origin)):_===7?u(_,f(i.wraparound)):_===8?u(_,3):_===9?u(_,f(r==="X10")):_===12?u(_,f(d.cursorBlink)):_===25?u(_,f(!o.isCursorHidden)):_===45?u(_,f(i.reverseWraparound)):_===66?u(_,f(i.applicationKeypad)):_===67?u(_,4):_===1e3?u(_,f(r==="VT200")):_===1002?u(_,f(r==="DRAG")):_===1003?u(_,f(r==="ANY")):_===1004?u(_,f(i.sendFocus)):_===1005?u(_,4):_===1006?u(_,f(n==="SGR")):_===1015?u(_,4):_===1016?u(_,f(n==="SGR_PIXELS")):_===1048?u(_,1):_===47||_===1047||_===1049?u(_,f(l===c)):_===2004?u(_,f(i.bracketedPasteMode)):_===2026?u(_,f(i.synchronizedOutput)):u(_,0)}_updateAttrColor(e,t,s,i,r){return t===2?(e|=50331648,e&=-16777216,e|=xs.fromColorRGB([s,i,r])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],r=0,n=0;do{if(i[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do i[1]===5&&(r=1),i[n+a+1+r]=o[a];while(++a=2||i[1]===2&&n+r>=5)break;i[1]&&(r=1)}while(++n+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=ye.fg,e.bg=ye.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,i=this._curAttrData;for(let r=0;r=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=ye.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=ye.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(e,r,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=ye.fg&16777215,i.bg&=-67108864,i.bg|=ye.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${v.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${v.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${v.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=ye.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!An(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${v.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>$n&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>$n&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),r=s.shift();if(/^\d+$/.exec(i)){let n=parseInt(i);if(In(n))if(r==="?")t.push({type:0,index:n});else{let o=Tn(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,r=s.findIndex(n=>n.startsWith("id="));return r!==-1&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let i=0;i=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=Tn(s[i]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let i=0;i=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=ye.clone(),this._eraseAttrDataInternal=ye.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ze;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${v.ESC}${o}${v.ESC}\\`),!0),i=this._bufferService.buffer,r=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},vr=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Nn=e,e=t,t=Nn),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};vr=pe([$(0,Fe)],vr);function In(e){return 0<=e&&e<256}var bd=5e7,On=12,wd=50,Cd=class extends X{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new x),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>bd)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],r=this._action(i,t);if(r){let o=a=>performance.now()-s>=On?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(s,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=On)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>wd&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Sr=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(h,a)),this._dataByLinkId.set(h.id,h),h.id}let s=e,i=this._getEntryIdKey(s),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Sr=pe([$(0,Fe)],Sr);var Fn=!1,xd=class extends X{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Zt),this._onBinary=this._register(new x),this.onBinary=this._onBinary.event,this._onData=this._register(new x),this.onData=this._onData.event,this._onLineFeed=this._register(new x),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new x),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new x),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new x),this._instantiationService=new Gc,this.optionsService=this._register(new rd(e)),this._instantiationService.setService(He,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(fr)),this._instantiationService.setService(Fe,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(_r)),this._instantiationService.setService(Ko,this._logService),this.coreService=this._register(this._instantiationService.createInstance(pr)),this._instantiationService.setService(Ft,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(mr)),this._instantiationService.setService(jo,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Pt)),this._instantiationService.setService(jl,this.unicodeService),this._charsetService=this._instantiationService.createInstance(hd),this._instantiationService.setService(Ul,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Sr),this._instantiationService.setService(qo,this._oscLinkService),this._inputHandler=this._register(new yd(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Te.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Te.forward(this._bufferService.onResize,this._onResize)),this._register(Te.forward(this.coreService.onData,this._onData)),this._register(Te.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Cd((t,s)=>this._inputHandler.parse(t,s))),this._register(Te.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new x),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Fn&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Fn=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,xa),t=Math.max(t,ka),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Mn.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Mn(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ae(()=>{for(let t of e)t.dispose()})}}},kd={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function Ed(e,t,s,i){var o;let r={type:0,cancel:!1,key:void 0},n=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key=v.ESC+"OA":r.key=v.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=v.ESC+"OD":r.key=v.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=v.ESC+"OC":r.key=v.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=v.ESC+"OB":r.key=v.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":v.DEL,e.altKey&&(r.key=v.ESC+r.key);break;case 9:if(e.shiftKey){r.key=v.ESC+"[Z";break}r.key=v.HT,r.cancel=!0;break;case 13:r.key=e.altKey?v.ESC+v.CR:v.CR,r.cancel=!0;break;case 27:r.key=v.ESC,e.altKey&&(r.key=v.ESC+v.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"D":t?r.key=v.ESC+"OD":r.key=v.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"C":t?r.key=v.ESC+"OC":r.key=v.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"A":t?r.key=v.ESC+"OA":r.key=v.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"B":t?r.key=v.ESC+"OB":r.key=v.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=v.ESC+"[2~");break;case 46:n?r.key=v.ESC+"[3;"+(n+1)+"~":r.key=v.ESC+"[3~";break;case 36:n?r.key=v.ESC+"[1;"+(n+1)+"H":t?r.key=v.ESC+"OH":r.key=v.ESC+"[H";break;case 35:n?r.key=v.ESC+"[1;"+(n+1)+"F":t?r.key=v.ESC+"OF":r.key=v.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=v.ESC+"[5;"+(n+1)+"~":r.key=v.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=v.ESC+"[6;"+(n+1)+"~":r.key=v.ESC+"[6~";break;case 112:n?r.key=v.ESC+"[1;"+(n+1)+"P":r.key=v.ESC+"OP";break;case 113:n?r.key=v.ESC+"[1;"+(n+1)+"Q":r.key=v.ESC+"OQ";break;case 114:n?r.key=v.ESC+"[1;"+(n+1)+"R":r.key=v.ESC+"OR";break;case 115:n?r.key=v.ESC+"[1;"+(n+1)+"S":r.key=v.ESC+"OS";break;case 116:n?r.key=v.ESC+"[15;"+(n+1)+"~":r.key=v.ESC+"[15~";break;case 117:n?r.key=v.ESC+"[17;"+(n+1)+"~":r.key=v.ESC+"[17~";break;case 118:n?r.key=v.ESC+"[18;"+(n+1)+"~":r.key=v.ESC+"[18~";break;case 119:n?r.key=v.ESC+"[19;"+(n+1)+"~":r.key=v.ESC+"[19~";break;case 120:n?r.key=v.ESC+"[20;"+(n+1)+"~":r.key=v.ESC+"[20~";break;case 121:n?r.key=v.ESC+"[21;"+(n+1)+"~":r.key=v.ESC+"[21~";break;case 122:n?r.key=v.ESC+"[23;"+(n+1)+"~":r.key=v.ESC+"[23~";break;case 123:n?r.key=v.ESC+"[24;"+(n+1)+"~":r.key=v.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=v.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=v.DEL:e.keyCode===219?r.key=v.ESC:e.keyCode===220?r.key=v.FS:e.keyCode===221&&(r.key=v.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let a=(o=kd[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)r.key=v.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(h);e.shiftKey&&(l=l.toUpperCase()),r.key=v.ESC+l}else if(e.keyCode===32)r.key=v.ESC+(e.ctrlKey?v.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=v.ESC+h,r.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=v.US),e.key==="@"&&(r.key=v.NUL));break}return r}var ge=0,Rd=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new oi,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new oi,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((r,n)=>this._getKey(r)-this._getKey(n)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let r=0;r=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[r]=e[t],t++):i[r]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ge=this._search(t),ge===-1)||this._getKey(this._array[ge])!==t)return!1;do if(this._array[ge]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ge),!0;while(++ger-n),t=0,s=new Array(this._array.length-e.length),i=0;for(let r=0;r0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ge=this._search(e),!(ge<0||ge>=this._array.length)&&this._getKey(this._array[ge])===e))do yield this._array[ge];while(++ge=this._array.length)&&this._getKey(this._array[ge])===e))do t(this._array[ge]);while(++ge=t;){let i=t+s>>1,r=this._getKey(this._array[i]);if(r>e)s=i-1;else if(r0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},Ri=0,Hn=0,Bd=class extends X{constructor(){super(),this._decorations=new Rd(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new x),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new x),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ae(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Ld(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let i=0,r=0;for(let n of this._decorations.getKeyIterator(t))i=n.options.x??0,r=i+(n.options.width??1),e>=i&&e{Ri=r.options.x??0,Hn=Ri+(r.options.width??1),e>=Ri&&e=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=i-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Wn=20,ai=class extends X{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;nthis._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Dd(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(j(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ae(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Wn+1&&(this._liveRegion.textContent+=Fi.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let r=e;r<=t;r++){let n=s.lines.get(s.ydisp+r),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",h=(s.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,o)),l.setAttribute("aria-posinset",h),l.setAttribute("aria-setsize",i),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],r=s.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==i)return;let o,a;if(t===0?(o=s,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=s,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var a;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:((a=i.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(s.node))return;let r=({node:h,offset:l})=>{let c=h instanceof Text?h.parentNode:h,d=parseInt(c==null?void 0:c.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(c);if(!u)return console.warn("columns is null. Race condition?"),null;let f=l=this._terminal.cols&&(++d,f=0),{row:d,column:f}},n=r(t),o=r(s);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;te;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{var n;It(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(j(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(j(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(j(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(j(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let i=0;i{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(n)&&(s=this._checkLinkProviderResult(n,e,s)):o.provideLinks(e.y,a=>{var l,c;if(this._isMouseOut)return;let h=a==null?void 0:a.map(d=>({link:d}));(l=this._activeProviderReplies)==null||l.set(n,h),s=this._checkLinkProviderResult(n,e,s),((c=this._activeProviderReplies)==null?void 0:c.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;ie?this._bufferService.cols:o.link.range.end.x;for(let l=a;l<=h;l++){if(s.has(l)){r.splice(n--,1);break}s.add(l)}}}}_checkLinkProviderResult(e,t,s){var n;if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),r=!1;for(let o=0;othis._linkAtPosition(a.link,t));o&&(s=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let o=0;othis._linkAtPosition(h.link,t));if(a){s=!0,this._handleNewLink(a);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Td(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,It(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.pointerCursor},set:s=>{var i;(i=this._currentLink)!=null&&i.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.underline},set:s=>{var i,r,n;(i=this._currentLink)!=null&&i.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return s<=r&&r<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,r){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:r}}};yr=pe([$(1,Br),$(2,mt),$(3,Fe),$(4,Go)],yr);function Td(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var $d=class extends xd{constructor(e={}){super(e),this._linkifier=this._register(new Zt),this.browser=_a,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Zt),this._onCursorMove=this._register(new x),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new x),this.onKey=this._onKey.event,this._onRender=this._register(new x),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new x),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new x),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new x),this.onBell=this._onBell.event,this._onFocus=this._register(new x),this._onBlur=this._register(new x),this._onA11yCharEmitter=this._register(new x),this._onA11yTabEmitter=this._register(new x),this._onWillOpen=this._register(new x),this._setup(),this._decorationService=this._instantiationService.createInstance(Bd),this._instantiationService.setService(ks,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(wc),this._instantiationService.setService(Go,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Wi)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Te.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Te.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Te.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Te.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ae(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let r=ne.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${v.ESC}]${i};${vd(r)}${da.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=be.toColor(...t.color));else{let n=s;this._themeService.modifyColors(o=>o[n]=be.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ai,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(v.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(v.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,r=t.getWidth(s),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(j(this.element,"copy",t=>{this.hasSelection()&&Il(t,this._selectionService)}));let e=t=>Ol(t,this.textarea,this.coreService,this.optionsService);this._register(j(this.textarea,"paste",e)),this._register(j(this.element,"paste",e)),fa?this._register(j(this.element,"mousedown",t=>{t.button===2&&Yr(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(j(this.element,"contextmenu",t=>{Yr(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Nr&&this._register(j(this.element,"auxclick",t=>{t.button===1&&Fo(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(j(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(j(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(j(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(j(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(j(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(j(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(j(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((r=this.element)==null?void 0:r.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(j(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Oi.get()),ga||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(yc,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(pt,this._coreBrowserService),this._register(j(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(j(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(lr,this._document,this._helperContainer),this._instantiationService.setService(ci,this._charSizeService),this._themeService=this._instantiationService.createInstance(ur),this._instantiationService.setService(es,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ri),this._instantiationService.setService(Vo,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(cr,this.rows,this.screenElement)),this._instantiationService.setService(mt,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(nr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(hr),this._instantiationService.setService(Br,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(yr,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(ir,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(dr,this.element,this.screenElement,i)),this._instantiationService.setService(ql,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(Te.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(rr,this.screenElement)),this._register(j(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(ai,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ii,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ii,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(ar,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(n){var l,c,d,u,f;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let a,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(a=3,n.button!==void 0&&(a=n.button<3?n.button:3)):a=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,a=n.button<3?n.button:3;break;case"mousedown":h=1,a=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let _=n.deltaY;if(_===0||e.coreMouseService.consumeWheelEvent(n,(u=(d=(c=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:c.device)==null?void 0:d.cell)==null?void 0:u.height,(f=e._coreBrowserService)==null?void 0:f.dpr)===0)return!1;h=_<0?0:1,a=4;break;default:return!1}return h===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(s(n),n.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(n)),wheel:n=>(s(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&s(n)},mousemove:n=>{n.buttons||s(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),n&8?i.mousemove||(t.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),n&16?i.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),n&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),n&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(j(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return s(n),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(n)})),this._register(j(t,"wheel",n=>{var o,a,h,l,c;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(l=(h=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:h.cell)==null?void 0:l.height,(c=e._coreBrowserService)==null?void 0:c.dpr)===0)return this.cancel(n,!0);let d=v.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Oo(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=Ed(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===v.ETX||s.key===v.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Ad(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Ze)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},zn=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new Nd(t)}getNullCell(){return new Ze}},Id=class extends X{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new x),this.onBufferChange=this._onBufferChange.event,this._normal=new zn(this._core.buffers.normal,"normal"),this._alternate=new zn(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},Od=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Fd=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Hd=["cols","rows"],at=0,Wd=class extends X{constructor(e){super(),this._core=this._register(new $d(e)),this._addonManager=this._register(new Pd),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,r)=>{this._checkReadonlyOptions(i),this._core.options[i]=r};for(let i in this._core.options){let r={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,r)}}_checkReadonlyOptions(e){if(Hd.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new Od(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Fd(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new Id(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Oi.get()},set promptLabel(e){Oi.set(e)},get tooMuchOutput(){return Fi.get()},set tooMuchOutput(e){Fi.set(e)}}}_verifyIntegers(...e){for(at of e)if(at===1/0||isNaN(at)||at%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(at of e)if(at&&(at===1/0||isNaN(at)||at%1!==0||at<0))throw new Error("This API only accepts positive integers")}};/** @@ -66,12 +66,12 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var Kd=class{constructor(e,t,s,i={}){this._terminal=e,this._regex=t,this._handler=s,this._options=i}provideLinks(e,t){let s=Vd.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(s))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(s,i)=>{if(this._options.hover){let{range:r}=t;this._options.hover(s,i,r)}},t))}};function qd(e){try{let t=new URL(e),s=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}var Vd=class Gs{static computeLink(t,s,i,r){let n=new RegExp(s.source,(s.flags||"")+"g"),[o,a]=Gs._getWindowedLineStrings(t-1,i),h=o.join(""),l,c=[];for(;l=n.exec(h);){let d=l[0];if(!qd(d))continue;let[u,f]=Gs._mapStrIdx(i,a,0,l.index),[_,p]=Gs._mapStrIdx(i,u,f,d.length);if(u===-1||f===-1||_===-1||p===-1)continue;let g={start:{x:f+1,y:u+1},end:{x:p,y:_+1}};c.push({range:g,text:d,activate:r})}return c}static _getWindowedLineStrings(t,s){let i,r=t,n=t,o=0,a="",h=[];if(i=s.buffer.active.getLine(t)){let l=i.translateToString(!0);if(i.isWrapped&&l[0]!==" "){for(o=0;(i=s.buffer.active.getLine(--r))&&o<2048&&(a=i.translateToString(!0),o+=a.length,h.push(a),!(!i.isWrapped||a.indexOf(" ")!==-1)););h.reverse()}for(h.push(l),o=0;(i=s.buffer.active.getLine(++n))&&i.isWrapped&&o<2048&&(a=i.translateToString(!0),o+=a.length,h.push(a),a.indexOf(" ")===-1););}return[h,r]}static _mapStrIdx(t,s,i,r){let n=t.buffer.active,o=n.getNullCell(),a=i;for(;r;){let h=n.getLine(s);if(!h)return[-1,-1];for(let l=a;l`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Xd(e,t){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var Yd=class{constructor(t=Xd,s={}){this._handler=t,this._options=s}activate(t){this._terminal=t;let s=this._options,i=s.urlRegex||Gd;this._linkProvider=this._terminal.registerLinkProvider(new Kd(this._terminal,i,this._handler,s))}dispose(){var t;(t=this._linkProvider)==null||t.dispose()}};class Jd{constructor(){D(this,"commands",[])}register(...t){this.commands.push(...t)}find(t){let s;for(const i of this.commands)i.matches(t)&&(!s||i.name.length>s.name.length)&&(s=i);return s}all(){return this.commands}}class ie{constructor(){D(this,"aliases",[]);D(this,"params")}matches(t){const s=t.toLowerCase().trim(),i=r=>s===r||s.startsWith(r+" ");return i(this.name)||this.aliases.some(i)}argsAfterName(t){const s=t.toLowerCase().trim(),i=[this.name,...this.aliases].sort((r,n)=>n.length-r.length);for(const r of i)if(s.startsWith(r))return t.trim().slice(r.length).trim();return t.trim()}}const Qe="\x1B[",se=`${Qe}0m`,Rt=`${Qe}1m`,Zd=`${Qe}2m`,Qd=`${Qe}3m`,_i=`${Qe}32m`,Qt=`${Qe}31m`,Bs=`${Qe}33m`,Ra=`${Qe}36m`,Ms=`${Qe}34m`,Ht=`${Qe}90m`,eu=`${Qe}92m`,tu=`${Qe}96m`;function Un(e,t){switch(t){case"success":return`${_i}${e}${se}`;case"error":return`${Qt}${e}${se}`;case"warning":return`${Bs}${e}${se}`;case"info":return`${Ra}${e}${se}`;case"value":return`${Ms}${e}${se}`;case"system":return`${Ht}${e}${se}`;default:return e}}function st(e){return`${Rt}${e}${se}`}function Pe(e){return`${Zd}${e}${se}`}function su(e){return`${Bs}${e}${se}`}function y(e){return`${Ms}${e}${se}`}function b(e){return`${Ht}${e}${se}`}function w(e,t){return`${Ht}${e}: ${se}${Ms}${Rt}${t}${se}`}function B(e,t,s=22){const i=e.split(" "),r=i[0];let n=Ra;r==="get"?n=_i:r==="set"&&(n=Bs);const o=i.length>1?`${n}${Rt}${r}${se} ${Ms}${i.slice(1).join(" ")}${se}`:`${n}${Rt}${e}${se}`,a=" ".repeat(Math.max(1,s-e.length));return` ${o}${a}${Ht}${t}${se}`}function z(e){return`${Rt}${Ms}${e}${se}`}function it(e){return`${Ht}${Qd}${e}${se}`}function iu(e){return`\x1B[1;92m${e||"user"}@pyMC${se}: \x1B[38;2;91;91;214m$${se} `}function Bi(e){return`${Qt}${Rt}●${se} ${Ht}${e}${se}`}function ru(e){return e<1500?eu:e<4e3?_i:e<8e3?Bs:e<15e3?Qt:`${Qt}${Rt}`}function nu(e){const t=e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(1)}s`;return`${ru(e)}${t}${se}`}function Ir(e){switch(e){case"excellent":return tu;case"good":return _i;case"fair":return Bs;case"poor":return Qt;case"critical":return`${Qt}${Rt}`;default:return Ht}}function ou(e,t){return`${Ir(t)}${e}${se}`}function jn(e){return e.replace(/[\p{Emoji_Presentation}\p{Extended_Pictographic}\uFE0F\u200D]/gu,"").trim()}const Hs="\x1B[2K\r";function au(e=1){return`\x1B[${e}A`}const lu="\x1B[K",hu="\x1B[H",cu="\x1B[J",du="\x1B[?1049h",Kn="\x1B[?1049l",uu="\x1B[?25l",qn="\x1B[?25h";function Ba(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function _u(e){return Ba(e).length}function br(e,t){let s=0;for(const i of e){const r=Ba(i).length;s+=r===0?1:Math.ceil(r/t)}return s}function fu(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function et(e,t){return fu(e)||t}function pu(){return document.documentElement.dataset.mode==="light"}function Ma(){const e=pu(),t=et("--terminal-bg","#0d0d0d"),s=et("--sys-blue",ve.blue);if(e){const f="#EFF0F1";return{background:f,foreground:"#111314",cursor:ve.blue,cursorAccent:f,selectionBackground:`${ve.blue}30`,selectionForeground:"#111314",black:"#111314",red:ve.red,green:ve.green,yellow:ve.amber,blue:ve.blue,magenta:ve.purple,cyan:ve.cyan,white:f,brightBlack:is[500],brightRed:ve.red,brightGreen:ve.green,brightYellow:ve.orange,brightBlue:ve.indigo,brightMagenta:ve.pink,brightCyan:ve.teal,brightWhite:is[600]}}const i=et("--text-primary","#e0e0e0"),r=s+"40",n=et("--sys-red",ve.red),o=et("--sys-green",ve.green),a=et("--sys-purple",ve.purple),h=et("--sys-blue",ve.blue),l=et("--sys-cyan",ve.cyan),c=et("--text-muted",is[500]),d=et("--text-secondary",is[400]),u=et("--bg-surface",is[900]);return{background:t,foreground:i,cursor:s,cursorAccent:t,selectionBackground:r,selectionForeground:i,black:u,red:n,green:o,yellow:a,blue:h,magenta:a,cyan:l,white:i,brightBlack:c,brightRed:n,brightGreen:"#4ADE80",brightYellow:a,brightBlue:h,brightMagenta:a,brightCyan:l,brightWhite:d}}function mu(e){return Ka.subscribe(()=>{e.options.theme=Ma()})}const Ls="\x1B[",Bt=`${Ls}0m`,gu=`${Ls}1m`,vu=`${Ls}2m`,La=`${Ls}34m`,Ds=`${Ls}90m`,Mi=24,Li=13,Vn=" ",Gn=" ",Su=[{label:"INFORMATION",entries:[{cmd:"status",desc:"Repeater status summary",alias:"st"},{cmd:"top",desc:"Live system overview (Ctrl+C to exit)",alias:"htop"},{cmd:"ver",desc:"Version info",alias:"version"},{cmd:"clock",desc:"System UTC time"},{cmd:"uptime",desc:"System uptime"},{cmd:"board",desc:"Board / platform info"},{cmd:"packets",desc:"Packet statistics"},{cmd:"stats-packets",desc:"Packet counters (firmware compat)"},{cmd:"stats-radio",desc:"Radio health stats (firmware compat)"},{cmd:"stats-core",desc:"Engine vitals (firmware compat)"}]},{label:"NETWORK",entries:[{cmd:"neighbors [sort]",desc:"Direct RF neighbors",alias:"nb",sub:"sig · name · rssi · snr · dist · heard"},{cmd:"ping {name}",desc:"Ping neighbor (name or 0xXX)"},{cmd:"identities",desc:"List configured identities",alias:"id ids"},{cmd:"keys",desc:"Transport keys"},{cmd:"acl",desc:"ACL statistics"},{cmd:"rooms",desc:"Room statistics"}]},{label:"RADIO",entries:[{cmd:"get {param}",desc:"Read parameter"},{cmd:"set {param} {value}",desc:"Write parameter"},{cmd:"advert",desc:"Send advertisement"}]},{label:"SYSTEM",entries:[{cmd:"restart",desc:"Restart service",alias:"reboot"},{cmd:"start cap [seconds]",desc:"Start packet capture"},{cmd:"end cap",desc:"Stop capture"},{cmd:"list cap",desc:"List captures"},{cmd:"export cap [id]",desc:"Download capture"}]},{label:"TOOLS",entries:[{cmd:"convert hex {value}",desc:"Hex → base64"},{cmd:"convert base64 {value}",desc:"Base64 → hex"},{cmd:"clear",desc:"Clear terminal",alias:"cls"},{cmd:"help [command]",desc:"Show this help",alias:"? h"}]}],yu=[{cat:"Identity",params:["name","role","lat","lon","public.key"]},{cat:"Radio",params:["radio","freq","tx","bw","sf","cr"]},{cat:"Timing",params:["txdelay","direct.txdelay","rxdelay"]},{cat:"Repeater",params:["mode","duty","repeat","flood.max","advert.interval"]},{cat:"Advanced",params:["multi.acks","int.thresh","agc.reset.interval"]},{cat:"set only",params:["log","prv.key"]}];function Da(e){return`${Ds}${"─".repeat(e)}${Bt}`}function bu(e){const t="pymc console",s="terminal",i=Math.max(3,e-t.length-s.length-6);return` ${La}${gu}${t}${Bt} ${Da(i)} ${Ds}${s}${Bt}`}function Ta(e){return` ${Ds}${e}${Bt}`}function wu(e,t){const s=[],i=e.alias?` ${vu}${e.alias}${Bt}`:"";return 4+Math.max(e.cmd.length,Mi)+e.desc.length+(e.alias?2+e.alias.length:0)<=t?s.push(Vn+B(e.cmd,e.desc,Mi)+i):(s.push(Vn+B(e.cmd,"",Mi)),s.push(Gn+b(e.desc)+i)),e.sub&&s.push(`${Gn}${Pe("└ "+e.sub)}`),s}function Xn(e){return e.split(" · ").map(t=>`${La}${t}${Bt}`).join(`${Ds} · ${Bt}`)}function Cu(e,t){const i=[];let r=[],n=0;for(const o of e){const a=r.length>0?3+o.length:o.length;n+a>t&&r.length>0?(i.push(r),r=[o],n=o.length):(r.push(o),n+=a)}return r.length>0&&i.push(r),i}function xu(e){const t=["",Ta("GET/SET QUALIFIERS")],s=Math.max(20,e-4-Li);for(const i of yu){const r=`${Ds}${i.cat.padEnd(Li)}${Bt}`,n=Cu(i.params,s),o=" ".repeat(4+Li);t.push(` ${r}${Xn(n[0].join(" · "))}`);for(let a=1;a help for detailed usage")}`]}class Eu extends ie{constructor(s){super();D(this,"name","help");D(this,"description","Show available commands");D(this,"aliases",["?","h"]);this.registry=s}execute({output:s,rawInput:i,cols:r}){const n=this.argsAfterName(i).toLowerCase().trim();if(n&&n!=="help"){const a=this.registry.find(n+" help")||this.registry.find(n);if(a){a.execute({output:s,rawInput:a.name+" help",args:[a.name,"help"],cols:r,signal:new AbortController().signal});return}s.write(`Unknown command: ${y(n)}`,"warning");return}const o=[bu(r),""];for(const a of Su){o.push(Ta(a.label));for(const h of a.entries)o.push(...wu(h,r));a.label==="RADIO"&&o.push(...xu(r)),o.push("")}o.push(...ku(r)),s.write(o.join(` + */var Kd=class{constructor(e,t,s,i={}){this._terminal=e,this._regex=t,this._handler=s,this._options=i}provideLinks(e,t){let s=Vd.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(s))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(s,i)=>{if(this._options.hover){let{range:r}=t;this._options.hover(s,i,r)}},t))}};function qd(e){try{let t=new URL(e),s=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}var Vd=class Gs{static computeLink(t,s,i,r){let n=new RegExp(s.source,(s.flags||"")+"g"),[o,a]=Gs._getWindowedLineStrings(t-1,i),h=o.join(""),l,c=[];for(;l=n.exec(h);){let d=l[0];if(!qd(d))continue;let[u,f]=Gs._mapStrIdx(i,a,0,l.index),[_,p]=Gs._mapStrIdx(i,u,f,d.length);if(u===-1||f===-1||_===-1||p===-1)continue;let g={start:{x:f+1,y:u+1},end:{x:p,y:_+1}};c.push({range:g,text:d,activate:r})}return c}static _getWindowedLineStrings(t,s){let i,r=t,n=t,o=0,a="",h=[];if(i=s.buffer.active.getLine(t)){let l=i.translateToString(!0);if(i.isWrapped&&l[0]!==" "){for(o=0;(i=s.buffer.active.getLine(--r))&&o<2048&&(a=i.translateToString(!0),o+=a.length,h.push(a),!(!i.isWrapped||a.indexOf(" ")!==-1)););h.reverse()}for(h.push(l),o=0;(i=s.buffer.active.getLine(++n))&&i.isWrapped&&o<2048&&(a=i.translateToString(!0),o+=a.length,h.push(a),a.indexOf(" ")===-1););}return[h,r]}static _mapStrIdx(t,s,i,r){let n=t.buffer.active,o=n.getNullCell(),a=i;for(;r;){let h=n.getLine(s);if(!h)return[-1,-1];for(let l=a;l`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Xd(e,t){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var Yd=class{constructor(t=Xd,s={}){this._handler=t,this._options=s}activate(t){this._terminal=t;let s=this._options,i=s.urlRegex||Gd;this._linkProvider=this._terminal.registerLinkProvider(new Kd(this._terminal,i,this._handler,s))}dispose(){var t;(t=this._linkProvider)==null||t.dispose()}};class Jd{constructor(){D(this,"commands",[])}register(...t){this.commands.push(...t)}find(t){let s;for(const i of this.commands)i.matches(t)&&(!s||i.name.length>s.name.length)&&(s=i);return s}all(){return this.commands}}class ie{constructor(){D(this,"aliases",[]);D(this,"params")}matches(t){const s=t.toLowerCase().trim(),i=r=>s===r||s.startsWith(r+" ");return i(this.name)||this.aliases.some(i)}argsAfterName(t){const s=t.toLowerCase().trim(),i=[this.name,...this.aliases].sort((r,n)=>n.length-r.length);for(const r of i)if(s.startsWith(r))return t.trim().slice(r.length).trim();return t.trim()}}const Qe="\x1B[",se=`${Qe}0m`,Rt=`${Qe}1m`,Zd=`${Qe}2m`,Qd=`${Qe}3m`,_i=`${Qe}32m`,Qt=`${Qe}31m`,Bs=`${Qe}33m`,Ra=`${Qe}36m`,Ls=`${Qe}34m`,Ht=`${Qe}90m`,eu=`${Qe}92m`,tu=`${Qe}96m`;function Un(e,t){switch(t){case"success":return`${_i}${e}${se}`;case"error":return`${Qt}${e}${se}`;case"warning":return`${Bs}${e}${se}`;case"info":return`${Ra}${e}${se}`;case"value":return`${Ls}${e}${se}`;case"system":return`${Ht}${e}${se}`;default:return e}}function st(e){return`${Rt}${e}${se}`}function Pe(e){return`${Zd}${e}${se}`}function su(e){return`${Bs}${e}${se}`}function y(e){return`${Ls}${e}${se}`}function b(e){return`${Ht}${e}${se}`}function w(e,t){return`${Ht}${e}: ${se}${Ls}${Rt}${t}${se}`}function B(e,t,s=22){const i=e.split(" "),r=i[0];let n=Ra;r==="get"?n=_i:r==="set"&&(n=Bs);const o=i.length>1?`${n}${Rt}${r}${se} ${Ls}${i.slice(1).join(" ")}${se}`:`${n}${Rt}${e}${se}`,a=" ".repeat(Math.max(1,s-e.length));return` ${o}${a}${Ht}${t}${se}`}function z(e){return`${Rt}${Ls}${e}${se}`}function it(e){return`${Ht}${Qd}${e}${se}`}function iu(e){return`\x1B[1;92m${e||"user"}@pyMC${se}: \x1B[38;2;91;91;214m$${se} `}function Bi(e){return`${Qt}${Rt}●${se} ${Ht}${e}${se}`}function ru(e){return e<1500?eu:e<4e3?_i:e<8e3?Bs:e<15e3?Qt:`${Qt}${Rt}`}function nu(e){const t=e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(1)}s`;return`${ru(e)}${t}${se}`}function Ir(e){switch(e){case"excellent":return tu;case"good":return _i;case"fair":return Bs;case"poor":return Qt;case"critical":return`${Qt}${Rt}`;default:return Ht}}function ou(e,t){return`${Ir(t)}${e}${se}`}function jn(e){return e.replace(/[\p{Emoji_Presentation}\p{Extended_Pictographic}\uFE0F\u200D]/gu,"").trim()}const Hs="\x1B[2K\r";function au(e=1){return`\x1B[${e}A`}const lu="\x1B[K",hu="\x1B[H",cu="\x1B[J",du="\x1B[?1049h",Kn="\x1B[?1049l",uu="\x1B[?25l",qn="\x1B[?25h";function Ba(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function _u(e){return Ba(e).length}function br(e,t){let s=0;for(const i of e){const r=Ba(i).length;s+=r===0?1:Math.ceil(r/t)}return s}function fu(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function et(e,t){return fu(e)||t}function pu(){return document.documentElement.dataset.mode==="light"}function La(){const e=pu(),t=et("--terminal-bg","#0d0d0d"),s=et("--sys-blue",ve.blue);if(e){const f="#EFF0F1";return{background:f,foreground:"#111314",cursor:ve.blue,cursorAccent:f,selectionBackground:`${ve.blue}30`,selectionForeground:"#111314",black:"#111314",red:ve.red,green:ve.green,yellow:ve.amber,blue:ve.blue,magenta:ve.purple,cyan:ve.cyan,white:f,brightBlack:is[500],brightRed:ve.red,brightGreen:ve.green,brightYellow:ve.orange,brightBlue:ve.indigo,brightMagenta:ve.pink,brightCyan:ve.teal,brightWhite:is[600]}}const i=et("--text-primary","#e0e0e0"),r=s+"40",n=et("--sys-red",ve.red),o=et("--sys-green",ve.green),a=et("--sys-purple",ve.purple),h=et("--sys-blue",ve.blue),l=et("--sys-cyan",ve.cyan),c=et("--text-muted",is[500]),d=et("--text-secondary",is[400]),u=et("--bg-surface",is[900]);return{background:t,foreground:i,cursor:s,cursorAccent:t,selectionBackground:r,selectionForeground:i,black:u,red:n,green:o,yellow:a,blue:h,magenta:a,cyan:l,white:i,brightBlack:c,brightRed:n,brightGreen:"#4ADE80",brightYellow:a,brightBlue:h,brightMagenta:a,brightCyan:l,brightWhite:d}}function mu(e){return Ka.subscribe(()=>{e.options.theme=La()})}const Ms="\x1B[",Bt=`${Ms}0m`,gu=`${Ms}1m`,vu=`${Ms}2m`,Ma=`${Ms}34m`,Ds=`${Ms}90m`,Li=24,Mi=13,Vn=" ",Gn=" ",Su=[{label:"INFORMATION",entries:[{cmd:"status",desc:"Repeater status summary",alias:"st"},{cmd:"top",desc:"Live system overview (Ctrl+C to exit)",alias:"htop"},{cmd:"ver",desc:"Version info",alias:"version"},{cmd:"clock",desc:"System UTC time"},{cmd:"uptime",desc:"System uptime"},{cmd:"board",desc:"Board / platform info"},{cmd:"packets",desc:"Packet statistics"},{cmd:"stats-packets",desc:"Packet counters (firmware compat)"},{cmd:"stats-radio",desc:"Radio health stats (firmware compat)"},{cmd:"stats-core",desc:"Engine vitals (firmware compat)"}]},{label:"NETWORK",entries:[{cmd:"neighbors [sort]",desc:"Direct RF neighbors",alias:"nb",sub:"sig · name · rssi · snr · dist · heard"},{cmd:"ping {name}",desc:"Ping neighbor (name or 0xXX)"},{cmd:"identities",desc:"List configured identities",alias:"id ids"},{cmd:"keys",desc:"Transport keys"},{cmd:"acl",desc:"ACL statistics"},{cmd:"rooms",desc:"Room statistics"}]},{label:"RADIO",entries:[{cmd:"get {param}",desc:"Read parameter"},{cmd:"set {param} {value}",desc:"Write parameter"},{cmd:"advert",desc:"Send advertisement"}]},{label:"SYSTEM",entries:[{cmd:"restart",desc:"Restart service",alias:"reboot"},{cmd:"start cap [seconds]",desc:"Start packet capture"},{cmd:"end cap",desc:"Stop capture"},{cmd:"list cap",desc:"List captures"},{cmd:"export cap [id]",desc:"Download capture"}]},{label:"TOOLS",entries:[{cmd:"convert hex {value}",desc:"Hex → base64"},{cmd:"convert base64 {value}",desc:"Base64 → hex"},{cmd:"clear",desc:"Clear terminal",alias:"cls"},{cmd:"help [command]",desc:"Show this help",alias:"? h"}]}],yu=[{cat:"Identity",params:["name","role","lat","lon","public.key"]},{cat:"Radio",params:["radio","freq","tx","bw","sf","cr"]},{cat:"Timing",params:["txdelay","direct.txdelay","rxdelay"]},{cat:"Repeater",params:["mode","duty","repeat","flood.max","advert.interval"]},{cat:"Advanced",params:["multi.acks","int.thresh","agc.reset.interval"]},{cat:"set only",params:["log","prv.key"]}];function Da(e){return`${Ds}${"─".repeat(e)}${Bt}`}function bu(e){const t="pymc console",s="terminal",i=Math.max(3,e-t.length-s.length-6);return` ${Ma}${gu}${t}${Bt} ${Da(i)} ${Ds}${s}${Bt}`}function Ta(e){return` ${Ds}${e}${Bt}`}function wu(e,t){const s=[],i=e.alias?` ${vu}${e.alias}${Bt}`:"";return 4+Math.max(e.cmd.length,Li)+e.desc.length+(e.alias?2+e.alias.length:0)<=t?s.push(Vn+B(e.cmd,e.desc,Li)+i):(s.push(Vn+B(e.cmd,"",Li)),s.push(Gn+b(e.desc)+i)),e.sub&&s.push(`${Gn}${Pe("└ "+e.sub)}`),s}function Xn(e){return e.split(" · ").map(t=>`${Ma}${t}${Bt}`).join(`${Ds} · ${Bt}`)}function Cu(e,t){const i=[];let r=[],n=0;for(const o of e){const a=r.length>0?3+o.length:o.length;n+a>t&&r.length>0?(i.push(r),r=[o],n=o.length):(r.push(o),n+=a)}return r.length>0&&i.push(r),i}function xu(e){const t=["",Ta("GET/SET QUALIFIERS")],s=Math.max(20,e-4-Mi);for(const i of yu){const r=`${Ds}${i.cat.padEnd(Mi)}${Bt}`,n=Cu(i.params,s),o=" ".repeat(4+Mi);t.push(` ${r}${Xn(n[0].join(" · "))}`);for(let a=1;a help for detailed usage")}`]}class Eu extends ie{constructor(s){super();D(this,"name","help");D(this,"description","Show available commands");D(this,"aliases",["?","h"]);this.registry=s}execute({output:s,rawInput:i,cols:r}){const n=this.argsAfterName(i).toLowerCase().trim();if(n&&n!=="help"){const a=this.registry.find(n+" help")||this.registry.find(n);if(a){a.execute({output:s,rawInput:a.name+" help",args:[a.name,"help"],cols:r,signal:new AbortController().signal});return}s.write(`Unknown command: ${y(n)}`,"warning");return}const o=[bu(r),""];for(const a of Su){o.push(Ta(a.label));for(const h of a.entries)o.push(...wu(h,r));a.label==="RADIO"&&o.push(...xu(r)),o.push("")}o.push(...ku(r)),s.write(o.join(` `))}}class Ru extends ie{constructor(){super(...arguments);D(this,"name","clear");D(this,"description","Clear terminal screen");D(this,"aliases",["cls"])}execute({output:s,rawInput:i}){if(this.argsAfterName(i).toLowerCase().trim()==="help"){s.write([z("clear"),` ${b("Clear all terminal output.")}`,"",B("clear","clear the screen"),"",z("Aliases"),` ${b("cls")}`].join(` `));return}s.clear()}}function Or(e){const t=Math.floor(e/86400),s=Math.floor(e%86400/3600),i=Math.floor(e%3600/60);return t>0?`${t}d ${s}h ${i}m`:s>0?`${s}h ${i}m`:`${i}m`}class Bu extends ie{constructor(){super(...arguments);D(this,"name","status");D(this,"description","Get repeater status summary");D(this,"aliases",["st"])}async execute({output:s,rawInput:i}){var n,o,a;if(this.argsAfterName(i).toLowerCase().trim()==="help"){s.write([z("status"),` ${b("Show a quick summary of mode, neighbor count, and uptime.")}`,"",B("status","show summary"),"",z("Aliases"),` ${b("st")}`].join(` `));return}const r=s.write("processing...","system");try{const h=await rt(),l=((o=(n=h.config)==null?void 0:n.repeater)==null?void 0:o.mode)||"unknown",c=Object.keys(h.neighbors||{}).length,d=Object.values(h.neighbors||{}).filter(_=>_.zero_hop).length,u=((a=h.config)==null?void 0:a.node_name)||h.node_name||"unknown",f=Or(h.uptime_seconds||0);s.update(r,[`${st(u)} ${b("repeater")}`,"",` ${w("Mode",y(l))}`,` ${w("Neighbors",`${y(String(d))} direct ${b(`${c} total`)}`)}`,` ${w("RX / TX",`${y(String(h.rx_count??0))} / ${y(String(h.tx_count??0))}`)}`,` ${w("Uptime",y(f))}`].join(` -`))}catch(h){s.update(r,`Error: ${h instanceof Error?h.message:"Command failed"}`,"error")}}}class Mu extends ie{constructor(){super(...arguments);D(this,"name","uptime");D(this,"description","Show system uptime")}async execute({output:s,rawInput:i}){if(this.argsAfterName(i).toLowerCase().trim()==="help"){s.write([z("uptime"),` ${b("Display how long the repeater service has been running.")}`,"",B("uptime","show uptime")].join(` -`));return}const r=s.write("processing...","system");try{const n=await rt();s.update(r,w("Uptime",y(Or(n.uptime_seconds||0))))}catch(n){s.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class Lu extends ie{constructor(){super(...arguments);D(this,"name","packets");D(this,"description","Show packet statistics")}async execute({output:s,rawInput:i}){if(this.argsAfterName(i).toLowerCase().trim()==="help"){s.write([z("packets"),` ${b("Display packet counters (received, transmitted, forwarded, dropped).")}`,"",B("packets","show packet stats")].join(` +`))}catch(h){s.update(r,`Error: ${h instanceof Error?h.message:"Command failed"}`,"error")}}}class Lu extends ie{constructor(){super(...arguments);D(this,"name","uptime");D(this,"description","Show system uptime")}async execute({output:s,rawInput:i}){if(this.argsAfterName(i).toLowerCase().trim()==="help"){s.write([z("uptime"),` ${b("Display how long the repeater service has been running.")}`,"",B("uptime","show uptime")].join(` +`));return}const r=s.write("processing...","system");try{const n=await rt();s.update(r,w("Uptime",y(Or(n.uptime_seconds||0))))}catch(n){s.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class Mu extends ie{constructor(){super(...arguments);D(this,"name","packets");D(this,"description","Show packet statistics")}async execute({output:s,rawInput:i}){if(this.argsAfterName(i).toLowerCase().trim()==="help"){s.write([z("packets"),` ${b("Display packet counters (received, transmitted, forwarded, dropped).")}`,"",B("packets","show packet stats")].join(` `));return}const r=s.write("processing...","system");try{const n=await rt(),o=(n.rx_count??0)+(n.tx_count??0);s.update(r,[z("Packet Stats")+` ${b(`${o} total`)}`,"",` ${w("Received",y(String(n.rx_count??0)))}`,` ${w("Transmitted",y(String(n.tx_count??0)))}`,` ${w("Forwarded",y(String(n.forwarded_count??0)))}`,` ${w("Dropped",y(String(n.dropped_count??0)))}`].join(` `))}catch(n){s.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}function Kt(e){return e>=1073741824?`${(e/1073741824).toFixed(1)} GB`:e>=1048576?`${(e/1048576).toFixed(0)} MB`:`${(e/1024).toFixed(0)} KB`}function Di(e){const t=Math.floor(e/86400),s=Math.floor(e%86400/3600),i=Math.floor(e%3600/60);return t>0?`${t}d ${s}h ${i}m`:s>0?`${s}h ${i}m`:`${i}m`}class Du extends ie{constructor(){super(...arguments);D(this,"name","board");D(this,"description","Show board/platform info")}async execute({output:s,rawInput:i}){var n;if(this.argsAfterName(i).toLowerCase().trim()==="help"){s.write([z("board"),` ${b("Display platform and hardware information.")}`,"",B("board","show board info")].join(` `));return}const r=s.write("loading...","system");try{const[o,a]=await Promise.all([ei(),rt()]),h=[];if(h.push(` ${w("Node",y(a.node_name||"Unknown"))}`),h.push(` ${w("Runtime",y(`pyMC_Repeater v${a.version||"?"}`))}`),a.core_version&&h.push(` ${w("Core",y(a.core_version))}`),h.push(""),o.success&&o.data){const l=o.data;h.push(` ${w("CPU",y(`${l.cpu.usage_percent.toFixed(1)}%`))} ${b(`${l.cpu.count} core${l.cpu.count>1?"s":""}`)}`),l.cpu.load_avg&&h.push(` ${w("Load",y(`${l.cpu.load_avg["1min"].toFixed(2)} / ${l.cpu.load_avg["5min"].toFixed(2)} / ${l.cpu.load_avg["15min"].toFixed(2)}`))}`);const c=Object.entries(l.temperatures||{});if(c.length>0){const d=c[0];h.push(` ${w("Temp",y(`${d[1].toFixed(1)}°C`))}${c.length>1?` ${b(c.slice(1).map(([u,f])=>`${u}: ${f.toFixed(1)}°C`).join(", "))}`:""}`)}h.push(""),h.push(` ${w("Memory",y(`${Kt(l.memory.used)} / ${Kt(l.memory.total)}`))} ${b(`${l.memory.usage_percent.toFixed(0)}%`)}`),h.push(` ${w("Disk",y(`${Kt(l.disk.used)} / ${Kt(l.disk.total)}`))} ${b(`${l.disk.usage_percent.toFixed(0)}%`)}`),h.push(""),(n=l.system)!=null&&n.uptime&&h.push(` ${w("System uptime",y(Di(l.system.uptime)))}`),h.push(` ${w("Service uptime",y(Di(a.uptime_seconds)))}`),l.network&&h.push(` ${w("Net TX/RX",y(`${Kt(l.network.bytes_sent)} / ${Kt(l.network.bytes_recv)}`))}`)}else h.push(` ${w("Platform",y("Linux"))}`),h.push(` ${w("Service uptime",y(Di(a.uptime_seconds)))}`),h.push(` ${b("Hardware stats unavailable")}`);s.update(r,h.join(` @@ -101,7 +101,7 @@ Run: sudo systemctl restart pymc_repeater`),Ts(i)}async function $i(e,t,s){const ⚠ Service restart required for changes to take effect Run: sudo systemctl restart pymc_repeater`),Ts(r)}function Vt(e,t,s,i){const r=parseInt(e);return isNaN(r)||rs?{ok:!1,error:`Error: ${i}`}:{ok:!0,value:r}}function cs(e,t,s,i){const r=parseFloat(e);return isNaN(r)||rs?{ok:!1,error:`Error: ${i}`}:{ok:!0,value:r}}function a_(e,t,s){const i=parseFloat(e);return isNaN(i)||i0?`${s}${"█".repeat(t)}${se}`:"")+b("·".repeat(5-t))}const ho=3.5;class c_ extends ie{constructor(){super(...arguments);D(this,"name","ping");D(this,"description","Ping neighbor (name or 0xXX)");D(this,"params","{target} [timeout]")}async execute({output:s,rawInput:i}){var u,f,_,p,g,k,q;const r=this.argsAfterName(i).trim(),n=r.split(/\s+/);if(((u=n[0])==null?void 0:u.toLowerCase())==="help"){s.write([z("ping"),` ${b("Send a ping to a neighbor and measure round-trip time, signal quality, and path.")}`,"",B("ping ","ping by node name"),B("ping 0xAB","ping by hex prefix"),B("ping 60","ping with custom timeout (seconds)"),"",it("Default timeout: 30s. Signal bars factor radio config and noise floor.")].join(` `));return}const o=n[n.length-1],a=parseInt(o),h=n.length>1&&!isNaN(a)&&a>0,l=h?n.slice(0,-1).join(" "):r,c=h?a:30;if(!l){s.write([z("ping"),` ${b("Send a ping to a neighbor and measure round-trip time.")}`,"",B("ping ","ping by node name"),B("ping 60","with custom timeout"),"",it('Run "ping help" for full usage.')].join(` -`));return}const d=Aa(s,l);try{const F=await rt(),T=Ja((_=(f=F==null?void 0:F.config)==null?void 0:f.mesh)==null?void 0:_.path_hash_mode),N=await Za(l,c,T);if(d.stop(),N.success&&N.data){const H=N.data,Z=(p=H.path)!=null&&p.length?H.path.length:0,me=(g=H.path)!=null&&g.length?H.path.join(" > "):"direct",Y=Qa(H);let oe;if(Y){const I=(k=F.config)==null?void 0:k.radio,R=I!=null&&I.spreading_factor&&(I!=null&&I.bandwidth)?{sf:I.spreading_factor,bwHz:I.bandwidth}:null,V=F.noise_floor_dbm,ee=V!=null&&V>-100?1:0,Se=H.rssi-ho,$e=xo(H.snr_db,Se,R,ee);oe=($e==null?void 0:$e.finalGrade)??"critical"}else oe=null;const J=oe?h_(oe):b("·····"),P=oe?oe.charAt(0).toUpperCase()+oe.slice(1):b("N/A"),S=[`${J} ${st("Reply from")} ${y(H.target_id)}`,"",` ${w("RTT",nu(H.rtt_ms))}`,` ${w("RSSI",Y?`${H.rssi} dBm`:b("N/A"))}`,` ${w("SNR",Y?`${H.snr_db} dB`:b("N/A"))}`,` ${w("Path",me)}${Z>0?b(` (${Z} hop${Z!==1?"s":""})`):""}`,` ${w("Quality",oe?ou(P,oe):P)}`],M=[],C=(q=F.config)==null?void 0:q.radio;if(C!=null&&C.spreading_factor&&(C!=null&&C.bandwidth)){const I=C.bandwidth>=1e3?C.bandwidth/1e3+"kHz":C.bandwidth+"Hz";M.push(`SF${C.spreading_factor}/${I}`)}M.push(`ant ${ho}dBi`);const L=F.noise_floor_dbm;L!=null&&M.push(`nf ${L}dBm`),T>1&&M.push(`${T}-byte hash`),S.push("",b(M.join(" "))),s.update(d.id,S.join(` +`));return}const d=Aa(s,l);try{const F=await rt(),T=Ja((_=(f=F==null?void 0:F.config)==null?void 0:f.mesh)==null?void 0:_.path_hash_mode),N=await Za(l,c,T);if(d.stop(),N.success&&N.data){const H=N.data,Z=(p=H.path)!=null&&p.length?H.path.length:0,me=(g=H.path)!=null&&g.length?H.path.join(" > "):"direct",Y=Qa(H);let oe;if(Y){const I=(k=F.config)==null?void 0:k.radio,R=I!=null&&I.spreading_factor&&(I!=null&&I.bandwidth)?{sf:I.spreading_factor,bwHz:I.bandwidth}:null,V=F.noise_floor_dbm,ee=V!=null&&V>-100?1:0,Se=H.rssi-ho,$e=xo(H.snr_db,Se,R,ee);oe=($e==null?void 0:$e.finalGrade)??"critical"}else oe=null;const J=oe?h_(oe):b("·····"),P=oe?oe.charAt(0).toUpperCase()+oe.slice(1):b("N/A"),S=[`${J} ${st("Reply from")} ${y(H.target_id)}`,"",` ${w("RTT",nu(H.rtt_ms))}`,` ${w("RSSI",Y?`${H.rssi} dBm`:b("N/A"))}`,` ${w("SNR",Y?`${H.snr_db} dB`:b("N/A"))}`,` ${w("Path",me)}${Z>0?b(` (${Z} hop${Z!==1?"s":""})`):""}`,` ${w("Quality",oe?ou(P,oe):P)}`],L=[],C=(q=F.config)==null?void 0:q.radio;if(C!=null&&C.spreading_factor&&(C!=null&&C.bandwidth)){const I=C.bandwidth>=1e3?C.bandwidth/1e3+"kHz":C.bandwidth+"Hz";L.push(`SF${C.spreading_factor}/${I}`)}L.push(`ant ${ho}dBi`);const M=F.noise_floor_dbm;M!=null&&L.push(`nf ${M}dBm`),T>1&&L.push(`${T}-byte hash`),S.push("",b(L.join(" "))),s.update(d.id,S.join(` `))}else s.update(d.id,N.error||"Ping failed","error")}catch(F){d.stop(),s.update(d.id,`Error: ${F instanceof Error?F.message:"Ping failed"}`,"error")}}}class d_ extends ie{constructor(){super(...arguments);D(this,"name","convert");D(this,"description","Convert between hex and base64");D(this,"params","hex|base64 {value}")}execute({output:s,args:i}){var o;const r=(o=i[1])==null?void 0:o.toLowerCase(),n=i.slice(2).join(" ").trim();if(r==="help"||!r&&!n){s.write([z("convert"),` ${b("Convert between hex and base64 encodings.")}`,"",B("convert hex ","hex → base64"),B("convert base64 ","base64 → hex"),"",it("Example: convert hex 48656C6C6F")].join(` `));return}r==="hex"?this.hexToBase64(s,n):r==="base64"?this.base64ToHex(s,n):s.write([z("convert"),` ${b("Convert between hex and base64 encodings.")}`,"",B("convert hex ","hex → base64"),B("convert base64 ","base64 → hex")].join(` `))}hexToBase64(s,i){if(!i){s.write("Usage: convert hex ","error");return}if(!/^[0-9a-fA-F]+$/.test(i)){s.write("Error: Input must be a hex string","error");return}if(i.length%2!==0){s.write("Error: Hex string must have even length","error");return}try{const r=new Uint8Array(i.length/2);for(let h=0;h[` ${st(h.room_name)}`,` ${w("msgs",y(String(h.total_messages)))} ${w("clients",`${y(String(h.active_clients))}${Pe(`/${h.total_clients}`)}`)} ${w("sync",h.sync_running?y("running"):Pe("idle"))}`]).flat()];s.update(r,a.join(` -`))}catch(n){s.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class M_ extends ie{constructor(){super(...arguments);D(this,"name","restart");D(this,"description","Restart pymc-repeater service");D(this,"aliases",["reboot"])}async execute({output:s,rawInput:i}){if(this.argsAfterName(i).toLowerCase().trim()==="help"){s.write([z("restart"),` ${b("Restart the pymc-repeater systemd service.")}`,"",B("restart","restart the service"),"",z("Aliases"),` ${b("reboot")}`,"",it("Requires polkit permissions for the web user."),it("The page will need a manual refresh after restart.")].join(` +`))}catch(n){s.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class L_ extends ie{constructor(){super(...arguments);D(this,"name","restart");D(this,"description","Restart pymc-repeater service");D(this,"aliases",["reboot"])}async execute({output:s,rawInput:i}){if(this.argsAfterName(i).toLowerCase().trim()==="help"){s.write([z("restart"),` ${b("Restart the pymc-repeater systemd service.")}`,"",B("restart","restart the service"),"",z("Aliases"),` ${b("reboot")}`,"",it("Requires polkit permissions for the web user."),it("The page will need a manual refresh after restart.")].join(` `));return}const r=s.write("Restarting service...","system");try{const n=new AbortController,o=setTimeout(()=>n.abort(),8e3),a=await yl(n.signal);if(clearTimeout(o),a.success){s.update(r,"Service restart initiated.","success"),await this.waitForService(s);return}const h=a.status;if(h===403||h===401){s.update(r,`Error: Permission denied. The web user needs polkit permissions to restart the service. -See: /etc/polkit-1/localauthority/50-local.d/pymc-repeater.pkla`,"error");return}s.update(r,a.error||"Restart failed","error")}catch(n){const o=n instanceof Error?n.message:"";o.includes("ERR_NETWORK")||o.includes("ECONNRESET")||o.includes("Failed to fetch")||o.includes("Load failed")||o.includes("network connection was lost")||o.includes("abort")||o.includes("timeout")||n instanceof DOMException&&n.name==="TimeoutError"||n instanceof DOMException&&n.name==="AbortError"?(s.update(r,"Service is restarting (connection dropped).","success"),await this.waitForService(s)):s.update(r,`Error: ${o||"Restart failed"}`,"error")}}waitForService(s){return new Promise(i=>{const r=s.write("Waiting for service...","system");let n=0;const o=30;setTimeout(()=>{const a=setInterval(async()=>{n++,s.update(r,`Waiting for service... ${n}s`,"system");try{const h=new AbortController,l=setTimeout(()=>h.abort(),3e3);await fetch(`${hl}/api/stats`,{signal:h.signal}),clearTimeout(l),clearInterval(a),s.update(r,`Service connected. (${n+4}s)`,"success"),i();return}catch{}n>=o&&(clearInterval(a),s.update(r,`Service did not respond within ${o+4}s. Check manually.`,"warning"),i())},1e3)},4e3)})}}const Wt="\x1B[",Oe=`${Wt}0m`,Fa=`${Wt}32m`,Hr=`${Wt}33m`,Wr=`${Wt}31m`,L_=`${Wt}36m`,Mt=`${Wt}90m`,Ha=`${Wt}1m`;function Yt(e){return e>=1073741824?`${(e/1073741824).toFixed(1)}G`:e>=1048576?`${(e/1048576).toFixed(0)}M`:e>=1024?`${(e/1024).toFixed(0)}K`:`${e}B`}function uo(e){const t=Math.floor(e/86400),s=Math.floor(e%86400/3600),i=Math.floor(e%3600/60);return t>0?`${t}d ${s}h ${i}m`:s>0?`${s}h ${i}m`:`${i}m`}function D_(e,t){const s=Math.max(0,Math.min(100,e)),i=Math.round(s/100*t),r=t-i,n=s>=90?Wr:s>=70?Hr:Fa,o=`${n}${"█".repeat(i)}${Oe}${Mt}${"░".repeat(r)}${Oe}`,a=`${s.toFixed(1)}%`.padStart(6);return`[${o}] ${n}${a}${Oe}`}function T_(e){return e>=80?`${Wr}${Ha}${e.toFixed(1)}°C${Oe}`:e>=60?`${Hr}${e.toFixed(1)}°C${Oe}`:`${Fa}${e.toFixed(1)}°C${Oe}`}const Cs=2,_o=" ";function Jt(e,t){const s=" ".repeat(Cs),i=t-Cs,r=_o.length,n=[];let o="",a=0;for(const h of e){const l=_u(h);a===0?(o=h,a=l):a+r+l<=i?(o+=_o+h,a+=r+l):(n.push(s+o),o=h,a=l)}return a>0&&n.push(s+o),n}function $_(e,t,s){var d,u;const i=e.node_name||"unknown",r=e.version?`v${e.version}`:"",n=(d=t.system)!=null&&d.uptime?uo(t.system.uptime):"?",o=uo(e.uptime_seconds||0),a=Math.max(3,s-Cs*2),h=((u=t.cpu.load_avg)==null?void 0:u["1min"].toFixed(2))??"?",l=t.cpu.load_avg?`${h} ${t.cpu.load_avg["5min"].toFixed(2)} ${t.cpu.load_avg["15min"].toFixed(2)}`:"?",c=s>=60?l:h;return[` ${L_}${Ha}${i}${Oe} ${Mt}${r}${Oe}`,` ${Mt}${"─".repeat(a)}${Oe}`,...Jt([w("Sys",y(n)),w("Svc",y(o)),w("Load",y(c))],s)]}function A_(e,t){const i=Cs+4+1+2+6,r=Math.max(6,Math.min(30,t-i)),n=i+r,o=t-n-2,a=[""],h=`${e.cpu.count} core${e.cpu.count>1?"s":""}`,l=`${Yt(e.memory.used)}/${Yt(e.memory.total)}`,c=`${Yt(e.disk.used)}/${Yt(e.disk.total)}`,d=(f,_,p)=>{const g=D_(_,r),k=o>=p.length?` ${Pe(p)}`:"";return` ${b(f.padEnd(4))}${g}${k}`};a.push(d("CPU",e.cpu.usage_percent,h)),a.push(d("Mem",e.memory.usage_percent,l)),a.push(d("Dsk",e.disk.usage_percent,c));const u=Object.entries(e.temperatures||{});if(u.length>0){const f=u.map(([_,p])=>`${Pe(_+":")} ${T_(p)}`);a.push(...Jt(f,t))}return a}function P_(e,t){var l,c;const s=e.neighbors||{},i=Object.keys(s).length,r=Object.values(s).filter(d=>d.zero_hop).length,n=((c=(l=e.config)==null?void 0:l.repeater)==null?void 0:c.mode)||"?",o=e.noise_floor_dbm!=null?`${e.noise_floor_dbm}dBm`:"?",a=e.duty_cycle_percent??0,h=["",` ${Mt}MESH${Oe}`];return h.push(...Jt([w("Mode",y(n)),w("Nbrs",`${y(String(r))}${Pe(`/${i}`)}`),w("Noise",y(o)),w("Air",y(`${a.toFixed(1)}%`))],t)),h.push(...Jt([w("RX",y(String(e.rx_count??0))),w("TX",y(String(e.tx_count??0))),w("FWD",y(String(e.forwarded_count??0))),w("Drop",y(String(e.dropped_count??0)))],t)),h.push(...Jt([w("RX/h",y(String(Math.round(e.rx_per_hour??0)))),w("FWD/h",y(String(Math.round(e.forwarded_per_hour??0))))],t)),h}function N_(e,t){if(!e.network)return[];const s=["",` ${Mt}NET${Oe}`];return s.push(...Jt([w("TX",y(Yt(e.network.bytes_sent))),w("RX",y(Yt(e.network.bytes_recv))),w("Pkt",`${y(String(e.network.packets_sent))}${Pe("/")}${y(String(e.network.packets_recv))}`)],t)),s}function I_(e,t,s){if(e.length===0)return[];const i=t>=50,r=t>=50?6:5,n=t>=50?6:5,o=i?7:0,a=Cs+0,h=Math.max(4,t-a-o-r-n-4),l=3,c=t>=50?8:5,d=s!=null?Math.max(0,Math.min(c,s-l)):c;if(d<=0)return[];const u=["",` ${Mt}PROCS${Oe}`],f=(i?"PID".padEnd(o):"")+"CPU".padStart(r)+"MEM".padStart(n)+" NAME";u.push(` ${Pe(f)}`);for(const _ of e.slice(0,d)){const p=i?Pe(String(_.pid).padEnd(o)):"",g=(t>=50?_.cpu_percent.toFixed(1):_.cpu_percent.toFixed(0)).padStart(r),k=(t>=50?_.memory_percent.toFixed(1):_.memory_percent.toFixed(0)).padStart(n),q=_.name.length>h?_.name.slice(0,h-1)+"…":_.name,F=_.cpu_percent>=50?Wr:_.cpu_percent>=20?Hr:"",T=F?`${F}${g}${Oe}`:g;u.push(` ${p}${T}${Pe(k)} ${q}`)}return u}function O_(){return new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function fo(e,t,s,i,r){if(!e||!t)return` ${Mt}Waiting for data…${Oe}`;const n=$_(e,t,i),o=A_(t,i),a=P_(e,i),h=N_(t,i),l=["",` ${Mt}${O_()} · Ctrl+C to exit${Oe}`],c=[...n,...o,...a,...h,...l],d=r?br(c,i):0,u=r?Math.max(0,r-d):void 0,f=I_(s,i,u),_=[...c.slice(0,-l.length),...f,...l];return r&&_.length>r&&(_.length=r),_.join(` +See: /etc/polkit-1/localauthority/50-local.d/pymc-repeater.pkla`,"error");return}s.update(r,a.error||"Restart failed","error")}catch(n){const o=n instanceof Error?n.message:"";o.includes("ERR_NETWORK")||o.includes("ECONNRESET")||o.includes("Failed to fetch")||o.includes("Load failed")||o.includes("network connection was lost")||o.includes("abort")||o.includes("timeout")||n instanceof DOMException&&n.name==="TimeoutError"||n instanceof DOMException&&n.name==="AbortError"?(s.update(r,"Service is restarting (connection dropped).","success"),await this.waitForService(s)):s.update(r,`Error: ${o||"Restart failed"}`,"error")}}waitForService(s){return new Promise(i=>{const r=s.write("Waiting for service...","system");let n=0;const o=30;setTimeout(()=>{const a=setInterval(async()=>{n++,s.update(r,`Waiting for service... ${n}s`,"system");try{const h=new AbortController,l=setTimeout(()=>h.abort(),3e3);await fetch(`${hl}/api/stats`,{signal:h.signal}),clearTimeout(l),clearInterval(a),s.update(r,`Service connected. (${n+4}s)`,"success"),i();return}catch{}n>=o&&(clearInterval(a),s.update(r,`Service did not respond within ${o+4}s. Check manually.`,"warning"),i())},1e3)},4e3)})}}const Wt="\x1B[",Oe=`${Wt}0m`,Fa=`${Wt}32m`,Hr=`${Wt}33m`,Wr=`${Wt}31m`,M_=`${Wt}36m`,Lt=`${Wt}90m`,Ha=`${Wt}1m`;function Yt(e){return e>=1073741824?`${(e/1073741824).toFixed(1)}G`:e>=1048576?`${(e/1048576).toFixed(0)}M`:e>=1024?`${(e/1024).toFixed(0)}K`:`${e}B`}function uo(e){const t=Math.floor(e/86400),s=Math.floor(e%86400/3600),i=Math.floor(e%3600/60);return t>0?`${t}d ${s}h ${i}m`:s>0?`${s}h ${i}m`:`${i}m`}function D_(e,t){const s=Math.max(0,Math.min(100,e)),i=Math.round(s/100*t),r=t-i,n=s>=90?Wr:s>=70?Hr:Fa,o=`${n}${"█".repeat(i)}${Oe}${Lt}${"░".repeat(r)}${Oe}`,a=`${s.toFixed(1)}%`.padStart(6);return`[${o}] ${n}${a}${Oe}`}function T_(e){return e>=80?`${Wr}${Ha}${e.toFixed(1)}°C${Oe}`:e>=60?`${Hr}${e.toFixed(1)}°C${Oe}`:`${Fa}${e.toFixed(1)}°C${Oe}`}const Cs=2,_o=" ";function Jt(e,t){const s=" ".repeat(Cs),i=t-Cs,r=_o.length,n=[];let o="",a=0;for(const h of e){const l=_u(h);a===0?(o=h,a=l):a+r+l<=i?(o+=_o+h,a+=r+l):(n.push(s+o),o=h,a=l)}return a>0&&n.push(s+o),n}function $_(e,t,s){var d,u;const i=e.node_name||"unknown",r=e.version?`v${e.version}`:"",n=(d=t.system)!=null&&d.uptime?uo(t.system.uptime):"?",o=uo(e.uptime_seconds||0),a=Math.max(3,s-Cs*2),h=((u=t.cpu.load_avg)==null?void 0:u["1min"].toFixed(2))??"?",l=t.cpu.load_avg?`${h} ${t.cpu.load_avg["5min"].toFixed(2)} ${t.cpu.load_avg["15min"].toFixed(2)}`:"?",c=s>=60?l:h;return[` ${M_}${Ha}${i}${Oe} ${Lt}${r}${Oe}`,` ${Lt}${"─".repeat(a)}${Oe}`,...Jt([w("Sys",y(n)),w("Svc",y(o)),w("Load",y(c))],s)]}function A_(e,t){const i=Cs+4+1+2+6,r=Math.max(6,Math.min(30,t-i)),n=i+r,o=t-n-2,a=[""],h=`${e.cpu.count} core${e.cpu.count>1?"s":""}`,l=`${Yt(e.memory.used)}/${Yt(e.memory.total)}`,c=`${Yt(e.disk.used)}/${Yt(e.disk.total)}`,d=(f,_,p)=>{const g=D_(_,r),k=o>=p.length?` ${Pe(p)}`:"";return` ${b(f.padEnd(4))}${g}${k}`};a.push(d("CPU",e.cpu.usage_percent,h)),a.push(d("Mem",e.memory.usage_percent,l)),a.push(d("Dsk",e.disk.usage_percent,c));const u=Object.entries(e.temperatures||{});if(u.length>0){const f=u.map(([_,p])=>`${Pe(_+":")} ${T_(p)}`);a.push(...Jt(f,t))}return a}function P_(e,t){var l,c;const s=e.neighbors||{},i=Object.keys(s).length,r=Object.values(s).filter(d=>d.zero_hop).length,n=((c=(l=e.config)==null?void 0:l.repeater)==null?void 0:c.mode)||"?",o=e.noise_floor_dbm!=null?`${e.noise_floor_dbm}dBm`:"?",a=e.duty_cycle_percent??0,h=["",` ${Lt}MESH${Oe}`];return h.push(...Jt([w("Mode",y(n)),w("Nbrs",`${y(String(r))}${Pe(`/${i}`)}`),w("Noise",y(o)),w("Air",y(`${a.toFixed(1)}%`))],t)),h.push(...Jt([w("RX",y(String(e.rx_count??0))),w("TX",y(String(e.tx_count??0))),w("FWD",y(String(e.forwarded_count??0))),w("Drop",y(String(e.dropped_count??0)))],t)),h.push(...Jt([w("RX/h",y(String(Math.round(e.rx_per_hour??0)))),w("FWD/h",y(String(Math.round(e.forwarded_per_hour??0))))],t)),h}function N_(e,t){if(!e.network)return[];const s=["",` ${Lt}NET${Oe}`];return s.push(...Jt([w("TX",y(Yt(e.network.bytes_sent))),w("RX",y(Yt(e.network.bytes_recv))),w("Pkt",`${y(String(e.network.packets_sent))}${Pe("/")}${y(String(e.network.packets_recv))}`)],t)),s}function I_(e,t,s){if(e.length===0)return[];const i=t>=50,r=t>=50?6:5,n=t>=50?6:5,o=i?7:0,a=Cs+0,h=Math.max(4,t-a-o-r-n-4),l=3,c=t>=50?8:5,d=s!=null?Math.max(0,Math.min(c,s-l)):c;if(d<=0)return[];const u=["",` ${Lt}PROCS${Oe}`],f=(i?"PID".padEnd(o):"")+"CPU".padStart(r)+"MEM".padStart(n)+" NAME";u.push(` ${Pe(f)}`);for(const _ of e.slice(0,d)){const p=i?Pe(String(_.pid).padEnd(o)):"",g=(t>=50?_.cpu_percent.toFixed(1):_.cpu_percent.toFixed(0)).padStart(r),k=(t>=50?_.memory_percent.toFixed(1):_.memory_percent.toFixed(0)).padStart(n),q=_.name.length>h?_.name.slice(0,h-1)+"…":_.name,F=_.cpu_percent>=50?Wr:_.cpu_percent>=20?Hr:"",T=F?`${F}${g}${Oe}`:g;u.push(` ${p}${T}${Pe(k)} ${q}`)}return u}function O_(){return new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function fo(e,t,s,i,r){if(!e||!t)return` ${Lt}Waiting for data…${Oe}`;const n=$_(e,t,i),o=A_(t,i),a=P_(e,i),h=N_(t,i),l=["",` ${Lt}${O_()} · Ctrl+C to exit${Oe}`],c=[...n,...o,...a,...h,...l],d=r?br(c,i):0,u=r?Math.max(0,r-d):void 0,f=I_(s,i,u),_=[...c.slice(0,-l.length),...f,...l];return r&&_.length>r&&(_.length=r),_.join(` `)}const F_=3e3;class H_ extends ie{constructor(){super(...arguments);D(this,"name","top");D(this,"description","Live system overview (Ctrl+C to exit)");D(this,"aliases",["htop"])}async execute({output:s,rawInput:i,cols:r,signal:n}){var l,c;if(this.argsAfterName(i).toLowerCase().trim()==="help"){s.write([z("top"),` ${b("Live-updating system overview combining hardware")}`,` ${b("stats, mesh metrics, and running processes.")}`,` ${b("Refreshes every 3s. Press Ctrl+C to exit.")}`,"",B("top","start live display"),"",z("Sections"),` ${b("Header Node name, version, uptime, load average")}`,` ${b("Gauges CPU, memory, disk usage with bar charts")}`,` ${b("Mesh Mode, neighbors, packet counts, airtime")}`,` ${b("Network TCP/IP bytes and packet counters")}`,` ${b("Processes Top 8 processes by CPU usage")}`,"",z("Aliases"),` ${b("htop")}`].join(` `));return}let o=null,a=[],h=xt.getState().stats;try{const[d,u]=await Promise.all([ei(),Ur()]);d.success&&d.data&&(o=d.data),u.success&&u.data&&(a=u.data.processes.sort((f,_)=>_.cpu_percent-f.cpu_percent))}catch{}if(!n.aborted){(l=s.enterFullscreen)==null||l.call(s);try{const d=s.write(fo(h,o,a,s.cols??r,s.rows));await new Promise(u=>{if(n.aborted){u();return}const f=async()=>{h=xt.getState().stats;try{const[p,g]=await Promise.all([ei(),Ur()]);p.success&&p.data&&(o=p.data),g.success&&g.data&&(a=g.data.processes.sort((k,q)=>q.cpu_percent-k.cpu_percent))}catch{}n.aborted||s.update(d,fo(h,o,a,s.cols??r,s.rows))},_=setInterval(()=>{if(n.aborted){clearInterval(_),u();return}f()},F_);n.addEventListener("abort",()=>{clearInterval(_),u()},{once:!0})})}finally{(c=s.exitFullscreen)==null||c.call(s)}}}}const po=["DONT PANIC","C0FFEE","FEED C0DE","LOL","I CANNOT DO THAT"];function zr(){return po[Math.floor(Math.random()*po.length)]}const Cr=new EventTarget,xr="shell-phrase";function Wa(e){Cr.dispatchEvent(new CustomEvent(xr,{detail:e??zr()}))}function W_(e){const t=s=>e(s.detail);return Cr.addEventListener(xr,t),()=>Cr.removeEventListener(xr,t)}class z_ extends ie{constructor(){super(...arguments);D(this,"name","fortune");D(this,"description","Display a fortune on the header");D(this,"aliases",["lol"])}execute({output:s}){const i=zr();Wa(i),s.write(b(` ${i}`))}}const kr=new EventTarget,Er="party-time";function U_(){kr.dispatchEvent(new Event(Er))}function j_(e){return kr.addEventListener(Er,e),()=>kr.removeEventListener(Er,e)}class K_ extends ie{constructor(){super(...arguments);D(this,"name","partytime");D(this,"description","Party on, Garth!");D(this,"aliases",["party","excellent","waynesworld"])}execute({output:s}){U_(),Wa("PARTY 0N GARTH"),s.write(b(" SCHWING!"))}}class q_ extends ie{constructor(){super(...arguments);D(this,"name","ver");D(this,"description","Show version info");D(this,"aliases",["version"])}async execute({output:s,rawInput:i}){if(this.argsAfterName(i).toLowerCase().trim()==="help"){s.write([z("ver"),` ${b("Display pyMC_Repeater, core, and console version.")}`,` ${b('Equivalent to firmware serial CLI "ver" command.')}`,"",B("ver","show version"),"",z("Aliases"),` ${b("version")}`].join(` -`));return}const r=s.write("processing...","system");try{const n=await rt();s.update(r,[` ${w("pyMC_Repeater",y(`v${n.version||"?"}`))}`,` ${w("pyMC_Core",y(n.core_version||"?"))}`,` ${w("pyMC_Console",y("v0.9.318"))}`].join(` +`));return}const r=s.write("processing...","system");try{const n=await rt();s.update(r,[` ${w("pyMC_Repeater",y(`v${n.version||"?"}`))}`,` ${w("pyMC_Core",y(n.core_version||"?"))}`,` ${w("pyMC_Console",y("v0.9.319"))}`].join(` `),"value")}catch(n){s.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class V_ extends ie{constructor(){super(...arguments);D(this,"name","clock");D(this,"description","Show system UTC time")}execute({output:s,rawInput:i}){if(this.argsAfterName(i).toLowerCase().trim()==="help"){s.write([z("clock"),` ${b("Display the current system UTC time.")}`,` ${b('Equivalent to firmware serial CLI "clock" command.')}`,` ${b("Use to verify NTP sync and correlate packet timestamps.")}`,"",B("clock","show UTC time")].join(` `));return}const r=new Date;s.write([` ${w("UTC",y(r.toUTCString()))}`,` ${w("ISO",y(r.toISOString()))}`,` ${w("Unix",y(String(Math.floor(r.getTime()/1e3))))}`].join(` `),"value")}}class G_ extends ie{constructor(){super(...arguments);D(this,"name","stats-packets");D(this,"description","Packet counters")}async execute({output:s,rawInput:i}){if(this.argsAfterName(i).toLowerCase().trim()==="help"){s.write([z("stats-packets"),` ${b("Display packet counters: sent, received, forwarded, dropped.")}`,` ${b('Equivalent to firmware serial CLI "stats-packets" command.')}`,"",B("stats-packets","show packet counters")].join(` @@ -154,9 +154,9 @@ See: /etc/polkit-1/localauthority/50-local.d/pymc-repeater.pkla`,"error");return `),"value")}catch(n){s.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}const Ni=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "],go=Do-1;class J_ extends ie{constructor(){super(...arguments);D(this,"name","hello");D(this,"description","Play the PYMC burst intro");D(this,"aliases",["hi","intro"])}async execute({output:s,signal:i}){if(i.aborted)return;let r=0;const n=s.write(vs(Ni,0).join(` `));try{await new Promise(o=>{const a=setInterval(()=>{if(i.aborted||r>=go){clearInterval(a),i.aborted||s.update(n,vs(Ni,go).join(` `)),o();return}r++,s.update(n,vs(Ni,r).join(` -`))},Mo);i.addEventListener("abort",()=>{clearInterval(a),o()},{once:!0})})}finally{Lo()}}}function Z_(){const e=new Jd,t=new Eu(e);return e.register(t,new Ru,new Bu,new q_,new V_,new Mu,new Lu,new Du,new G_,new X_,new Y_,new ju,new Qu,new c_,new e_,new s_,new d_,new x_,new k_,new E_,new R_,new B_,new M_,new H_,new z_,new K_,new J_),e}const Q_=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),vo=Ro(e=>({entries:[],commandHistory:[],isInitialized:!1,addEntry:t=>{const s=Q_(),i={...t,id:s,timestamp:Date.now()};return e(r=>({entries:[...r.entries,i]})),s},updateEntry:(t,s)=>{e(i=>({entries:i.entries.map(r=>r.id===t?{...r,...s}:r)}))},addCommand:t=>{e(s=>({commandHistory:[...s.commandHistory,t]}))},clearEntries:()=>{e({entries:[],commandHistory:[]})},setInitialized:t=>{e({isInitialized:t})}}));function ef({isOpen:e,onClose:t}){const s=Pa(),i=xt(n=>n.stats),r=n=>{const o=s.find(a=>a.id===n);o&&Oa(o,i)};return m.jsxs(To,{open:e,onClose:t,size:"sm",children:[m.jsx($o,{icon:m.jsx(jr,{size:20}),title:"Download Captures",onClose:t}),m.jsx(Ao,{className:"flex flex-col gap-2",children:s.length===0?m.jsxs("div",{className:"flex flex-col items-center gap-2 py-6 text-fg-muted",children:[m.jsx(Tl,{className:"w-8 h-8 opacity-40"}),m.jsx("p",{className:"text-sm",children:"No captures available."})]}):s.map(n=>m.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 radius-inset bg-elevated/50 border border-edge-subtle",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"type-label text-fg-primary truncate",children:n.filename}),m.jsxs("p",{className:"text-xs text-fg-muted mt-0.5",children:[n.packetCount," packets · ",n.durationSec,"s · ~",Zs(n.sizeBytes)]})]}),m.jsx(cl,{plain:!0,color:"primary",onClick:()=>r(n.id),title:"Download",className:"flex-shrink-0",children:m.jsx(jr,{"data-slot":"icon"})})]},n.id))})]})}function tf(){const e=Pa(),[t,s]=U.useState(!1);return m.jsxs(m.Fragment,{children:[m.jsx(Po,{icon:m.jsx(Ll,{size:20}),onClick:()=>s(!0),title:e.length>0?`Download captures (${e.length})`:"Captures",variant:"red",iconActiveColor:ve.red}),m.jsx(ef,{isOpen:t,onClose:()=>s(!1)})]})}const So=[{name:"acl",description:"Access control list statistics — identity and client counts.",body:["```","> acl","ACL Stats",""," Identities 2"," Total clients 5"," Admin 2"," Guest 3"," Repeater 1 ids 3 clients"," Room Server 1 ids 2 clients","```"],searchText:"acl access control list statistics identity client"},{name:"advert",description:"Broadcast a repeater advertisement to the mesh.",body:["```","> advert","✓ Advert sent","```"],searchText:"advert advertisement broadcast mesh"},{name:"board",description:"Hardware and platform info — CPU, memory, disk, temperatures, network I/O.",body:["```","> board"," Node Local-Node"," Runtime pyMC_Repeater v1.0.0"," Core v1.12.0",""," CPU 12.3% 4 cores"," Load 0.42 / 0.38 / 0.35"," Temp 48.2°C",""," Memory 412 MB / 664 MB 62%"," Disk 5.2 GB / 28.7 GB 18%",""," System uptime 14d 3h 22m"," Service uptime 2d 14h 32m"," Net TX/RX 128 MB / 342 MB","```"],searchText:"board hardware platform cpu memory disk temperature network"},{name:"cap",description:"Packet capture — start, stop, list, and export captures.",body:["**Sub-commands:** `start cap [sec]` · `end cap` · `list cap` · `export cap [id]`","","**`start cap [seconds]`** — Begin capture (default 120s, max 3600):","```","> start cap","Capturing... 118s remaining (4 captured)","","✓ Capture complete!"," Captured: 23 packets"," Duration: 120s"," Size: ~14.2 KB","```","","**`end cap`** — Stop capture early:","```","> end cap","✓ Capture stopped!"," Captured: 12 packets","```","","**`list cap`** — List saved captures:","```","> list cap","Capture Reports (2):"," 1. 23 pkts • 120s • ~14.2 KB (id: abc123)"," 2. 12 pkts • 34s • ~7.1 KB (id: def456)","```","","**`export cap [id]`** — Download by ID or index:","```","> export cap 1","✓ Downloading capture-abc123.json...","```"],searchText:"cap capture packet start end list export download diagnostic"},{name:"clear",description:"Clear the terminal screen.",body:["**Alias:** `cls`","```","> clear","```"],searchText:"clear cls screen"},{name:"clock",description:"Current system UTC time. Useful for NTP sync and packet timestamp correlation.",body:["```","> clock"," UTC Wed, 12 Feb 2026 00:01:34 GMT"," ISO 2026-02-12T00:01:34.000Z"," Unix 1770768094","```"],searchText:"clock time utc ntp unix iso timestamp"},{name:"convert",description:"Convert between hex and base64 encodings.",body:["**Usage:** `convert hex ` · `convert base64 `","```","> convert hex 48656C6C6F"," hex 48656C6C6F"," base64 SGVsbG8=","","> convert base64 SGVsbG8="," base64 SGVsbG8="," hex 48656C6C6F","```"],searchText:"convert hex base64 encoding decode"},{name:"get",description:"Read a configuration parameter.",body:[],interactive:"get",searchText:"get read config parameter name role lat lon radio freq tx bw sf cr txdelay mode duty flood advert"},{name:"help",description:"Show all commands, or detailed help for a specific command.",body:["**Alias:** `?` · `h`","```","> help Full command listing","> help ping Detailed help for ping","> ping help Same thing","```"],searchText:"help commands reference guide"},{name:"identities",description:"List all configured repeater and room server identities.",body:["**Alias:** `id` · `ids`","```","> identities","Identities (2)",""," 1. Local-Node repeater 0A1B2C3D"," 2. local-room room_server 0E5F6A7B","```"],searchText:"identities id ids repeater room server identity"},{name:"keys",description:"List configured transport encryption keys.",body:["```","> keys","Transport Keys (1)",""," main-transport flood: allow","```"],searchText:"keys transport encryption"},{name:"neighbors",description:"Direct RF neighbors with signal quality, RSSI, SNR, distance, and last-heard.",body:["**Alias:** `nb`","","**Sort qualifiers:** `sig` · `name` · `rssi` · `snr` · `dist` · `heard`","```","> neighbors","Direct Neighbors (4)","","+-------+-----------+-----------+--------+-------+--------+","| ▁▃▅▇█ | Node-1 | -87 dBm | 8.5 dB | 2.1km | 3m ago |","| ▁▃▅▇. | Relay-2 | -94 dBm | 5.2 dB | 4.8km | 1m ago |","| ▁▃▅.. | Node-3 | -108 dBm | 1.0 dB | 8.3km | 5m ago |","| ▁▃... | Node-4 | -118 dBm | -3 dB | 14km | 12m ago|","+-------+-----------+-----------+--------+-------+--------+","| SIG | NAME | RSSI | SNR | DIST | HEARD |","+-------+-----------+-----------+--------+-------+--------+","SF11/250kHz ant 3.5dBi nf -112dBm","```","","- **sig** — signal grade (weakest first)","- **name** — alphabetical","- **rssi** — RSSI (weakest first)","- **snr** — SNR (lowest first)","- **dist** — distance (closest first)","- **heard** — last seen (oldest first)"],searchText:"neighbors nb signal rssi snr distance sort direct rf"},{name:"packets",description:"Packet counters — received, transmitted, forwarded, dropped.",body:["```","> packets","Packet Stats 1321 total",""," Received 1284"," Transmitted 37"," Forwarded 891"," Dropped 14","```"],searchText:"packets received transmitted forwarded dropped counter"},{name:"ping",description:"Ping a neighbor by name or hex prefix. Shows RTT, signal quality, and path.",body:["**Usage:** `ping [timeout]`","```","> ping Node-1","▁▃▅▇█ Reply from Node-1",""," RTT 342ms"," RSSI -87 dBm"," SNR 8.5 dB"," Path direct"," Quality Excellent","```","","Custom timeout (default 30s):","```","> ping Node-4 60","```"],searchText:"ping rtt round trip time signal quality path neighbor"},{name:"restart",description:"Restart the pymc-repeater systemd service.",body:["**Alias:** `reboot`","```","> restart","Service is restarting (connection dropped).","Waiting for service... 8s","Service connected. (12s)","```","","The terminal polls automatically until the service comes back up."],searchText:"restart reboot service systemd"},{name:"rooms",description:"Room server statistics — message counts, active clients, sync status.",body:["```","> rooms","Rooms (1)",""," Local Room"," msgs 142 clients 3/5 sync running","```"],searchText:"rooms room server messages clients sync"},{name:"set",description:"Write a configuration parameter.",body:[],interactive:"set",searchText:"set write config parameter name lat lon freq tx bw sf cr txdelay mode duty log flood advert"},{name:"stats-core",description:"Engine vitals — uptime, duplicate cache, CPU, memory, temperature.",body:["```","> stats-core"," Core Stats",""," Uptime 2d 14h 32m"," Dup cache 128 entries TTL 900s",""," CPU 12.3% 4 cores"," Load 0.42 / 0.38 / 0.35"," Memory 412 MB / 664 MB 62%"," Temp 48.2°C","```"],searchText:"stats core engine vitals uptime cache cpu memory temperature"},{name:"stats-packets",description:"Firmware-compatible packet counters with rates and duplicate cache depth.",body:["```","> stats-packets"," Packet Counters",""," RX 1284 22.4/hr"," TX 37"," Forwarded 891 15.2/hr"," Dropped 14",""," Dup cache 128","```"],searchText:"stats packets firmware counter rate duplicate cache"},{name:"stats-radio",description:"Radio health — noise floor, airtime, duty cycle, and radio configuration.",body:["```","> stats-radio"," Radio Stats",""," Radio 906.875 MHz SF11 BW 250 kHz CR 4/5 22 dBm",""," Noise floor -112 dBm"," Airtime used 4.2s remaining: 55.8m"," Total airtime 1.2m"," Duty cycle 1.2%"," Utilization 0.8%","```"],searchText:"stats radio noise floor airtime duty cycle utilization"},{name:"status",description:"Quick summary of mode, neighbors, and uptime.",body:["**Alias:** `st`","```","> status","Local-Node repeater",""," Mode forward"," Neighbors 4 direct 12 total"," RX / TX 1284 / 37"," Uptime 2d 14h 32m","```"],searchText:"status st summary mode neighbors uptime"},{name:"top",description:"Live-updating system overview — CPU/memory gauges, mesh counters, processes.",body:["**Alias:** `htop`","","Refreshes every 3s. Press **Ctrl+C** to exit.","```","> top","Local-Node v1.0.0","──────────────────────────────────"," Sys 14d 3h 22m Svc 2d 14h 32m Load 0.42 0.38 0.35",""," CPU [████░░░░░░░░░░░░] 12.3% 4 cores"," Mem [██████████░░░░░░] 62.1% 412M/664M"," Dsk [███░░░░░░░░░░░░░] 18.4% 5.2G/28.7G"," cpu_thermal: 48.2°C",""," MESH"," Mode forward Nbrs 4/12 Noise -112dBm Air 1.2%"," RX 1284 TX 37 FWD 891 Drop 14"," RX/h 22 FWD/h 15",""," PROCS"," CPU MEM NAME"," 8.2 3.1 python3"," 2.1 1.4 cherrypy",""," 14:32:08 · Ctrl+C to exit","```","","Uses alternate screen buffer — scrollback is preserved."],searchText:"top htop live system overview cpu memory gauges mesh processes"},{name:"uptime",description:"How long the repeater service has been running.",body:["```","> uptime","Uptime 2d 14h 32m","```"],searchText:"uptime service running duration"},{name:"ver",description:"Version info for all three components.",body:["**Alias:** `version`","```","> ver"," pyMC_Repeater v1.0.0"," pyMC_Core v1.12.0"," pyMC_Console v1.0.0","```"],searchText:"ver version pymc repeater core console"}],sf=[{param:"name",category:"Identity",example:["> get name","name Local-Node"]},{param:"role",category:"Identity",example:["> get role","role repeater"]},{param:"lat",category:"Identity",example:["> get lat","lat 34.0522"],range:"-90 to 90"},{param:"lon",category:"Identity",example:["> get lon","lon -118.2437"],range:"-180 to 180"},{param:"public.key",category:"Identity",example:["> get public.key","public.key 0A1B2C3D4E5F..."]},{param:"radio",category:"Radio",example:["> get radio"," freq 906.875 MHz"," bw 250 kHz"," sf 11"," cr 4/5"," tx 22 dBm"]},{param:"freq",category:"Radio",example:["> get freq","freq 906.875 MHz"],range:"100–1000 MHz"},{param:"tx",category:"Radio",example:["> get tx","tx 22 dBm"],range:"2–22 dBm"},{param:"bw",category:"Radio",example:["> get bw","bw 250 kHz"],range:"7.8–500 kHz"},{param:"sf",category:"Radio",example:["> get sf","sf 11"],range:"5–12"},{param:"cr",category:"Radio",example:["> get cr","cr 4/5"],range:"5–8"},{param:"af",category:"Timing",example:["> get af","⚠ airtime_factor not yet exposed by pyMC_Repeater API."," Firmware range: 0-9. Tracked in CLI-Alignment.md."],range:"0–9 (pending)"},{param:"txdelay",category:"Timing",example:["> get txdelay","txdelay 1.0"],range:"0.0–5.0"},{param:"direct.txdelay",category:"Timing",example:["> get direct.txdelay","direct.txdelay 0.5"],range:"0.0–5.0"},{param:"rxdelay",category:"Timing",example:["> get rxdelay","rxdelay 0.0"],range:"≥ 0"},{param:"mode",category:"Repeater",example:["> get mode","mode forward"],range:"forward / monitor"},{param:"duty",category:"Repeater",example:["> get duty","duty on"],range:"on / off"},{param:"flood.max",category:"Repeater",example:["> get flood.max","flood.max 3"],range:"0–64"},{param:"advert.interval",category:"Repeater",example:["> get advert.interval","advert.interval 120m"],range:"0 (off) or 1–10080 min"},{param:"multi.acks",category:"Advanced",example:["> get multi.acks","multi.acks 0"],range:"0–255"},{param:"int.thresh",category:"Advanced",example:["> get int.thresh","int.thresh -120 dBm"],range:"-200 to 0 dBm"},{param:"agc.reset.interval",category:"Advanced",example:["> get agc.reset.interval","agc.reset.interval 0"],range:"≥ 0 (×4)"}],rf=[{param:"name",category:"Identity",example:["> set name Local-Node","OK - node_name set to Local-Node"],range:"text (no [ ] \\ / : , ? *)"},{param:"lat",category:"Identity",example:["> set lat 34.0522","OK - latitude set to 34.0522"],range:"-90 to 90"},{param:"lon",category:"Identity",example:["> set lon -118.2437","OK - longitude set to -118.2437"],range:"-180 to 180"},{param:"freq",category:"Radio",example:["> set freq 906.875","OK - frequency set to 906875000"],range:"100–1000 MHz"},{param:"tx",category:"Radio",example:["> set tx 22","OK - tx_power set to 22"],range:"2–22 dBm"},{param:"bw",category:"Radio",example:["> set bw 250","OK - bandwidth set to 250000"],range:"7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125, 250, 500 kHz"},{param:"sf",category:"Radio",example:["> set sf 11","OK - spreading_factor set to 11"],range:"5–12"},{param:"cr",category:"Radio",example:["> set cr 5","OK - coding_rate set to 5"],range:"5–8"},{param:"af",category:"Timing",example:["> set af 2","⚠ airtime_factor not yet exposed by pyMC_Repeater API."," Firmware range: 0-9. Needs backend support."],range:"0–9 (pending)"},{param:"txdelay",category:"Timing",example:["> set txdelay 1.0","OK - tx_delay_factor set to 1"],range:"0.0–5.0"},{param:"direct.txdelay",category:"Timing",example:["> set direct.txdelay 0.5","OK - direct_tx_delay_factor set to 0.5"],range:"0.0–5.0"},{param:"rxdelay",category:"Timing",example:["> set rxdelay 0","OK - rx_delay_base set to 0"],range:"≥ 0"},{param:"mode",category:"Repeater",example:["> set mode forward","OK - Mode set to forward"],range:"forward / monitor"},{param:"flood.max",category:"Repeater",example:["> set flood.max 3","OK - max_flood_hops set to 3"],range:"0–64"},{param:"advert.interval",category:"Repeater",example:["> set advert.interval 120","OK - Local advert interval set to 120m"],range:"0 (off) or 1–10080 min"},{param:"duty",category:"Repeater",example:["> set duty on","OK - Duty cycle enabled"],range:"on / off"},{param:"log",category:"Repeater",example:["> set log info","OK - Log level set to INFO"],range:"debug, info, warning, error"},{param:"multi.acks",category:"Advanced",example:["> set multi.acks 0","OK - multi_acks set to 0"],range:"0–255"},{param:"int.thresh",category:"Advanced",example:["> set int.thresh -120","OK - interference_threshold set to -120"],range:"-200 to 0 dBm"},{param:"agc.reset.interval",category:"Advanced",example:["> set agc.reset.interval 8","OK - AGC reset interval set to 8"],range:"≥ 0 (rounded to ×4)"},{param:"prv.key",category:"Advanced",example:["> set prv.key <128-hex>","To set this key, run on the Pi:",""," sudo ./convert_firmware_key.sh ","","Then restart: sudo systemctl restart pymc-repeater"],range:"128-char hex (SSH only)"}];function nf({mode:e}){const t=e==="get"?sf:rf,[s,i]=U.useState(0),r=t[s],n=U.useMemo(()=>{const o=new Map;for(const a of t){const h=o.get(a.category)||[];h.push(a),o.set(a.category,h)}return Array.from(o.entries())},[t]);return m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("div",{className:"flex flex-col gap-1.5",children:n.map(([o,a])=>m.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[m.jsx("span",{className:"text-xs text-fg-muted w-16 shrink-0 text-right pr-1",children:o}),a.map(h=>{const l=t.indexOf(h),c=l===s;return m.jsx("button",{onClick:()=>i(l),className:ti("px-1.5 py-0.5 type-data-xs radius-badge transition-colors cursor-pointer",c?"bg-sys-blue text-fg-invert font-semibold":"bg-elevated text-fg-secondary hover:bg-elevated/80 hover:text-sys-blue"),children:h.param},h.param)})]},o))}),m.jsx("pre",{className:"px-3 py-2.5 radius-inner bg-body text-fg-secondary type-code overflow-x-auto border border-edge-subtle",children:r.example.map((o,a)=>m.jsx("div",{children:o||" "},a))}),r.range&&m.jsxs("p",{className:"text-xs text-fg-muted",children:[m.jsx("span",{className:"text-fg-secondary font-medium",children:r.param})," — ",r.range]})]})}function yo(e,t){const s=e.split(/(\*\*[^*]+\*\*)/g);return m.jsx("span",{children:s.map((i,r)=>i.startsWith("**")&&i.endsWith("**")?m.jsx("strong",{className:"text-fg-primary font-semibold",children:i.slice(2,-2)},r):i.split(/(`[^`]+`)/g).map((o,a)=>o.startsWith("`")&&o.endsWith("`")?m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue type-data-xs",children:o.slice(1,-1)},`${r}-${a}`):m.jsx("span",{children:o},`${r}-${a}`)))},t)}function of({lines:e}){const t=[];let s=0;for(;sm.jsx("div",{children:n||" "},o))},t.length));continue}if(!i.trim()){t.push(m.jsx("div",{className:"h-1.5"},t.length)),s++;continue}if(i.startsWith("- ")){t.push(m.jsxs("div",{className:"flex gap-2 text-sm text-fg-secondary pl-2 py-0.5",children:[m.jsx("span",{className:"text-fg-muted shrink-0",children:"•"}),m.jsx("span",{children:yo(i.slice(2),0)})]},t.length)),s++;continue}t.push(m.jsx("p",{className:"text-sm text-fg-secondary py-0.5",children:yo(i,0)},t.length)),s++}return m.jsx(m.Fragment,{children:t})}function af({isOpen:e,onClose:t,onUseCommand:s}){const[i,r]=U.useState(""),n=U.useMemo(()=>{if(!i.trim())return So;const a=i.toLowerCase();return So.filter(h=>h.name.includes(a)||h.searchText.includes(a)||h.description.toLowerCase().includes(a))},[i]),o=i.trim().length>0;return m.jsxs(To,{open:e,onClose:t,size:"3xl",motionPlus:!0,className:"sm:min-w-[540px] md:min-w-[680px]",children:[m.jsx($o,{icon:m.jsx(No,{size:20}),title:"Terminal Command Guide",onClose:t}),m.jsxs(Ao,{className:"flex flex-col gap-0 !px-0 !py-0",children:[m.jsx("div",{className:"sticky top-0 z-10 px-5 py-3 border-b border-edge-subtle bg-surface/95 backdrop-blur-sm",children:m.jsxs("div",{className:"relative",children:[m.jsx(Vr,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-muted"}),m.jsx("input",{type:"text",value:i,onChange:a=>r(a.target.value),placeholder:"Search commands...",className:"w-full pl-8 pr-3 py-1.5 text-sm bg-elevated border border-edge-subtle radius-inner text-fg-primary placeholder:text-fg-muted focus:outline-none focus:ring-1 focus:ring-sys-blue/50",autoFocus:!0})]})}),m.jsxs("div",{className:"overflow-y-auto px-5 py-3 h-[420px] sm:h-[520px] md:h-[600px]",children:[m.jsx(fi,{mode:"popLayout",children:n.length===0?m.jsxs($s.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:qr.normal,ease:Kr.easeOut},className:"flex flex-col items-center gap-2 py-10 text-fg-muted",children:[m.jsx(Vr,{className:"w-6 h-6 opacity-40"}),m.jsxs("p",{className:"text-sm",children:['No commands match "',i,'"']})]},"empty"):m.jsx($s.div,{initial:!1,className:"flex flex-col gap-1",children:m.jsx(fi,{initial:!1,children:n.map(a=>m.jsx($s.div,{layout:"position",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:dl.fade,className:"min-w-0",children:m.jsx(ul,{children:({open:h})=>m.jsxs("div",{className:ti("radius-inner border transition-colors",h?"border-edge-subtle bg-elevated/50":"border-transparent hover:bg-elevated/30"),children:[m.jsxs("div",{className:"flex items-center w-full min-w-0",children:[m.jsxs(_l,{className:"flex items-center gap-3 flex-1 min-w-0 px-3 py-2 text-left cursor-pointer",children:[m.jsx(kl,{size:14,className:ti("shrink-0 text-fg-muted transition-transform duration-150",h&&"rotate-90")}),m.jsx("code",{className:"text-sm font-semibold text-sys-blue font-mono shrink-0",children:a.name}),m.jsx("span",{className:"text-xs text-fg-muted truncate min-w-0",children:a.description})]}),s&&m.jsx("button",{onClick:l=>{l.stopPropagation(),s(a.name)},className:"shrink-0 mr-2 px-2 py-0.5 text-xs font-semibold uppercase tracking-wider radius-badge bg-elevated text-fg-muted hover:text-sys-blue hover:bg-elevated/80 transition-colors cursor-pointer",title:`Use "${a.name}" in terminal`,children:"use"})]}),m.jsx(fl,{className:"px-3 pb-3 pt-0 pl-9",children:a.interactive?m.jsx(nf,{mode:a.interactive}):m.jsx(of,{lines:a.body})})]})})},a.name))})},"list")}),m.jsx(fi,{children:!o&&m.jsxs($s.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{duration:qr.normal,ease:Kr.easeOut},className:"mt-4 px-3 py-3 radius-inner border border-edge-subtle bg-elevated/30",children:[m.jsx("p",{className:"text-xs font-semibold text-fg-muted mb-2",children:"Tips"}),m.jsxs("div",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:[m.jsxs("p",{children:["Type ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:" help"})," in the terminal for detailed usage."]}),m.jsxs("p",{children:["Most commands have shorter aliases (e.g. ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"st"}),", ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"nb"}),", ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"id"}),")."]}),m.jsxs("p",{children:["Signal bars ",m.jsx("span",{className:"font-mono",children:"▁▃▅▇█"})," are colored by link quality grade based on RSSI, SNR, and radio config."]}),m.jsx("p",{children:"Captures are stored in browser session only — export before closing the tab."})]})]})})]})]})]})}function lf({onUseCommand:e}){const[t,s]=U.useState(!1),i=e?r=>{s(!1),e(r)}:void 0;return m.jsxs(m.Fragment,{children:[m.jsx(Po,{icon:m.jsx(No,{size:17,className:"translate-y-px"}),onClick:()=>s(!0),title:"CLI Command Guide"}),m.jsx(af,{isOpen:t,onClose:()=>s(!1),onUseCommand:i})]})}const za=Z_(),Qs=za.all().flatMap(e=>[{cmd:e.name,desc:e.description,params:e.params,required:!!e.params},...e.aliases.filter(t=>t.includes(" ")).map(t=>({cmd:t,desc:e.description,params:e.params,required:!!e.params}))]);Qs.push({cmd:"start cap",desc:"Start packet capture",params:"[seconds]",required:!0},{cmd:"end cap",desc:"Stop capture"},{cmd:"list cap",desc:"List captures"},{cmd:"export cap",desc:"Download capture",params:"[id]",required:!0});const Ws=["sig","name","rssi","snr","dist","heard"],hf={get:["name","role","lat","lon","radio","freq","tx","bw","sf","cr","af","txdelay","direct.txdelay","rxdelay","mode","repeat","flood.max","flood.advert.interval","advert.interval","duty","duty.max","multi.acks","int.thresh","agc.reset.interval","public.key","prv.key"],set:["name","lat","lon","freq","tx","bw","sf","cr","af","txdelay","direct.txdelay","rxdelay","mode","repeat","flood.max","flood.advert.interval","advert.interval","duty","log","multi.acks","int.thresh","agc.reset.interval","prv.key"],convert:["hex","base64"],neighbors:Ws,nb:Ws,"get neighbors":Ws,"get neighbor":Ws,"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 cr":["5","6","7","8"],"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","error"],"start cap":["30","60","120","300"]},Ii=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "];function ds(){return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)||window.innerWidth<640}function cf(e,t){const s=e.toLowerCase(),i=s.trim();if(!i)return[];const r=s.length>i.length&&s.endsWith(" ");if(!i.includes(" ")&&!r)return Qs.filter(h=>h.cmd.toLowerCase().startsWith(i));const n=r?i:i.substring(0,i.lastIndexOf(" ")),o=r?"":i.substring(i.lastIndexOf(" ")+1);if(n==="ping"&&t.length>0)return t.filter(h=>h.toLowerCase().startsWith(o)).slice(0,10).map(h=>({cmd:`ping ${h}`,desc:`→ ${h}`}));const a=hf[n];if(a){const h=a.filter(l=>l.toLowerCase().startsWith(o)).map(l=>({cmd:`${n} ${l}`,desc:`→ ${l}`}));if(!r&&o){const l=new Set(h.map(c=>c.cmd));for(const c of Qs){const d=c.cmd.toLowerCase();d.startsWith(i)&&!l.has(d)&&(h.push(c),l.add(d))}}return h}return Qs.filter(h=>h.cmd.toLowerCase().startsWith(i))}function Cf(){const e=pl(),{addCommand:t}=vo(),s=U.useRef(null),i=U.useRef(null),r=U.useRef(null),n=U.useRef(null),o=U.useRef(""),a=U.useRef(-1),h=U.useRef(""),l=U.useRef(!1),c=U.useRef(null),d=U.useRef(!1),u=U.useRef(!1),f=U.useRef(!1),_=U.useRef(!1),p=U.useRef([]),g=U.useRef(()=>{}),k=ml(),[q,F]=U.useState("C0dE"),[T,N]=U.useState(!1),H=U.useRef(null),Z=7,me=280,Y="C0dE",oe=U.useCallback(E=>{H.current&&(clearInterval(H.current),H.current=null);const A=Y.padEnd(Z),W=A+" "+E+" "+A;let O=0;const K=W.length-Z;N(!0),F(W.slice(0,Z)),H.current=setInterval(()=>{if(O++,O>K){clearInterval(H.current),H.current=null,N(!1),F(Y);return}F(W.slice(O,O+Z))},me)},[]);U.useEffect(()=>{const E=W_(oe),A=setInterval(()=>{Math.random()<.02&&oe(zr())},45e3);return()=>{E(),clearInterval(A),H.current&&clearInterval(H.current)}},[oe]);const[J,P]=U.useState(!1),S=U.useRef(null);U.useEffect(()=>{const E=j_(()=>{S.current&&clearTimeout(S.current),P(!0),S.current=setTimeout(()=>P(!1),5e3)});return()=>{E(),S.current&&clearTimeout(S.current)}},[]);const[M,C]=U.useState({show:!1,options:[],selectedIndex:0,input:""}),L=U.useRef([]),I=U.useRef(0);U.useEffect(()=>{e!=null&&e.neighbors&&(p.current=Object.values(e.neighbors).map(E=>E.node_name||E.name).filter(E=>!!E).sort())},[e==null?void 0:e.neighbors]);const R=U.useCallback(()=>{var E;(E=i.current)==null||E.write(iu(gl()))},[]),V=U.useCallback(()=>{const E=i.current;E&&(E.write(Hs),R(),E.write(o.current))},[R]),ee=U.useCallback(E=>{const A=cf(E,p.current);L.current=A,I.current=0;const W=A.length>0&&E.trim().length>0;C({show:W,options:A,selectedIndex:0,input:E.trim()})},[]),Se=U.useCallback(()=>{L.current=[],I.current=0,C({show:!1,options:[],selectedIndex:0,input:""})},[]),$e=U.useCallback(E=>{var W;const A=L.current[E];A&&(o.current=A.required?A.cmd+" ":A.cmd,V(),A.required?ee(o.current):Se(),(W=i.current)==null||W.focus())},[V,ee,Se]),Ne=U.useCallback(async E=>{const A=i.current;if(!A)return;const W=E.trim();if(!W){R();return}l.current=!0;const O=new AbortController;c.current=O,t(W),a.current=-1;let K=0;const ue={get cols(){return A.cols},get rows(){return A.rows},write(te,we="default"){const zt=(we==="default"?te:Un(te,we)).split(` -`);for(const Dt of zt)A.writeln(Dt);return K=br(zt,A.cols),String(K)},update(te,we,Lt){if(f.current)A.write(hu);else if(K>0)for(let gt=0;gt{clearInterval(a),o()},{once:!0})})}finally{Mo()}}}function Z_(){const e=new Jd,t=new Eu(e);return e.register(t,new Ru,new Bu,new q_,new V_,new Lu,new Mu,new Du,new G_,new X_,new Y_,new ju,new Qu,new c_,new e_,new s_,new d_,new x_,new k_,new E_,new R_,new B_,new L_,new H_,new z_,new K_,new J_),e}const Q_=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),vo=Ro(e=>({entries:[],commandHistory:[],isInitialized:!1,addEntry:t=>{const s=Q_(),i={...t,id:s,timestamp:Date.now()};return e(r=>({entries:[...r.entries,i]})),s},updateEntry:(t,s)=>{e(i=>({entries:i.entries.map(r=>r.id===t?{...r,...s}:r)}))},addCommand:t=>{e(s=>({commandHistory:[...s.commandHistory,t]}))},clearEntries:()=>{e({entries:[],commandHistory:[]})},setInitialized:t=>{e({isInitialized:t})}}));function ef({isOpen:e,onClose:t}){const s=Pa(),i=xt(n=>n.stats),r=n=>{const o=s.find(a=>a.id===n);o&&Oa(o,i)};return m.jsxs(To,{open:e,onClose:t,size:"sm",children:[m.jsx($o,{icon:m.jsx(jr,{size:20}),title:"Download Captures",onClose:t}),m.jsx(Ao,{className:"flex flex-col gap-2",children:s.length===0?m.jsxs("div",{className:"flex flex-col items-center gap-2 py-6 text-fg-muted",children:[m.jsx(Tl,{className:"w-8 h-8 opacity-40"}),m.jsx("p",{className:"text-sm",children:"No captures available."})]}):s.map(n=>m.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 radius-inset bg-elevated/50 border border-edge-subtle",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"type-label text-fg-primary truncate",children:n.filename}),m.jsxs("p",{className:"text-xs text-fg-muted mt-0.5",children:[n.packetCount," packets · ",n.durationSec,"s · ~",Zs(n.sizeBytes)]})]}),m.jsx(cl,{plain:!0,color:"primary",onClick:()=>r(n.id),title:"Download",className:"flex-shrink-0",children:m.jsx(jr,{"data-slot":"icon"})})]},n.id))})]})}function tf(){const e=Pa(),[t,s]=U.useState(!1);return m.jsxs(m.Fragment,{children:[m.jsx(Po,{icon:m.jsx(Ml,{size:20}),onClick:()=>s(!0),title:e.length>0?`Download captures (${e.length})`:"Captures",variant:"red",iconActiveColor:ve.red}),m.jsx(ef,{isOpen:t,onClose:()=>s(!1)})]})}const So=[{name:"acl",description:"Access control list statistics — identity and client counts.",body:["```","> acl","ACL Stats",""," Identities 2"," Total clients 5"," Admin 2"," Guest 3"," Repeater 1 ids 3 clients"," Room Server 1 ids 2 clients","```"],searchText:"acl access control list statistics identity client"},{name:"advert",description:"Broadcast a repeater advertisement to the mesh.",body:["```","> advert","✓ Advert sent","```"],searchText:"advert advertisement broadcast mesh"},{name:"board",description:"Hardware and platform info — CPU, memory, disk, temperatures, network I/O.",body:["```","> board"," Node Local-Node"," Runtime pyMC_Repeater v1.0.0"," Core v1.12.0",""," CPU 12.3% 4 cores"," Load 0.42 / 0.38 / 0.35"," Temp 48.2°C",""," Memory 412 MB / 664 MB 62%"," Disk 5.2 GB / 28.7 GB 18%",""," System uptime 14d 3h 22m"," Service uptime 2d 14h 32m"," Net TX/RX 128 MB / 342 MB","```"],searchText:"board hardware platform cpu memory disk temperature network"},{name:"cap",description:"Packet capture — start, stop, list, and export captures.",body:["**Sub-commands:** `start cap [sec]` · `end cap` · `list cap` · `export cap [id]`","","**`start cap [seconds]`** — Begin capture (default 120s, max 3600):","```","> start cap","Capturing... 118s remaining (4 captured)","","✓ Capture complete!"," Captured: 23 packets"," Duration: 120s"," Size: ~14.2 KB","```","","**`end cap`** — Stop capture early:","```","> end cap","✓ Capture stopped!"," Captured: 12 packets","```","","**`list cap`** — List saved captures:","```","> list cap","Capture Reports (2):"," 1. 23 pkts • 120s • ~14.2 KB (id: abc123)"," 2. 12 pkts • 34s • ~7.1 KB (id: def456)","```","","**`export cap [id]`** — Download by ID or index:","```","> export cap 1","✓ Downloading capture-abc123.json...","```"],searchText:"cap capture packet start end list export download diagnostic"},{name:"clear",description:"Clear the terminal screen.",body:["**Alias:** `cls`","```","> clear","```"],searchText:"clear cls screen"},{name:"clock",description:"Current system UTC time. Useful for NTP sync and packet timestamp correlation.",body:["```","> clock"," UTC Wed, 12 Feb 2026 00:01:34 GMT"," ISO 2026-02-12T00:01:34.000Z"," Unix 1770768094","```"],searchText:"clock time utc ntp unix iso timestamp"},{name:"convert",description:"Convert between hex and base64 encodings.",body:["**Usage:** `convert hex ` · `convert base64 `","```","> convert hex 48656C6C6F"," hex 48656C6C6F"," base64 SGVsbG8=","","> convert base64 SGVsbG8="," base64 SGVsbG8="," hex 48656C6C6F","```"],searchText:"convert hex base64 encoding decode"},{name:"get",description:"Read a configuration parameter.",body:[],interactive:"get",searchText:"get read config parameter name role lat lon radio freq tx bw sf cr txdelay mode duty flood advert"},{name:"help",description:"Show all commands, or detailed help for a specific command.",body:["**Alias:** `?` · `h`","```","> help Full command listing","> help ping Detailed help for ping","> ping help Same thing","```"],searchText:"help commands reference guide"},{name:"identities",description:"List all configured repeater and room server identities.",body:["**Alias:** `id` · `ids`","```","> identities","Identities (2)",""," 1. Local-Node repeater 0A1B2C3D"," 2. local-room room_server 0E5F6A7B","```"],searchText:"identities id ids repeater room server identity"},{name:"keys",description:"List configured transport encryption keys.",body:["```","> keys","Transport Keys (1)",""," main-transport flood: allow","```"],searchText:"keys transport encryption"},{name:"neighbors",description:"Direct RF neighbors with signal quality, RSSI, SNR, distance, and last-heard.",body:["**Alias:** `nb`","","**Sort qualifiers:** `sig` · `name` · `rssi` · `snr` · `dist` · `heard`","```","> neighbors","Direct Neighbors (4)","","+-------+-----------+-----------+--------+-------+--------+","| ▁▃▅▇█ | Node-1 | -87 dBm | 8.5 dB | 2.1km | 3m ago |","| ▁▃▅▇. | Relay-2 | -94 dBm | 5.2 dB | 4.8km | 1m ago |","| ▁▃▅.. | Node-3 | -108 dBm | 1.0 dB | 8.3km | 5m ago |","| ▁▃... | Node-4 | -118 dBm | -3 dB | 14km | 12m ago|","+-------+-----------+-----------+--------+-------+--------+","| SIG | NAME | RSSI | SNR | DIST | HEARD |","+-------+-----------+-----------+--------+-------+--------+","SF11/250kHz ant 3.5dBi nf -112dBm","```","","- **sig** — signal grade (weakest first)","- **name** — alphabetical","- **rssi** — RSSI (weakest first)","- **snr** — SNR (lowest first)","- **dist** — distance (closest first)","- **heard** — last seen (oldest first)"],searchText:"neighbors nb signal rssi snr distance sort direct rf"},{name:"packets",description:"Packet counters — received, transmitted, forwarded, dropped.",body:["```","> packets","Packet Stats 1321 total",""," Received 1284"," Transmitted 37"," Forwarded 891"," Dropped 14","```"],searchText:"packets received transmitted forwarded dropped counter"},{name:"ping",description:"Ping a neighbor by name or hex prefix. Shows RTT, signal quality, and path.",body:["**Usage:** `ping [timeout]`","```","> ping Node-1","▁▃▅▇█ Reply from Node-1",""," RTT 342ms"," RSSI -87 dBm"," SNR 8.5 dB"," Path direct"," Quality Excellent","```","","Custom timeout (default 30s):","```","> ping Node-4 60","```"],searchText:"ping rtt round trip time signal quality path neighbor"},{name:"restart",description:"Restart the pymc-repeater systemd service.",body:["**Alias:** `reboot`","```","> restart","Service is restarting (connection dropped).","Waiting for service... 8s","Service connected. (12s)","```","","The terminal polls automatically until the service comes back up."],searchText:"restart reboot service systemd"},{name:"rooms",description:"Room server statistics — message counts, active clients, sync status.",body:["```","> rooms","Rooms (1)",""," Local Room"," msgs 142 clients 3/5 sync running","```"],searchText:"rooms room server messages clients sync"},{name:"set",description:"Write a configuration parameter.",body:[],interactive:"set",searchText:"set write config parameter name lat lon freq tx bw sf cr txdelay mode duty log flood advert"},{name:"stats-core",description:"Engine vitals — uptime, duplicate cache, CPU, memory, temperature.",body:["```","> stats-core"," Core Stats",""," Uptime 2d 14h 32m"," Dup cache 128 entries TTL 900s",""," CPU 12.3% 4 cores"," Load 0.42 / 0.38 / 0.35"," Memory 412 MB / 664 MB 62%"," Temp 48.2°C","```"],searchText:"stats core engine vitals uptime cache cpu memory temperature"},{name:"stats-packets",description:"Firmware-compatible packet counters with rates and duplicate cache depth.",body:["```","> stats-packets"," Packet Counters",""," RX 1284 22.4/hr"," TX 37"," Forwarded 891 15.2/hr"," Dropped 14",""," Dup cache 128","```"],searchText:"stats packets firmware counter rate duplicate cache"},{name:"stats-radio",description:"Radio health — noise floor, airtime, duty cycle, and radio configuration.",body:["```","> stats-radio"," Radio Stats",""," Radio 906.875 MHz SF11 BW 250 kHz CR 4/5 22 dBm",""," Noise floor -112 dBm"," Airtime used 4.2s remaining: 55.8m"," Total airtime 1.2m"," Duty cycle 1.2%"," Utilization 0.8%","```"],searchText:"stats radio noise floor airtime duty cycle utilization"},{name:"status",description:"Quick summary of mode, neighbors, and uptime.",body:["**Alias:** `st`","```","> status","Local-Node repeater",""," Mode forward"," Neighbors 4 direct 12 total"," RX / TX 1284 / 37"," Uptime 2d 14h 32m","```"],searchText:"status st summary mode neighbors uptime"},{name:"top",description:"Live-updating system overview — CPU/memory gauges, mesh counters, processes.",body:["**Alias:** `htop`","","Refreshes every 3s. Press **Ctrl+C** to exit.","```","> top","Local-Node v1.0.0","──────────────────────────────────"," Sys 14d 3h 22m Svc 2d 14h 32m Load 0.42 0.38 0.35",""," CPU [████░░░░░░░░░░░░] 12.3% 4 cores"," Mem [██████████░░░░░░] 62.1% 412M/664M"," Dsk [███░░░░░░░░░░░░░] 18.4% 5.2G/28.7G"," cpu_thermal: 48.2°C",""," MESH"," Mode forward Nbrs 4/12 Noise -112dBm Air 1.2%"," RX 1284 TX 37 FWD 891 Drop 14"," RX/h 22 FWD/h 15",""," PROCS"," CPU MEM NAME"," 8.2 3.1 python3"," 2.1 1.4 cherrypy",""," 14:32:08 · Ctrl+C to exit","```","","Uses alternate screen buffer — scrollback is preserved."],searchText:"top htop live system overview cpu memory gauges mesh processes"},{name:"uptime",description:"How long the repeater service has been running.",body:["```","> uptime","Uptime 2d 14h 32m","```"],searchText:"uptime service running duration"},{name:"ver",description:"Version info for all three components.",body:["**Alias:** `version`","```","> ver"," pyMC_Repeater v1.0.0"," pyMC_Core v1.12.0"," pyMC_Console v1.0.0","```"],searchText:"ver version pymc repeater core console"}],sf=[{param:"name",category:"Identity",example:["> get name","name Local-Node"]},{param:"role",category:"Identity",example:["> get role","role repeater"]},{param:"lat",category:"Identity",example:["> get lat","lat 34.0522"],range:"-90 to 90"},{param:"lon",category:"Identity",example:["> get lon","lon -118.2437"],range:"-180 to 180"},{param:"public.key",category:"Identity",example:["> get public.key","public.key 0A1B2C3D4E5F..."]},{param:"radio",category:"Radio",example:["> get radio"," freq 906.875 MHz"," bw 250 kHz"," sf 11"," cr 4/5"," tx 22 dBm"]},{param:"freq",category:"Radio",example:["> get freq","freq 906.875 MHz"],range:"100–1000 MHz"},{param:"tx",category:"Radio",example:["> get tx","tx 22 dBm"],range:"2–22 dBm"},{param:"bw",category:"Radio",example:["> get bw","bw 250 kHz"],range:"7.8–500 kHz"},{param:"sf",category:"Radio",example:["> get sf","sf 11"],range:"5–12"},{param:"cr",category:"Radio",example:["> get cr","cr 4/5"],range:"5–8"},{param:"af",category:"Timing",example:["> get af","⚠ airtime_factor not yet exposed by pyMC_Repeater API."," Firmware range: 0-9. Tracked in CLI-Alignment.md."],range:"0–9 (pending)"},{param:"txdelay",category:"Timing",example:["> get txdelay","txdelay 1.0"],range:"0.0–5.0"},{param:"direct.txdelay",category:"Timing",example:["> get direct.txdelay","direct.txdelay 0.5"],range:"0.0–5.0"},{param:"rxdelay",category:"Timing",example:["> get rxdelay","rxdelay 0.0"],range:"≥ 0"},{param:"mode",category:"Repeater",example:["> get mode","mode forward"],range:"forward / monitor"},{param:"duty",category:"Repeater",example:["> get duty","duty on"],range:"on / off"},{param:"flood.max",category:"Repeater",example:["> get flood.max","flood.max 3"],range:"0–64"},{param:"advert.interval",category:"Repeater",example:["> get advert.interval","advert.interval 120m"],range:"0 (off) or 1–10080 min"},{param:"multi.acks",category:"Advanced",example:["> get multi.acks","multi.acks 0"],range:"0–255"},{param:"int.thresh",category:"Advanced",example:["> get int.thresh","int.thresh -120 dBm"],range:"-200 to 0 dBm"},{param:"agc.reset.interval",category:"Advanced",example:["> get agc.reset.interval","agc.reset.interval 0"],range:"≥ 0 (×4)"}],rf=[{param:"name",category:"Identity",example:["> set name Local-Node","OK - node_name set to Local-Node"],range:"text (no [ ] \\ / : , ? *)"},{param:"lat",category:"Identity",example:["> set lat 34.0522","OK - latitude set to 34.0522"],range:"-90 to 90"},{param:"lon",category:"Identity",example:["> set lon -118.2437","OK - longitude set to -118.2437"],range:"-180 to 180"},{param:"freq",category:"Radio",example:["> set freq 906.875","OK - frequency set to 906875000"],range:"100–1000 MHz"},{param:"tx",category:"Radio",example:["> set tx 22","OK - tx_power set to 22"],range:"2–22 dBm"},{param:"bw",category:"Radio",example:["> set bw 250","OK - bandwidth set to 250000"],range:"7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125, 250, 500 kHz"},{param:"sf",category:"Radio",example:["> set sf 11","OK - spreading_factor set to 11"],range:"5–12"},{param:"cr",category:"Radio",example:["> set cr 5","OK - coding_rate set to 5"],range:"5–8"},{param:"af",category:"Timing",example:["> set af 2","⚠ airtime_factor not yet exposed by pyMC_Repeater API."," Firmware range: 0-9. Needs backend support."],range:"0–9 (pending)"},{param:"txdelay",category:"Timing",example:["> set txdelay 1.0","OK - tx_delay_factor set to 1"],range:"0.0–5.0"},{param:"direct.txdelay",category:"Timing",example:["> set direct.txdelay 0.5","OK - direct_tx_delay_factor set to 0.5"],range:"0.0–5.0"},{param:"rxdelay",category:"Timing",example:["> set rxdelay 0","OK - rx_delay_base set to 0"],range:"≥ 0"},{param:"mode",category:"Repeater",example:["> set mode forward","OK - Mode set to forward"],range:"forward / monitor"},{param:"flood.max",category:"Repeater",example:["> set flood.max 3","OK - max_flood_hops set to 3"],range:"0–64"},{param:"advert.interval",category:"Repeater",example:["> set advert.interval 120","OK - Local advert interval set to 120m"],range:"0 (off) or 1–10080 min"},{param:"duty",category:"Repeater",example:["> set duty on","OK - Duty cycle enabled"],range:"on / off"},{param:"log",category:"Repeater",example:["> set log info","OK - Log level set to INFO"],range:"debug, info, warning, error"},{param:"multi.acks",category:"Advanced",example:["> set multi.acks 0","OK - multi_acks set to 0"],range:"0–255"},{param:"int.thresh",category:"Advanced",example:["> set int.thresh -120","OK - interference_threshold set to -120"],range:"-200 to 0 dBm"},{param:"agc.reset.interval",category:"Advanced",example:["> set agc.reset.interval 8","OK - AGC reset interval set to 8"],range:"≥ 0 (rounded to ×4)"},{param:"prv.key",category:"Advanced",example:["> set prv.key <128-hex>","To set this key, run on the Pi:",""," sudo ./convert_firmware_key.sh ","","Then restart: sudo systemctl restart pymc-repeater"],range:"128-char hex (SSH only)"}];function nf({mode:e}){const t=e==="get"?sf:rf,[s,i]=U.useState(0),r=t[s],n=U.useMemo(()=>{const o=new Map;for(const a of t){const h=o.get(a.category)||[];h.push(a),o.set(a.category,h)}return Array.from(o.entries())},[t]);return m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("div",{className:"flex flex-col gap-1.5",children:n.map(([o,a])=>m.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[m.jsx("span",{className:"text-xs text-fg-muted w-16 shrink-0 text-right pr-1",children:o}),a.map(h=>{const l=t.indexOf(h),c=l===s;return m.jsx("button",{onClick:()=>i(l),className:ti("px-1.5 py-0.5 type-data-xs radius-badge transition-colors cursor-pointer",c?"bg-sys-blue text-fg-invert font-semibold":"bg-elevated text-fg-secondary hover:bg-elevated/80 hover:text-sys-blue"),children:h.param},h.param)})]},o))}),m.jsx("pre",{className:"px-3 py-2.5 radius-inner bg-body text-fg-secondary type-code overflow-x-auto border border-edge-subtle",children:r.example.map((o,a)=>m.jsx("div",{children:o||" "},a))}),r.range&&m.jsxs("p",{className:"text-xs text-fg-muted",children:[m.jsx("span",{className:"text-fg-secondary font-medium",children:r.param})," — ",r.range]})]})}function yo(e,t){const s=e.split(/(\*\*[^*]+\*\*)/g);return m.jsx("span",{children:s.map((i,r)=>i.startsWith("**")&&i.endsWith("**")?m.jsx("strong",{className:"text-fg-primary font-semibold",children:i.slice(2,-2)},r):i.split(/(`[^`]+`)/g).map((o,a)=>o.startsWith("`")&&o.endsWith("`")?m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue type-data-xs",children:o.slice(1,-1)},`${r}-${a}`):m.jsx("span",{children:o},`${r}-${a}`)))},t)}function of({lines:e}){const t=[];let s=0;for(;sm.jsx("div",{children:n||" "},o))},t.length));continue}if(!i.trim()){t.push(m.jsx("div",{className:"h-1.5"},t.length)),s++;continue}if(i.startsWith("- ")){t.push(m.jsxs("div",{className:"flex gap-2 text-sm text-fg-secondary pl-2 py-0.5",children:[m.jsx("span",{className:"text-fg-muted shrink-0",children:"•"}),m.jsx("span",{children:yo(i.slice(2),0)})]},t.length)),s++;continue}t.push(m.jsx("p",{className:"text-sm text-fg-secondary py-0.5",children:yo(i,0)},t.length)),s++}return m.jsx(m.Fragment,{children:t})}function af({isOpen:e,onClose:t,onUseCommand:s}){const[i,r]=U.useState(""),n=U.useMemo(()=>{if(!i.trim())return So;const a=i.toLowerCase();return So.filter(h=>h.name.includes(a)||h.searchText.includes(a)||h.description.toLowerCase().includes(a))},[i]),o=i.trim().length>0;return m.jsxs(To,{open:e,onClose:t,size:"3xl",motionPlus:!0,className:"sm:min-w-[540px] md:min-w-[680px]",children:[m.jsx($o,{icon:m.jsx(No,{size:20}),title:"Terminal Command Guide",onClose:t}),m.jsxs(Ao,{className:"flex flex-col gap-0 !px-0 !py-0",children:[m.jsx("div",{className:"sticky top-0 z-10 px-5 py-3 border-b border-edge-subtle bg-surface/95 backdrop-blur-sm",children:m.jsxs("div",{className:"relative",children:[m.jsx(Vr,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-muted"}),m.jsx("input",{type:"text",value:i,onChange:a=>r(a.target.value),placeholder:"Search commands...",className:"w-full pl-8 pr-3 py-1.5 text-sm bg-elevated border border-edge-subtle radius-inner text-fg-primary placeholder:text-fg-muted focus:outline-none focus:ring-1 focus:ring-sys-blue/50",autoFocus:!0})]})}),m.jsxs("div",{className:"overflow-y-auto px-5 py-3 h-[420px] sm:h-[520px] md:h-[600px]",children:[m.jsx(fi,{mode:"popLayout",children:n.length===0?m.jsxs($s.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:qr.normal,ease:Kr.easeOut},className:"flex flex-col items-center gap-2 py-10 text-fg-muted",children:[m.jsx(Vr,{className:"w-6 h-6 opacity-40"}),m.jsxs("p",{className:"text-sm",children:['No commands match "',i,'"']})]},"empty"):m.jsx($s.div,{initial:!1,className:"flex flex-col gap-1",children:m.jsx(fi,{initial:!1,children:n.map(a=>m.jsx($s.div,{layout:"position",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:dl.fade,className:"min-w-0",children:m.jsx(ul,{children:({open:h})=>m.jsxs("div",{className:ti("radius-inner border transition-colors",h?"border-edge-subtle bg-elevated/50":"border-transparent hover:bg-elevated/30"),children:[m.jsxs("div",{className:"flex items-center w-full min-w-0",children:[m.jsxs(_l,{className:"flex items-center gap-3 flex-1 min-w-0 px-3 py-2 text-left cursor-pointer",children:[m.jsx(kl,{size:14,className:ti("shrink-0 text-fg-muted transition-transform duration-150",h&&"rotate-90")}),m.jsx("code",{className:"text-sm font-semibold text-sys-blue font-mono shrink-0",children:a.name}),m.jsx("span",{className:"text-xs text-fg-muted truncate min-w-0",children:a.description})]}),s&&m.jsx("button",{onClick:l=>{l.stopPropagation(),s(a.name)},className:"shrink-0 mr-2 px-2 py-0.5 text-xs font-semibold uppercase tracking-wider radius-badge bg-elevated text-fg-muted hover:text-sys-blue hover:bg-elevated/80 transition-colors cursor-pointer",title:`Use "${a.name}" in terminal`,children:"use"})]}),m.jsx(fl,{className:"px-3 pb-3 pt-0 pl-9",children:a.interactive?m.jsx(nf,{mode:a.interactive}):m.jsx(of,{lines:a.body})})]})})},a.name))})},"list")}),m.jsx(fi,{children:!o&&m.jsxs($s.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{duration:qr.normal,ease:Kr.easeOut},className:"mt-4 px-3 py-3 radius-inner border border-edge-subtle bg-elevated/30",children:[m.jsx("p",{className:"text-xs font-semibold text-fg-muted mb-2",children:"Tips"}),m.jsxs("div",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:[m.jsxs("p",{children:["Type ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:" help"})," in the terminal for detailed usage."]}),m.jsxs("p",{children:["Most commands have shorter aliases (e.g. ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"st"}),", ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"nb"}),", ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"id"}),")."]}),m.jsxs("p",{children:["Signal bars ",m.jsx("span",{className:"font-mono",children:"▁▃▅▇█"})," are colored by link quality grade based on RSSI, SNR, and radio config."]}),m.jsx("p",{children:"Captures are stored in browser session only — export before closing the tab."})]})]})})]})]})]})}function lf({onUseCommand:e}){const[t,s]=U.useState(!1),i=e?r=>{s(!1),e(r)}:void 0;return m.jsxs(m.Fragment,{children:[m.jsx(Po,{icon:m.jsx(No,{size:17,className:"translate-y-px"}),onClick:()=>s(!0),title:"CLI Command Guide"}),m.jsx(af,{isOpen:t,onClose:()=>s(!1),onUseCommand:i})]})}const za=Z_(),Qs=za.all().flatMap(e=>[{cmd:e.name,desc:e.description,params:e.params,required:!!e.params},...e.aliases.filter(t=>t.includes(" ")).map(t=>({cmd:t,desc:e.description,params:e.params,required:!!e.params}))]);Qs.push({cmd:"start cap",desc:"Start packet capture",params:"[seconds]",required:!0},{cmd:"end cap",desc:"Stop capture"},{cmd:"list cap",desc:"List captures"},{cmd:"export cap",desc:"Download capture",params:"[id]",required:!0});const Ws=["sig","name","rssi","snr","dist","heard"],hf={get:["name","role","lat","lon","radio","freq","tx","bw","sf","cr","af","txdelay","direct.txdelay","rxdelay","mode","repeat","flood.max","flood.advert.interval","advert.interval","duty","duty.max","multi.acks","int.thresh","agc.reset.interval","public.key","prv.key"],set:["name","lat","lon","freq","tx","bw","sf","cr","af","txdelay","direct.txdelay","rxdelay","mode","repeat","flood.max","flood.advert.interval","advert.interval","duty","log","multi.acks","int.thresh","agc.reset.interval","prv.key"],convert:["hex","base64"],neighbors:Ws,nb:Ws,"get neighbors":Ws,"get neighbor":Ws,"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 cr":["5","6","7","8"],"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","error"],"start cap":["30","60","120","300"]},Ii=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "];function ds(){return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)||window.innerWidth<640}function cf(e,t){const s=e.toLowerCase(),i=s.trim();if(!i)return[];const r=s.length>i.length&&s.endsWith(" ");if(!i.includes(" ")&&!r)return Qs.filter(h=>h.cmd.toLowerCase().startsWith(i));const n=r?i:i.substring(0,i.lastIndexOf(" ")),o=r?"":i.substring(i.lastIndexOf(" ")+1);if(n==="ping"&&t.length>0)return t.filter(h=>h.toLowerCase().startsWith(o)).slice(0,10).map(h=>({cmd:`ping ${h}`,desc:`→ ${h}`}));const a=hf[n];if(a){const h=a.filter(l=>l.toLowerCase().startsWith(o)).map(l=>({cmd:`${n} ${l}`,desc:`→ ${l}`}));if(!r&&o){const l=new Set(h.map(c=>c.cmd));for(const c of Qs){const d=c.cmd.toLowerCase();d.startsWith(i)&&!l.has(d)&&(h.push(c),l.add(d))}}return h}return Qs.filter(h=>h.cmd.toLowerCase().startsWith(i))}function Cf(){const e=pl(),{addCommand:t}=vo(),s=U.useRef(null),i=U.useRef(null),r=U.useRef(null),n=U.useRef(null),o=U.useRef(""),a=U.useRef(-1),h=U.useRef(""),l=U.useRef(!1),c=U.useRef(null),d=U.useRef(!1),u=U.useRef(!1),f=U.useRef(!1),_=U.useRef(!1),p=U.useRef([]),g=U.useRef(()=>{}),k=ml(),[q,F]=U.useState("C0dE"),[T,N]=U.useState(!1),H=U.useRef(null),Z=7,me=280,Y="C0dE",oe=U.useCallback(E=>{H.current&&(clearInterval(H.current),H.current=null);const A=Y.padEnd(Z),W=A+" "+E+" "+A;let O=0;const K=W.length-Z;N(!0),F(W.slice(0,Z)),H.current=setInterval(()=>{if(O++,O>K){clearInterval(H.current),H.current=null,N(!1),F(Y);return}F(W.slice(O,O+Z))},me)},[]);U.useEffect(()=>{const E=W_(oe),A=setInterval(()=>{Math.random()<.02&&oe(zr())},45e3);return()=>{E(),clearInterval(A),H.current&&clearInterval(H.current)}},[oe]);const[J,P]=U.useState(!1),S=U.useRef(null);U.useEffect(()=>{const E=j_(()=>{S.current&&clearTimeout(S.current),P(!0),S.current=setTimeout(()=>P(!1),5e3)});return()=>{E(),S.current&&clearTimeout(S.current)}},[]);const[L,C]=U.useState({show:!1,options:[],selectedIndex:0,input:""}),M=U.useRef([]),I=U.useRef(0);U.useEffect(()=>{e!=null&&e.neighbors&&(p.current=Object.values(e.neighbors).map(E=>E.node_name||E.name).filter(E=>!!E).sort())},[e==null?void 0:e.neighbors]);const R=U.useCallback(()=>{var E;(E=i.current)==null||E.write(iu(gl()))},[]),V=U.useCallback(()=>{const E=i.current;E&&(E.write(Hs),R(),E.write(o.current))},[R]),ee=U.useCallback(E=>{const A=cf(E,p.current);M.current=A,I.current=0;const W=A.length>0&&E.trim().length>0;C({show:W,options:A,selectedIndex:0,input:E.trim()})},[]),Se=U.useCallback(()=>{M.current=[],I.current=0,C({show:!1,options:[],selectedIndex:0,input:""})},[]),$e=U.useCallback(E=>{var W;const A=M.current[E];A&&(o.current=A.required?A.cmd+" ":A.cmd,V(),A.required?ee(o.current):Se(),(W=i.current)==null||W.focus())},[V,ee,Se]),Ne=U.useCallback(async E=>{const A=i.current;if(!A)return;const W=E.trim();if(!W){R();return}l.current=!0;const O=new AbortController;c.current=O,t(W),a.current=-1;let K=0;const ue={get cols(){return A.cols},get rows(){return A.rows},write(te,we="default"){const zt=(we==="default"?te:Un(te,we)).split(` +`);for(const Dt of zt)A.writeln(Dt);return K=br(zt,A.cols),String(K)},update(te,we,Mt){if(f.current)A.write(hu);else if(K>0)for(let gt=0;gt{const A=i.current;if(!A||!u.current)return;if(l.current){for(let K=0;KrequestAnimationFrame(()=>{var ue;return(ue=document.querySelector(`[data-ac-index="${K}"]`))==null?void 0:ue.scrollIntoView({block:"nearest"})});for(let K=0;K0){const te=L.current[I.current];te&&(o.current=te.cmd,V())}Se();const je=o.current;o.current="",A.writeln(""),Ne(je);continue}if(ue===127||ue===8){o.current.length>0&&(o.current=o.current.slice(0,-1),A.write("\b \b"),ee(o.current));continue}if(ue===3){o.current="",Se(),A.writeln("^C"),R();continue}if(ue===12){A.clear(),Se(),V();continue}if(ue===9){L.current.length>0&&$e(I.current);continue}if(ue===27){if(E.charCodeAt(K+1)===91){const je=E.charCodeAt(K+2);if(K+=2,je===65){if(L.current.length>0){const te=Math.max(I.current-1,0);I.current=te,C(we=>({...we,selectedIndex:te})),O(te)}else W.length>0&&(a.current===-1&&(h.current=o.current),a.current0){const te=Math.min(I.current+1,L.current.length-1);I.current=te,C(we=>({...we,selectedIndex:te})),O(te)}else a.current>0?(a.current--,o.current=W[W.length-1-a.current]||"",V()):a.current===0&&(a.current=-1,o.current=h.current,V());continue}if(je===67||je===68)continue;continue}L.current.length>0&&Se();continue}ue>=32&&(o.current+=E[K],A.write(E[K]),a.current=-1,ee(o.current))}},[Se,ee,$e,R,V,Ne]);U.useEffect(()=>{g.current=re},[re]);const Ge=U.useCallback(async()=>{const E=i.current;if(!E||d.current)return;d.current=!0,_.current=!1;const A="\x1B[94m",W="\x1B[0m",O=()=>_.current,K=Ii.length,ue=Do-1;try{const te=vs(Ii,0);for(const we of te)E.writeln(we);await new Promise(we=>{let Lt=0;const zt=setInterval(()=>{if(O()){clearInterval(zt),we();return}if(Lt>=ue){clearInterval(zt),we();return}Lt++,E.write(`\x1B[${K}F`);const Dt=vs(Ii,Lt);for(const gt of Dt)E.write(`\x1B[2K${gt} -`)},Mo)})}finally{Lo()}if(O()||(E.writeln(""),E.write(b("● Initializing terminal...")),await new Promise(te=>setTimeout(te,300)),O())||(E.write(Hs),E.writeln(`${A}✓ Initializing terminal...${W}`),E.write(b("● Connecting to repeater...")),await new Promise(te=>setTimeout(te,500)),O()))return;E.write(Hs),vl.getState().health==="connected"?E.writeln(`${A}✓ Connected to repeater${W}`):E.writeln(su("~ Connection status unknown")),E.writeln(b("Ready. Type 'help' for commands.")),E.writeln(""),R(),u.current=!0},[R]);U.useEffect(()=>{const E=s.current;if(!E)return;const A=ds()?12:13,W=new Wd({theme:Ma(),fontFamily:'"JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',fontSize:A,lineHeight:ds()?1.1:1,cursorBlink:!1,cursorStyle:"underline",scrollback:1e4,convertEol:!0,allowTransparency:!0,rightClickSelectsWord:!1}),O=new jd;W.loadAddon(O),W.loadAddon(new Yd),W.open(E),O.fit(),i.current=W,r.current=O;const K=W.onData(te=>g.current(te)),ue=mu(W),je=new ResizeObserver(()=>{requestAnimationFrame(()=>O.fit())});return je.observe(E),Ge(),ds()||W.focus(),()=>{var te;_.current=!0,(te=c.current)==null||te.abort(),f.current&&(W.write(qn+Kn),f.current=!1),K.dispose(),ue(),je.disconnect(),W.dispose(),i.current=null,r.current=null,d.current=!1,u.current=!1}},[]);const We=U.useCallback(E=>{const A=E.target.value;A.length>0&&(re(A),E.target.value="")},[re]),ut=U.useCallback(E=>{E.key==="Enter"?(E.preventDefault(),re("\r")):E.key==="Backspace"?(E.preventDefault(),re("")):E.key==="ArrowUp"?(E.preventDefault(),re("\x1B[A")):E.key==="ArrowDown"&&(E.preventDefault(),re("\x1B[B"))},[re]),ss=U.useCallback(()=>{var E,A;ds()?(E=n.current)==null||E.focus():(A=i.current)==null||A.focus()},[]);U.useEffect(()=>{if(!ds())return;const E=()=>{var K;const O=(K=s.current)==null?void 0:K.querySelector(".xterm-viewport");O&&(O.scrollTop=O.scrollHeight),requestAnimationFrame(()=>{var ue;return(ue=r.current)==null?void 0:ue.fit()})},A=window.visualViewport;if(A){const O=()=>{A.heightA.removeEventListener("resize",O)}const W=n.current;if(W){const O=()=>setTimeout(E,300);return W.addEventListener("focus",O),()=>W.removeEventListener("focus",O)}},[]);const nt=U.useCallback(E=>{o.current=E+" ",V(),ee(o.current),setTimeout(()=>{var A;(A=s.current)==null||A.click()},400)},[V,ee]);return m.jsx(bl,{children:m.jsx(wl,{ready:!0,children:m.jsxs("div",{className:"terminal-card flex flex-col gap-1 sm:gap-1.5",children:[m.jsxs("div",{className:"card-terminal-header flex-wrap",children:[m.jsx("span",{className:"seven-seg-panel",children:m.jsx(xl,{text:q,minChars:7,size:24,noCycle:T})}),m.jsx("div",{className:"header-well self-stretch flex-col sm:order-first",children:m.jsxs("div",{className:`indicator-key${k==="connected"?" indicator-key--active":k==="degraded"?" indicator-key--sending":""}`,children:[m.jsx("span",{className:"indicator-key__label",children:"ONLINE"}),m.jsx("span",{className:"indicator-key__led"})]})}),m.jsx("div",{className:"card-terminal-ridge flex-1 min-w-4 sm:hidden"}),m.jsxs("div",{className:"header-well flex items-center gap-1 sm:order-last",children:[m.jsx(lf,{onUseCommand:nt}),m.jsx(tf,{})]}),m.jsx("div",{className:"card-terminal-ridge flex-1 min-w-8 hidden sm:block"})]}),m.jsx(Cl,{noPadding:!0,isLoaded:!0,className:"flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",onClick:ss,children:m.jsxs("div",{className:"card-terminal-well flex-1 min-h-0 flex flex-col overflow-hidden",children:[m.jsxs("div",{className:"flex-1 min-h-0 terminal-gutter relative",children:[m.jsx("div",{ref:s,className:"h-full w-full"}),J&&m.jsxs("div",{className:"absolute inset-0 z-10 flex items-center justify-center",onClick:()=>P(!1),children:[m.jsx("div",{className:"absolute inset-0 animate-[partytime-bg_5s_ease-out_forwards]",style:{background:"rgba(0,0,0,0.82)"}}),m.jsxs("div",{className:"relative z-10 animate-[partytime-crt_5s_ease-out_forwards] partytime-glow",children:[m.jsx("img",{src:"/assets/partytime.gif",alt:"No way.",className:"max-h-[60vh] max-w-[70vw] object-contain rounded"}),m.jsx("div",{className:"absolute inset-0 pointer-events-none rounded partytime-scanlines"})]})]})]}),M.show&&M.options.length>0&&m.jsxs("div",{className:"flex-shrink-0 overflow-hidden terminal-completions",style:{borderTop:"1px solid var(--terminal-border)",background:"var(--terminal-bg-input)"},children:[m.jsx("div",{className:"overflow-y-auto",style:{maxHeight:"176px"},children:M.options.map((E,A)=>{const W=A===M.selectedIndex,O=M.input.length;return m.jsxs("div",{"data-ac-index":A,onClick:()=>$e(A),className:ti("terminal-ac-option",W?"text-sys-blue":"text-fg-primary"),style:{background:W?"var(--terminal-autocomplete-hover)":void 0},onMouseEnter:K=>{W||(K.currentTarget.style.background="var(--terminal-autocomplete-hover)")},onMouseLeave:K=>{W||(K.currentTarget.style.background="")},children:[m.jsx("span",{className:"terminal-ac-option__indicator",children:W?"▸":""}),m.jsxs("span",{className:"terminal-ac-option__cmd",children:[m.jsx("span",{className:"font-semibold text-sys-blue",children:E.cmd.substring(0,O)}),E.cmd.substring(O)]}),m.jsx("span",{className:"terminal-ac-option__desc",children:E.desc})]},E.cmd)})}),m.jsxs("div",{className:"terminal-ac-hints",children:[m.jsx("span",{className:"hidden sm:inline",children:"Tab · ↑↓ · Esc"}),m.jsx("span",{className:"sm:hidden",children:"Tap to select"}),m.jsxs("span",{children:[M.options.length," match",M.options.length!==1?"es":""]})]})]}),m.jsxs("div",{className:"terminal-mobile-input-bar sm:hidden",children:[m.jsx("input",{ref:n,type:"text",className:"terminal-mobile-input",onChange:We,onKeyDown:ut,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,enterKeyHint:"send","aria-label":"Terminal input",placeholder:"Type command..."}),m.jsx("button",{type:"button",className:"terminal-send-btn",onClick:()=>re("\r"),"aria-label":"Run command",children:m.jsx(Bl,{})})]}),m.jsxs("div",{className:"terminal-status-bar",children:[m.jsx("span",{className:"hidden sm:inline",children:"↑↓ History · Tab · Esc"}),m.jsx("span",{className:"sm:hidden",children:"Tap input to type"}),(e==null?void 0:e.version)&&m.jsxs("span",{children:["pyMC v",e.version]})]})]})})]})})})}export{Cf as default}; +Type 'help' for available commands.`,"error");c.current=null,l.current=!1,A.writeln(""),R()},[t,R]),re=U.useCallback(E=>{const A=i.current;if(!A||!u.current)return;if(l.current){for(let K=0;KrequestAnimationFrame(()=>{var ue;return(ue=document.querySelector(`[data-ac-index="${K}"]`))==null?void 0:ue.scrollIntoView({block:"nearest"})});for(let K=0;K0){const te=M.current[I.current];te&&(o.current=te.cmd,V())}Se();const je=o.current;o.current="",A.writeln(""),Ne(je);continue}if(ue===127||ue===8){o.current.length>0&&(o.current=o.current.slice(0,-1),A.write("\b \b"),ee(o.current));continue}if(ue===3){o.current="",Se(),A.writeln("^C"),R();continue}if(ue===12){A.clear(),Se(),V();continue}if(ue===9){M.current.length>0&&$e(I.current);continue}if(ue===27){if(E.charCodeAt(K+1)===91){const je=E.charCodeAt(K+2);if(K+=2,je===65){if(M.current.length>0){const te=Math.max(I.current-1,0);I.current=te,C(we=>({...we,selectedIndex:te})),O(te)}else W.length>0&&(a.current===-1&&(h.current=o.current),a.current0){const te=Math.min(I.current+1,M.current.length-1);I.current=te,C(we=>({...we,selectedIndex:te})),O(te)}else a.current>0?(a.current--,o.current=W[W.length-1-a.current]||"",V()):a.current===0&&(a.current=-1,o.current=h.current,V());continue}if(je===67||je===68)continue;continue}M.current.length>0&&Se();continue}ue>=32&&(o.current+=E[K],A.write(E[K]),a.current=-1,ee(o.current))}},[Se,ee,$e,R,V,Ne]);U.useEffect(()=>{g.current=re},[re]);const Ge=U.useCallback(async()=>{const E=i.current;if(!E||d.current)return;d.current=!0,_.current=!1;const A="\x1B[94m",W="\x1B[0m",O=()=>_.current,K=Ii.length,ue=Do-1;try{const te=vs(Ii,0);for(const we of te)E.writeln(we);await new Promise(we=>{let Mt=0;const zt=setInterval(()=>{if(O()){clearInterval(zt),we();return}if(Mt>=ue){clearInterval(zt),we();return}Mt++,E.write(`\x1B[${K}F`);const Dt=vs(Ii,Mt);for(const gt of Dt)E.write(`\x1B[2K${gt} +`)},Lo)})}finally{Mo()}if(O()||(E.writeln(""),E.write(b("● Initializing terminal...")),await new Promise(te=>setTimeout(te,300)),O())||(E.write(Hs),E.writeln(`${A}✓ Initializing terminal...${W}`),E.write(b("● Connecting to repeater...")),await new Promise(te=>setTimeout(te,500)),O()))return;E.write(Hs),vl.getState().health==="connected"?E.writeln(`${A}✓ Connected to repeater${W}`):E.writeln(su("~ Connection status unknown")),E.writeln(b("Ready. Type 'help' for commands.")),E.writeln(""),R(),u.current=!0},[R]);U.useEffect(()=>{const E=s.current;if(!E)return;const A=ds()?12:13,W=new Wd({theme:La(),fontFamily:'"JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',fontSize:A,lineHeight:ds()?1.1:1,cursorBlink:!1,cursorStyle:"underline",scrollback:1e4,convertEol:!0,allowTransparency:!0,rightClickSelectsWord:!1}),O=new jd;W.loadAddon(O),W.loadAddon(new Yd),W.open(E),O.fit(),i.current=W,r.current=O;const K=W.onData(te=>g.current(te)),ue=mu(W),je=new ResizeObserver(()=>{requestAnimationFrame(()=>O.fit())});return je.observe(E),Ge(),ds()||W.focus(),()=>{var te;_.current=!0,(te=c.current)==null||te.abort(),f.current&&(W.write(qn+Kn),f.current=!1),K.dispose(),ue(),je.disconnect(),W.dispose(),i.current=null,r.current=null,d.current=!1,u.current=!1}},[]);const We=U.useCallback(E=>{const A=E.target.value;A.length>0&&(re(A),E.target.value="")},[re]),ut=U.useCallback(E=>{E.key==="Enter"?(E.preventDefault(),re("\r")):E.key==="Backspace"?(E.preventDefault(),re("")):E.key==="ArrowUp"?(E.preventDefault(),re("\x1B[A")):E.key==="ArrowDown"&&(E.preventDefault(),re("\x1B[B"))},[re]),ss=U.useCallback(()=>{var E,A;ds()?(E=n.current)==null||E.focus():(A=i.current)==null||A.focus()},[]);U.useEffect(()=>{if(!ds())return;const E=()=>{var K;const O=(K=s.current)==null?void 0:K.querySelector(".xterm-viewport");O&&(O.scrollTop=O.scrollHeight),requestAnimationFrame(()=>{var ue;return(ue=r.current)==null?void 0:ue.fit()})},A=window.visualViewport;if(A){const O=()=>{A.heightA.removeEventListener("resize",O)}const W=n.current;if(W){const O=()=>setTimeout(E,300);return W.addEventListener("focus",O),()=>W.removeEventListener("focus",O)}},[]);const nt=U.useCallback(E=>{o.current=E+" ",V(),ee(o.current),setTimeout(()=>{var A;(A=s.current)==null||A.click()},400)},[V,ee]);return m.jsx(bl,{children:m.jsx(wl,{ready:!0,children:m.jsxs("div",{className:"terminal-card flex flex-col gap-1 sm:gap-1.5",children:[m.jsxs("div",{className:"card-terminal-header flex-wrap",children:[m.jsx("span",{className:"seven-seg-panel",children:m.jsx(xl,{text:q,minChars:7,size:24,noCycle:T})}),m.jsx("div",{className:"header-well self-stretch flex-col sm:order-first",children:m.jsxs("div",{className:`indicator-key${k==="connected"?" indicator-key--active":k==="degraded"?" indicator-key--sending":""}`,children:[m.jsx("span",{className:"indicator-key__label",children:"ONLINE"}),m.jsx("span",{className:"indicator-key__led"})]})}),m.jsx("div",{className:"card-terminal-ridge flex-1 min-w-4 sm:hidden"}),m.jsxs("div",{className:"header-well flex items-center gap-1 sm:order-last",children:[m.jsx(lf,{onUseCommand:nt}),m.jsx(tf,{})]}),m.jsx("div",{className:"card-terminal-ridge flex-1 min-w-8 hidden sm:block"})]}),m.jsx(Cl,{noPadding:!0,isLoaded:!0,className:"flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",onClick:ss,children:m.jsxs("div",{className:"card-terminal-well flex-1 min-h-0 flex flex-col overflow-hidden",children:[m.jsxs("div",{className:"flex-1 min-h-0 terminal-gutter relative",children:[m.jsx("div",{ref:s,className:"h-full w-full"}),J&&m.jsxs("div",{className:"absolute inset-0 z-10 flex items-center justify-center",onClick:()=>P(!1),children:[m.jsx("div",{className:"absolute inset-0 animate-[partytime-bg_5s_ease-out_forwards]",style:{background:"rgba(0,0,0,0.82)"}}),m.jsxs("div",{className:"relative z-10 animate-[partytime-crt_5s_ease-out_forwards] partytime-glow",children:[m.jsx("img",{src:"/assets/partytime.gif",alt:"No way.",className:"max-h-[60vh] max-w-[70vw] object-contain rounded"}),m.jsx("div",{className:"absolute inset-0 pointer-events-none rounded partytime-scanlines"})]})]})]}),L.show&&L.options.length>0&&m.jsxs("div",{className:"flex-shrink-0 overflow-hidden terminal-completions",style:{borderTop:"1px solid var(--terminal-border)",background:"var(--terminal-bg-input)"},children:[m.jsx("div",{className:"overflow-y-auto",style:{maxHeight:"176px"},children:L.options.map((E,A)=>{const W=A===L.selectedIndex,O=L.input.length;return m.jsxs("div",{"data-ac-index":A,onClick:()=>$e(A),className:ti("terminal-ac-option",W?"text-sys-blue":"text-fg-primary"),style:{background:W?"var(--terminal-autocomplete-hover)":void 0},onMouseEnter:K=>{W||(K.currentTarget.style.background="var(--terminal-autocomplete-hover)")},onMouseLeave:K=>{W||(K.currentTarget.style.background="")},children:[m.jsx("span",{className:"terminal-ac-option__indicator",children:W?"▸":""}),m.jsxs("span",{className:"terminal-ac-option__cmd",children:[m.jsx("span",{className:"font-semibold text-sys-blue",children:E.cmd.substring(0,O)}),E.cmd.substring(O)]}),m.jsx("span",{className:"terminal-ac-option__desc",children:E.desc})]},E.cmd)})}),m.jsxs("div",{className:"terminal-ac-hints",children:[m.jsx("span",{className:"hidden sm:inline",children:"Tab · ↑↓ · Esc"}),m.jsx("span",{className:"sm:hidden",children:"Tap to select"}),m.jsxs("span",{children:[L.options.length," match",L.options.length!==1?"es":""]})]})]}),m.jsxs("div",{className:"terminal-mobile-input-bar sm:hidden",children:[m.jsx("input",{ref:n,type:"text",className:"terminal-mobile-input",onChange:We,onKeyDown:ut,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,enterKeyHint:"send","aria-label":"Terminal input",placeholder:"Type command..."}),m.jsx("button",{type:"button",className:"terminal-send-btn",onClick:()=>re("\r"),"aria-label":"Run command",children:m.jsx(Bl,{})})]}),m.jsxs("div",{className:"terminal-status-bar",children:[m.jsx("span",{className:"hidden sm:inline",children:"↑↓ History · Tab · Esc"}),m.jsx("span",{className:"sm:hidden",children:"Tap input to type"}),(e==null?void 0:e.version)&&m.jsxs("span",{children:["pyMC v",e.version]})]})]})})]})})})}export{Cf as default}; diff --git a/frontend/dist/assets/Test-BEpj0lEQ.js b/frontend/dist/assets/Test-DjOBviXb.js similarity index 95% rename from frontend/dist/assets/Test-BEpj0lEQ.js rename to frontend/dist/assets/Test-DjOBviXb.js index fcf26b89..06989259 100644 --- a/frontend/dist/assets/Test-BEpj0lEQ.js +++ b/frontend/dist/assets/Test-DjOBviXb.js @@ -1,4 +1,4 @@ -import{e as Ae,r as p,gs as _e,gt as Ie,af as Be,ag as Ve,j as e,a7 as U,V as ye,dV as He,dJ as qe,c as le,aE as We,Q as Ye,a6 as Oe,gu as Xe,O as $,cn as z,v as ze,c7 as Ge,bY as Je,H as me,Z,gv as Qe,L as xe}from"./index-C2xvS0Jd.js";import{C as Q,P as Ke,a as Ue,B as De}from"./PageLayout-Cg7r5tdt.js";import{useResolveSource as Ze}from"./usePipelineStore-Do-g28wv.js";import{C as et}from"./chevron-right-C9GG0xWI.js";import{R as se,C as ae}from"./Grid-kVOI-wJp.js";import"./node-types-BD70swWz.js";/** +import{e as Ae,r as p,gs as _e,gt as Ie,af as Be,ag as Ve,j as e,a7 as U,V as ye,dV as He,dK as qe,c as le,aF as We,Q as Oe,a6 as Ye,gu as Xe,O as $,co as z,v as ze,c8 as Ge,bZ as Je,H as me,Z,gv as Qe,L as xe}from"./index-D33fcA3L.js";import{C as Q,P as Ke,a as Ue,B as De}from"./PageLayout-CRN-E5xi.js";import{useResolveSource as Ze}from"./usePipelineStore-DDHEHTlZ.js";import{C as et}from"./chevron-right-D4kUPDBw.js";import{R as se,C as ae}from"./Grid-DQYUnZsY.js";import"./node-types-BoqnL0Eg.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -8,5 +8,5 @@ import{e as Ae,r as p,gs as _e,gt as Ie,af as Be,ag as Ve,j as e,a7 as U,V as ye * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const at=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],nt=Ae("toggle-right",at),ot=/\[RX\] CRC error #(\d+)\s*-\s*RSSI=(-?\d+)dBm,\s*SNR=(-?[\d.]+)dB,\s*SignalRSSI=(-?\d+)dBm,\s*Length=(\d+),\s*NoiseFloor=(-?[\d.]+)dBm,\s*DeviceErrors=(0x[0-9A-Fa-f]+),\s*IRQ=(0x[0-9A-Fa-f]+),\s*RawData=(.+)/;function lt(r,a){const v=ot.exec(r);return v?{timestamp:a,errorNumber:parseInt(v[1],10),rssiDbm:parseInt(v[2],10),snrDb:parseFloat(v[3]),signalRssiDbm:parseInt(v[4],10),payloadLength:parseInt(v[5],10),noiseFloorDbm:parseFloat(v[6]),deviceErrors:v[7],irq:v[8],rawData:v[9].trim()}:null}const rt=1e4;function it(r){if(typeof r=="number")return r>1e12?Math.floor(r/1e3):r;const a=new Date(r).getTime();return isNaN(a)?Math.floor(Date.now()/1e3):Math.floor(a/1e3)}function ve(r){return r.deviceErrors!=="—"&&(r.rssiDbm!==0||r.snrDb!==0)}function ue(r){return r>=-80?"text-sys-green":r>=-100?"text-sys-amber":"text-sys-red"}function fe(r){return r>=5?"text-sys-green":r>=0?"text-sys-amber":"text-sys-red"}function Re(r){return new Date(r*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function ke(r){return new Date(r*1e3).toLocaleDateString([],{month:"short",day:"numeric"})}function ct(r){if(r.length===0)return{total:0,hasRf:!1,avgRssi:0,avgSnr:0,worstSnr:0,avgNoiseFloor:0,errorsPerHour:0,uniqueDeviceErrors:new Set};const a=r.filter(ve);let v=0,g=0,c=0,R=1/0;const D=new Set;for(const i of a)v+=i.rssiDbm,g+=i.snrDb,c+=i.noiseFloorDbm,i.snrDbi.timestamp-m.timestamp),o=u.length>=2?(u[u.length-1].timestamp-u[0].timestamp)/3600:0;return{total:y,hasRf:f>0,avgRssi:f>0?v/f:0,avgSnr:f>0?g/f:0,worstSnr:R===1/0?0:R,avgNoiseFloor:f>0?c/f:0,errorsPerHour:o>0?y/o:0,uniqueDeviceErrors:D}}const dt=p.memo(function({entry:a,isFirst:v}){const[g,c]=p.useState(!1);return e.jsxs("div",{className:le("group transition-base",!v&&"border-t border-edge-subtle/40"),children:[e.jsxs("button",{type:"button",onClick:()=>c(R=>!R),className:"w-full text-left py-2 px-3 hover:bg-subtle-fill/50 transition-base flex items-center gap-2 min-w-0",children:[g?e.jsx(We,{className:"w-3 h-3 text-fg-muted shrink-0"}):e.jsx(et,{className:"w-3 h-3 text-fg-muted shrink-0"}),e.jsx("span",{className:"type-data-xs text-fg-muted w-14 shrink-0 tabular-nums",children:Re(a.timestamp)}),e.jsxs("span",{className:"type-data-xs text-sys-red w-10 shrink-0 tabular-nums",children:["#",a.errorNumber]}),ve(a)?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:le("type-data-xs w-16 shrink-0 tabular-nums",ue(a.rssiDbm)),children:[a.rssiDbm," dBm"]}),e.jsxs("span",{className:le("type-data-xs w-14 shrink-0 tabular-nums",fe(a.snrDb)),children:[a.snrDb.toFixed(1)," dB"]}),e.jsxs("span",{className:"type-data-xs text-fg-secondary w-10 shrink-0 tabular-nums",children:[a.payloadLength,"B"]}),e.jsxs("span",{className:"type-data-xs text-fg-muted w-20 shrink-0 tabular-nums hidden sm:inline",children:["NF ",a.noiseFloorDbm.toFixed(1)]}),a.deviceErrors!=="0x0000"&&a.deviceErrors!=="—"&&e.jsxs(ye,{color:"red",className:"hidden md:inline-flex",children:["ERR ",a.deviceErrors]})]}):e.jsx("span",{className:"type-data-xs text-fg-muted italic",children:"timestamp only — no RF diagnostics"})]}),g&&e.jsx("div",{className:"px-3 pb-2.5 pt-0.5 ml-5 space-y-1.5",children:ve(a)?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-x-4 gap-y-1",children:[e.jsx(K,{label:"RSSI",value:`${a.rssiDbm} dBm`,color:ue(a.rssiDbm)}),e.jsx(K,{label:"SNR",value:`${a.snrDb.toFixed(1)} dB`,color:fe(a.snrDb)}),e.jsx(K,{label:"Signal RSSI",value:`${a.signalRssiDbm} dBm`,color:ue(a.signalRssiDbm)}),e.jsx(K,{label:"Noise Floor",value:`${a.noiseFloorDbm.toFixed(1)} dBm`}),e.jsx(K,{label:"Payload Length",value:`${a.payloadLength} bytes`}),e.jsx(K,{label:"Device Errors",value:a.deviceErrors,color:a.deviceErrors!=="0x0000"?"text-sys-red":void 0}),e.jsx(K,{label:"IRQ Flags",value:a.irq}),e.jsx(K,{label:"Date",value:ke(a.timestamp)})]}),a.rawData&&a.rawData!=="(read failed)"&&e.jsxs("div",{className:"mt-1.5",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-0.5",children:"RAW DATA"}),e.jsx("pre",{className:"type-data-xs text-fg-secondary bg-subtle-fill/50 radius-badge p-2 overflow-x-auto whitespace-pre-wrap break-all max-h-20",children:a.rawData})]}),a.rawData==="(read failed)"&&e.jsx("p",{className:"type-data-xs text-sys-amber italic",children:"Buffer read failed"})]}):e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1",children:[e.jsx(K,{label:"Date",value:ke(a.timestamp)}),e.jsx(K,{label:"Time",value:Re(a.timestamp)})]})})]})});function K({label:r,value:a,color:v}){return e.jsxs("div",{children:[e.jsx("p",{className:"type-micro text-fg-muted",children:r}),e.jsx("p",{className:le("type-data-xs",v??"text-fg-secondary"),children:a})]})}function ht(){const[r,a]=p.useState([]),[v,g]=p.useState(!0),[c,R]=p.useState("none"),[D,y]=p.useState(0),f=p.useRef(null),u=p.useCallback(async()=>{var m,b,S;try{const j=await _e(24);if(j.success&&((m=j.data)!=null&&m.entries)&&j.data.entries.length>0){a(j.data.entries),R("journalctl"),g(!1),y(Date.now());return}}catch{}try{const j=await Ie();if(j!=null&&j.logs){const s=[];for(const x of j.logs){if(!((b=x.message)!=null&&b.includes("CRC error")))continue;const n=it(x.timestamp),t=lt(x.message,n);t&&s.push(t)}if(s.length>0){s.sort((x,n)=>n.timestamp-x.timestamp),a(s),R("logs"),g(!1),y(Date.now());return}}}catch{}try{const[j,s]=await Promise.all([Be(24),Ve(24)]);if(j.success&&((S=j.data)!=null&&S.history)&&j.data.history.length>0){const x=j.data.history.map((n,t)=>({timestamp:n.timestamp,errorNumber:t+1,rssiDbm:0,snrDb:0,signalRssiDbm:0,payloadLength:0,noiseFloorDbm:0,deviceErrors:"—",irq:"—",rawData:""}));x.sort((n,t)=>t.timestamp-n.timestamp),a(x),R("history"),g(!1),y(Date.now());return}if(s.success&&s.data&&s.data.count>0){const x=s.data.newest_timestamp??Math.floor(Date.now()/1e3);a([{timestamp:x,errorNumber:s.data.count,rssiDbm:0,snrDb:0,signalRssiDbm:0,payloadLength:0,noiseFloorDbm:0,deviceErrors:"—",irq:"—",rawData:""}]),R("history"),g(!1),y(Date.now());return}}catch{}a([]),R("none"),g(!1),y(Date.now())},[]);p.useEffect(()=>(u(),f.current=setInterval(u,rt),()=>{f.current&&clearInterval(f.current)}),[u]);const o=p.useMemo(()=>ct(r),[r]),i=p.useMemo(()=>[...r].sort((m,b)=>b.timestamp-m.timestamp),[r]);return e.jsxs(Q,{children:[e.jsx(U,{title:"CRC Error Log",icon:e.jsx(qe,{className:"icon-sm"}),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[c!=="none"&&e.jsx(ye,{color:"zinc",className:"hidden sm:inline-flex",children:c==="journalctl"?"journalctl":c==="logs"?"memory":"history"}),e.jsxs(ye,{color:o.total>0?"red":"green",children:[o.total," error",o.total!==1?"s":""]}),e.jsx("button",{type:"button",onClick:u,className:"p-1 radius-inner hover:bg-subtle-fill transition-base text-fg-muted hover:text-fg-primary",title:"Refresh CRC logs",children:e.jsx(He,{className:"w-3.5 h-3.5"})})]})}),o.total>0&&e.jsxs("div",{className:le("grid gap-2 mb-3",o.hasRf?"grid-cols-2 sm:grid-cols-3 lg:grid-cols-6":"grid-cols-2 sm:grid-cols-3"),children:[e.jsx(oe,{label:"Total",value:o.total.toString()}),e.jsx(oe,{label:"Rate",value:o.errorsPerHour>0?`${o.errorsPerHour.toFixed(1)}/hr`:"—"}),o.hasRf&&e.jsxs(e.Fragment,{children:[e.jsx(oe,{label:"Avg RSSI",value:`${o.avgRssi.toFixed(0)} dBm`,color:ue(o.avgRssi)}),e.jsx(oe,{label:"Avg SNR",value:`${o.avgSnr.toFixed(1)} dB`,color:fe(o.avgSnr)}),e.jsx(oe,{label:"Worst SNR",value:`${o.worstSnr.toFixed(1)} dB`,color:fe(o.worstSnr)}),e.jsx(oe,{label:"Avg NF",value:`${o.avgNoiseFloor.toFixed(1)} dBm`})]})]}),v?e.jsx("div",{className:"flex items-center justify-center py-8 text-fg-muted type-data-xs",children:"Loading CRC logs…"}):r.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-1.5",children:[e.jsx("p",{className:"text-fg-muted type-data-sm",children:"No CRC errors detected"}),e.jsx("p",{className:"text-fg-muted/60 type-data-xs",children:"CRC errors appear when corrupted packets are received by the SX1262"})]}):e.jsx("div",{className:"surface-inner radius-inner overflow-hidden max-h-80 overflow-y-auto",children:i.map((m,b)=>e.jsx(dt,{entry:m,isFirst:b===0},`${m.timestamp}-${m.errorNumber}`))}),D>0&&e.jsxs("p",{className:"type-data-xs text-fg-muted/50 mt-2 text-right",children:["Last updated ",new Date(D).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})]})]})}function oe({label:r,value:a,color:v}){return e.jsxs("div",{className:"surface-inner radius-inner p-2",children:[e.jsx("p",{className:"type-micro text-fg-muted",children:r}),e.jsx("p",{className:le("type-data-sm tabular-nums",v??"text-fg-primary"),children:a})]})}const ne=300,Le=288,Se=.2,W=32,O=20,be=30;function Pe(r){return new Date(r*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function we(r){if(r.length===0)return[];const a=r.length,v=Math.max(1,Math.floor(a/6)),g=[];for(let c=0;c=a)continue;const l=g.get(t);if(l&&(je(n)?l.v++:ft(n)&&l.o++,mt(n)&&l.e++),n.lbt_backoff_delays_ms){const w=c.get(t);if(w)try{const C=JSON.parse(n.lbt_backoff_delays_ms);if(Array.isArray(C))for(const h of C)typeof h=="number"&&!isNaN(h)&&w.push(h)}catch{}}n.lbt_attempts!==void 0&&n.lbt_attempts>0&&(y.set(t,(y.get(t)??0)+1),n.lbt_attempts>1&&f.set(t,(f.get(t)??0)+1));const N=n.type??n.payload_type??-1;if(N===z.REQ||N===z.ANON_REQ){const w=R.get(t);w!==void 0&&R.set(t,w+1)}if(N===z.ACK){const w=D.get(t);w!==void 0&&D.set(t,w+1)}}const u=[];for(const[n,{v:t,o:l,e:N}]of g){const w=t+l+N;u.push({ts:n,value:t,overhead:l,error:N,efficiency:w>0?t/w:null,ema:null})}u.sort((n,t)=>n.ts-t.ts);let o=null;for(const n of u)if(n.efficiency!==null){const t=1-n.efficiency;o=o===null?t:Se*t+(1-Se)*o,n.ema=o}const i=[];for(const[n,t]of c){if(t.length===0){i.push({ts:n,mean:0,median:0,stddev:0,min:0,max:0,q25:0,q75:0,sampleCount:0,cv:0,skewness:0,skewnessVelocity:0});continue}t.sort((T,A)=>T-A);const l=t.length,N=t.reduce((T,A)=>T+A,0)/l,w=t.reduce((T,A)=>T+(A-N)**2,0)/Math.max(l-1,1),C=Math.sqrt(w);let h=0;for(const T of t)h+=(T-N)**3;h/=l;const L=C>0?h/(C*C*C):0;i.push({ts:n,mean:N,median:t[Math.floor(l*.5)],stddev:C,min:t[0],max:t[l-1],q25:t[Math.floor(l*.25)],q75:t[Math.floor(l*.75)],sampleCount:l,cv:N>0?C/N:0,skewness:L,skewnessVelocity:0})}i.sort((n,t)=>n.ts-t.ts);let m=-1;for(let n=0;n=0){const t=i[n].ts-i[m].ts;t>0&&(i[n].skewnessVelocity=(i[n].skewness-i[m].skewness)/t)}m=n}const b=[...R.entries()].sort((n,t)=>n[0]-t[0]),S=[...D.entries()].sort((n,t)=>n[0]-t[0]),j=[];for(let n=0;n0?C/w:null,L=l>0?Math.min(N/l,1):null;let T=0,A=0,M=0;if(L!==null){T=L;const k=1-L;h!==null&&h>0?(M=k*h,A=k*(1-h)):A=k}j.push({ts:t,reqCount:l,ackCount:N,reliability:L,lbtRetryRate:h,successFrac:T,lostFrac:A,blockedFrac:M})}return{efficiency:u,jitter:i,reliability:j}}function pt(r,a,v,g){const c=r+a;if(v>=.85)return g<.5?{label:"Healthy Backhaul",description:"Low failure rate with stable RF environment",colorVar:"var(--sys-green)",colorClass:"text-sys-green"}:{label:"Stable — Elevated Jitter",description:`Reliability ${(v*100).toFixed(0)}% is healthy but CV=${g.toFixed(2)} indicates RF variability`,colorVar:"var(--sys-teal)",colorClass:"text-sys-teal"};if(c<1)return{label:"Insufficient Data",description:"Not enough REQ/ACK pairs to classify failure mode",colorVar:"var(--sys-blue)",colorClass:"text-sys-blue"};const R=r/c;return R>.6?{label:"Local RF Congestion",description:`LBT blocking ${Math.round(R*100)}% of failures — radio can't find clear air`,colorVar:"var(--sys-red)",colorClass:"text-sys-red"}:R<.3?{label:"Remote Node Deafness",description:`${Math.round((1-R)*100)}% of failures from RF loss — sent but not acknowledged`,colorVar:"var(--sys-amber)",colorClass:"text-sys-amber"}:{label:"Mixed Failure Mode",description:`Both LBT blocking (${Math.round(r)}) and RF loss (${Math.round(a)}) contributing`,colorVar:"var(--sys-amber)",colorClass:"text-sys-amber"}}const gt=p.memo(function({buckets:a,logScale:v,onHoverIdx:g}){const c=p.useRef(null),R=p.useRef(null),D=p.useRef(a),y=p.useRef(v);D.current=a,y.current=v;const f=p.useRef(g);f.current=g;const u=p.useMemo(()=>[0,.25,.5,.75,1].map(m=>({label:`${Math.round(m*100)}%`,pos:(1-m)*100})),[]),o=p.useMemo(()=>we(a),[a.length]),i=p.useMemo(()=>{const m=a.map(S=>S.ts),b=a.map(()=>1);return[m,b]},[a.length]);return p.useEffect(()=>{const m=c.current;if(!m||a.length===0)return;const b=me(()=>{const j=m.getBoundingClientRect(),s=Math.floor(j.width)||400,x=Math.floor(j.height)||200,n=new xe({width:s,height:x,padding:[0,0,0,0],cursor:{show:!0,sync:{key:"signal-lab"},x:!0,y:!1},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],legend:{show:!1},hooks:{setCursor:[t=>{if(f.current){const l=t.cursor.idx??null;f.current(l)}}],draw:[t=>{const l=t.ctx,{left:N,top:w,width:C,height:h}=t.bbox,L=devicePixelRatio||1,T=D.current,A=y.current,M=T.length;if(M===0||C<=0||h<=0)return;if(l.save(),t.cursor.idx!=null&&t.cursor.idx>=0&&t.cursor.idxk&&(k=E)}const B=w+h/2,_=h/2,I=C/M,Y=ee(),V=F=>A?F<=0?0:Math.log10(1+F)/Math.log10(1+k):F/k;for(let F=0;F{const s=j[0];if(!s||!R.current)return;const{width:x,height:n}=s.contentRect;x>0&&n>0&&R.current.setSize({width:Math.floor(x),height:Math.floor(n)})});return S.observe(m),()=>{var j;b(),S.disconnect(),(j=R.current)==null||j.destroy(),R.current=null}},[i]),p.useEffect(()=>{var m;(m=R.current)==null||m.redraw()},[a,v]),a.length===0?e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted",children:"No data"}):e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0",style:{width:W,bottom:O},"aria-hidden":"true",children:u.map((m,b)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${m.pos}%`,transform:m.pos<=1?"none":m.pos>=99?"translateY(-100%)":"translateY(-50%)",right:0},children:m.label},b))}),e.jsx("div",{ref:c,className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:W,right:0,top:0,bottom:O}}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:W,height:O},"aria-hidden":"true",children:o.map((m,b)=>e.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${m.pos}%`,transform:b===0?"none":b===o.length-1?"translateX(-100%)":"translateX(-50%)"},children:m.label},b))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 shrink-0 pt-1",style:{paddingLeft:W},children:[e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:Me,children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.green}}),"Value ▲"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:Ne,children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.amber}}),"Overhead ▼"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Wasted airtime — duplicated or dropped packets. Spikes here mean RF collisions or routing loops.",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.red}}),"Error ▼"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Smoothed trend line — rising means overhead or errors are growing, falling means your mesh is getting more efficient",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:"var(--fg-secondary)"}}),"Trend"]})]})]})}),$e=p.memo(function({buckets:a}){const v=p.useRef(null),g=p.useRef(null),c=p.useRef(a);c.current=a;const{cvMax:R,skewMax:D}=p.useMemo(()=>{let i=1,m=1;for(const b of a)b.sampleCount!==0&&(b.cv>i&&(i=b.cv),Math.abs(b.skewness)>m&&(m=Math.abs(b.skewness)));return{cvMax:Math.ceil(i*2)/2,skewMax:Math.ceil(m*2)/2}},[a]),y=p.useMemo(()=>[0,.25,.5,.75,1].map(i=>({label:(R*i).toFixed(1),pos:(1-i)*100})),[R]),f=p.useMemo(()=>[{label:`+${D.toFixed(1)}`,pos:0},{label:"0",pos:50},{label:`−${D.toFixed(1)}`,pos:100}],[D]),u=p.useMemo(()=>we(a),[a.length]),o=p.useMemo(()=>{const i=a.map(b=>b.ts),m=a.map(()=>1);return[i,m]},[a.length]);return p.useEffect(()=>{const i=v.current;if(!i||a.length===0)return;const m=me(()=>{const S=i.getBoundingClientRect(),j=Math.floor(S.width)||400,s=Math.floor(S.height)||200,x=new xe({width:j,height:s,padding:[0,0,0,0],cursor:{show:!0,sync:{key:"signal-lab"},x:!0,y:!1},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],legend:{show:!1},hooks:{draw:[n=>{const t=n.ctx,{left:l,top:N,width:w,height:C}=n.bbox,h=devicePixelRatio||1,L=c.current,T=L.length;if(T===0||w<=0||C<=0)return;if(t.save(),n.cursor.idx!=null&&n.cursor.idx>=0&&n.cursor.idx0&&d.cv>A&&(A=d.cv);A=Math.ceil(A*2)/2;const M=w/T,k=M>4*h?1:0,B=ee();for(let d=0;d0&&(Y.push(V),V=[]);continue}const q=Math.abs(P.median-P.mean)/Math.max(P.mean,1),X=Math.min(q/A,1)*C;V.push({x:l+d*M+M/2,deltaY:I-X})}V.length>0&&Y.push(V),t.lineCap="round",t.lineJoin="round";for(const d of Y){if(d.length===1){t.fillStyle=_,t.beginPath(),t.arc(d[0].x,d[0].deltaY,1.5*h,0,Math.PI*2),t.fill();continue}t.fillStyle=_,t.globalAlpha=.2,t.beginPath(),t.moveTo(d[0].x,d[0].deltaY);for(let P=1;PN+C*(1-Math.min(d/A,1));if(t.lineWidth=1*h,t.setLineDash([4*h,4*h]),.5<=A){t.strokeStyle=$.teal,t.globalAlpha=.4,t.beginPath();const d=Math.round(G(.5))+.5;t.moveTo(l,d),t.lineTo(l+w,d),t.stroke()}if(1<=A){t.strokeStyle=$.red,t.globalAlpha=.4,t.beginPath();const d=Math.round(G(1))+.5;t.moveTo(l,d),t.lineTo(l+w,d),t.stroke()}t.setLineDash([]),t.globalAlpha=1,t.strokeStyle=B,t.globalAlpha=.12,t.lineWidth=1*h,t.setLineDash([4*h,4*h]);for(const d of[.25,.5,.75]){const P=Math.round(N+C*(1-d))+.5;t.beginPath(),t.moveTo(l,P),t.lineTo(l+w,P),t.stroke()}t.setLineDash([]),t.globalAlpha=1;let F=1;for(const d of L)d.sampleCount>0&&(F=Math.max(F,Math.abs(d.skewness)));F=Math.ceil(F*2)/2;const E=d=>N+C*(.5-d/(2*F));t.strokeStyle=$.indigo,t.globalAlpha=.25,t.lineWidth=1*h,t.setLineDash([2*h,2*h]);const H=Math.round(E(0))+.5;t.beginPath(),t.moveTo(l,H),t.lineTo(l+w,H),t.stroke(),t.setLineDash([]),t.globalAlpha=1,t.strokeStyle=$.indigo,t.lineWidth=1.5*h,t.lineCap="round",t.lineJoin="round";let J=!1;for(let d=0;d{const j=S[0];if(!j||!g.current)return;const{width:s,height:x}=j.contentRect;s>0&&x>0&&g.current.setSize({width:Math.floor(s),height:Math.floor(x)})});return b.observe(i),()=>{var S;m(),b.disconnect(),(S=g.current)==null||S.destroy(),g.current=null}},[o]),p.useEffect(()=>{var i;(i=g.current)==null||i.redraw()},[a]),a.length===0?e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted",children:"No LBT data"}):e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0",style:{width:W,bottom:O},"aria-hidden":"true",children:y.map((i,m)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${i.pos}%`,transform:i.pos<=1?"none":i.pos>=99?"translateY(-100%)":"translateY(-50%)",right:0},children:i.label},m))}),e.jsx("div",{ref:v,className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:W,right:be,top:0,bottom:O}}),e.jsx("div",{className:"absolute top-0 right-0",style:{width:be,bottom:O},"aria-hidden":"true",children:f.map((i,m)=>e.jsx("span",{className:"type-data-xs pl-1",style:{position:"absolute",top:`${i.pos}%`,transform:i.pos<=1?"none":i.pos>=99?"translateY(-100%)":"translateY(-50%)",left:0,color:$.indigo},children:i.label},m))}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:W,right:be,height:O},"aria-hidden":"true",children:u.map((i,m)=>e.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${i.pos}%`,transform:m===0?"none":m===u.length-1?"translateX(-100%)":"translateX(-50%)"},children:i.label},m))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 shrink-0 pt-1",style:{paddingLeft:W},children:[e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Channel access is predictable — your network isn't congested and nodes can transmit when they need to",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.teal}}),"Stable"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Some contention on the channel — nodes occasionally wait longer to transmit. Watch for a worsening trend.",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.amber}}),"Moderate"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Heavy channel congestion — nodes are fighting for airtime. Consider reducing duty cycle, spreading traffic, or adding repeaters.",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.red}}),"Volatile"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Gap between typical and average wait times — a large gap means a few extreme delays are pulling the average up",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:"var(--fg-secondary)"}}),"Median–Mean"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs",style:{color:$.indigo},title:"Delay distribution shape — positive (above zero) means occasional long waits from traffic bursts, negative means delays are capped and predictable",children:[e.jsx("span",{className:"w-3 h-0.5 rounded-xs shrink-0",style:{background:$.indigo}}),"γ₁ Skewness"]})]})]})}),bt=p.memo(function({buckets:a}){const v=p.useRef(null),g=p.useRef(null),c=p.useRef(a);c.current=a;const R=p.useMemo(()=>[0,.25,.5,.75,1].map(f=>({label:`${Math.round(f*100)}%`,pos:(1-f)*100})),[]),D=p.useMemo(()=>we(a),[a.length]),y=p.useMemo(()=>{const f=a.map(o=>o.ts),u=a.map(()=>1);return[f,u]},[a.length]);return p.useEffect(()=>{const f=v.current;if(!f||a.length===0)return;const u=me(()=>{const i=f.getBoundingClientRect(),m=Math.floor(i.width)||400,b=Math.floor(i.height)||200,S=new xe({width:m,height:b,padding:[0,0,0,0],cursor:{show:!0,sync:{key:"signal-lab"},x:!0,y:!1},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],legend:{show:!1},hooks:{draw:[j=>{const s=j.ctx,{left:x,top:n,width:t,height:l}=j.bbox,N=devicePixelRatio||1,w=c.current,C=w.length;if(C===0||t<=0||l<=0)return;if(s.save(),j.cursor.idx!=null&&j.cursor.idx>=0&&j.cursor.idx{const m=i[0];if(!m||!g.current)return;const{width:b,height:S}=m.contentRect;b>0&&S>0&&g.current.setSize({width:Math.floor(b),height:Math.floor(S)})});return o.observe(f),()=>{var i;u(),o.disconnect(),(i=g.current)==null||i.destroy(),g.current=null}},[y]),p.useEffect(()=>{var f;(f=g.current)==null||f.redraw()},[a]),a.length===0?e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted",children:"No data"}):e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0",style:{width:W,bottom:O},"aria-hidden":"true",children:R.map((f,u)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${f.pos}%`,transform:f.pos<=1?"none":f.pos>=99?"translateY(-100%)":"translateY(-50%)",right:0},children:f.label},u))}),e.jsx("div",{ref:v,className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:W,right:0,top:0,bottom:O}}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:W,height:O},"aria-hidden":"true",children:D.map((f,u)=>e.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${f.pos}%`,transform:u===0?"none":u===D.length-1?"translateX(-100%)":"translateX(-50%)"},children:f.label},u))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 shrink-0 pt-1",style:{paddingLeft:W},children:[e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Messages that made it through and were acknowledged — the healthy portion of your mesh traffic",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.green}}),"Success"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Messages sent but never acknowledged — lost to RF interference, distance, or obstacles. Persistent losses suggest a weak link.",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.amber}}),"Lost"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Couldn't even transmit because the channel was busy — sign of local congestion or a nearby heavy transmitter",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.red}}),"Blocked"]})]})]})}),Te=3e4,Fe=p.memo(function({buckets:a,hoveredIdx:v}){const g=p.useRef(null),c=p.useRef(a),R=p.useRef(v),D=p.useRef(performance.now()),y=p.useRef(0);c.current=a,R.current=v,p.useEffect(()=>{D.current=performance.now()},[a]);const{cvMax:f,skewMax:u}=p.useMemo(()=>{let b=1,S=1;for(const j of a)j.sampleCount!==0&&(j.cv>b&&(b=j.cv),Math.abs(j.skewness)>S&&(S=Math.abs(j.skewness)));return{cvMax:Math.ceil(b*2)/2,skewMax:Math.ceil(S*2)/2}},[a]),o=p.useMemo(()=>[{label:`+${u.toFixed(1)}`,pos:0},{label:"0",pos:50},{label:`−${u.toFixed(1)}`,pos:100}],[u]),i=p.useMemo(()=>[{label:"0",pos:0},{label:(f/2).toFixed(1),pos:50},{label:f.toFixed(1),pos:100}],[f]);return p.useEffect(()=>{if(!g.current)return;function S(){const j=g.current;if(!j)return;const s=j.getContext("2d");if(!s)return;const x=j.getBoundingClientRect(),n=devicePixelRatio||1,t=Math.floor(x.width*n),l=Math.floor(x.height*n);if(t<=0||l<=0)return;(j.width!==t||j.height!==l)&&(j.width=t,j.height=l),s.clearRect(0,0,t,l),s.save();const N=c.current,w=ee(),C=pe(),h=4*n,L=h,T=h,A=t-2*h,M=l-2*h;if(A<=0||M<=0){s.restore();return}let k=1,B=1;for(const d of N)d.sampleCount!==0&&(d.cv>k&&(k=d.cv),Math.abs(d.skewness)>B&&(B=Math.abs(d.skewness)));k=Math.ceil(k*2)/2,B=Math.ceil(B*2)/2;const _=d=>L+d/k*A,I=d=>T+M*(.5-d/(2*B));s.strokeStyle=w,s.globalAlpha=.08,s.lineWidth=1*n,s.setLineDash([3*n,3*n]);for(const d of[.25,.5,.75]){const P=Math.round(L+d*A)+.5;s.beginPath(),s.moveTo(P,T),s.lineTo(P,T+M),s.stroke()}for(const d of[.25,.75]){const P=Math.round(T+d*M)+.5;s.beginPath(),s.moveTo(L,P),s.lineTo(L+A,P),s.stroke()}s.setLineDash([]),s.globalAlpha=1;const Y=Math.round(I(0))+.5;s.strokeStyle=$.indigo,s.globalAlpha=.3,s.lineWidth=1*n,s.beginPath(),s.moveTo(L,Y),s.lineTo(L+A,Y),s.stroke(),s.globalAlpha=1,s.font=`${9*n}px ${C}`,s.fillStyle=w,s.globalAlpha=.1,s.textAlign="center",s.textBaseline="middle",s.fillText("Stable",L+A*.25,I(0)),s.fillText("Burst Mode",L+A*.75,T+M*.2),s.fillText("Saturated",L+A*.75,T+M*.8),s.globalAlpha=1;const V=[];for(let d=0;d1){s.strokeStyle=w,s.globalAlpha=.45,s.lineWidth=1.5*n,s.lineCap="round",s.lineJoin="round",s.beginPath(),s.moveTo(_(H[0].cv),I(H[0].sk));for(let de=1;de0&&(s.strokeStyle=w,s.lineWidth=2*n,s.beginPath(),s.arc(_(d.cv),I(d.skewness),E+3*n,0,Math.PI*2),s.stroke())}s.restore(),G{y.current&&cancelAnimationFrame(y.current)}},[a,v]),a.some(b=>b.sampleCount>0)?e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0",style:{width:W,bottom:O},"aria-hidden":"true",children:o.map((b,S)=>e.jsx("span",{className:"type-data-xs text-right pr-1.5",style:{position:"absolute",top:`${b.pos}%`,transform:b.pos<=1?"none":b.pos>=99?"translateY(-100%)":"translateY(-50%)",right:0,color:$.indigo},children:b.label},S))}),e.jsx("canvas",{ref:g,className:"absolute block radius-inner depth-stroke-inset bg-chart-inner",style:{left:W,right:0,top:0,bottom:O,width:`calc(100% - ${W}px)`,height:`calc(100% - ${O}px)`}}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:W,height:O},"aria-hidden":"true",children:i.map((b,S)=>e.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${b.pos}%`,transform:S===0?"none":S===i.length-1?"translateX(-100%)":"translateX(-50%)"},children:b.label},S))})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 shrink-0 pt-1 type-data-xs text-fg-secondary",style:{paddingLeft:W},children:"X: CV \\u00b7 Y: \\u03b3\\u2081 \\u00b7 Trail: last 5"})]}):e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted",children:"No LBT data"})}),yt=p.memo(function({value:a,maxValue:v,theoreticalMax:g,collisionThreshold:c,label:R}){const D=p.useRef(null),y=p.useRef({value:a,maxValue:v,theoreticalMax:g,collisionThreshold:c,label:R});y.current={value:a,maxValue:v,theoreticalMax:g,collisionThreshold:c,label:R};const f=p.useCallback(()=>{const u=D.current;if(!u)return;const o=u.getContext("2d");if(!o)return;const i=u.getBoundingClientRect();if(i.width===0||i.height===0)return;const m=devicePixelRatio||1;u.width=Math.floor(i.width*m),u.height=Math.floor(i.height*m);const b=u.width,S=u.height,j=pe(),s=ee(),{value:x,maxValue:n,theoreticalMax:t,collisionThreshold:l,label:N}=y.current,w=Math.min(b,S)/180;o.clearRect(0,0,b,S);const C=b/2,h=S*.52,L=Math.min(C-8*w,h-8*w),T=L*.72,A=Math.PI*.75,M=Math.PI*.25+Math.PI,k=M-A,B=n>0?Math.min(x/n,1):0,_=A+B*k;o.beginPath(),o.arc(C,h,L,A,M),o.arc(C,h,T,M,A,!0),o.closePath(),o.fillStyle=re()?Z[800]:Z[200],o.fill();const I=l&&n>0?Math.min(l/n,.95):.5,Y=t&&n>0?Math.min(t/n,.99):.85,V=o.createConicGradient(A,C,h);if(V.addColorStop(0,$.green),V.addColorStop(I*.8,$.green),V.addColorStop(I,$.amber),V.addColorStop(Y,$.red),V.addColorStop(1,$.red),o.beginPath(),o.arc(C,h,L,A,_),o.arc(C,h,T,_,A,!0),o.closePath(),o.fillStyle=V,o.fill(),l&&l>0&&n>0){const F=Math.min(l/n,1),E=A+F*k;o.strokeStyle=$.amber,o.globalAlpha=.6,o.lineWidth=Math.max(1,1.5*w),o.beginPath(),o.moveTo(C+Math.cos(E)*(T-1*w),h+Math.sin(E)*(T-1*w)),o.lineTo(C+Math.cos(E)*(L+1*w),h+Math.sin(E)*(L+1*w)),o.stroke(),o.globalAlpha=1}if(t>0&&n>0){const F=Math.min(t/n,1),E=A+F*k;o.beginPath(),o.arc(C,h,L,A,E),o.arc(C,h,T,E,A,!0),o.closePath(),o.fillStyle=s,o.globalAlpha=.07,o.fill(),o.globalAlpha=1,o.strokeStyle=$.red,o.globalAlpha=.5,o.lineWidth=Math.max(1,1.5*w),o.beginPath(),o.moveTo(C+Math.cos(E)*(T-2*w),h+Math.sin(E)*(T-2*w)),o.lineTo(C+Math.cos(E)*(L+2*w),h+Math.sin(E)*(L+2*w)),o.stroke(),o.globalAlpha=1}o.fillStyle=s,o.textAlign="center",o.textBaseline="middle",o.font=`bold ${Math.round(20*w)}px ${j}`,o.fillText(`${(x*1e3).toFixed(1)}`,C,h-4*w),o.font=`${Math.round(7.5*w)}px ${j}`,o.globalAlpha=.6,o.fillText("×10⁻³",C,h+10*w),o.globalAlpha=1,o.font=`bold ${Math.round(9*w)}px ${j}`,o.fillText(N,C,h+L+12*w);const G=t>0?x/t*100:0;o.font=`${Math.round(8*w)}px ${j}`,o.globalAlpha=.55,o.fillText(`${G.toFixed(0)}% cap`,C,h+L+24*w),o.globalAlpha=1},[]);return p.useEffect(()=>{f()},[a,v,g,c,R,f]),p.useEffect(()=>{const u=D.current;if(!u)return;const o=new ResizeObserver(()=>f());return o.observe(u),()=>o.disconnect()},[f]),e.jsx("canvas",{ref:D,className:"w-full h-full"})});function vt({efficiency:r,jitter:a,reliability:v,packets:g}){const c=r.reduce((M,k)=>M+k.value,0),R=r.reduce((M,k)=>M+k.overhead,0),D=r.reduce((M,k)=>M+k.error,0),y=c+R+D,f=y>0?c/y:0,u=a.filter(M=>M.sampleCount>0),o=u.length>0?u.reduce((M,k)=>M+k.cv,0)/u.length:0,i=u.reduce((M,k)=>Math.max(M,k.cv),0),m=v.reduce((M,k)=>M+k.reqCount,0),b=v.reduce((M,k)=>M+k.ackCount,0),S=m>0?Math.min(b/m,1):1,j=v.reduce((M,k)=>M+k.blockedFrac*k.reqCount,0),s=v.reduce((M,k)=>M+k.lostFrac*k.reqCount,0),x=pt(j,s,S,o),n=S>=.85?Ge:Je,t=g.length>=2?(g[g.length-1].timestamp-g[0].timestamp)/3600:0,l=t>0?Math.round(g.length/t):0,N=u.length>0?u[u.length-1]:null,w=(N==null?void 0:N.skewness)??0,C=(N==null?void 0:N.skewnessVelocity)??0,h=Math.abs(w),L=w>.1?"Right-skew (burst)":w<-.1?"Left-skew (saturated)":"Symmetric",T=Math.abs(C)<.01?"→":C>0?"↗":"↘",A=[{label:"Network Efficiency",value:`${(f*100).toFixed(1)}%`,color:f>.5?"text-sys-green":f>.3?"text-sys-amber":"text-sys-red",sub:`${c.toLocaleString()} value / ${y.toLocaleString()} total`},{label:"LBT Stability (CV)",value:o.toFixed(2),color:o<.5?"text-sys-teal":o<1?"text-sys-amber":"text-sys-red",sub:`peak ${i.toFixed(2)} · ${o<.5?"Stable":o<1?"Moderate":"Volatile"}`},{label:"Path Reliability",value:`${(S*100).toFixed(1)}%`,color:S>.85?"text-sys-green":S>.7?"text-sys-amber":"text-sys-red",sub:`${Math.round(j)} blocked · ${Math.round(s)} lost · ${b} ACK`},{label:"Throughput",value:`${l.toLocaleString()} /hr`,color:"text-fg-primary",sub:`${g.length.toLocaleString()} in ${t>0?`${t.toFixed(1)}h`:"—"} window`},{label:"Skewness (γ₁)",value:`${w>=0?"+":""}${w.toFixed(2)} ${T}`,color:h<.3?"text-sys-teal":h<1?"text-sys-indigo":"text-sys-red",sub:L}];return e.jsxs("div",{children:[e.jsxs("div",{className:"surface-inner radius-inner px-3 py-2.5 mb-3 flex items-start gap-2.5",style:{borderLeft:`3px solid ${x.colorVar}`},children:[e.jsx(n,{className:`w-4 h-4 shrink-0 mt-0.5 ${x.colorClass}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`type-label font-semibold ${x.colorClass}`,children:x.label}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-0.5",children:x.description})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:A.map(M=>e.jsxs("div",{className:"surface-inner radius-inner p-3",children:[e.jsx("p",{className:"type-micro text-fg-muted truncate",children:M.label}),e.jsx("p",{className:`type-data-xl ${M.color}`,children:M.value}),e.jsx("p",{className:"type-data-xs text-fg-muted",children:M.sub})]},M.label))})]})}function Ee({talkers:r}){if(r.length===0)return e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted type-data-xs",children:"No source data"});const a=r.reduce((c,R)=>Math.max(c,R.total),1),g=re()?Z[700]:Z[300];return e.jsx("div",{className:"flex flex-col h-full min-w-0 overflow-hidden",children:e.jsx("div",{className:"flex-1 min-h-0 gap-y-0.5",style:{display:"grid",gridTemplateColumns:"0.75rem 4.5rem 1fr auto",alignItems:"center",columnGap:"0.375rem"},children:r.map((c,R)=>{const D=a>0?c.total/a*100:0,y=c.total>0?c.value/c.total*100:0,f=`${c.name||c.hash.slice(0,8)}: ${c.value} useful messages + ${c.tax} overhead packets = ${c.total} total. ${c.taxPct.toFixed(0)}% of this node's traffic is infrastructure overhead`;return e.jsxs("div",{title:f,className:"col-span-full grid gap-y-0.5 cursor-default",style:{gridTemplateColumns:"subgrid",alignItems:"center"},children:[e.jsx("span",{className:"type-data-xs text-fg-muted text-right",children:R+1}),e.jsx("span",{className:"type-data-xs text-fg-secondary truncate",children:c.name||c.hash.slice(0,8)}),e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"h-2 radius-badge overflow-hidden flex relative",style:{width:`${D}%`,minWidth:4},children:[e.jsx("div",{className:"h-full",style:{width:`${y}%`,background:$.blue}}),e.jsx("div",{className:"absolute top-0 h-full",style:{left:`${y}%`,width:"1.5px",background:g}}),e.jsx("div",{className:"h-full flex-1",style:{background:$.indigo}})]})}),e.jsxs("span",{className:"data-box data-box-compact",style:{"--data-box-color":"var(--fg-muted)"},children:[c.taxPct.toFixed(0),"%"]})]},c.hash)})})})}function wt(r,a){return p.useMemo(()=>{var x,n,t,l;const v=ze(a),g=v.spreadingFactor,c=v.bandwidthHz,R=v.codingRate;let D=0,y=0;if(r.length>=2){y=r[r.length-1].timestamp-r[0].timestamp;for(const N of r)D+=N.length??N.payload_length??32}const f=g*(4/R)/Math.pow(2,g),u=.27,o=.2,i=((n=(x=a==null?void 0:a.config)==null?void 0:x.duty_cycle)==null?void 0:n.max_airtime_percent)??100,m=((l=(t=a==null?void 0:a.config)==null?void 0:t.duty_cycle)==null?void 0:l.enforcement_enabled)!==!1?Math.min(1,i/100):1,b=f*Math.min(u,m),S=f*Math.min(o,m);if(y<=0)return{value:0,maxValue:b*1.3,theoreticalSe:b,collisionSe:S};const s=D*8/y/c;return{value:s,maxValue:Math.max(b*1.3,s*1.2),theoreticalSe:b,collisionSe:S}},[r,a])}function jt(r){var D;if(r.length<2)return[];const a=Math.floor(Date.now()/1e3),v=a-Le*ne,g=new Map;for(let y=v;y=a||(D=g.get(f))==null||D.push(y.timestamp)}const c=[];for(const[y,f]of g){if(f.length<2){c.push({ts:y,mean:0,median:0,stddev:0,min:0,max:0,q25:0,q75:0,sampleCount:0,cv:0,skewness:0,skewnessVelocity:0});continue}f.sort((s,x)=>s-x);const u=[];for(let s=1;ss-x);const o=u.length,i=u.reduce((s,x)=>s+x,0)/o,m=u.reduce((s,x)=>s+(x-i)**2,0)/Math.max(o-1,1),b=Math.sqrt(m);let S=0;for(const s of u)S+=(s-i)**3;S/=o;const j=b>0?S/(b*b*b):0;c.push({ts:y,mean:i,median:u[Math.floor(o*.5)],stddev:b,min:u[0],max:u[o-1],q25:u[Math.floor(o*.25)],q75:u[Math.floor(o*.75)],sampleCount:o,cv:i>0?b/i:0,skewness:j,skewnessVelocity:0})}c.sort((y,f)=>y.ts-f.ts);let R=-1;for(let y=0;y=0){const f=c[y].ts-c[R].ts;f>0&&(c[y].skewnessVelocity=(c[y].skewness-c[R].skewness)/f)}R=y}return c}const Mt=p.memo(function({packets:a}){const v=p.useRef(null),g=p.useRef(null),c=p.useMemo(()=>a.filter(s=>s.rssi<0),[a]),R=p.useRef(c);R.current=c;const{rssiMin:D,rssiMax:y,snrMin:f,snrMax:u,medianRssi:o,medianSnr:i}=p.useMemo(()=>{if(c.length===0)return{rssiMin:-130,rssiMax:-30,snrMin:-20,snrMax:15,medianRssi:0,medianSnr:0};const s=c.map(n=>n.rssi).sort((n,t)=>n-t),x=c.map(n=>n.snr).sort((n,t)=>n-t);return{rssiMin:Math.min(s[0],-130),rssiMax:Math.max(s[s.length-1],-30),snrMin:Math.min(x[0],-20),snrMax:Math.max(x[x.length-1],15),medianRssi:s[Math.floor(s.length/2)],medianSnr:x[Math.floor(x.length/2)]}},[c]),m=p.useRef({rssiMin:D,rssiMax:y,snrMin:f,snrMax:u,medianRssi:o,medianSnr:i});m.current={rssiMin:D,rssiMax:y,snrMin:f,snrMax:u,medianRssi:o,medianSnr:i};const b=p.useMemo(()=>{const s=y-D;return[0,.25,.5,.75,1].map(x=>({label:`${Math.round(y-x*s)}`,pos:x*100}))},[D,y]),S=p.useMemo(()=>{if(c.length===0)return[];const s=c[0].timestamp,x=c[c.length-1].timestamp;return[0,.25,.5,.75,1].map(n=>({label:Pe(s+n*(x-s)),pos:n*100}))},[c]),j=p.useMemo(()=>{const s=c.map(n=>n.timestamp),x=c.map(()=>1);return[s,x]},[c.length]);return p.useEffect(()=>{const s=v.current;if(!s||c.length===0)return;const x=me(()=>{const t=s.getBoundingClientRect(),l=Math.floor(t.width)||400,N=Math.floor(t.height)||200,w=new xe({width:l,height:N,padding:[0,0,0,0],cursor:{show:!0,x:!0,y:!1},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],legend:{show:!1},hooks:{draw:[C=>{const h=C.ctx,{left:L,top:T,width:A,height:M}=C.bbox,k=devicePixelRatio||1,B=R.current;if(B.length===0||A<=0||M<=0)return;const _=m.current;h.save();const I=ee();h.strokeStyle=I,h.globalAlpha=.1,h.lineWidth=1*k,h.setLineDash([4*k,4*k]);for(const P of[.25,.5,.75]){const q=Math.round(T+M*P)+.5;h.beginPath(),h.moveTo(L,q),h.lineTo(L+A,q),h.stroke()}h.setLineDash([]),h.globalAlpha=1;const Y=B[0].timestamp,G=B[B.length-1].timestamp-Y||1,F=_.rssiMax-_.rssiMin||1,E=_.snrMax-_.snrMin||1,H=Math.max(2,Math.min(4,200/Math.sqrt(B.length)))*k;for(const P of B){const q=L+(P.timestamp-Y)/G*A,X=T+(_.rssiMax-P.rssi)/F*M,te=Math.max(0,Math.min(1,(P.snr-_.snrMin)/E)),ge=te<.33?$.red:te<.66?$.amber:$.teal;h.fillStyle=ge,h.globalAlpha=.7,h.beginPath(),h.arc(q,X,H,0,Math.PI*2),h.fill()}h.globalAlpha=1;const J=pe();h.font=`${10*k}px ${J}`,h.textAlign="right",h.textBaseline="top",h.fillStyle=I,h.globalAlpha=.7;const d=6*k;h.fillText(`RSSI ${_.medianRssi} dBm`,L+A-d,T+d),h.fillText(`SNR ${_.medianSnr.toFixed(1)} dB`,L+A-d,T+d+14*k),h.fillText(`n=${B.length}`,L+A-d,T+d+28*k),h.globalAlpha=1,h.restore()}]}},j,s);g.current=w}),n=new ResizeObserver(t=>{const l=t[0];if(!l||!g.current)return;const{width:N,height:w}=l.contentRect;N>0&&w>0&&g.current.setSize({width:Math.floor(N),height:Math.floor(w)})});return n.observe(s),()=>{var t;x(),n.disconnect(),(t=g.current)==null||t.destroy(),g.current=null}},[j]),p.useEffect(()=>{var s;(s=g.current)==null||s.redraw()},[c]),c.length===0?e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted type-data-xs",children:"No RF data from observer"}):e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0",style:{width:W,bottom:O},"aria-hidden":"true",children:b.map((s,x)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${s.pos}%`,transform:s.pos<=1?"none":s.pos>=99?"translateY(-100%)":"translateY(-50%)",right:0},children:s.label},x))}),e.jsx("div",{ref:v,className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:W,right:0,top:0,bottom:O}}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:W,height:O},"aria-hidden":"true",children:S.map((s,x)=>e.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${s.pos}%`,transform:x===0?"none":x===S.length-1?"translateX(-100%)":"translateX(-50%)"},children:s.label},x))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 shrink-0 pt-1",style:{paddingLeft:W},children:[e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Strong signal — packets arrived clearly above the noise floor, reliable decoding expected",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:$.teal}}),"High SNR"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Moderate signal — decoding should work but there's less margin for interference or fading",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:$.amber}}),"Mid SNR"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Weak signal — packets barely above the noise floor, expect higher error rates and missed frames",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:$.red}}),"Low SNR"]})]})]})});function Nt({packets:r}){const a=Qe(),v=Ze(),g=p.useMemo(()=>a?r.filter(D=>D._mqttSource):[],[r,a]),c=p.useMemo(()=>jt(g),[g]),R=p.useMemo(()=>{var f;const D=new Map;for(const u of g){const o=v(u),i=o.hash||u.src_hash||(u._advertSender?u._advertSender.slice(0,16):null)||((f=u.packet_hash)==null?void 0:f.slice(0,8));if(!i)continue;let m=D.get(i);m||(m={value:0,tax:0,name:null},D.set(i,m)),je(u)?m.value++:m.tax++,m.name||(m.name=o.name||u._advertName||null)}const y=[];for(const[u,o]of D){const i=o.value+o.tax;y.push({hash:u,name:o.name,value:o.value,tax:o.tax,total:i,taxPct:i>0?o.tax/i*100:0})}return y.sort((u,o)=>o.tax-u.tax),y.slice(0,5)},[g,v]);return!a||g.length===0?null:e.jsxs(De,{children:[e.jsx(se,{template:"auto",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"type-micro text-fg-primary",children:"MQTT OBSERVER"}),e.jsxs("span",{className:"data-box data-box-compact data-box-outlined",style:{"--data-box-accent":"var(--sys-teal)"},children:[g.length.toLocaleString()," pkts"]})]})}),e.jsxs(se,{template:"panel",children:[e.jsx(ae,{span:12,md:6,children:e.jsxs(Q,{skeletonType:"chart",children:[e.jsx(U,{title:"Arrival Stability (CV)"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx($e,{buckets:c})})]})}),e.jsx(ae,{span:12,md:6,children:e.jsxs(Q,{skeletonType:"chart",children:[e.jsx(U,{title:"Observer RF"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Mt,{packets:g})})]})})]}),e.jsxs(se,{template:"panel",children:[e.jsx(ae,{span:12,md:6,children:e.jsxs(Q,{children:[e.jsx(U,{title:"MQTT Top Taxers",actions:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:"flex items-center gap-1 type-data-xs text-fg-muted",title:Me,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full inline-block",style:{background:$.blue}}),"Value"]}),e.jsxs("span",{className:"flex items-center gap-1 type-data-xs text-fg-muted",title:Ne,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full inline-block",style:{background:$.indigo}}),"Tax"]})]})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsx(Ee,{talkers:R})})]})}),e.jsx(ae,{span:12,md:6,children:e.jsxs(Q,{skeletonType:"chart",children:[e.jsx(U,{title:"IAT Phase Space"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Fe,{buckets:c,hoveredIdx:null})})]})})]})]})}function Dt(){var m,b,S,j;const r=Ye(),a=Oe(),[v,g]=p.useState(!1),[c,R]=p.useState(null),{efficiency:D,jitter:y,reliability:f}=p.useMemo(()=>xt(r),[r]),u=wt(r,a),o=p.useMemo(()=>{const s=new Map;for(const n of r){const t=n.src_hash;if(!t)continue;let l=s.get(t);l||(l={value:0,tax:0,name:null},s.set(t,l)),je(n)?l.value++:l.tax++,!l.name&&n._advertName&&(l.name=n._advertName)}const x=[];for(const[n,t]of s){const l=t.value+t.tax;x.push({hash:n,name:t.name,value:t.value,tax:t.tax,total:l,taxPct:l>0?t.tax/l*100:0})}return x.sort((n,t)=>t.tax-n.tax),x.slice(0,5)},[r]),i=p.useCallback(()=>g(s=>!s),[]);return e.jsxs(Ke,{children:[e.jsx(Ue,{title:"Signal Lab",icon:e.jsx(Xe,{}),controls:e.jsxs("button",{onClick:i,className:`flex items-center gap-1.5 px-3 py-1.5 radius-inner + */const at=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],nt=Ae("toggle-right",at),ot=/\[RX\] CRC error #(\d+)\s*-\s*RSSI=(-?\d+)dBm,\s*SNR=(-?[\d.]+)dB,\s*SignalRSSI=(-?\d+)dBm,\s*Length=(\d+),\s*NoiseFloor=(-?[\d.]+)dBm,\s*DeviceErrors=(0x[0-9A-Fa-f]+),\s*IRQ=(0x[0-9A-Fa-f]+),\s*RawData=(.+)/;function lt(r,a){const v=ot.exec(r);return v?{timestamp:a,errorNumber:parseInt(v[1],10),rssiDbm:parseInt(v[2],10),snrDb:parseFloat(v[3]),signalRssiDbm:parseInt(v[4],10),payloadLength:parseInt(v[5],10),noiseFloorDbm:parseFloat(v[6]),deviceErrors:v[7],irq:v[8],rawData:v[9].trim()}:null}const rt=1e4;function it(r){if(typeof r=="number")return r>1e12?Math.floor(r/1e3):r;const a=new Date(r).getTime();return isNaN(a)?Math.floor(Date.now()/1e3):Math.floor(a/1e3)}function ve(r){return r.deviceErrors!=="—"&&(r.rssiDbm!==0||r.snrDb!==0)}function ue(r){return r>=-80?"text-sys-green":r>=-100?"text-sys-amber":"text-sys-red"}function fe(r){return r>=5?"text-sys-green":r>=0?"text-sys-amber":"text-sys-red"}function Re(r){return new Date(r*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function ke(r){return new Date(r*1e3).toLocaleDateString([],{month:"short",day:"numeric"})}function ct(r){if(r.length===0)return{total:0,hasRf:!1,avgRssi:0,avgSnr:0,worstSnr:0,avgNoiseFloor:0,errorsPerHour:0,uniqueDeviceErrors:new Set};const a=r.filter(ve);let v=0,g=0,c=0,R=1/0;const D=new Set;for(const i of a)v+=i.rssiDbm,g+=i.snrDb,c+=i.noiseFloorDbm,i.snrDbi.timestamp-m.timestamp),o=u.length>=2?(u[u.length-1].timestamp-u[0].timestamp)/3600:0;return{total:y,hasRf:f>0,avgRssi:f>0?v/f:0,avgSnr:f>0?g/f:0,worstSnr:R===1/0?0:R,avgNoiseFloor:f>0?c/f:0,errorsPerHour:o>0?y/o:0,uniqueDeviceErrors:D}}const dt=p.memo(function({entry:a,isFirst:v}){const[g,c]=p.useState(!1);return e.jsxs("div",{className:le("group transition-base",!v&&"border-t border-edge-subtle/40"),children:[e.jsxs("button",{type:"button",onClick:()=>c(R=>!R),className:"w-full text-left py-2 px-3 hover:bg-subtle-fill/50 transition-base flex items-center gap-2 min-w-0",children:[g?e.jsx(We,{className:"w-3 h-3 text-fg-muted shrink-0"}):e.jsx(et,{className:"w-3 h-3 text-fg-muted shrink-0"}),e.jsx("span",{className:"type-data-xs text-fg-muted w-14 shrink-0 tabular-nums",children:Re(a.timestamp)}),e.jsxs("span",{className:"type-data-xs text-sys-red w-10 shrink-0 tabular-nums",children:["#",a.errorNumber]}),ve(a)?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:le("type-data-xs w-16 shrink-0 tabular-nums",ue(a.rssiDbm)),children:[a.rssiDbm," dBm"]}),e.jsxs("span",{className:le("type-data-xs w-14 shrink-0 tabular-nums",fe(a.snrDb)),children:[a.snrDb.toFixed(1)," dB"]}),e.jsxs("span",{className:"type-data-xs text-fg-secondary w-10 shrink-0 tabular-nums",children:[a.payloadLength,"B"]}),e.jsxs("span",{className:"type-data-xs text-fg-muted w-20 shrink-0 tabular-nums hidden sm:inline",children:["NF ",a.noiseFloorDbm.toFixed(1)]}),a.deviceErrors!=="0x0000"&&a.deviceErrors!=="—"&&e.jsxs(ye,{color:"red",className:"hidden md:inline-flex",children:["ERR ",a.deviceErrors]})]}):e.jsx("span",{className:"type-data-xs text-fg-muted italic",children:"timestamp only — no RF diagnostics"})]}),g&&e.jsx("div",{className:"px-3 pb-2.5 pt-0.5 ml-5 space-y-1.5",children:ve(a)?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-x-4 gap-y-1",children:[e.jsx(K,{label:"RSSI",value:`${a.rssiDbm} dBm`,color:ue(a.rssiDbm)}),e.jsx(K,{label:"SNR",value:`${a.snrDb.toFixed(1)} dB`,color:fe(a.snrDb)}),e.jsx(K,{label:"Signal RSSI",value:`${a.signalRssiDbm} dBm`,color:ue(a.signalRssiDbm)}),e.jsx(K,{label:"Noise Floor",value:`${a.noiseFloorDbm.toFixed(1)} dBm`}),e.jsx(K,{label:"Payload Length",value:`${a.payloadLength} bytes`}),e.jsx(K,{label:"Device Errors",value:a.deviceErrors,color:a.deviceErrors!=="0x0000"?"text-sys-red":void 0}),e.jsx(K,{label:"IRQ Flags",value:a.irq}),e.jsx(K,{label:"Date",value:ke(a.timestamp)})]}),a.rawData&&a.rawData!=="(read failed)"&&e.jsxs("div",{className:"mt-1.5",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-0.5",children:"RAW DATA"}),e.jsx("pre",{className:"type-data-xs text-fg-secondary bg-subtle-fill/50 radius-badge p-2 overflow-x-auto whitespace-pre-wrap break-all max-h-20",children:a.rawData})]}),a.rawData==="(read failed)"&&e.jsx("p",{className:"type-data-xs text-sys-amber italic",children:"Buffer read failed"})]}):e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1",children:[e.jsx(K,{label:"Date",value:ke(a.timestamp)}),e.jsx(K,{label:"Time",value:Re(a.timestamp)})]})})]})});function K({label:r,value:a,color:v}){return e.jsxs("div",{children:[e.jsx("p",{className:"type-micro text-fg-muted",children:r}),e.jsx("p",{className:le("type-data-xs",v??"text-fg-secondary"),children:a})]})}function ht(){const[r,a]=p.useState([]),[v,g]=p.useState(!0),[c,R]=p.useState("none"),[D,y]=p.useState(0),f=p.useRef(null),u=p.useCallback(async()=>{var m,b,S;try{const j=await _e(24);if(j.success&&((m=j.data)!=null&&m.entries)&&j.data.entries.length>0){a(j.data.entries),R("journalctl"),g(!1),y(Date.now());return}}catch{}try{const j=await Ie();if(j!=null&&j.logs){const s=[];for(const x of j.logs){if(!((b=x.message)!=null&&b.includes("CRC error")))continue;const n=it(x.timestamp),t=lt(x.message,n);t&&s.push(t)}if(s.length>0){s.sort((x,n)=>n.timestamp-x.timestamp),a(s),R("logs"),g(!1),y(Date.now());return}}}catch{}try{const[j,s]=await Promise.all([Be(24),Ve(24)]);if(j.success&&((S=j.data)!=null&&S.history)&&j.data.history.length>0){const x=j.data.history.map((n,t)=>({timestamp:n.timestamp,errorNumber:t+1,rssiDbm:0,snrDb:0,signalRssiDbm:0,payloadLength:0,noiseFloorDbm:0,deviceErrors:"—",irq:"—",rawData:""}));x.sort((n,t)=>t.timestamp-n.timestamp),a(x),R("history"),g(!1),y(Date.now());return}if(s.success&&s.data&&s.data.count>0){const x=s.data.newest_timestamp??Math.floor(Date.now()/1e3);a([{timestamp:x,errorNumber:s.data.count,rssiDbm:0,snrDb:0,signalRssiDbm:0,payloadLength:0,noiseFloorDbm:0,deviceErrors:"—",irq:"—",rawData:""}]),R("history"),g(!1),y(Date.now());return}}catch{}a([]),R("none"),g(!1),y(Date.now())},[]);p.useEffect(()=>(u(),f.current=setInterval(u,rt),()=>{f.current&&clearInterval(f.current)}),[u]);const o=p.useMemo(()=>ct(r),[r]),i=p.useMemo(()=>[...r].sort((m,b)=>b.timestamp-m.timestamp),[r]);return e.jsxs(Q,{children:[e.jsx(U,{title:"CRC Error Log",icon:e.jsx(qe,{className:"icon-sm"}),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[c!=="none"&&e.jsx(ye,{color:"zinc",className:"hidden sm:inline-flex",children:c==="journalctl"?"journalctl":c==="logs"?"memory":"history"}),e.jsxs(ye,{color:o.total>0?"red":"green",children:[o.total," error",o.total!==1?"s":""]}),e.jsx("button",{type:"button",onClick:u,className:"p-1 radius-inner hover:bg-subtle-fill transition-base text-fg-muted hover:text-fg-primary",title:"Refresh CRC logs",children:e.jsx(He,{className:"w-3.5 h-3.5"})})]})}),o.total>0&&e.jsxs("div",{className:le("grid gap-2 mb-3",o.hasRf?"grid-cols-2 sm:grid-cols-3 lg:grid-cols-6":"grid-cols-2 sm:grid-cols-3"),children:[e.jsx(oe,{label:"Total",value:o.total.toString()}),e.jsx(oe,{label:"Rate",value:o.errorsPerHour>0?`${o.errorsPerHour.toFixed(1)}/hr`:"—"}),o.hasRf&&e.jsxs(e.Fragment,{children:[e.jsx(oe,{label:"Avg RSSI",value:`${o.avgRssi.toFixed(0)} dBm`,color:ue(o.avgRssi)}),e.jsx(oe,{label:"Avg SNR",value:`${o.avgSnr.toFixed(1)} dB`,color:fe(o.avgSnr)}),e.jsx(oe,{label:"Worst SNR",value:`${o.worstSnr.toFixed(1)} dB`,color:fe(o.worstSnr)}),e.jsx(oe,{label:"Avg NF",value:`${o.avgNoiseFloor.toFixed(1)} dBm`})]})]}),v?e.jsx("div",{className:"flex items-center justify-center py-8 text-fg-muted type-data-xs",children:"Loading CRC logs…"}):r.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-1.5",children:[e.jsx("p",{className:"text-fg-muted type-data-sm",children:"No CRC errors detected"}),e.jsx("p",{className:"text-fg-muted/60 type-data-xs",children:"CRC errors appear when corrupted packets are received by the SX1262"})]}):e.jsx("div",{className:"surface-inner radius-inner overflow-hidden max-h-80 overflow-y-auto",children:i.map((m,b)=>e.jsx(dt,{entry:m,isFirst:b===0},`${m.timestamp}-${m.errorNumber}`))}),D>0&&e.jsxs("p",{className:"type-data-xs text-fg-muted/50 mt-2 text-right",children:["Last updated ",new Date(D).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})]})]})}function oe({label:r,value:a,color:v}){return e.jsxs("div",{className:"surface-inner radius-inner p-2",children:[e.jsx("p",{className:"type-micro text-fg-muted",children:r}),e.jsx("p",{className:le("type-data-sm tabular-nums",v??"text-fg-primary"),children:a})]})}const ne=300,Le=288,Se=.2,W=32,Y=20,be=30;function Pe(r){return new Date(r*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function we(r){if(r.length===0)return[];const a=r.length,v=Math.max(1,Math.floor(a/6)),g=[];for(let c=0;c=a)continue;const l=g.get(t);if(l&&(je(n)?l.v++:ft(n)&&l.o++,mt(n)&&l.e++),n.lbt_backoff_delays_ms){const w=c.get(t);if(w)try{const C=JSON.parse(n.lbt_backoff_delays_ms);if(Array.isArray(C))for(const h of C)typeof h=="number"&&!isNaN(h)&&w.push(h)}catch{}}n.lbt_attempts!==void 0&&n.lbt_attempts>0&&(y.set(t,(y.get(t)??0)+1),n.lbt_attempts>1&&f.set(t,(f.get(t)??0)+1));const N=n.type??n.payload_type??-1;if(N===z.REQ||N===z.ANON_REQ){const w=R.get(t);w!==void 0&&R.set(t,w+1)}if(N===z.ACK){const w=D.get(t);w!==void 0&&D.set(t,w+1)}}const u=[];for(const[n,{v:t,o:l,e:N}]of g){const w=t+l+N;u.push({ts:n,value:t,overhead:l,error:N,efficiency:w>0?t/w:null,ema:null})}u.sort((n,t)=>n.ts-t.ts);let o=null;for(const n of u)if(n.efficiency!==null){const t=1-n.efficiency;o=o===null?t:Se*t+(1-Se)*o,n.ema=o}const i=[];for(const[n,t]of c){if(t.length===0){i.push({ts:n,mean:0,median:0,stddev:0,min:0,max:0,q25:0,q75:0,sampleCount:0,cv:0,skewness:0,skewnessVelocity:0});continue}t.sort((T,A)=>T-A);const l=t.length,N=t.reduce((T,A)=>T+A,0)/l,w=t.reduce((T,A)=>T+(A-N)**2,0)/Math.max(l-1,1),C=Math.sqrt(w);let h=0;for(const T of t)h+=(T-N)**3;h/=l;const L=C>0?h/(C*C*C):0;i.push({ts:n,mean:N,median:t[Math.floor(l*.5)],stddev:C,min:t[0],max:t[l-1],q25:t[Math.floor(l*.25)],q75:t[Math.floor(l*.75)],sampleCount:l,cv:N>0?C/N:0,skewness:L,skewnessVelocity:0})}i.sort((n,t)=>n.ts-t.ts);let m=-1;for(let n=0;n=0){const t=i[n].ts-i[m].ts;t>0&&(i[n].skewnessVelocity=(i[n].skewness-i[m].skewness)/t)}m=n}const b=[...R.entries()].sort((n,t)=>n[0]-t[0]),S=[...D.entries()].sort((n,t)=>n[0]-t[0]),j=[];for(let n=0;n0?C/w:null,L=l>0?Math.min(N/l,1):null;let T=0,A=0,M=0;if(L!==null){T=L;const k=1-L;h!==null&&h>0?(M=k*h,A=k*(1-h)):A=k}j.push({ts:t,reqCount:l,ackCount:N,reliability:L,lbtRetryRate:h,successFrac:T,lostFrac:A,blockedFrac:M})}return{efficiency:u,jitter:i,reliability:j}}function pt(r,a,v,g){const c=r+a;if(v>=.85)return g<.5?{label:"Healthy Backhaul",description:"Low failure rate with stable RF environment",colorVar:"var(--sys-green)",colorClass:"text-sys-green"}:{label:"Stable — Elevated Jitter",description:`Reliability ${(v*100).toFixed(0)}% is healthy but CV=${g.toFixed(2)} indicates RF variability`,colorVar:"var(--sys-teal)",colorClass:"text-sys-teal"};if(c<1)return{label:"Insufficient Data",description:"Not enough REQ/ACK pairs to classify failure mode",colorVar:"var(--sys-blue)",colorClass:"text-sys-blue"};const R=r/c;return R>.6?{label:"Local RF Congestion",description:`LBT blocking ${Math.round(R*100)}% of failures — radio can't find clear air`,colorVar:"var(--sys-red)",colorClass:"text-sys-red"}:R<.3?{label:"Remote Node Deafness",description:`${Math.round((1-R)*100)}% of failures from RF loss — sent but not acknowledged`,colorVar:"var(--sys-amber)",colorClass:"text-sys-amber"}:{label:"Mixed Failure Mode",description:`Both LBT blocking (${Math.round(r)}) and RF loss (${Math.round(a)}) contributing`,colorVar:"var(--sys-amber)",colorClass:"text-sys-amber"}}const gt=p.memo(function({buckets:a,logScale:v,onHoverIdx:g}){const c=p.useRef(null),R=p.useRef(null),D=p.useRef(a),y=p.useRef(v);D.current=a,y.current=v;const f=p.useRef(g);f.current=g;const u=p.useMemo(()=>[0,.25,.5,.75,1].map(m=>({label:`${Math.round(m*100)}%`,pos:(1-m)*100})),[]),o=p.useMemo(()=>we(a),[a.length]),i=p.useMemo(()=>{const m=a.map(S=>S.ts),b=a.map(()=>1);return[m,b]},[a.length]);return p.useEffect(()=>{const m=c.current;if(!m||a.length===0)return;const b=me(()=>{const j=m.getBoundingClientRect(),s=Math.floor(j.width)||400,x=Math.floor(j.height)||200,n=new xe({width:s,height:x,padding:[0,0,0,0],cursor:{show:!0,sync:{key:"signal-lab"},x:!0,y:!1},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],legend:{show:!1},hooks:{setCursor:[t=>{if(f.current){const l=t.cursor.idx??null;f.current(l)}}],draw:[t=>{const l=t.ctx,{left:N,top:w,width:C,height:h}=t.bbox,L=devicePixelRatio||1,T=D.current,A=y.current,M=T.length;if(M===0||C<=0||h<=0)return;if(l.save(),t.cursor.idx!=null&&t.cursor.idx>=0&&t.cursor.idxk&&(k=E)}const B=w+h/2,_=h/2,I=C/M,O=ee(),V=F=>A?F<=0?0:Math.log10(1+F)/Math.log10(1+k):F/k;for(let F=0;F{const s=j[0];if(!s||!R.current)return;const{width:x,height:n}=s.contentRect;x>0&&n>0&&R.current.setSize({width:Math.floor(x),height:Math.floor(n)})});return S.observe(m),()=>{var j;b(),S.disconnect(),(j=R.current)==null||j.destroy(),R.current=null}},[i]),p.useEffect(()=>{var m;(m=R.current)==null||m.redraw()},[a,v]),a.length===0?e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted",children:"No data"}):e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0",style:{width:W,bottom:Y},"aria-hidden":"true",children:u.map((m,b)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${m.pos}%`,transform:m.pos<=1?"none":m.pos>=99?"translateY(-100%)":"translateY(-50%)",right:0},children:m.label},b))}),e.jsx("div",{ref:c,className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:W,right:0,top:0,bottom:Y}}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:W,height:Y},"aria-hidden":"true",children:o.map((m,b)=>e.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${m.pos}%`,transform:b===0?"none":b===o.length-1?"translateX(-100%)":"translateX(-50%)"},children:m.label},b))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 shrink-0 pt-1",style:{paddingLeft:W},children:[e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:Me,children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.green}}),"Value ▲"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:Ne,children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.amber}}),"Overhead ▼"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Wasted airtime — duplicated or dropped packets. Spikes here mean RF collisions or routing loops.",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.red}}),"Error ▼"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Smoothed trend line — rising means overhead or errors are growing, falling means your mesh is getting more efficient",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:"var(--fg-secondary)"}}),"Trend"]})]})]})}),$e=p.memo(function({buckets:a}){const v=p.useRef(null),g=p.useRef(null),c=p.useRef(a);c.current=a;const{cvMax:R,skewMax:D}=p.useMemo(()=>{let i=1,m=1;for(const b of a)b.sampleCount!==0&&(b.cv>i&&(i=b.cv),Math.abs(b.skewness)>m&&(m=Math.abs(b.skewness)));return{cvMax:Math.ceil(i*2)/2,skewMax:Math.ceil(m*2)/2}},[a]),y=p.useMemo(()=>[0,.25,.5,.75,1].map(i=>({label:(R*i).toFixed(1),pos:(1-i)*100})),[R]),f=p.useMemo(()=>[{label:`+${D.toFixed(1)}`,pos:0},{label:"0",pos:50},{label:`−${D.toFixed(1)}`,pos:100}],[D]),u=p.useMemo(()=>we(a),[a.length]),o=p.useMemo(()=>{const i=a.map(b=>b.ts),m=a.map(()=>1);return[i,m]},[a.length]);return p.useEffect(()=>{const i=v.current;if(!i||a.length===0)return;const m=me(()=>{const S=i.getBoundingClientRect(),j=Math.floor(S.width)||400,s=Math.floor(S.height)||200,x=new xe({width:j,height:s,padding:[0,0,0,0],cursor:{show:!0,sync:{key:"signal-lab"},x:!0,y:!1},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],legend:{show:!1},hooks:{draw:[n=>{const t=n.ctx,{left:l,top:N,width:w,height:C}=n.bbox,h=devicePixelRatio||1,L=c.current,T=L.length;if(T===0||w<=0||C<=0)return;if(t.save(),n.cursor.idx!=null&&n.cursor.idx>=0&&n.cursor.idx0&&d.cv>A&&(A=d.cv);A=Math.ceil(A*2)/2;const M=w/T,k=M>4*h?1:0,B=ee();for(let d=0;d0&&(O.push(V),V=[]);continue}const q=Math.abs(P.median-P.mean)/Math.max(P.mean,1),X=Math.min(q/A,1)*C;V.push({x:l+d*M+M/2,deltaY:I-X})}V.length>0&&O.push(V),t.lineCap="round",t.lineJoin="round";for(const d of O){if(d.length===1){t.fillStyle=_,t.beginPath(),t.arc(d[0].x,d[0].deltaY,1.5*h,0,Math.PI*2),t.fill();continue}t.fillStyle=_,t.globalAlpha=.2,t.beginPath(),t.moveTo(d[0].x,d[0].deltaY);for(let P=1;PN+C*(1-Math.min(d/A,1));if(t.lineWidth=1*h,t.setLineDash([4*h,4*h]),.5<=A){t.strokeStyle=$.teal,t.globalAlpha=.4,t.beginPath();const d=Math.round(G(.5))+.5;t.moveTo(l,d),t.lineTo(l+w,d),t.stroke()}if(1<=A){t.strokeStyle=$.red,t.globalAlpha=.4,t.beginPath();const d=Math.round(G(1))+.5;t.moveTo(l,d),t.lineTo(l+w,d),t.stroke()}t.setLineDash([]),t.globalAlpha=1,t.strokeStyle=B,t.globalAlpha=.12,t.lineWidth=1*h,t.setLineDash([4*h,4*h]);for(const d of[.25,.5,.75]){const P=Math.round(N+C*(1-d))+.5;t.beginPath(),t.moveTo(l,P),t.lineTo(l+w,P),t.stroke()}t.setLineDash([]),t.globalAlpha=1;let F=1;for(const d of L)d.sampleCount>0&&(F=Math.max(F,Math.abs(d.skewness)));F=Math.ceil(F*2)/2;const E=d=>N+C*(.5-d/(2*F));t.strokeStyle=$.indigo,t.globalAlpha=.25,t.lineWidth=1*h,t.setLineDash([2*h,2*h]);const H=Math.round(E(0))+.5;t.beginPath(),t.moveTo(l,H),t.lineTo(l+w,H),t.stroke(),t.setLineDash([]),t.globalAlpha=1,t.strokeStyle=$.indigo,t.lineWidth=1.5*h,t.lineCap="round",t.lineJoin="round";let J=!1;for(let d=0;d{const j=S[0];if(!j||!g.current)return;const{width:s,height:x}=j.contentRect;s>0&&x>0&&g.current.setSize({width:Math.floor(s),height:Math.floor(x)})});return b.observe(i),()=>{var S;m(),b.disconnect(),(S=g.current)==null||S.destroy(),g.current=null}},[o]),p.useEffect(()=>{var i;(i=g.current)==null||i.redraw()},[a]),a.length===0?e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted",children:"No LBT data"}):e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0",style:{width:W,bottom:Y},"aria-hidden":"true",children:y.map((i,m)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${i.pos}%`,transform:i.pos<=1?"none":i.pos>=99?"translateY(-100%)":"translateY(-50%)",right:0},children:i.label},m))}),e.jsx("div",{ref:v,className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:W,right:be,top:0,bottom:Y}}),e.jsx("div",{className:"absolute top-0 right-0",style:{width:be,bottom:Y},"aria-hidden":"true",children:f.map((i,m)=>e.jsx("span",{className:"type-data-xs pl-1",style:{position:"absolute",top:`${i.pos}%`,transform:i.pos<=1?"none":i.pos>=99?"translateY(-100%)":"translateY(-50%)",left:0,color:$.indigo},children:i.label},m))}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:W,right:be,height:Y},"aria-hidden":"true",children:u.map((i,m)=>e.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${i.pos}%`,transform:m===0?"none":m===u.length-1?"translateX(-100%)":"translateX(-50%)"},children:i.label},m))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 shrink-0 pt-1",style:{paddingLeft:W},children:[e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Channel access is predictable — your network isn't congested and nodes can transmit when they need to",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.teal}}),"Stable"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Some contention on the channel — nodes occasionally wait longer to transmit. Watch for a worsening trend.",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.amber}}),"Moderate"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Heavy channel congestion — nodes are fighting for airtime. Consider reducing duty cycle, spreading traffic, or adding repeaters.",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.red}}),"Volatile"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Gap between typical and average wait times — a large gap means a few extreme delays are pulling the average up",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:"var(--fg-secondary)"}}),"Median–Mean"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs",style:{color:$.indigo},title:"Delay distribution shape — positive (above zero) means occasional long waits from traffic bursts, negative means delays are capped and predictable",children:[e.jsx("span",{className:"w-3 h-0.5 rounded-xs shrink-0",style:{background:$.indigo}}),"γ₁ Skewness"]})]})]})}),bt=p.memo(function({buckets:a}){const v=p.useRef(null),g=p.useRef(null),c=p.useRef(a);c.current=a;const R=p.useMemo(()=>[0,.25,.5,.75,1].map(f=>({label:`${Math.round(f*100)}%`,pos:(1-f)*100})),[]),D=p.useMemo(()=>we(a),[a.length]),y=p.useMemo(()=>{const f=a.map(o=>o.ts),u=a.map(()=>1);return[f,u]},[a.length]);return p.useEffect(()=>{const f=v.current;if(!f||a.length===0)return;const u=me(()=>{const i=f.getBoundingClientRect(),m=Math.floor(i.width)||400,b=Math.floor(i.height)||200,S=new xe({width:m,height:b,padding:[0,0,0,0],cursor:{show:!0,sync:{key:"signal-lab"},x:!0,y:!1},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],legend:{show:!1},hooks:{draw:[j=>{const s=j.ctx,{left:x,top:n,width:t,height:l}=j.bbox,N=devicePixelRatio||1,w=c.current,C=w.length;if(C===0||t<=0||l<=0)return;if(s.save(),j.cursor.idx!=null&&j.cursor.idx>=0&&j.cursor.idx{const m=i[0];if(!m||!g.current)return;const{width:b,height:S}=m.contentRect;b>0&&S>0&&g.current.setSize({width:Math.floor(b),height:Math.floor(S)})});return o.observe(f),()=>{var i;u(),o.disconnect(),(i=g.current)==null||i.destroy(),g.current=null}},[y]),p.useEffect(()=>{var f;(f=g.current)==null||f.redraw()},[a]),a.length===0?e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted",children:"No data"}):e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0",style:{width:W,bottom:Y},"aria-hidden":"true",children:R.map((f,u)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${f.pos}%`,transform:f.pos<=1?"none":f.pos>=99?"translateY(-100%)":"translateY(-50%)",right:0},children:f.label},u))}),e.jsx("div",{ref:v,className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:W,right:0,top:0,bottom:Y}}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:W,height:Y},"aria-hidden":"true",children:D.map((f,u)=>e.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${f.pos}%`,transform:u===0?"none":u===D.length-1?"translateX(-100%)":"translateX(-50%)"},children:f.label},u))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 shrink-0 pt-1",style:{paddingLeft:W},children:[e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Messages that made it through and were acknowledged — the healthy portion of your mesh traffic",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.green}}),"Success"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Messages sent but never acknowledged — lost to RF interference, distance, or obstacles. Persistent losses suggest a weak link.",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.amber}}),"Lost"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Couldn't even transmit because the channel was busy — sign of local congestion or a nearby heavy transmitter",children:[e.jsx("span",{className:"w-3 h-3 rounded-xs shrink-0",style:{background:$.red}}),"Blocked"]})]})]})}),Te=3e4,Fe=p.memo(function({buckets:a,hoveredIdx:v}){const g=p.useRef(null),c=p.useRef(a),R=p.useRef(v),D=p.useRef(performance.now()),y=p.useRef(0);c.current=a,R.current=v,p.useEffect(()=>{D.current=performance.now()},[a]);const{cvMax:f,skewMax:u}=p.useMemo(()=>{let b=1,S=1;for(const j of a)j.sampleCount!==0&&(j.cv>b&&(b=j.cv),Math.abs(j.skewness)>S&&(S=Math.abs(j.skewness)));return{cvMax:Math.ceil(b*2)/2,skewMax:Math.ceil(S*2)/2}},[a]),o=p.useMemo(()=>[{label:`+${u.toFixed(1)}`,pos:0},{label:"0",pos:50},{label:`−${u.toFixed(1)}`,pos:100}],[u]),i=p.useMemo(()=>[{label:"0",pos:0},{label:(f/2).toFixed(1),pos:50},{label:f.toFixed(1),pos:100}],[f]);return p.useEffect(()=>{if(!g.current)return;function S(){const j=g.current;if(!j)return;const s=j.getContext("2d");if(!s)return;const x=j.getBoundingClientRect(),n=devicePixelRatio||1,t=Math.floor(x.width*n),l=Math.floor(x.height*n);if(t<=0||l<=0)return;(j.width!==t||j.height!==l)&&(j.width=t,j.height=l),s.clearRect(0,0,t,l),s.save();const N=c.current,w=ee(),C=pe(),h=4*n,L=h,T=h,A=t-2*h,M=l-2*h;if(A<=0||M<=0){s.restore();return}let k=1,B=1;for(const d of N)d.sampleCount!==0&&(d.cv>k&&(k=d.cv),Math.abs(d.skewness)>B&&(B=Math.abs(d.skewness)));k=Math.ceil(k*2)/2,B=Math.ceil(B*2)/2;const _=d=>L+d/k*A,I=d=>T+M*(.5-d/(2*B));s.strokeStyle=w,s.globalAlpha=.08,s.lineWidth=1*n,s.setLineDash([3*n,3*n]);for(const d of[.25,.5,.75]){const P=Math.round(L+d*A)+.5;s.beginPath(),s.moveTo(P,T),s.lineTo(P,T+M),s.stroke()}for(const d of[.25,.75]){const P=Math.round(T+d*M)+.5;s.beginPath(),s.moveTo(L,P),s.lineTo(L+A,P),s.stroke()}s.setLineDash([]),s.globalAlpha=1;const O=Math.round(I(0))+.5;s.strokeStyle=$.indigo,s.globalAlpha=.3,s.lineWidth=1*n,s.beginPath(),s.moveTo(L,O),s.lineTo(L+A,O),s.stroke(),s.globalAlpha=1,s.font=`${9*n}px ${C}`,s.fillStyle=w,s.globalAlpha=.1,s.textAlign="center",s.textBaseline="middle",s.fillText("Stable",L+A*.25,I(0)),s.fillText("Burst Mode",L+A*.75,T+M*.2),s.fillText("Saturated",L+A*.75,T+M*.8),s.globalAlpha=1;const V=[];for(let d=0;d1){s.strokeStyle=w,s.globalAlpha=.45,s.lineWidth=1.5*n,s.lineCap="round",s.lineJoin="round",s.beginPath(),s.moveTo(_(H[0].cv),I(H[0].sk));for(let de=1;de0&&(s.strokeStyle=w,s.lineWidth=2*n,s.beginPath(),s.arc(_(d.cv),I(d.skewness),E+3*n,0,Math.PI*2),s.stroke())}s.restore(),G{y.current&&cancelAnimationFrame(y.current)}},[a,v]),a.some(b=>b.sampleCount>0)?e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0",style:{width:W,bottom:Y},"aria-hidden":"true",children:o.map((b,S)=>e.jsx("span",{className:"type-data-xs text-right pr-1.5",style:{position:"absolute",top:`${b.pos}%`,transform:b.pos<=1?"none":b.pos>=99?"translateY(-100%)":"translateY(-50%)",right:0,color:$.indigo},children:b.label},S))}),e.jsx("canvas",{ref:g,className:"absolute block radius-inner depth-stroke-inset bg-chart-inner",style:{left:W,right:0,top:0,bottom:Y,width:`calc(100% - ${W}px)`,height:`calc(100% - ${Y}px)`}}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:W,height:Y},"aria-hidden":"true",children:i.map((b,S)=>e.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${b.pos}%`,transform:S===0?"none":S===i.length-1?"translateX(-100%)":"translateX(-50%)"},children:b.label},S))})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 shrink-0 pt-1 type-data-xs text-fg-secondary",style:{paddingLeft:W},children:"X: CV \\u00b7 Y: \\u03b3\\u2081 \\u00b7 Trail: last 5"})]}):e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted",children:"No LBT data"})}),yt=p.memo(function({value:a,maxValue:v,theoreticalMax:g,collisionThreshold:c,label:R}){const D=p.useRef(null),y=p.useRef({value:a,maxValue:v,theoreticalMax:g,collisionThreshold:c,label:R});y.current={value:a,maxValue:v,theoreticalMax:g,collisionThreshold:c,label:R};const f=p.useCallback(()=>{const u=D.current;if(!u)return;const o=u.getContext("2d");if(!o)return;const i=u.getBoundingClientRect();if(i.width===0||i.height===0)return;const m=devicePixelRatio||1;u.width=Math.floor(i.width*m),u.height=Math.floor(i.height*m);const b=u.width,S=u.height,j=pe(),s=ee(),{value:x,maxValue:n,theoreticalMax:t,collisionThreshold:l,label:N}=y.current,w=Math.min(b,S)/180;o.clearRect(0,0,b,S);const C=b/2,h=S*.52,L=Math.min(C-8*w,h-8*w),T=L*.72,A=Math.PI*.75,M=Math.PI*.25+Math.PI,k=M-A,B=n>0?Math.min(x/n,1):0,_=A+B*k;o.beginPath(),o.arc(C,h,L,A,M),o.arc(C,h,T,M,A,!0),o.closePath(),o.fillStyle=re()?Z[800]:Z[200],o.fill();const I=l&&n>0?Math.min(l/n,.95):.5,O=t&&n>0?Math.min(t/n,.99):.85,V=o.createConicGradient(A,C,h);if(V.addColorStop(0,$.green),V.addColorStop(I*.8,$.green),V.addColorStop(I,$.amber),V.addColorStop(O,$.red),V.addColorStop(1,$.red),o.beginPath(),o.arc(C,h,L,A,_),o.arc(C,h,T,_,A,!0),o.closePath(),o.fillStyle=V,o.fill(),l&&l>0&&n>0){const F=Math.min(l/n,1),E=A+F*k;o.strokeStyle=$.amber,o.globalAlpha=.6,o.lineWidth=Math.max(1,1.5*w),o.beginPath(),o.moveTo(C+Math.cos(E)*(T-1*w),h+Math.sin(E)*(T-1*w)),o.lineTo(C+Math.cos(E)*(L+1*w),h+Math.sin(E)*(L+1*w)),o.stroke(),o.globalAlpha=1}if(t>0&&n>0){const F=Math.min(t/n,1),E=A+F*k;o.beginPath(),o.arc(C,h,L,A,E),o.arc(C,h,T,E,A,!0),o.closePath(),o.fillStyle=s,o.globalAlpha=.07,o.fill(),o.globalAlpha=1,o.strokeStyle=$.red,o.globalAlpha=.5,o.lineWidth=Math.max(1,1.5*w),o.beginPath(),o.moveTo(C+Math.cos(E)*(T-2*w),h+Math.sin(E)*(T-2*w)),o.lineTo(C+Math.cos(E)*(L+2*w),h+Math.sin(E)*(L+2*w)),o.stroke(),o.globalAlpha=1}o.fillStyle=s,o.textAlign="center",o.textBaseline="middle",o.font=`bold ${Math.round(20*w)}px ${j}`,o.fillText(`${(x*1e3).toFixed(1)}`,C,h-4*w),o.font=`${Math.round(7.5*w)}px ${j}`,o.globalAlpha=.6,o.fillText("×10⁻³",C,h+10*w),o.globalAlpha=1,o.font=`bold ${Math.round(9*w)}px ${j}`,o.fillText(N,C,h+L+12*w);const G=t>0?x/t*100:0;o.font=`${Math.round(8*w)}px ${j}`,o.globalAlpha=.55,o.fillText(`${G.toFixed(0)}% cap`,C,h+L+24*w),o.globalAlpha=1},[]);return p.useEffect(()=>{f()},[a,v,g,c,R,f]),p.useEffect(()=>{const u=D.current;if(!u)return;const o=new ResizeObserver(()=>f());return o.observe(u),()=>o.disconnect()},[f]),e.jsx("canvas",{ref:D,className:"w-full h-full"})});function vt({efficiency:r,jitter:a,reliability:v,packets:g}){const c=r.reduce((M,k)=>M+k.value,0),R=r.reduce((M,k)=>M+k.overhead,0),D=r.reduce((M,k)=>M+k.error,0),y=c+R+D,f=y>0?c/y:0,u=a.filter(M=>M.sampleCount>0),o=u.length>0?u.reduce((M,k)=>M+k.cv,0)/u.length:0,i=u.reduce((M,k)=>Math.max(M,k.cv),0),m=v.reduce((M,k)=>M+k.reqCount,0),b=v.reduce((M,k)=>M+k.ackCount,0),S=m>0?Math.min(b/m,1):1,j=v.reduce((M,k)=>M+k.blockedFrac*k.reqCount,0),s=v.reduce((M,k)=>M+k.lostFrac*k.reqCount,0),x=pt(j,s,S,o),n=S>=.85?Ge:Je,t=g.length>=2?(g[g.length-1].timestamp-g[0].timestamp)/3600:0,l=t>0?Math.round(g.length/t):0,N=u.length>0?u[u.length-1]:null,w=(N==null?void 0:N.skewness)??0,C=(N==null?void 0:N.skewnessVelocity)??0,h=Math.abs(w),L=w>.1?"Right-skew (burst)":w<-.1?"Left-skew (saturated)":"Symmetric",T=Math.abs(C)<.01?"→":C>0?"↗":"↘",A=[{label:"Network Efficiency",value:`${(f*100).toFixed(1)}%`,color:f>.5?"text-sys-green":f>.3?"text-sys-amber":"text-sys-red",sub:`${c.toLocaleString()} value / ${y.toLocaleString()} total`},{label:"LBT Stability (CV)",value:o.toFixed(2),color:o<.5?"text-sys-teal":o<1?"text-sys-amber":"text-sys-red",sub:`peak ${i.toFixed(2)} · ${o<.5?"Stable":o<1?"Moderate":"Volatile"}`},{label:"Path Reliability",value:`${(S*100).toFixed(1)}%`,color:S>.85?"text-sys-green":S>.7?"text-sys-amber":"text-sys-red",sub:`${Math.round(j)} blocked · ${Math.round(s)} lost · ${b} ACK`},{label:"Throughput",value:`${l.toLocaleString()} /hr`,color:"text-fg-primary",sub:`${g.length.toLocaleString()} in ${t>0?`${t.toFixed(1)}h`:"—"} window`},{label:"Skewness (γ₁)",value:`${w>=0?"+":""}${w.toFixed(2)} ${T}`,color:h<.3?"text-sys-teal":h<1?"text-sys-indigo":"text-sys-red",sub:L}];return e.jsxs("div",{children:[e.jsxs("div",{className:"surface-inner radius-inner px-3 py-2.5 mb-3 flex items-start gap-2.5",style:{borderLeft:`3px solid ${x.colorVar}`},children:[e.jsx(n,{className:`w-4 h-4 shrink-0 mt-0.5 ${x.colorClass}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`type-label font-semibold ${x.colorClass}`,children:x.label}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-0.5",children:x.description})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:A.map(M=>e.jsxs("div",{className:"surface-inner radius-inner p-3",children:[e.jsx("p",{className:"type-micro text-fg-muted truncate",children:M.label}),e.jsx("p",{className:`type-data-xl ${M.color}`,children:M.value}),e.jsx("p",{className:"type-data-xs text-fg-muted",children:M.sub})]},M.label))})]})}function Ee({talkers:r}){if(r.length===0)return e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted type-data-xs",children:"No source data"});const a=r.reduce((c,R)=>Math.max(c,R.total),1),g=re()?Z[700]:Z[300];return e.jsx("div",{className:"flex flex-col h-full min-w-0 overflow-hidden",children:e.jsx("div",{className:"flex-1 min-h-0 gap-y-0.5",style:{display:"grid",gridTemplateColumns:"0.75rem 4.5rem 1fr auto",alignItems:"center",columnGap:"0.375rem"},children:r.map((c,R)=>{const D=a>0?c.total/a*100:0,y=c.total>0?c.value/c.total*100:0,f=`${c.name||c.hash.slice(0,8)}: ${c.value} useful messages + ${c.tax} overhead packets = ${c.total} total. ${c.taxPct.toFixed(0)}% of this node's traffic is infrastructure overhead`;return e.jsxs("div",{title:f,className:"col-span-full grid gap-y-0.5 cursor-default",style:{gridTemplateColumns:"subgrid",alignItems:"center"},children:[e.jsx("span",{className:"type-data-xs text-fg-muted text-right",children:R+1}),e.jsx("span",{className:"type-data-xs text-fg-secondary truncate",children:c.name||c.hash.slice(0,8)}),e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"h-2 radius-badge overflow-hidden flex relative",style:{width:`${D}%`,minWidth:4},children:[e.jsx("div",{className:"h-full",style:{width:`${y}%`,background:$.blue}}),e.jsx("div",{className:"absolute top-0 h-full",style:{left:`${y}%`,width:"1.5px",background:g}}),e.jsx("div",{className:"h-full flex-1",style:{background:$.indigo}})]})}),e.jsxs("span",{className:"data-box data-box-compact",style:{"--data-box-color":"var(--fg-muted)"},children:[c.taxPct.toFixed(0),"%"]})]},c.hash)})})})}function wt(r,a){return p.useMemo(()=>{var x,n,t,l;const v=ze(a),g=v.spreadingFactor,c=v.bandwidthHz,R=v.codingRate;let D=0,y=0;if(r.length>=2){y=r[r.length-1].timestamp-r[0].timestamp;for(const N of r)D+=N.length??N.payload_length??32}const f=g*(4/R)/Math.pow(2,g),u=.27,o=.2,i=((n=(x=a==null?void 0:a.config)==null?void 0:x.duty_cycle)==null?void 0:n.max_airtime_percent)??100,m=((l=(t=a==null?void 0:a.config)==null?void 0:t.duty_cycle)==null?void 0:l.enforcement_enabled)!==!1?Math.min(1,i/100):1,b=f*Math.min(u,m),S=f*Math.min(o,m);if(y<=0)return{value:0,maxValue:b*1.3,theoreticalSe:b,collisionSe:S};const s=D*8/y/c;return{value:s,maxValue:Math.max(b*1.3,s*1.2),theoreticalSe:b,collisionSe:S}},[r,a])}function jt(r){var D;if(r.length<2)return[];const a=Math.floor(Date.now()/1e3),v=a-Le*ne,g=new Map;for(let y=v;y=a||(D=g.get(f))==null||D.push(y.timestamp)}const c=[];for(const[y,f]of g){if(f.length<2){c.push({ts:y,mean:0,median:0,stddev:0,min:0,max:0,q25:0,q75:0,sampleCount:0,cv:0,skewness:0,skewnessVelocity:0});continue}f.sort((s,x)=>s-x);const u=[];for(let s=1;ss-x);const o=u.length,i=u.reduce((s,x)=>s+x,0)/o,m=u.reduce((s,x)=>s+(x-i)**2,0)/Math.max(o-1,1),b=Math.sqrt(m);let S=0;for(const s of u)S+=(s-i)**3;S/=o;const j=b>0?S/(b*b*b):0;c.push({ts:y,mean:i,median:u[Math.floor(o*.5)],stddev:b,min:u[0],max:u[o-1],q25:u[Math.floor(o*.25)],q75:u[Math.floor(o*.75)],sampleCount:o,cv:i>0?b/i:0,skewness:j,skewnessVelocity:0})}c.sort((y,f)=>y.ts-f.ts);let R=-1;for(let y=0;y=0){const f=c[y].ts-c[R].ts;f>0&&(c[y].skewnessVelocity=(c[y].skewness-c[R].skewness)/f)}R=y}return c}const Mt=p.memo(function({packets:a}){const v=p.useRef(null),g=p.useRef(null),c=p.useMemo(()=>a.filter(s=>s.rssi<0),[a]),R=p.useRef(c);R.current=c;const{rssiMin:D,rssiMax:y,snrMin:f,snrMax:u,medianRssi:o,medianSnr:i}=p.useMemo(()=>{if(c.length===0)return{rssiMin:-130,rssiMax:-30,snrMin:-20,snrMax:15,medianRssi:0,medianSnr:0};const s=c.map(n=>n.rssi).sort((n,t)=>n-t),x=c.map(n=>n.snr).sort((n,t)=>n-t);return{rssiMin:Math.min(s[0],-130),rssiMax:Math.max(s[s.length-1],-30),snrMin:Math.min(x[0],-20),snrMax:Math.max(x[x.length-1],15),medianRssi:s[Math.floor(s.length/2)],medianSnr:x[Math.floor(x.length/2)]}},[c]),m=p.useRef({rssiMin:D,rssiMax:y,snrMin:f,snrMax:u,medianRssi:o,medianSnr:i});m.current={rssiMin:D,rssiMax:y,snrMin:f,snrMax:u,medianRssi:o,medianSnr:i};const b=p.useMemo(()=>{const s=y-D;return[0,.25,.5,.75,1].map(x=>({label:`${Math.round(y-x*s)}`,pos:x*100}))},[D,y]),S=p.useMemo(()=>{if(c.length===0)return[];const s=c[0].timestamp,x=c[c.length-1].timestamp;return[0,.25,.5,.75,1].map(n=>({label:Pe(s+n*(x-s)),pos:n*100}))},[c]),j=p.useMemo(()=>{const s=c.map(n=>n.timestamp),x=c.map(()=>1);return[s,x]},[c.length]);return p.useEffect(()=>{const s=v.current;if(!s||c.length===0)return;const x=me(()=>{const t=s.getBoundingClientRect(),l=Math.floor(t.width)||400,N=Math.floor(t.height)||200,w=new xe({width:l,height:N,padding:[0,0,0,0],cursor:{show:!0,x:!0,y:!1},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],legend:{show:!1},hooks:{draw:[C=>{const h=C.ctx,{left:L,top:T,width:A,height:M}=C.bbox,k=devicePixelRatio||1,B=R.current;if(B.length===0||A<=0||M<=0)return;const _=m.current;h.save();const I=ee();h.strokeStyle=I,h.globalAlpha=.1,h.lineWidth=1*k,h.setLineDash([4*k,4*k]);for(const P of[.25,.5,.75]){const q=Math.round(T+M*P)+.5;h.beginPath(),h.moveTo(L,q),h.lineTo(L+A,q),h.stroke()}h.setLineDash([]),h.globalAlpha=1;const O=B[0].timestamp,G=B[B.length-1].timestamp-O||1,F=_.rssiMax-_.rssiMin||1,E=_.snrMax-_.snrMin||1,H=Math.max(2,Math.min(4,200/Math.sqrt(B.length)))*k;for(const P of B){const q=L+(P.timestamp-O)/G*A,X=T+(_.rssiMax-P.rssi)/F*M,te=Math.max(0,Math.min(1,(P.snr-_.snrMin)/E)),ge=te<.33?$.red:te<.66?$.amber:$.teal;h.fillStyle=ge,h.globalAlpha=.7,h.beginPath(),h.arc(q,X,H,0,Math.PI*2),h.fill()}h.globalAlpha=1;const J=pe();h.font=`${10*k}px ${J}`,h.textAlign="right",h.textBaseline="top",h.fillStyle=I,h.globalAlpha=.7;const d=6*k;h.fillText(`RSSI ${_.medianRssi} dBm`,L+A-d,T+d),h.fillText(`SNR ${_.medianSnr.toFixed(1)} dB`,L+A-d,T+d+14*k),h.fillText(`n=${B.length}`,L+A-d,T+d+28*k),h.globalAlpha=1,h.restore()}]}},j,s);g.current=w}),n=new ResizeObserver(t=>{const l=t[0];if(!l||!g.current)return;const{width:N,height:w}=l.contentRect;N>0&&w>0&&g.current.setSize({width:Math.floor(N),height:Math.floor(w)})});return n.observe(s),()=>{var t;x(),n.disconnect(),(t=g.current)==null||t.destroy(),g.current=null}},[j]),p.useEffect(()=>{var s;(s=g.current)==null||s.redraw()},[c]),c.length===0?e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted type-data-xs",children:"No RF data from observer"}):e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0",style:{width:W,bottom:Y},"aria-hidden":"true",children:b.map((s,x)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${s.pos}%`,transform:s.pos<=1?"none":s.pos>=99?"translateY(-100%)":"translateY(-50%)",right:0},children:s.label},x))}),e.jsx("div",{ref:v,className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:W,right:0,top:0,bottom:Y}}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{left:W,height:Y},"aria-hidden":"true",children:S.map((s,x)=>e.jsx("span",{className:"type-data-xs text-fg-secondary absolute top-1",style:{left:`${s.pos}%`,transform:x===0?"none":x===S.length-1?"translateX(-100%)":"translateX(-50%)"},children:s.label},x))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 shrink-0 pt-1",style:{paddingLeft:W},children:[e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Strong signal — packets arrived clearly above the noise floor, reliable decoding expected",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:$.teal}}),"High SNR"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Moderate signal — decoding should work but there's less margin for interference or fading",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:$.amber}}),"Mid SNR"]}),e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-fg-secondary",title:"Weak signal — packets barely above the noise floor, expect higher error rates and missed frames",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:$.red}}),"Low SNR"]})]})]})});function Nt({packets:r}){const a=Qe(),v=Ze(),g=p.useMemo(()=>a?r.filter(D=>D._mqttSource):[],[r,a]),c=p.useMemo(()=>jt(g),[g]),R=p.useMemo(()=>{var f;const D=new Map;for(const u of g){const o=v(u),i=o.hash||u.src_hash||(u._advertSender?u._advertSender.slice(0,16):null)||((f=u.packet_hash)==null?void 0:f.slice(0,8));if(!i)continue;let m=D.get(i);m||(m={value:0,tax:0,name:null},D.set(i,m)),je(u)?m.value++:m.tax++,m.name||(m.name=o.name||u._advertName||null)}const y=[];for(const[u,o]of D){const i=o.value+o.tax;y.push({hash:u,name:o.name,value:o.value,tax:o.tax,total:i,taxPct:i>0?o.tax/i*100:0})}return y.sort((u,o)=>o.tax-u.tax),y.slice(0,5)},[g,v]);return!a||g.length===0?null:e.jsxs(De,{children:[e.jsx(se,{template:"auto",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"type-micro text-fg-primary",children:"MQTT OBSERVER"}),e.jsxs("span",{className:"data-box data-box-compact data-box-outlined",style:{"--data-box-accent":"var(--sys-teal)"},children:[g.length.toLocaleString()," pkts"]})]})}),e.jsxs(se,{template:"panel",children:[e.jsx(ae,{span:12,md:6,children:e.jsxs(Q,{skeletonType:"chart",children:[e.jsx(U,{title:"Arrival Stability (CV)"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx($e,{buckets:c})})]})}),e.jsx(ae,{span:12,md:6,children:e.jsxs(Q,{skeletonType:"chart",children:[e.jsx(U,{title:"Observer RF"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Mt,{packets:g})})]})})]}),e.jsxs(se,{template:"panel",children:[e.jsx(ae,{span:12,md:6,children:e.jsxs(Q,{children:[e.jsx(U,{title:"MQTT Top Taxers",actions:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:"flex items-center gap-1 type-data-xs text-fg-muted",title:Me,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full inline-block",style:{background:$.blue}}),"Value"]}),e.jsxs("span",{className:"flex items-center gap-1 type-data-xs text-fg-muted",title:Ne,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full inline-block",style:{background:$.indigo}}),"Tax"]})]})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsx(Ee,{talkers:R})})]})}),e.jsx(ae,{span:12,md:6,children:e.jsxs(Q,{skeletonType:"chart",children:[e.jsx(U,{title:"IAT Phase Space"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Fe,{buckets:c,hoveredIdx:null})})]})})]})]})}function Dt(){var m,b,S,j;const r=Oe(),a=Ye(),[v,g]=p.useState(!1),[c,R]=p.useState(null),{efficiency:D,jitter:y,reliability:f}=p.useMemo(()=>xt(r),[r]),u=wt(r,a),o=p.useMemo(()=>{const s=new Map;for(const n of r){const t=n.src_hash;if(!t)continue;let l=s.get(t);l||(l={value:0,tax:0,name:null},s.set(t,l)),je(n)?l.value++:l.tax++,!l.name&&n._advertName&&(l.name=n._advertName)}const x=[];for(const[n,t]of s){const l=t.value+t.tax;x.push({hash:n,name:t.name,value:t.value,tax:t.tax,total:l,taxPct:l>0?t.tax/l*100:0})}return x.sort((n,t)=>t.tax-n.tax),x.slice(0,5)},[r]),i=p.useCallback(()=>g(s=>!s),[]);return e.jsxs(Ke,{children:[e.jsx(Ue,{title:"Signal Lab",icon:e.jsx(Xe,{}),controls:e.jsxs("button",{onClick:i,className:`flex items-center gap-1.5 px-3 py-1.5 radius-inner surface-control transition-base type-data-xs text-fg-secondary`,title:"Switch to log scale to see low-traffic periods more clearly — useful when a few busy buckets dominate the chart",children:[v?e.jsx(nt,{className:"w-4 h-4 text-sys-blue"}):e.jsx(st,{className:"w-4 h-4"}),"Log₁₀"]})}),e.jsxs(De,{children:[e.jsx(se,{template:"auto",children:e.jsx(Q,{children:e.jsx(vt,{efficiency:D,jitter:y,reliability:f,packets:r})})}),e.jsx(se,{template:"auto",children:e.jsx(ht,{})}),e.jsx(se,{template:"hero",children:e.jsxs(Q,{skeletonType:"chart",children:[e.jsx(U,{title:"Traffic Balance"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(gt,{buckets:D,logScale:v,onHoverIdx:R})})]})}),e.jsxs(se,{template:"panel",children:[e.jsx(ae,{span:12,md:6,children:e.jsxs(Q,{skeletonType:"chart",children:[e.jsx(U,{title:"LBT Stability (CV)"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx($e,{buckets:y})})]})}),e.jsx(ae,{span:12,md:6,children:e.jsxs(Q,{skeletonType:"chart",children:[e.jsx(U,{title:"Path Reliability (Rₚ)"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(bt,{buckets:f})})]})})]}),e.jsxs(se,{template:"panel",children:[e.jsx(ae,{span:12,md:6,children:e.jsxs(Q,{skeletonType:"chart",children:[e.jsx(U,{title:"Phase Space Map"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Fe,{buckets:y,hoveredIdx:c})})]})}),e.jsx(ae,{span:12,md:6,children:e.jsxs("div",{className:"h-full flex flex-col gap-3",children:[e.jsx(Q,{compact:!0,className:"!h-auto shrink-0",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-16 sm:w-20 aspect-square shrink-0",children:e.jsx(yt,{value:u.value,maxValue:u.maxValue,theoreticalMax:u.theoreticalSe,collisionThreshold:u.collisionSe,label:`SF${((b=(m=a==null?void 0:a.config)==null?void 0:m.radio)==null?void 0:b.spreading_factor)??7} / ${ut(((j=(S=a==null?void 0:a.config)==null?void 0:S.radio)==null?void 0:j.bandwidth)??125e3)}kHz`})}),e.jsxs("div",{className:"flex-1 min-w-0",title:"How much of the available channel your mesh is using. Amber zone (~20%) = collisions start degrading throughput. Red zone (~27%) = practical ceiling for a shared LoRa channel. Below amber = healthy headroom.",children:[e.jsx("p",{className:"type-micro mb-0.5",children:"RX UTILIZATION"}),e.jsx("p",{className:"type-data-xs text-fg-muted mb-1 hidden sm:block",children:"Channel capacity (Sₑ)"}),e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"type-data-lg text-fg-primary",children:(u.value*1e3).toFixed(1)}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:"×10⁻³ bit/s/Hz"})]})]})]})}),e.jsxs(Q,{className:"flex-1 min-h-0",children:[e.jsx(U,{title:"Top Taxers",actions:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:"flex items-center gap-1 type-data-xs text-fg-muted",title:Me,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full inline-block",style:{background:$.blue}}),"Value"]}),e.jsxs("span",{className:"flex items-center gap-1 type-data-xs text-fg-muted",title:Ne,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full inline-block",style:{background:$.indigo}}),"Tax"]})]})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsx(Ee,{talkers:o})})]})]})})]})]}),e.jsx(Nt,{packets:r})]})}export{Dt as default}; diff --git a/frontend/dist/assets/activity-BFfde9uG.js b/frontend/dist/assets/activity-D6ySIfuC.js similarity index 89% rename from frontend/dist/assets/activity-BFfde9uG.js rename to frontend/dist/assets/activity-D6ySIfuC.js index 3888913d..2b159860 100644 --- a/frontend/dist/assets/activity-BFfde9uG.js +++ b/frontend/dist/assets/activity-D6ySIfuC.js @@ -1,4 +1,4 @@ -import{e as t}from"./index-C2xvS0Jd.js";/** +import{e as t}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/antenna-Dr-Egqv0.js b/frontend/dist/assets/antenna-rn7EByqR.js similarity index 91% rename from frontend/dist/assets/antenna-Dr-Egqv0.js rename to frontend/dist/assets/antenna-rn7EByqR.js index ca70ae7c..fd5e5154 100644 --- a/frontend/dist/assets/antenna-Dr-Egqv0.js +++ b/frontend/dist/assets/antenna-rn7EByqR.js @@ -1,4 +1,4 @@ -import{e}from"./index-C2xvS0Jd.js";/** +import{e}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/arrow-down-4OY_dsXk.js b/frontend/dist/assets/arrow-down-BI9NpupK.js similarity index 86% rename from frontend/dist/assets/arrow-down-4OY_dsXk.js rename to frontend/dist/assets/arrow-down-BI9NpupK.js index bbc3848a..30873058 100644 --- a/frontend/dist/assets/arrow-down-4OY_dsXk.js +++ b/frontend/dist/assets/arrow-down-BI9NpupK.js @@ -1,4 +1,4 @@ -import{e as o}from"./index-C2xvS0Jd.js";/** +import{e as o}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/arrow-right-DySc3ssS.js b/frontend/dist/assets/arrow-right-aT_K-Mjc.js similarity index 86% rename from frontend/dist/assets/arrow-right-DySc3ssS.js rename to frontend/dist/assets/arrow-right-aT_K-Mjc.js index 8a633e10..f76d08fb 100644 --- a/frontend/dist/assets/arrow-right-DySc3ssS.js +++ b/frontend/dist/assets/arrow-right-aT_K-Mjc.js @@ -1,4 +1,4 @@ -import{e as o}from"./index-C2xvS0Jd.js";/** +import{e as o}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/arrow-up-C0VG8Et4.js b/frontend/dist/assets/arrow-up-C4DdHKHn.js similarity index 86% rename from frontend/dist/assets/arrow-up-C0VG8Et4.js rename to frontend/dist/assets/arrow-up-C4DdHKHn.js index ff7e3f4e..f8da94d1 100644 --- a/frontend/dist/assets/arrow-up-C0VG8Et4.js +++ b/frontend/dist/assets/arrow-up-C4DdHKHn.js @@ -1,4 +1,4 @@ -import{e as o}from"./index-C2xvS0Jd.js";/** +import{e as o}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/car-D35Wwv-5.js b/frontend/dist/assets/car-CeuvJE3C.js similarity index 92% rename from frontend/dist/assets/car-D35Wwv-5.js rename to frontend/dist/assets/car-CeuvJE3C.js index 6fbb4b20..c057fa5f 100644 --- a/frontend/dist/assets/car-D35Wwv-5.js +++ b/frontend/dist/assets/car-CeuvJE3C.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-C2xvS0Jd.js";/** +import{e as c}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/chat-utils-DnJ-lYj3.js b/frontend/dist/assets/chat-utils-DIy1-SG1.js similarity index 97% rename from frontend/dist/assets/chat-utils-DnJ-lYj3.js rename to frontend/dist/assets/chat-utils-DIy1-SG1.js index 64f3c063..89c1e4d1 100644 --- a/frontend/dist/assets/chat-utils-DnJ-lYj3.js +++ b/frontend/dist/assets/chat-utils-DIy1-SG1.js @@ -1 +1 @@ -import{r as g,Z as d,O as l}from"./index-C2xvS0Jd.js";function p(e){const n=parseInt(e.slice(1,3),16)/255,t=parseInt(e.slice(3,5),16)/255,r=parseInt(e.slice(5,7),16)/255,o=Math.max(n,t,r),i=Math.min(n,t,r),a=(o+i)/2;if(o===i)return[0,0,a];const s=o-i,u=a>.5?s/(2-o-i):s/(o+i);let c=0;return o===n?c=((t-r)/s+(t(c<0&&(c+=1),c>1&&(c-=1),c<1/6?s+(u-s)*6*c:c<1/2?u:c<2/3?s+(u-s)*(2/3-c)*6:s),o=t<.5?t*(1+n):t+n-t*n,i=2*t-o,a=s=>Math.round(s*255).toString(16).padStart(2,"0");return`#${a(r(i,o,e+1/3))}${a(r(i,o,e))}${a(r(i,o,e-1/3))}`}function S(e,n,t){let r=n[0]-e[0];return r>.5&&(r-=1),r<-.5&&(r+=1),[(e[0]+r*t+1)%1,e[1]+(n[1]-e[1])*t,e[2]+(n[2]-e[2])*t]}const x=[l.red,l.orange,l.amber,l.green,l.teal,l.cyan,l.blue,l.indigo,l.purple,l.pink],m=4,h=[];{const e=x.map(p);for(let n=0;n3||n.replace(f,"").replace(/[\u200D\uFE0F\s]/g,"").length>0?0:t.length}function C(e){const n=e.match(f);if(n&&n.length>0){const t=n[0],r=e.replace(f,"").trim();return{emoji:t,cleanName:r||e}}return{emoji:null,cleanName:e}}function y(e){const{cleanName:n}=C(e),t=n.split(/[\s-_]+/).filter(Boolean);if(t.length>=2){const o=Array.from(t[0])[0]||"",i=Array.from(t[1])[0]||"";return(o+i).toUpperCase()}return Array.from(n).slice(0,2).join("").toUpperCase()}function M(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function T(e,n){const t=/@\[([^\]]+)\]/g,r=[];let o=0,i;const a=n!=null&&n.isOutgoing?d[200]:l.blue,s=n==null?void 0:n.onMentionClick;for(;(i=t.exec(e))!==null;){i.index>o&&r.push(e.slice(o,i.index));const u=i[1];r.push(g.createElement(s?"button":"span",{key:i.index,className:s?"font-bold hover:underline underline-offset-2 cursor-pointer":"font-bold",style:{color:a},...s&&{type:"button",onClick:c=>{c.stopPropagation(),s(u)}}},u)),o=i.index+i[0].length}return o0?r:e}export{y as a,M as b,N as c,C as e,T as f,j as g}; +import{r as g,Z as d,O as l}from"./index-D33fcA3L.js";function p(e){const n=parseInt(e.slice(1,3),16)/255,t=parseInt(e.slice(3,5),16)/255,r=parseInt(e.slice(5,7),16)/255,o=Math.max(n,t,r),i=Math.min(n,t,r),a=(o+i)/2;if(o===i)return[0,0,a];const s=o-i,u=a>.5?s/(2-o-i):s/(o+i);let c=0;return o===n?c=((t-r)/s+(t(c<0&&(c+=1),c>1&&(c-=1),c<1/6?s+(u-s)*6*c:c<1/2?u:c<2/3?s+(u-s)*(2/3-c)*6:s),o=t<.5?t*(1+n):t+n-t*n,i=2*t-o,a=s=>Math.round(s*255).toString(16).padStart(2,"0");return`#${a(r(i,o,e+1/3))}${a(r(i,o,e))}${a(r(i,o,e-1/3))}`}function S(e,n,t){let r=n[0]-e[0];return r>.5&&(r-=1),r<-.5&&(r+=1),[(e[0]+r*t+1)%1,e[1]+(n[1]-e[1])*t,e[2]+(n[2]-e[2])*t]}const x=[l.red,l.orange,l.amber,l.green,l.teal,l.cyan,l.blue,l.indigo,l.purple,l.pink],m=4,h=[];{const e=x.map(p);for(let n=0;n3||n.replace(f,"").replace(/[\u200D\uFE0F\s]/g,"").length>0?0:t.length}function C(e){const n=e.match(f);if(n&&n.length>0){const t=n[0],r=e.replace(f,"").trim();return{emoji:t,cleanName:r||e}}return{emoji:null,cleanName:e}}function y(e){const{cleanName:n}=C(e),t=n.split(/[\s-_]+/).filter(Boolean);if(t.length>=2){const o=Array.from(t[0])[0]||"",i=Array.from(t[1])[0]||"";return(o+i).toUpperCase()}return Array.from(n).slice(0,2).join("").toUpperCase()}function M(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function T(e,n){const t=/@\[([^\]]+)\]/g,r=[];let o=0,i;const a=n!=null&&n.isOutgoing?d[200]:l.blue,s=n==null?void 0:n.onMentionClick;for(;(i=t.exec(e))!==null;){i.index>o&&r.push(e.slice(o,i.index));const u=i[1];r.push(g.createElement(s?"button":"span",{key:i.index,className:s?"font-bold hover:underline underline-offset-2 cursor-pointer":"font-bold",style:{color:a},...s&&{type:"button",onClick:c=>{c.stopPropagation(),s(u)}}},u)),o=i.index+i[0].length}return o0?r:e}export{y as a,M as b,N as c,C as e,T as f,j as g}; diff --git a/frontend/dist/assets/check-check-UEaQfqci.js b/frontend/dist/assets/check-check-C-QgFmon.js similarity index 88% rename from frontend/dist/assets/check-check-UEaQfqci.js rename to frontend/dist/assets/check-check-C-QgFmon.js index d519427b..c49512bf 100644 --- a/frontend/dist/assets/check-check-UEaQfqci.js +++ b/frontend/dist/assets/check-check-C-QgFmon.js @@ -1,4 +1,4 @@ -import{e}from"./index-C2xvS0Jd.js";/** +import{e}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/chevron-right-C9GG0xWI.js b/frontend/dist/assets/chevron-right-D4kUPDBw.js similarity index 85% rename from frontend/dist/assets/chevron-right-C9GG0xWI.js rename to frontend/dist/assets/chevron-right-D4kUPDBw.js index 209cc972..ea4efb00 100644 --- a/frontend/dist/assets/chevron-right-C9GG0xWI.js +++ b/frontend/dist/assets/chevron-right-D4kUPDBw.js @@ -1,4 +1,4 @@ -import{e as o}from"./index-C2xvS0Jd.js";/** +import{e as o}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/chevron-up-CTCjpmk_.js b/frontend/dist/assets/chevron-up-DyOgmQ5-.js similarity index 99% rename from frontend/dist/assets/chevron-up-CTCjpmk_.js rename to frontend/dist/assets/chevron-up-DyOgmQ5-.js index 10bf673b..997371e0 100644 --- a/frontend/dist/assets/chevron-up-CTCjpmk_.js +++ b/frontend/dist/assets/chevron-up-DyOgmQ5-.js @@ -1,4 +1,4 @@ -import{r as x,b9 as F,e as R}from"./index-C2xvS0Jd.js";function S(r,l,e){let s=e.initialDeps??[],t,n=!0;function o(){var i,h,u;let c;e.key&&((i=e.debug)!=null&&i.call(e))&&(c=Date.now());const f=r();if(!(f.length!==s.length||f.some((p,d)=>s[d]!==p)))return t;s=f;let m;if(e.key&&((h=e.debug)!=null&&h.call(e))&&(m=Date.now()),t=l(...f),e.key&&((u=e.debug)!=null&&u.call(e))){const p=Math.round((Date.now()-c)*100)/100,d=Math.round((Date.now()-m)*100)/100,b=d/16,E=(g,w)=>{for(g=String(g);g.lengths[d]!==p)))return t;s=f;let m;if(e.key&&((h=e.debug)!=null&&h.call(e))&&(m=Date.now()),t=l(...f),e.key&&((u=e.debug)!=null&&u.call(e))){const p=Math.round((Date.now()-c)*100)/100,d=Math.round((Date.now()-m)*100)/100,b=d/16,E=(g,w)=>{for(g=String(g);g.length{s=i},o}function M(r,l){if(r===void 0)throw new Error("Unexpected undefined");return r}const _=(r,l)=>Math.abs(r-l)<1.01,T=(r,l,e)=>{let s;return function(...t){r.clearTimeout(s),s=r.setTimeout(()=>l.apply(this,t),e)}},z=r=>{const{offsetWidth:l,offsetHeight:e}=r;return{width:l,height:e}},k=r=>r,W=r=>{const l=Math.max(r.startIndex-r.overscan,0),e=Math.min(r.endIndex+r.overscan,r.count-1),s=[];for(let t=l;t<=e;t++)s.push(t);return s},D=(r,l)=>{const e=r.scrollElement;if(!e)return;const s=r.targetWindow;if(!s)return;const t=o=>{const{width:i,height:h}=o;l({width:Math.round(i),height:Math.round(h)})};if(t(z(e)),!s.ResizeObserver)return()=>{};const n=new s.ResizeObserver(o=>{const i=()=>{const h=o[0];if(h!=null&&h.borderBoxSize){const u=h.borderBoxSize[0];if(u){t({width:u.inlineSize,height:u.blockSize});return}}t(z(e))};r.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()});return n.observe(e,{box:"border-box"}),()=>{n.unobserve(e)}},C={passive:!0},O=typeof window>"u"?!0:"onscrollend"in window,L=(r,l)=>{const e=r.scrollElement;if(!e)return;const s=r.targetWindow;if(!s)return;let t=0;const n=r.options.useScrollendEvent&&O?()=>{}:T(s,()=>{l(t,!1)},r.options.isScrollingResetDelay),o=c=>()=>{const{horizontal:f,isRtl:a}=r.options;t=f?e.scrollLeft*(a&&-1||1):e.scrollTop,n(),l(t,c)},i=o(!0),h=o(!1);e.addEventListener("scroll",i,C);const u=r.options.useScrollendEvent&&O;return u&&e.addEventListener("scrollend",h,C),()=>{e.removeEventListener("scroll",i),u&&e.removeEventListener("scrollend",h)}},j=(r,l,e)=>{if(l!=null&&l.borderBoxSize){const s=l.borderBoxSize[0];if(s)return Math.round(s[e.options.horizontal?"inlineSize":"blockSize"])}return r[e.options.horizontal?"offsetWidth":"offsetHeight"]},P=(r,{adjustments:l=0,behavior:e},s)=>{var t,n;const o=r+l;(n=(t=s.scrollElement)==null?void 0:t.scrollTo)==null||n.call(t,{[s.options.horizontal?"left":"top"]:o,behavior:e})};class B{constructor(l){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let e=null;const s=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(t=>{t.forEach(n=>{const o=()=>{this._measureElement(n.target,n)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var t;(t=s())==null||t.disconnect(),e=null},observe:t=>{var n;return(n=s())==null?void 0:n.observe(t,{box:"border-box"})},unobserve:t=>{var n;return(n=s())==null?void 0:n.unobserve(t)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([s,t])=>{typeof t>"u"&&delete e[s]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:k,rangeExtractor:W,onChange:()=>{},measureElement:j,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var s,t;(t=(s=this.options).onChange)==null||t.call(s,this,e)},this.maybeNotify=S(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((e=this.scrollElement)==null?void 0:e.window)??null,this.elementsCache.forEach(t=>{this.observer.observe(t)}),this.unsubs.push(this.options.observeElementRect(this,t=>{this.scrollRect=t,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(t,n)=>{this.scrollAdjustments=0,this.scrollDirection=n?this.getScrollOffset()this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,s)=>{const t=new Map,n=new Map;for(let o=s-1;o>=0;o--){const i=e[o];if(t.has(i.lane))continue;const h=n.get(i.lane);if(h==null||i.end>h.end?n.set(i.lane,i):i.endo.end===i.end?o.index-i.index:o.end-i.end)[0]:void 0},this.getMeasurementOptions=S(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,s,t,n,o,i)=>(this.prevLanes!==void 0&&this.prevLanes!==i&&(this.lanesChangedFlag=!0),this.prevLanes=i,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:s,scrollMargin:t,getItemKey:n,enabled:o,lanes:i}),{key:!1}),this.getMeasurements=S(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:s,scrollMargin:t,getItemKey:n,enabled:o,lanes:i},h)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(const a of this.laneAssignments.keys())a>=e&&this.laneAssignments.delete(a);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(a=>{this.itemSizeCache.set(a.key,a.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);const c=this.measurementsCache.slice(0,u),f=new Array(i).fill(void 0);for(let a=0;a1){d=p;const v=f[d],y=v!==void 0?c[v]:void 0;b=y?y.end+this.options.gap:s+t}else{const v=this.options.lanes===1?c[a-1]:this.getFurthestMeasurement(c,a);b=v?v.end+this.options.gap:s+t,d=v?v.lane:a%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(a,d)}const E=h.get(m),g=typeof E=="number"?E:this.options.estimateSize(a),w=b+g;c[a]={index:a,start:b,size:g,end:w,key:m,lane:d},f[d]=a}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=S(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,s,t,n)=>this.range=e.length>0&&s>0?H({measurements:e,outerSize:s,scrollOffset:t,lanes:n}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=S(()=>{let e=null,s=null;const t=this.calculateRange();return t&&(e=t.startIndex,s=t.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,s]},(e,s,t,n,o)=>n===null||o===null?[]:e({startIndex:n,endIndex:o,overscan:s,count:t}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{const s=this.options.indexAttribute,t=e.getAttribute(s);return t?parseInt(t,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this._measureElement=(e,s)=>{const t=this.indexFromElement(e),n=this.measurementsCache[t];if(!n)return;const o=n.key,i=this.elementsCache.get(o);i!==e&&(i&&this.observer.unobserve(i),this.observer.observe(e),this.elementsCache.set(o,e)),e.isConnected&&this.resizeItem(t,this.options.measureElement(e,s,this))},this.resizeItem=(e,s)=>{const t=this.measurementsCache[e];if(!t)return;const n=this.itemSizeCache.get(t.key)??t.size,o=s-n;o!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(t,o,this):t.start{if(!e){this.elementsCache.forEach((s,t)=>{s.isConnected||(this.observer.unobserve(s),this.elementsCache.delete(t))});return}this._measureElement(e,void 0)},this.getVirtualItems=S(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,s)=>{const t=[];for(let n=0,o=e.length;nthis.options.debug}),this.getVirtualItemForOffset=e=>{const s=this.getMeasurements();if(s.length!==0)return M(s[A(0,s.length-1,t=>M(s[t]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,s,t=0)=>{if(!this.scrollElement)return 0;const n=this.getSize(),o=this.getScrollOffset();s==="auto"&&(s=e>=o+n?"end":"start"),s==="center"?e+=(t-n)/2:s==="end"&&(e-=n);const i=this.getMaxScrollOffset();return Math.max(Math.min(i,e),0)},this.getOffsetForIndex=(e,s="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const t=this.measurementsCache[e];if(!t)return;const n=this.getSize(),o=this.getScrollOffset();if(s==="auto")if(t.end>=o+n-this.options.scrollPaddingEnd)s="end";else if(t.start<=o+this.options.scrollPaddingStart)s="start";else return[o,s];if(s==="end"&&e===this.options.count-1)return[this.getMaxScrollOffset(),s];const i=s==="end"?t.end+this.options.scrollPaddingEnd:t.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(i,s,t.size),s]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(e,{align:s="start",behavior:t}={})=>{t==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(e,s),{adjustments:void 0,behavior:t})},this.scrollToIndex=(e,{align:s="auto",behavior:t}={})=>{t==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),e=Math.max(0,Math.min(e,this.options.count-1)),this.currentScrollToIndex=e;let n=0;const o=10,i=u=>{if(!this.targetWindow)return;const c=this.getOffsetForIndex(e,u);if(!c){console.warn("Failed to get offset for index:",e);return}const[f,a]=c;this._scrollToOffset(f,{adjustments:void 0,behavior:t}),this.targetWindow.requestAnimationFrame(()=>{const m=()=>{if(this.currentScrollToIndex!==e)return;const p=this.getScrollOffset(),d=this.getOffsetForIndex(e,a);if(!d){console.warn("Failed to get offset for index:",e);return}_(d[0],p)||h(a)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(m):m()})},h=u=>{this.targetWindow&&this.currentScrollToIndex===e&&(n++,ni(u)):console.warn(`Failed to scroll to index ${e} after ${o} attempts.`))};i(s)},this.scrollBy=(e,{behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+e,{adjustments:void 0,behavior:s})},this.getTotalSize=()=>{var e;const s=this.getMeasurements();let t;if(s.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=((e=s[s.length-1])==null?void 0:e.end)??0;else{const n=Array(this.options.lanes).fill(null);let o=s.length-1;for(;o>=0&&n.some(i=>i===null);){const i=s[o];n[i.lane]===null&&(n[i.lane]=i.end),o--}t=Math.max(...n.filter(i=>i!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:s,behavior:t})=>{this.options.scrollToFn(e,{behavior:t,adjustments:s},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(l)}}const A=(r,l,e,s)=>{for(;r<=l;){const t=(r+l)/2|0,n=e(t);if(ns)l=t-1;else return t}return r>0?r-1:0};function H({measurements:r,outerSize:l,scrollOffset:e,lanes:s}){const t=r.length-1,n=h=>r[h].start;if(r.length<=s)return{startIndex:0,endIndex:t};let o=A(0,t,n,e),i=o;if(s===1)for(;i1){const h=Array(s).fill(0);for(;ic=0&&u.some(c=>c>=e);){const c=r[o];u[c.lane]=c.start,o--}o=Math.max(0,o-o%s),i=Math.min(t,i+(s-1-i%s))}return{startIndex:o,endIndex:i}}const I=typeof document<"u"?x.useLayoutEffect:x.useEffect;function N({useFlushSync:r=!0,...l}){const e=x.useReducer(()=>({}),{})[1],s={...l,onChange:(n,o)=>{var i;r&&o?F.flushSync(e):e(),(i=l.onChange)==null||i.call(l,n,o)}},[t]=x.useState(()=>new B(s));return t.setOptions(s),I(()=>t._didMount(),[]),I(()=>t._willUpdate()),t}function q(r){return N({observeElementRect:D,observeElementOffset:L,scrollToFn:P,...r})}/** diff --git a/frontend/dist/assets/circle-alert-kdR_gb55.js b/frontend/dist/assets/circle-alert-BgZmhbSe.js similarity index 90% rename from frontend/dist/assets/circle-alert-kdR_gb55.js rename to frontend/dist/assets/circle-alert-BgZmhbSe.js index b0309a49..d9b2bca7 100644 --- a/frontend/dist/assets/circle-alert-kdR_gb55.js +++ b/frontend/dist/assets/circle-alert-BgZmhbSe.js @@ -1,4 +1,4 @@ -import{e}from"./index-C2xvS0Jd.js";/** +import{e}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/circle-question-mark-CF3fGjhH.js b/frontend/dist/assets/circle-question-mark-CO80vHQp.js similarity index 89% rename from frontend/dist/assets/circle-question-mark-CF3fGjhH.js rename to frontend/dist/assets/circle-question-mark-CO80vHQp.js index e266104c..174ab5f1 100644 --- a/frontend/dist/assets/circle-question-mark-CF3fGjhH.js +++ b/frontend/dist/assets/circle-question-mark-CO80vHQp.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-C2xvS0Jd.js";/** +import{e as c}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/circle-stop-DHdw14LD.js b/frontend/dist/assets/circle-stop-Dh0g22OE.js similarity index 94% rename from frontend/dist/assets/circle-stop-DHdw14LD.js rename to frontend/dist/assets/circle-stop-Dh0g22OE.js index ac17b8bd..6fee8f81 100644 --- a/frontend/dist/assets/circle-stop-DHdw14LD.js +++ b/frontend/dist/assets/circle-stop-Dh0g22OE.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-C2xvS0Jd.js";/** +import{e as c}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/clock-DU0z3qMB.js b/frontend/dist/assets/clock-D_m2QiHa.js similarity index 87% rename from frontend/dist/assets/clock-DU0z3qMB.js rename to frontend/dist/assets/clock-D_m2QiHa.js index b78611c0..15e83028 100644 --- a/frontend/dist/assets/clock-DU0z3qMB.js +++ b/frontend/dist/assets/clock-D_m2QiHa.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-C2xvS0Jd.js";/** +import{e as c}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/compass-D_q1TimF.js b/frontend/dist/assets/compass-CncUthiD.js similarity index 89% rename from frontend/dist/assets/compass-D_q1TimF.js rename to frontend/dist/assets/compass-CncUthiD.js index a787e58c..153afdcf 100644 --- a/frontend/dist/assets/compass-D_q1TimF.js +++ b/frontend/dist/assets/compass-CncUthiD.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-C2xvS0Jd.js";/** +import{e as c}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/consumer-registry-DJyYnY6J.js b/frontend/dist/assets/consumer-registry-DXaeZxMm.js similarity index 92% rename from frontend/dist/assets/consumer-registry-DJyYnY6J.js rename to frontend/dist/assets/consumer-registry-DXaeZxMm.js index 7153936c..31892c0e 100644 --- a/frontend/dist/assets/consumer-registry-DJyYnY6J.js +++ b/frontend/dist/assets/consumer-registry-DXaeZxMm.js @@ -1 +1 @@ -import{ax as n,r as i}from"./index-C2xvS0Jd.js";const p=t=>(t.type??t.payload_type)===n.ADVERT,l=t=>(t.type??t.payload_type)===n.TRACE,h=t=>(t.type??t.payload_type)===n.TXT_MSG,_=t=>(t.type??t.payload_type)===n.PATH,d=t=>(t.type??t.payload_type)===n.ACK,g=t=>{const e=t.type??t.payload_type;return e===n.GRP_TXT||e===n.GRP_DATA},m=t=>(t.path_length??(Array.isArray(t.original_path)?t.original_path.length:0))>0,A=t=>!!t.src_hash,T=t=>t.airtime_ms!=null,c=new Set,o=new Map;function a(t,e){return`${t}|${e}`}function u(t,e){const s=a(t,e);o.set(s,(o.get(s)??0)+1)}function y(t,e){const s=a(t,e),r=o.get(s)??0;r>1?o.set(s,r-1):o.delete(s)}function C(t){for(const e of t){const s=a(e.target,e.fn);c.has(s)||c.add(s)}}function P(t){i.useEffect(()=>{for(const e of t)u(e.target,e.fn);return()=>{for(const e of t)y(e.target,e.fn)}},[t])}export{m as a,A as b,h as c,d,p as e,l as f,_ as g,T as h,g as i,C as r,P as u}; +import{ax as n,r as i}from"./index-D33fcA3L.js";const p=t=>(t.type??t.payload_type)===n.ADVERT,l=t=>(t.type??t.payload_type)===n.TRACE,h=t=>(t.type??t.payload_type)===n.TXT_MSG,_=t=>(t.type??t.payload_type)===n.PATH,d=t=>(t.type??t.payload_type)===n.ACK,g=t=>{const e=t.type??t.payload_type;return e===n.GRP_TXT||e===n.GRP_DATA},m=t=>(t.path_length??(Array.isArray(t.original_path)?t.original_path.length:0))>0,A=t=>!!t.src_hash,T=t=>t.airtime_ms!=null,c=new Set,o=new Map;function a(t,e){return`${t}|${e}`}function u(t,e){const s=a(t,e);o.set(s,(o.get(s)??0)+1)}function y(t,e){const s=a(t,e),r=o.get(s)??0;r>1?o.set(s,r-1):o.delete(s)}function C(t){for(const e of t){const s=a(e.target,e.fn);c.has(s)||c.add(s)}}function P(t){i.useEffect(()=>{for(const e of t)u(e.target,e.fn);return()=>{for(const e of t)y(e.target,e.fn)}},[t])}export{m as a,A as b,h as c,d,p as e,l as f,_ as g,T as h,g as i,C as r,P as u}; diff --git a/frontend/dist/assets/cpu-CUBKtjSm.js b/frontend/dist/assets/cpu--k4RdYyx.js similarity index 94% rename from frontend/dist/assets/cpu-CUBKtjSm.js rename to frontend/dist/assets/cpu--k4RdYyx.js index ece4398d..cbe62ac0 100644 --- a/frontend/dist/assets/cpu-CUBKtjSm.js +++ b/frontend/dist/assets/cpu--k4RdYyx.js @@ -1,4 +1,4 @@ -import{e as h}from"./index-C2xvS0Jd.js";/** +import{e as h}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/database-cyku2KnA.js b/frontend/dist/assets/database-Bm4-qoOy.js similarity index 90% rename from frontend/dist/assets/database-cyku2KnA.js rename to frontend/dist/assets/database-Bm4-qoOy.js index 23554710..11f06c25 100644 --- a/frontend/dist/assets/database-cyku2KnA.js +++ b/frontend/dist/assets/database-Bm4-qoOy.js @@ -1,4 +1,4 @@ -import{e}from"./index-C2xvS0Jd.js";/** +import{e}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/easing-2tSIucrJ.js b/frontend/dist/assets/easing-D0twVjny.js similarity index 57% rename from frontend/dist/assets/easing-2tSIucrJ.js rename to frontend/dist/assets/easing-D0twVjny.js index 7ef5e7c2..d568ae8a 100644 --- a/frontend/dist/assets/easing-2tSIucrJ.js +++ b/frontend/dist/assets/easing-D0twVjny.js @@ -1 +1 @@ -import{gR as s}from"./index-C2xvS0Jd.js";const e=s(.65,0,.35,1),t=s(.33,1,.68,1),c=s(.33,.67,.67,1),u=s(.76,0,.24,1);export{t as a,e as b,c,u as e}; +import{gR as s}from"./index-D33fcA3L.js";const e=s(.65,0,.35,1),t=s(.33,1,.68,1),c=s(.33,.67,.67,1),u=s(.76,0,.24,1);export{t as a,e as b,c,u as e}; diff --git a/frontend/dist/assets/element-movement-CSQuYFsD.js b/frontend/dist/assets/element-movement-BL6huHzq.js similarity index 73% rename from frontend/dist/assets/element-movement-CSQuYFsD.js rename to frontend/dist/assets/element-movement-BL6huHzq.js index 53709ebe..711c8a6f 100644 --- a/frontend/dist/assets/element-movement-CSQuYFsD.js +++ b/frontend/dist/assets/element-movement-BL6huHzq.js @@ -1 +1 @@ -import{r as o,aT as p,d3 as v,gp as b,gq as x,dj as $,bx as m}from"./index-C2xvS0Jd.js";function y(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function D(e=y){return o.useCallback((t,n)=>{if(typeof e=="string"){let u=e;return(t==null?void 0:t[u])===(n==null?void 0:n[u])}return e(t,n)},[e])}var w=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(w||{});function M(e){let t=o.useRef(null),n=p(l=>{t.current=l.pointerType,!v(l.currentTarget)&&l.pointerType==="mouse"&&l.button===w.Left&&(l.preventDefault(),e(l))}),u=p(l=>{t.current!=="mouse"&&(v(l.currentTarget)||e(l))});return{onPointerDown:n,onClick:u}}var R=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(R||{});const j={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},I=200,h=5;function E(e,{trigger:t,action:n,close:u,select:l}){let r=o.useRef(null),i=o.useRef(null),c=o.useRef(null);b(e&&t!==null,"pointerdown",s=>{x(s==null?void 0:s.target)&&t!=null&&t.contains(s.target)&&(i.current=s.x,c.current=s.y,r.current=s.timeStamp)}),b(e&&t!==null,"pointerup",s=>{var a,d;let f=r.current;if(f===null||(r.current=null,!$(s.target))||Math.abs(s.x-((a=i.current)!=null?a:s.x))I&&(l(g.target),u());break}case 2:{u();break}}},{capture:!0})}function k(e){return[e.screenX,e.screenY]}function N(){let e=o.useRef([-1,-1]);return{wasMoved(t){let n=k(t);return e.current[0]===n[0]&&e.current[1]===n[1]?!1:(e.current=n,!0)},update(t){e.current=k(t)}}}function L(e){throw new Error("Unexpected object: "+e)}var S=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(S||{});function P(e,t){let n=t.resolveItems();if(n.length<=0)return null;let u=t.resolveActiveIndex(),l=u??-1;switch(e.focus){case 0:{for(let r=0;r=0;--r)if(!t.resolveDisabled(n[r],r,n))return r;return u}case 2:{for(let r=l+1;r=0;--r)if(!t.resolveDisabled(n[r],r,n))return r;return u}case 4:{for(let r=0;r({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function T(e){let t=e.getBoundingClientRect();return`${t.x},${t.y}`}function F(e,t,n){let u=m();if(t.kind==="Tracked"){let l=function(){r!==T(e)&&(u.dispose(),n())},{position:r}=t,i=new ResizeObserver(l);i.observe(e),u.add(()=>i.disconnect()),u.addEventListener(window,"scroll",l,{passive:!0}),u.addEventListener(window,"resize",l)}return()=>u.dispose()}export{E as L,j as S,z as a,T as b,S as c,D as d,P as f,w as g,F as p,M as s,N as u}; +import{r as o,aU as p,d4 as v,gp as b,gq as $,dk as m,by as x}from"./index-D33fcA3L.js";function y(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function D(e=y){return o.useCallback((t,n)=>{if(typeof e=="string"){let u=e;return(t==null?void 0:t[u])===(n==null?void 0:n[u])}return e(t,n)},[e])}var w=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(w||{});function M(e){let t=o.useRef(null),n=p(l=>{t.current=l.pointerType,!v(l.currentTarget)&&l.pointerType==="mouse"&&l.button===w.Left&&(l.preventDefault(),e(l))}),u=p(l=>{t.current!=="mouse"&&(v(l.currentTarget)||e(l))});return{onPointerDown:n,onClick:u}}var R=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(R||{});const E={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},I=200,k=5;function N(e,{trigger:t,action:n,close:u,select:l}){let r=o.useRef(null),i=o.useRef(null),c=o.useRef(null);b(e&&t!==null,"pointerdown",s=>{$(s==null?void 0:s.target)&&t!=null&&t.contains(s.target)&&(i.current=s.x,c.current=s.y,r.current=s.timeStamp)}),b(e&&t!==null,"pointerup",s=>{var a,d;let f=r.current;if(f===null||(r.current=null,!m(s.target))||Math.abs(s.x-((a=i.current)!=null?a:s.x))I&&(l(g.target),u());break}case 2:{u();break}}},{capture:!0})}function h(e){return[e.screenX,e.screenY]}function j(){let e=o.useRef([-1,-1]);return{wasMoved(t){let n=h(t);return e.current[0]===n[0]&&e.current[1]===n[1]?!1:(e.current=n,!0)},update(t){e.current=h(t)}}}function L(e){throw new Error("Unexpected object: "+e)}var S=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(S||{});function P(e,t){let n=t.resolveItems();if(n.length<=0)return null;let u=t.resolveActiveIndex(),l=u??-1;switch(e.focus){case 0:{for(let r=0;r=0;--r)if(!t.resolveDisabled(n[r],r,n))return r;return u}case 2:{for(let r=l+1;r=0;--r)if(!t.resolveDisabled(n[r],r,n))return r;return u}case 4:{for(let r=0;r({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function T(e){let t=e.getBoundingClientRect();return`${t.x},${t.y}`}function F(e,t,n){let u=x();if(t.kind==="Tracked"){let l=function(){r!==T(e)&&(u.dispose(),n())},{position:r}=t,i=new ResizeObserver(l);i.observe(e),u.add(()=>i.disconnect()),u.addEventListener(window,"scroll",l,{passive:!0}),u.addEventListener(window,"resize",l)}return()=>u.dispose()}export{N as L,E as S,z as a,T as b,S as c,D as d,P as f,w as g,F as p,M as s,j as u}; diff --git a/frontend/dist/assets/fieldset-DQmrmWyj.js b/frontend/dist/assets/fieldset-DsbEWHIy.js similarity index 80% rename from frontend/dist/assets/fieldset-DQmrmWyj.js rename to frontend/dist/assets/fieldset-DsbEWHIy.js index a093e3b8..724d71ed 100644 --- a/frontend/dist/assets/fieldset-DQmrmWyj.js +++ b/frontend/dist/assets/fieldset-DsbEWHIy.js @@ -1 +1 @@ -import{j as a,dM as l,c as i,b2 as n,fH as c}from"./index-C2xvS0Jd.js";function x({disabled:e,className:s,children:t}){return a.jsx(l,{disabled:e,className:i("flex flex-col gap-2",s),children:t})}function m({required:e,className:s,children:t,...r}){return a.jsxs(n,{className:i("text-sm font-medium text-fg-primary select-none","data-[disabled]:opacity-50",r.title&&"cursor-help",s),...r,children:[t,e&&a.jsx("span",{className:"text-sys-red ml-0.5","aria-hidden":"true",children:"*"})]})}function o({className:e,children:s,...t}){return a.jsx(c,{className:i("text-sm text-fg-muted","data-[disabled]:opacity-50",e),...t,children:s})}export{o as D,x as F,m as L}; +import{j as a,dM as l,c as i,b3 as n,fH as c}from"./index-D33fcA3L.js";function x({disabled:e,className:s,children:t}){return a.jsx(l,{disabled:e,className:i("flex flex-col gap-2",s),children:t})}function m({required:e,className:s,children:t,...r}){return a.jsxs(n,{className:i("text-sm font-medium text-fg-primary select-none","data-[disabled]:opacity-50",r.title&&"cursor-help",s),...r,children:[t,e&&a.jsx("span",{className:"text-sys-red ml-0.5","aria-hidden":"true",children:"*"})]})}function o({className:e,children:s,...t}){return a.jsx(c,{className:i("text-sm text-fg-muted","data-[disabled]:opacity-50",e),...t,children:s})}export{o as D,x as F,m as L}; diff --git a/frontend/dist/assets/frozen-C10EXZ59.js b/frontend/dist/assets/frozen-C10EXZ59.js new file mode 100644 index 00000000..b9ac4d98 --- /dev/null +++ b/frontend/dist/assets/frozen-C10EXZ59.js @@ -0,0 +1 @@ +import{bv as l,r as o}from"./index-D33fcA3L.js";function a({children:t,freeze:e},n){let r=f(e,t);return o.isValidElement(r)?o.cloneElement(r,{ref:n}):l.createElement(l.Fragment,null,r)}const s=l.forwardRef(a);function f(t,e){let[n,r]=o.useState(e);return!t&&n!==e&&r(e),t?n:e}export{s,f as u}; diff --git a/frontend/dist/assets/frozen-Cx4cJH6f.js b/frontend/dist/assets/frozen-Cx4cJH6f.js deleted file mode 100644 index 15fcc09c..00000000 --- a/frontend/dist/assets/frozen-Cx4cJH6f.js +++ /dev/null @@ -1 +0,0 @@ -import{bu as l,r as o}from"./index-C2xvS0Jd.js";function a({children:t,freeze:e},n){let r=f(e,t);return o.isValidElement(r)?o.cloneElement(r,{ref:n}):l.createElement(l.Fragment,null,r)}const c=l.forwardRef(a);function f(t,e){let[n,r]=o.useState(e);return!t&&n!==e&&r(e),t?n:e}export{c as s,f as u}; diff --git a/frontend/dist/assets/funnel-DGVJFdsh.js b/frontend/dist/assets/funnel-BBIwSMOb.js similarity index 90% rename from frontend/dist/assets/funnel-DGVJFdsh.js rename to frontend/dist/assets/funnel-BBIwSMOb.js index 3cc93c83..58f1abe3 100644 --- a/frontend/dist/assets/funnel-DGVJFdsh.js +++ b/frontend/dist/assets/funnel-BBIwSMOb.js @@ -1,4 +1,4 @@ -import{e}from"./index-C2xvS0Jd.js";/** +import{e}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/git-branch-BhoB5t-Q.js b/frontend/dist/assets/git-branch-Ryinnbc1.js similarity index 90% rename from frontend/dist/assets/git-branch-BhoB5t-Q.js rename to frontend/dist/assets/git-branch-Ryinnbc1.js index f6ce1a6f..0be8c353 100644 --- a/frontend/dist/assets/git-branch-BhoB5t-Q.js +++ b/frontend/dist/assets/git-branch-Ryinnbc1.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-C2xvS0Jd.js";/** +import{e as c}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/hash-DjqT3oXN.js b/frontend/dist/assets/hash-Ba9bZo8v.js similarity index 91% rename from frontend/dist/assets/hash-DjqT3oXN.js rename to frontend/dist/assets/hash-Ba9bZo8v.js index 68449619..f8ba3aad 100644 --- a/frontend/dist/assets/hash-DjqT3oXN.js +++ b/frontend/dist/assets/hash-Ba9bZo8v.js @@ -1,4 +1,4 @@ -import{e}from"./index-C2xvS0Jd.js";/** +import{e}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/index-QCPybZMd.js b/frontend/dist/assets/index-5slIee7x.js similarity index 98% rename from frontend/dist/assets/index-QCPybZMd.js rename to frontend/dist/assets/index-5slIee7x.js index eaf59dc6..555dbfe2 100644 --- a/frontend/dist/assets/index-QCPybZMd.js +++ b/frontend/dist/assets/index-5slIee7x.js @@ -1 +1 @@ -import{gS as J,r as i,M as R,q as H,j as u,gT as Q,m as k,gU as Z,gV as O,d as _,c2 as ee,gW as te,gX as ne}from"./index-C2xvS0Jd.js";import{a as G}from"./index-wtt5rE5a.js";function re({children:n,isValidProp:e,...t}){e&&J(e),t={...i.useContext(R),...t},t.isStatic=H(()=>t.isStatic);const s=i.useMemo(()=>t,[JSON.stringify(t.transition),t.transformPagePoint,t.reducedMotion]);return u.jsx(R.Provider,{value:s,children:n})}function ie(n){const e=H(()=>Q(n)),{isStatic:t}=i.useContext(R);if(t){const[,s]=i.useState(n);i.useEffect(()=>e.on("change",s),[])}return e}const j="var(--mask-height, 0.15em)",E="var(--mask-width, 0.5em)",I=`calc(${E} / var(--invert-x, 1))`,M="#000 0, transparent 71%",se=`linear-gradient(to right, transparent 0, #000 ${I}, #000 calc(100% - ${I}), transparent),linear-gradient(to bottom, transparent 0, #000 ${j}, #000 calc(100% - ${j}), transparent 100%),radial-gradient(at bottom right, ${M}),radial-gradient(at bottom left, ${M}), radial-gradient(at top left, ${M}), radial-gradient(at top right, ${M})`,ae=`100% calc(100% - ${j} * 2),calc(100% - ${I} * 2) 100%,${I} ${j},${I} ${j},${I} ${j},${I} ${j}`;Z({"--invert-x":{correct:(n,{treeScale:e,projectionDelta:t})=>t.x.scale*e.x}});function oe({children:n,layoutDependency:e}){return u.jsx(k.span,{layout:!0,layoutDependency:e,"aria-hidden":!0,style:{display:"inline-flex","--invert-x":1,margin:`0 calc(-1*${E})`,padding:`calc(${j}/2) ${E}`,position:"relative",zIndex:-1,overflow:"clip",WebkitMaskImage:se,WebkitMaskSize:ae,WebkitMaskPosition:"center, center, top left, top right, bottom right, bottom left",WebkitMaskRepeat:"no-repeat"},children:n})}function K(){const n=i.useRef(!0);return i.useEffect(()=>{n.current=!1},[]),n.current}function N(n){const{width:e,fontSize:t}=getComputedStyle(n);return`${parseFloat(e)/parseFloat(t)}em`}const X=new WeakMap,ce=i.forwardRef(function({value:e,initialValue:t=e,...s},a){const{transition:x}=i.useContext(R),g=i.useRef(t).current,b=K(),c=i.useRef(null),y=i.useRef(null);i.useImperativeHandle(a,()=>y.current,[]);const w=i.useRef(new Array(10)),h=O(),f=h?e:0;i.useLayoutEffect(()=>{!c.current||!w.current[g]||(c.current.style.width=N(w.current[g]))},[]);const m=i.useRef(t);i.useLayoutEffect(()=>{var $;if(!c.current||f===m.current)return;const r=c.current.getBoundingClientRect(),o=($=y.current)==null?void 0:$.getBoundingClientRect(),v=r.height*(f-m.current)+(r.top-(o?o.top||0:r.top));return G(c.current,{y:[v,0]},x),()=>{m.current=f}},[f]);const[p,l]=i.useState();i.useEffect(()=>{if(b&&g===f||!w.current[f])return;const r=N(w.current[f]);y.current&&X.set(y.current,r),l(r)},[f]);const d=r=>u.jsx("span",{style:{display:"inline-block",padding:`calc(${j}/2) 0`},ref:o=>void(w.current[r]=o),children:r},r);return u.jsx(k.span,{...s,ref:y,layout:"position","data-state":h?void 0:"exiting",style:{display:"inline-flex",justifyContent:"center",width:p},children:u.jsxs("span",{ref:c,style:{display:"inline-flex",justifyContent:"center",flexDirection:"column",alignItems:"center",position:"relative"},children:[f!==0&&u.jsx("span",{style:{...F,bottom:"100%",left:0},children:new Array(f).fill(null).map((r,o)=>d(o))}),d(f),f!==9&&u.jsx("span",{style:{...F,top:"100%",left:0},children:new Array(9-f).fill(null).map((r,o)=>d(f+o+1))})]})})}),F={display:"flex",flexDirection:"column",alignItems:"center",position:"absolute",width:"100%"},q=i.createContext({justify:"left"}),le=i.forwardRef(function({partKey:e,type:t,children:s,layoutDependency:a,...x},g){const b=O(),{justify:c}=i.useContext(q);return u.jsx(k.span,{...x,"data-state":b?void 0:"exiting",style:{display:"inline-flex",justifyContent:c,padding:`calc(${j}/2) 0`,position:"relative"},layout:"position",layoutDependency:a,ref:g,children:u.jsx(_,{mode:"popLayout",anchorX:c,initial:!1,children:u.jsx(k.span,{layout:c==="right"?"position":!1,layoutDependency:a,initial:{opacity:0},animate:{opacity:[null,1]},exit:{opacity:[null,0]},style:{display:"inline-block",whiteSpace:"pre"},children:s},s)})})}),D=i.forwardRef(function({parts:e,justify:t="left",mode:s,style:a,name:x,layoutDependency:g,...b},c){const y=i.useRef(null);i.useImperativeHandle(c,()=>y.current,[]);const w=i.useMemo(()=>({justify:t}),[t]),h=i.useRef(null),f=K(),[m,p]=i.useState();return i.useEffect(()=>{if(!h.current)return;if(f){y.current&&(y.current.style.width=N(h.current));return}const l=Array.from(h.current.children).map(d=>{if(!(d instanceof HTMLElement))return;if(d.dataset.state==="exiting"){const v=d.nextSibling;return d.remove(),()=>{h.current&&h.current.insertBefore(d,v)}}const r=X.get(d);if(!r)return;const o=d.style.width;return d.style.width=r,()=>{d.style.width=o}});p(N(h.current));for(let d=l.length-1;d>=0;d--){const r=l[d];r&&r()}},[e.map(l=>l.value).join("")]),u.jsx(q.Provider,{value:w,children:u.jsx(k.span,{layoutDependency:g,...b,ref:y,className:`number-section-${x}`,style:{...a,display:"inline-flex",justifyContent:t,width:m},children:u.jsxs("span",{ref:h,style:{display:"inline-flex",justifyContent:"inherit",position:"relative"},children:["​",u.jsx(_,{mode:s,anchorX:t,initial:!1,children:e.map(l=>l.type==="integer"||l.type==="fraction"?u.jsx(ce,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:l.value,initialValue:f?void 0:0,layoutDependency:g},l.key):u.jsx(le,{type:l.type,partKey:l.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},layoutDependency:g,children:l.value},l.type==="literal"?`${l.key}:${l.value}`:l.key))})]})})})}),ue=(n,{locales:e,format:t},s,a)=>{const g=new Intl.NumberFormat(e,t).formatToParts(Number(n));s&&g.unshift({type:"prefix",value:s}),a&&g.push({type:"suffix",value:a});const b=[],c=[],y=[],w=[],h={},f=r=>`${r}:${h[r]=(h[r]??-1)+1}`;let m="",p=!1,l=!1;for(const r of g){m+=r.value;const o=r.type==="minusSign"||r.type==="plusSign"?"sign":r.type;switch(o){case"integer":p=!0,c.push(...r.value.split("").map(v=>({type:o,value:parseInt(v)})));break;case"group":c.push({type:o,value:r.value});break;case"decimal":l=!0,y.push({type:o,value:r.value,key:f(o)});break;case"fraction":y.push(...r.value.split("").map(v=>({type:o,value:parseInt(v),key:f(o)})));break;default:(p||l?w:b).push({type:o,value:r.value,key:f(o)})}}const d=[];for(let r=c.length-1;r>=0;r--)d.unshift({...c[r],key:f(c[r].type)});return{pre:b,integer:d,fraction:y,post:w,formatted:m}},fe={opacity:{duration:1,ease:te},layout:{type:"spring",duration:1,bounce:0},y:{type:"spring",duration:1,bounce:0}},ve=i.forwardRef(function({children:e,locales:t,format:s,transition:a,style:x,suffix:g,prefix:b,...c},y){const w=i.useMemo(()=>ue(e,{locales:t,format:s},b,g),[e,t,s]),{pre:h,integer:f,fraction:m,post:p,formatted:l}=w,d=i.useContext(R).transition;a=a??d??fe;const{layoutDependency:r}=c,o=i.useMemo(()=>{if(r!==void 0)return{layoutDependency:r,value:e}},[r,e]);return u.jsx(ee,{children:u.jsx(re,{transition:a,children:u.jsx(k.div,{...c,ref:y,layout:!0,layoutDependency:o,style:{lineHeight:1,...x,display:"inline-flex",isolation:"isolate",whiteSpace:"nowrap"},children:u.jsxs(k.div,{layout:!0,layoutDependency:o,"aria-label":l,style:{display:"inline-flex",direction:"ltr",isolation:"isolate",position:"relative",zIndex:-1},children:[u.jsx(D,{style:{padding:`calc(${j}/2) 0`},layoutDependency:o,"aria-hidden":!0,justify:"right",mode:"popLayout",parts:h,name:"pre"}),u.jsxs(oe,{layoutDependency:o,children:[u.jsx(D,{layoutDependency:o,justify:"right",parts:f,name:"integer"}),u.jsx(D,{layout:"position",layoutDependency:o,parts:m,name:"fraction"})]}),u.jsx(D,{style:{padding:`calc(${j}/2) 0`},"aria-hidden":!0,layout:"position",layoutDependency:o,mode:"popLayout",parts:p,name:"post"})]})})})})});k.create(i.Fragment);function U(n,e){return n.length>e.length||n.length>0&&!e.startsWith(n)}function Y(n,e,t){return n+(e-n)*t}function de(n,e,t,s,a){if(U(e,n))return t*a;if(s==="natural")return pe(n,e,t);if(typeof s=="number"&&s>0){const x=t*(s/100);return t+Y(-x,x,Math.random())}return t}function pe(n,e,t){const s=e.length,a=n[s],x=n[s-1];if(!a)return t;const b=n.slice(0,s).lastIndexOf(" "),c=s-b-1,y=b+1,h=n.slice(s).indexOf(" "),m=(h===-1?n.length:s+h)-y;let p=1;if(x&&/[.!?]/.test(x)&&a===" "&&(p*=3),m<=3?p*=.7:(c===0&&a!==" "&&(p*=1.5),c===m-1&&(p*=1.4)),c>0&&c3){const o=Math.min(c/m,.4);p*=1-o}ye.has(a)&&(p*=1.5),me.has(a)&&(p*=1.5),/\d/.test(a)&&(p*=1.3),m>8&&(p*=1.3),a!==a.toLowerCase()&&(p*=1.25);const l=200;if(s>l){const o=Math.min((s-l)/1e3,.3);p*=1+o}const d=Y(-.25,.25,Math.random());p*=1+d;const r=t*p;return Math.max(t*.2,r)}const ye=new Set([".",",","!","?",":",";","'",'"',"-","(",")"]),me=new Set(["!","@","#","$","%","^","&","*","(",")","_","+","{","}","|",":",'"',"<",">","?"]);function he(n,e){let t=e-1;for(;t>=0&&/\s/.test(n[t]);)t--;for(;t>=0&&!/\s/.test(n[t]);)t--;return Math.max(0,t+1)}function ge(n,e){const t=Math.min(n.length,e.length);let s=0;for(let a=0;a{var C;(C=S.current)==null||C.call(S),S.current=null},T=()=>{W.current=G(P.current,{opacity:[1,1,0,0]},{duration:b,times:[0,.5,.5,1],ease:"linear",repeat:1/0,repeatType:"reverse"})};return i.useEffect(()=>{m==="all"&&e!==v.current&&$.set(""),v.current=e},[e,m]),i.useEffect(()=>{var V;if(!y){T(),L();return}(V=W.current)==null||V.cancel();const C=()=>{const z=xe($.get(),e,m,p);$.set(z),z!==e?B():(T(),c==null||c())},B=()=>{S.current=ne(C,de(e,$.get(),A,a,l))};return S.current||B(),L},[y,c,e,A,a,l,p]),u.jsxs(o,{ref:r,...d,"aria-label":w||e,children:[u.jsx(k.span,{className:h,style:f,children:$}),u.jsx(k.span,{ref:P,className:x,style:{display:"inline-block",width:"2px",height:"1em",backgroundColor:"currentColor",position:"relative",top:"0.1em",left:"0.2em",...g}})]})});export{ve as A,ie as u}; +import{gS as J,r as i,M as R,q as H,j as u,gT as Q,m as k,gU as Z,gV as O,d as _,c3 as ee,gW as te,gX as ne}from"./index-D33fcA3L.js";import{a as G}from"./index-DuiHY5wq.js";function re({children:n,isValidProp:e,...t}){e&&J(e),t={...i.useContext(R),...t},t.isStatic=H(()=>t.isStatic);const s=i.useMemo(()=>t,[JSON.stringify(t.transition),t.transformPagePoint,t.reducedMotion]);return u.jsx(R.Provider,{value:s,children:n})}function ie(n){const e=H(()=>Q(n)),{isStatic:t}=i.useContext(R);if(t){const[,s]=i.useState(n);i.useEffect(()=>e.on("change",s),[])}return e}const j="var(--mask-height, 0.15em)",E="var(--mask-width, 0.5em)",I=`calc(${E} / var(--invert-x, 1))`,M="#000 0, transparent 71%",se=`linear-gradient(to right, transparent 0, #000 ${I}, #000 calc(100% - ${I}), transparent),linear-gradient(to bottom, transparent 0, #000 ${j}, #000 calc(100% - ${j}), transparent 100%),radial-gradient(at bottom right, ${M}),radial-gradient(at bottom left, ${M}), radial-gradient(at top left, ${M}), radial-gradient(at top right, ${M})`,ae=`100% calc(100% - ${j} * 2),calc(100% - ${I} * 2) 100%,${I} ${j},${I} ${j},${I} ${j},${I} ${j}`;Z({"--invert-x":{correct:(n,{treeScale:e,projectionDelta:t})=>t.x.scale*e.x}});function oe({children:n,layoutDependency:e}){return u.jsx(k.span,{layout:!0,layoutDependency:e,"aria-hidden":!0,style:{display:"inline-flex","--invert-x":1,margin:`0 calc(-1*${E})`,padding:`calc(${j}/2) ${E}`,position:"relative",zIndex:-1,overflow:"clip",WebkitMaskImage:se,WebkitMaskSize:ae,WebkitMaskPosition:"center, center, top left, top right, bottom right, bottom left",WebkitMaskRepeat:"no-repeat"},children:n})}function K(){const n=i.useRef(!0);return i.useEffect(()=>{n.current=!1},[]),n.current}function N(n){const{width:e,fontSize:t}=getComputedStyle(n);return`${parseFloat(e)/parseFloat(t)}em`}const X=new WeakMap,ce=i.forwardRef(function({value:e,initialValue:t=e,...s},a){const{transition:x}=i.useContext(R),g=i.useRef(t).current,b=K(),c=i.useRef(null),y=i.useRef(null);i.useImperativeHandle(a,()=>y.current,[]);const w=i.useRef(new Array(10)),h=O(),f=h?e:0;i.useLayoutEffect(()=>{!c.current||!w.current[g]||(c.current.style.width=N(w.current[g]))},[]);const m=i.useRef(t);i.useLayoutEffect(()=>{var $;if(!c.current||f===m.current)return;const r=c.current.getBoundingClientRect(),o=($=y.current)==null?void 0:$.getBoundingClientRect(),v=r.height*(f-m.current)+(r.top-(o?o.top||0:r.top));return G(c.current,{y:[v,0]},x),()=>{m.current=f}},[f]);const[p,l]=i.useState();i.useEffect(()=>{if(b&&g===f||!w.current[f])return;const r=N(w.current[f]);y.current&&X.set(y.current,r),l(r)},[f]);const d=r=>u.jsx("span",{style:{display:"inline-block",padding:`calc(${j}/2) 0`},ref:o=>void(w.current[r]=o),children:r},r);return u.jsx(k.span,{...s,ref:y,layout:"position","data-state":h?void 0:"exiting",style:{display:"inline-flex",justifyContent:"center",width:p},children:u.jsxs("span",{ref:c,style:{display:"inline-flex",justifyContent:"center",flexDirection:"column",alignItems:"center",position:"relative"},children:[f!==0&&u.jsx("span",{style:{...F,bottom:"100%",left:0},children:new Array(f).fill(null).map((r,o)=>d(o))}),d(f),f!==9&&u.jsx("span",{style:{...F,top:"100%",left:0},children:new Array(9-f).fill(null).map((r,o)=>d(f+o+1))})]})})}),F={display:"flex",flexDirection:"column",alignItems:"center",position:"absolute",width:"100%"},q=i.createContext({justify:"left"}),le=i.forwardRef(function({partKey:e,type:t,children:s,layoutDependency:a,...x},g){const b=O(),{justify:c}=i.useContext(q);return u.jsx(k.span,{...x,"data-state":b?void 0:"exiting",style:{display:"inline-flex",justifyContent:c,padding:`calc(${j}/2) 0`,position:"relative"},layout:"position",layoutDependency:a,ref:g,children:u.jsx(_,{mode:"popLayout",anchorX:c,initial:!1,children:u.jsx(k.span,{layout:c==="right"?"position":!1,layoutDependency:a,initial:{opacity:0},animate:{opacity:[null,1]},exit:{opacity:[null,0]},style:{display:"inline-block",whiteSpace:"pre"},children:s},s)})})}),D=i.forwardRef(function({parts:e,justify:t="left",mode:s,style:a,name:x,layoutDependency:g,...b},c){const y=i.useRef(null);i.useImperativeHandle(c,()=>y.current,[]);const w=i.useMemo(()=>({justify:t}),[t]),h=i.useRef(null),f=K(),[m,p]=i.useState();return i.useEffect(()=>{if(!h.current)return;if(f){y.current&&(y.current.style.width=N(h.current));return}const l=Array.from(h.current.children).map(d=>{if(!(d instanceof HTMLElement))return;if(d.dataset.state==="exiting"){const v=d.nextSibling;return d.remove(),()=>{h.current&&h.current.insertBefore(d,v)}}const r=X.get(d);if(!r)return;const o=d.style.width;return d.style.width=r,()=>{d.style.width=o}});p(N(h.current));for(let d=l.length-1;d>=0;d--){const r=l[d];r&&r()}},[e.map(l=>l.value).join("")]),u.jsx(q.Provider,{value:w,children:u.jsx(k.span,{layoutDependency:g,...b,ref:y,className:`number-section-${x}`,style:{...a,display:"inline-flex",justifyContent:t,width:m},children:u.jsxs("span",{ref:h,style:{display:"inline-flex",justifyContent:"inherit",position:"relative"},children:["​",u.jsx(_,{mode:s,anchorX:t,initial:!1,children:e.map(l=>l.type==="integer"||l.type==="fraction"?u.jsx(ce,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:l.value,initialValue:f?void 0:0,layoutDependency:g},l.key):u.jsx(le,{type:l.type,partKey:l.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},layoutDependency:g,children:l.value},l.type==="literal"?`${l.key}:${l.value}`:l.key))})]})})})}),ue=(n,{locales:e,format:t},s,a)=>{const g=new Intl.NumberFormat(e,t).formatToParts(Number(n));s&&g.unshift({type:"prefix",value:s}),a&&g.push({type:"suffix",value:a});const b=[],c=[],y=[],w=[],h={},f=r=>`${r}:${h[r]=(h[r]??-1)+1}`;let m="",p=!1,l=!1;for(const r of g){m+=r.value;const o=r.type==="minusSign"||r.type==="plusSign"?"sign":r.type;switch(o){case"integer":p=!0,c.push(...r.value.split("").map(v=>({type:o,value:parseInt(v)})));break;case"group":c.push({type:o,value:r.value});break;case"decimal":l=!0,y.push({type:o,value:r.value,key:f(o)});break;case"fraction":y.push(...r.value.split("").map(v=>({type:o,value:parseInt(v),key:f(o)})));break;default:(p||l?w:b).push({type:o,value:r.value,key:f(o)})}}const d=[];for(let r=c.length-1;r>=0;r--)d.unshift({...c[r],key:f(c[r].type)});return{pre:b,integer:d,fraction:y,post:w,formatted:m}},fe={opacity:{duration:1,ease:te},layout:{type:"spring",duration:1,bounce:0},y:{type:"spring",duration:1,bounce:0}},ve=i.forwardRef(function({children:e,locales:t,format:s,transition:a,style:x,suffix:g,prefix:b,...c},y){const w=i.useMemo(()=>ue(e,{locales:t,format:s},b,g),[e,t,s]),{pre:h,integer:f,fraction:m,post:p,formatted:l}=w,d=i.useContext(R).transition;a=a??d??fe;const{layoutDependency:r}=c,o=i.useMemo(()=>{if(r!==void 0)return{layoutDependency:r,value:e}},[r,e]);return u.jsx(ee,{children:u.jsx(re,{transition:a,children:u.jsx(k.div,{...c,ref:y,layout:!0,layoutDependency:o,style:{lineHeight:1,...x,display:"inline-flex",isolation:"isolate",whiteSpace:"nowrap"},children:u.jsxs(k.div,{layout:!0,layoutDependency:o,"aria-label":l,style:{display:"inline-flex",direction:"ltr",isolation:"isolate",position:"relative",zIndex:-1},children:[u.jsx(D,{style:{padding:`calc(${j}/2) 0`},layoutDependency:o,"aria-hidden":!0,justify:"right",mode:"popLayout",parts:h,name:"pre"}),u.jsxs(oe,{layoutDependency:o,children:[u.jsx(D,{layoutDependency:o,justify:"right",parts:f,name:"integer"}),u.jsx(D,{layout:"position",layoutDependency:o,parts:m,name:"fraction"})]}),u.jsx(D,{style:{padding:`calc(${j}/2) 0`},"aria-hidden":!0,layout:"position",layoutDependency:o,mode:"popLayout",parts:p,name:"post"})]})})})})});k.create(i.Fragment);function U(n,e){return n.length>e.length||n.length>0&&!e.startsWith(n)}function Y(n,e,t){return n+(e-n)*t}function de(n,e,t,s,a){if(U(e,n))return t*a;if(s==="natural")return pe(n,e,t);if(typeof s=="number"&&s>0){const x=t*(s/100);return t+Y(-x,x,Math.random())}return t}function pe(n,e,t){const s=e.length,a=n[s],x=n[s-1];if(!a)return t;const b=n.slice(0,s).lastIndexOf(" "),c=s-b-1,y=b+1,h=n.slice(s).indexOf(" "),m=(h===-1?n.length:s+h)-y;let p=1;if(x&&/[.!?]/.test(x)&&a===" "&&(p*=3),m<=3?p*=.7:(c===0&&a!==" "&&(p*=1.5),c===m-1&&(p*=1.4)),c>0&&c3){const o=Math.min(c/m,.4);p*=1-o}ye.has(a)&&(p*=1.5),me.has(a)&&(p*=1.5),/\d/.test(a)&&(p*=1.3),m>8&&(p*=1.3),a!==a.toLowerCase()&&(p*=1.25);const l=200;if(s>l){const o=Math.min((s-l)/1e3,.3);p*=1+o}const d=Y(-.25,.25,Math.random());p*=1+d;const r=t*p;return Math.max(t*.2,r)}const ye=new Set([".",",","!","?",":",";","'",'"',"-","(",")"]),me=new Set(["!","@","#","$","%","^","&","*","(",")","_","+","{","}","|",":",'"',"<",">","?"]);function he(n,e){let t=e-1;for(;t>=0&&/\s/.test(n[t]);)t--;for(;t>=0&&!/\s/.test(n[t]);)t--;return Math.max(0,t+1)}function ge(n,e){const t=Math.min(n.length,e.length);let s=0;for(let a=0;a{var C;(C=S.current)==null||C.call(S),S.current=null},T=()=>{W.current=G(P.current,{opacity:[1,1,0,0]},{duration:b,times:[0,.5,.5,1],ease:"linear",repeat:1/0,repeatType:"reverse"})};return i.useEffect(()=>{m==="all"&&e!==v.current&&$.set(""),v.current=e},[e,m]),i.useEffect(()=>{var V;if(!y){T(),L();return}(V=W.current)==null||V.cancel();const C=()=>{const z=xe($.get(),e,m,p);$.set(z),z!==e?B():(T(),c==null||c())},B=()=>{S.current=ne(C,de(e,$.get(),A,a,l))};return S.current||B(),L},[y,c,e,A,a,l,p]),u.jsxs(o,{ref:r,...d,"aria-label":w||e,children:[u.jsx(k.span,{className:h,style:f,children:$}),u.jsx(k.span,{ref:P,className:x,style:{display:"inline-block",width:"2px",height:"1em",backgroundColor:"currentColor",position:"relative",top:"0.1em",left:"0.2em",...g}})]})});export{ve as A,ie as u}; diff --git a/frontend/dist/assets/index-C2xvS0Jd.js b/frontend/dist/assets/index-D33fcA3L.js similarity index 99% rename from frontend/dist/assets/index-C2xvS0Jd.js rename to frontend/dist/assets/index-D33fcA3L.js index fab26072..1bcc3e5f 100644 --- a/frontend/dist/assets/index-C2xvS0Jd.js +++ b/frontend/dist/assets/index-D33fcA3L.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-TId1VvOA.js","assets/PageLayout-Cg7r5tdt.js","assets/consumer-registry-DJyYnY6J.js","assets/DataValue-9iNfucjq.js","assets/index-QCPybZMd.js","assets/index-wtt5rE5a.js","assets/node-types-BD70swWz.js","assets/meshcore-tx-constants-DgpFTAmf.js","assets/PacketList-BlTe2eo4.js","assets/chevron-up-CTCjpmk_.js","assets/primitives-Ctn6pdEU.js","assets/badge-colors-Dl76Mz8m.js","assets/chat-utils-DnJ-lYj3.js","assets/SignalIndicator-DO8Lkax5.js","assets/arrow-up-C0VG8Et4.js","assets/arrow-right-DySc3ssS.js","assets/arrow-down-4OY_dsXk.js","assets/chevron-right-C9GG0xWI.js","assets/payload-detail-BAEvS7Pl.js","assets/map-pin-CQk00ph2.js","assets/circle-question-mark-CF3fGjhH.js","assets/layers-BICmdhXR.js","assets/hash-DjqT3oXN.js","assets/clock-DU0z3qMB.js","assets/route-Awj5QSAO.js","assets/activity-BFfde9uG.js","assets/database-cyku2KnA.js","assets/useMapViewStore-DnPjO7Qt.js","assets/shield-DvZvtyKV.js","assets/MqttModeBadge-DOXwpg3i.js","assets/zap-v3FkQoQ-.js","assets/usePipelineStore-Do-g28wv.js","assets/LightSparkline-Dtyxi9BD.js","assets/link-scoring-BjtZpDDb.js","assets/AutoConfigureDialog-C6zj_Lmv.js","assets/wand-sparkles-D9rSrVnU.js","assets/ChatBubble-DsIWWOdr.js","assets/message-square-text-B47-Hjgn.js","assets/message-square-BE66c4_-.js","assets/shield-check-BB1TbeiZ.js","assets/Grid-kVOI-wJp.js","assets/Packets-DkmiTj3L.js","assets/element-movement-CSQuYFsD.js","assets/use-tree-walker-BpJfMrbM.js","assets/frozen-Cx4cJH6f.js","assets/AnalyzerFilterPanel-CckWnD46.js","assets/funnel-DGVJFdsh.js","assets/search-DPGHPI2q.js","assets/Contacts-CTRl8l-x.js","assets/listbox-DnHpTyQt.js","assets/use-text-value-CU5Ho7TY.js","assets/CollisionExplorerModal-Du9NEbAu.js","assets/BasemapLayer-DQCsZLc0.js","assets/share-2-DLfTr0kI.js","assets/target-BpFOYbOg.js","assets/map-pin-off-D8fZRJ6M.js","assets/trash-2-Def3YmfN.js","assets/ConfirmModal-eC-cl0ep.js","assets/maplibre-gl-B1CfjdFi.css","assets/Statistics-B5Y-pM3d.js","assets/easing-2tSIucrJ.js","assets/compass-D_q1TimF.js","assets/settings-2-OYYe3udS.js","assets/network-D80fXCJJ.js","assets/MeshGraph-D_cqlL51.js","assets/max-BBb5g8bL.js","assets/variants-cyDnzhWy.js","assets/git-branch-BhoB5t-Q.js","assets/rotate-ccw-Sqgw9a-1.js","assets/System-C3tiCIme.js","assets/thermometer-CG3c-cKn.js","assets/cpu-CUBKtjSm.js","assets/Logs-DyZ7duPG.js","assets/circle-stop-DHdw14LD.js","assets/Terminal-CrgP7ye2.js","assets/system-Cf6Lcq9I.js","assets/KeycapButton-BVIaMPId.js","assets/keycap-sfx-ByZp-njj.js","assets/Terminal-6GBZ9nXN.css","assets/Configuration-BmeDX9th.js","assets/pencil-55Hza1I4.js","assets/repeat-CprMAEnr.js","assets/antenna-Dr-Egqv0.js","assets/plus-CH14Vv92.js","assets/key-round-DBZOsqH6.js","assets/RoomServer-BLm1y_Ek.js","assets/fieldset-DQmrmWyj.js","assets/wifi-Bc9OxL0c.js","assets/PacketObservatory-CBpUbS9G.js","assets/Sessions-CB2LEa_r.js","assets/Mqtt-DF6wnkuy.js","assets/check-check-UEaQfqci.js","assets/wifi-off-omfJv-eS.js","assets/Companion-DeUMmHbn.js","assets/circle-alert-kdR_gb55.js","assets/Test-BEpj0lEQ.js"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-Bn3hcO_4.js","assets/PageLayout-CRN-E5xi.js","assets/consumer-registry-DXaeZxMm.js","assets/DataValue-B0xdrk88.js","assets/index-5slIee7x.js","assets/index-DuiHY5wq.js","assets/node-types-BoqnL0Eg.js","assets/meshcore-tx-constants-DgpFTAmf.js","assets/PacketList-CbRsdi2q.js","assets/chevron-up-DyOgmQ5-.js","assets/primitives-C8YoaXqf.js","assets/badge-colors-Dl76Mz8m.js","assets/chat-utils-DIy1-SG1.js","assets/SignalIndicator-DmWlnzMv.js","assets/arrow-up-C4DdHKHn.js","assets/arrow-right-aT_K-Mjc.js","assets/arrow-down-BI9NpupK.js","assets/chevron-right-D4kUPDBw.js","assets/payload-detail-DbnSd5NL.js","assets/map-pin-B_Rx-xpd.js","assets/circle-question-mark-CO80vHQp.js","assets/layers-DguV5fdN.js","assets/hash-Ba9bZo8v.js","assets/clock-D_m2QiHa.js","assets/route-5o9tQENO.js","assets/activity-D6ySIfuC.js","assets/database-Bm4-qoOy.js","assets/useMapViewStore-Ey8vE9rr.js","assets/shield-Ceq641wy.js","assets/MqttModeBadge-BtcQeS2v.js","assets/zap-C-Mue2DZ.js","assets/usePipelineStore-DDHEHTlZ.js","assets/LightSparkline-r3FtGEtW.js","assets/link-scoring-Chr3N5ba.js","assets/AutoConfigureDialog-CDgcxIyE.js","assets/wand-sparkles-CEbXzjVw.js","assets/ChatBubble-BqRoJxSW.js","assets/message-square-text-DlzXvsDV.js","assets/message-square-DFs8_yFI.js","assets/shield-check-DOoXovft.js","assets/Grid-DQYUnZsY.js","assets/Packets-DmI71CFc.js","assets/element-movement-BL6huHzq.js","assets/use-tree-walker-DjLWwhV9.js","assets/frozen-C10EXZ59.js","assets/AnalyzerFilterPanel-Cq7b3I2L.js","assets/funnel-BBIwSMOb.js","assets/search-DN8guzpX.js","assets/Contacts-2M50JufT.js","assets/listbox-DkfYDEqr.js","assets/use-text-value-iYUkduzo.js","assets/CollisionExplorerModal-P8ZOhB65.js","assets/BasemapLayer-DhvtWc_h.js","assets/share-2-BAsDxZE2.js","assets/target-B3CHoIpd.js","assets/map-pin-off-V0MBukP5.js","assets/trash-2-CUY4NG5t.js","assets/ConfirmModal-J2_Sxirm.js","assets/maplibre-gl-B1CfjdFi.css","assets/Statistics-C8dae4fy.js","assets/easing-D0twVjny.js","assets/compass-CncUthiD.js","assets/settings-2-C5Lvk9-M.js","assets/network-Btok3jeo.js","assets/MeshGraph-DJIb7g1_.js","assets/max-CkBnBUwN.js","assets/variants-ByRhxIcL.js","assets/git-branch-Ryinnbc1.js","assets/rotate-ccw-B3SnN1wY.js","assets/System-DDVQJuHy.js","assets/thermometer-A8kLkazp.js","assets/cpu--k4RdYyx.js","assets/Logs-Dy7jDjKn.js","assets/circle-stop-Dh0g22OE.js","assets/Terminal-DLdeTxtN.js","assets/system-4FyMIaL1.js","assets/KeycapButton-xWUX1i8p.js","assets/keycap-sfx-ByZp-njj.js","assets/Terminal-6GBZ9nXN.css","assets/Configuration-BMVfY1Wg.js","assets/pencil-Cg0kSr82.js","assets/repeat-DUo9RRDi.js","assets/antenna-rn7EByqR.js","assets/plus-C0dCjBh9.js","assets/key-round-n5zCigFv.js","assets/RoomServer-D7QRe_4I.js","assets/fieldset-DsbEWHIy.js","assets/wifi-D716s0ef.js","assets/PacketObservatory-Dkvi-AKO.js","assets/Sessions-ChDjzsGf.js","assets/Mqtt-C8Anxpfs.js","assets/check-check-C-QgFmon.js","assets/wifi-off-BQtV63nI.js","assets/Companion-CMsDpx5g.js","assets/circle-alert-BgZmhbSe.js","assets/Test-DjOBviXb.js"])))=>i.map(i=>d[i]); var HM=Object.defineProperty;var Qk=e=>{throw TypeError(e)};var WM=(e,t,n)=>t in e?HM(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Be=(e,t,n)=>WM(e,typeof t!="symbol"?t+"":t,n),H0=(e,t,n)=>t.has(e)||Qk("Cannot "+n);var he=(e,t,n)=>(H0(e,t,"read from private field"),n?n.call(e):t.get(e)),en=(e,t,n)=>t.has(e)?Qk("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Tt=(e,t,n,r)=>(H0(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),yt=(e,t,n)=>(H0(e,t,"access private method"),n);var Ep=(e,t,n,r)=>({set _(s){Tt(e,t,s,n)},get _(){return he(e,t,r)}});function qM(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();function GM(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var W0={exports:{}},Ed={},q0={exports:{}},qt={};/** * @license React * react.production.min.js @@ -311,7 +311,7 @@ Please change the parent to {S.contains(_)&&S.removeChild(_)}},[t]),P.jsx(hq,{isPresent:t,childRef:i,sizeRef:a,children:B.cloneElement(e,{ref:f})})}const mq=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:s,presenceAffectsLayout:o,mode:i,anchorX:a,anchorY:c,root:u})=>{const f=IE(gq),h=B.useId();let p=!0,g=B.useMemo(()=>(p=!1,{id:h,initial:t,isPresent:n,custom:s,onExitComplete:y=>{f.set(y,!0);for(const b of f.values())if(!b)return;r&&r()},register:y=>(f.set(y,!1),()=>f.delete(y))}),[n,f,r]);return o&&p&&(g={...g}),B.useMemo(()=>{f.forEach((y,b)=>f.set(b,!1))},[n]),B.useEffect(()=>{!n&&!f.size&&r&&r()},[n]),i==="popLayout"&&(e=P.jsx(pq,{isPresent:n,anchorX:a,anchorY:c,root:u,children:e})),P.jsx(Qf.Provider,{value:g,children:e})};function gq(){return new Map}function X8(e=!0){const t=B.useContext(Qf);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:s}=t,o=B.useId();B.useEffect(()=>{if(e)return s(o)},[e]);const i=B.useCallback(()=>e&&r&&r(o),[o,r,e]);return!n&&r?[!1,i]:[!0]}function Gie(){return yq(B.useContext(Qf))}function yq(e){return e===null?!0:e.isPresent}const Ip=e=>e.key||"";function F5(e){const t=[];return B.Children.forEach(e,n=>{B.isValidElement(n)&&t.push(n)}),t}const Iu=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:s=!0,mode:o="sync",propagate:i=!1,anchorX:a="left",anchorY:c="top",root:u})=>{const[f,h]=X8(i),p=B.useMemo(()=>F5(e),[e]),g=i&&!f?[]:p.map(Ip),y=B.useRef(!0),b=B.useRef(p),w=IE(()=>new Map),C=B.useRef(new Set),[v,x]=B.useState(p),[_,S]=B.useState(p);NE(()=>{y.current=!1,b.current=p;for(let A=0;A<_.length;A++){const D=Ip(_[A]);g.includes(D)?(w.delete(D),C.current.delete(D)):w.get(D)!==!0&&w.set(D,!1)}},[_,g.length,g.join("-")]);const k=[];if(p!==v){let A=[...p];for(let D=0;D<_.length;D++){const L=_[D],N=Ip(L);g.includes(N)||(A.splice(D,0,L),k.push(L))}return o==="wait"&&k.length&&(A=k),S(F5(A)),x(p),null}const{forceRender:F}=B.useContext(Af);return P.jsx(P.Fragment,{children:_.map(A=>{const D=Ip(A),L=i&&!f?!1:p===_||g.includes(D),N=()=>{if(C.current.has(D))return;if(C.current.add(D),w.has(D))w.set(D,!0);else return;let I=!0;w.forEach(U=>{U||(I=!1)}),I&&(F==null||F(),S(b.current),i&&(h==null||h()),r&&r())};return P.jsx(mq,{isPresent:L,initial:!y.current||n?void 0:!1,custom:t,presenceAffectsLayout:s,mode:o,root:u,onExitComplete:L?void 0:N,anchorX:a,anchorY:c,children:A},D)})})},bq=B.createContext(null);function vq(){const e=B.useRef(!1);return NE(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function wq(){const e=vq(),[t,n]=B.useState(0),r=B.useCallback(()=>{e.current&&n(t+1)},[t]);return[B.useCallback(()=>An.postRender(r),[r]),t]}const J8=e=>e===!0,Eq=e=>J8(e===!0)||e==="id",Cq=({children:e,id:t,inherit:n=!0})=>{const r=B.useContext(Af),s=B.useContext(bq),[o,i]=wq(),a=B.useRef(null),c=r.id||s;a.current===null&&(Eq(n)&&c&&(t=t?c+"-"+t:c),a.current={id:t,group:J8(n)&&r.group||T5()});const u=B.useMemo(()=>({...a.current,forceRender:o}),[i]);return P.jsx(Af.Provider,{value:u,children:e})},Z8=B.createContext({strict:!1}),P5={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let M5=!1;function xq(){if(M5)return;const e={};for(const t in P5)e[t]={isEnabled:n=>P5[t].some(r=>!!n[r])};_8(e),M5=!0}function eB(){return xq(),nW()}function kq(e){const t=eB();for(const n in e)t[n]={...t[n],...e[n]};_8(t)}const Sq=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function xg(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Sq.has(e)}let tB=e=>!xg(e);function Aq(e){typeof e=="function"&&(tB=t=>t.startsWith("on")?!xg(t):e(t))}try{Aq(require("@emotion/is-prop-valid").default)}catch{}function _q(e,t,n){const r={};for(const s in e)s==="values"&&typeof e.values=="object"||(tB(s)||n===!0&&xg(s)||!t&&!xg(s)||e.draggable&&s.startsWith("onDrag"))&&(r[s]=e[s]);return r}const ly=B.createContext({});function Dq(e,t){if(ay(e)){const{initial:n,animate:r}=e;return{initial:n===!1||Bf(n)?n:void 0,animate:Bf(r)?r:void 0}}return e.inherit!==!1?t:{}}function Tq(e){const{initial:t,animate:n}=Dq(e,B.useContext(ly));return B.useMemo(()=>({initial:t,animate:n}),[R5(t),R5(n)])}function R5(e){return Array.isArray(e)?e.join(" "):e}const pC=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function nB(e,t,n){for(const r in t)!Jr(t[r])&&!R8(r,n)&&(e[r]=t[r])}function Bq({transformTemplate:e},t){return B.useMemo(()=>{const n=pC();return dC(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Fq(e,t){const n=e.style||{},r={};return nB(r,n,e),Object.assign(r,Bq(e,t)),r}function Pq(e,t){const n={},r=Fq(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const rB=()=>({...pC(),attrs:{}});function Mq(e,t,n,r){const s=B.useMemo(()=>{const o=rB();return L8(o,t,N8(r),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};nB(o,e.style,e),s.style={...o,...s.style}}return s}const Rq=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function mC(e){return typeof e!="string"||e.includes("-")?!1:!!(Rq.indexOf(e)>-1||/[A-Z]/u.test(e))}function Lq(e,t,n,{latestValues:r},s,o=!1,i){const c=(i??mC(e)?Mq:Pq)(t,r,s,e),u=_q(t,typeof e=="string",o),f=e!==B.Fragment?{...u,...c,ref:n}:{},{children:h}=t,p=B.useMemo(()=>Jr(h)?h.get():h,[h]);return B.createElement(e,{...f,children:p})}function Iq({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,s){return{latestValues:Nq(n,r,s,e),renderState:t()}}function Nq(e,t,n,r){const s={},o=r(e,{});for(const p in o)s[p]=Cm(o[p]);let{initial:i,animate:a}=e;const c=ay(e),u=A8(e);t&&u&&!c&&e.inherit!==!1&&(i===void 0&&(i=t.initial),a===void 0&&(a=t.animate));let f=n?n.initial===!1:!1;f=f||i===!1;const h=f?a:i;if(h&&typeof h!="boolean"&&!iy(h)){const p=Array.isArray(h)?h:[h];for(let g=0;g(t,n)=>{const r=B.useContext(ly),s=B.useContext(Qf),o=()=>Iq(e,t,r,s);return n?o():IE(o)},jq=sB({scrapeMotionValuesFromProps:fC,createRenderState:pC}),Oq=sB({scrapeMotionValuesFromProps:j8,createRenderState:rB}),$q=Symbol.for("motionComponentSymbol");function Uq(e,t,n){const r=B.useRef(n);B.useInsertionEffect(()=>{r.current=n});const s=B.useRef(null);return B.useCallback(o=>{var a;o&&((a=e.onMount)==null||a.call(e,o)),t&&(o?t.mount(o):t.unmount());const i=r.current;if(typeof i=="function")if(o){const c=i(o);typeof c=="function"&&(s.current=c)}else s.current?(s.current(),s.current=null):i(o);else i&&(i.current=o)},[t])}const oB=B.createContext({});function zd(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function zq(e,t,n,r,s,o){var C,v;const{visualElement:i}=B.useContext(ly),a=B.useContext(Z8),c=B.useContext(Qf),u=B.useContext(hC).reducedMotion,f=B.useRef(null),h=B.useRef(!1);r=r||a.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:i,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,isSVG:o}),h.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));const p=f.current,g=B.useContext(oB);p&&!p.projection&&s&&(p.type==="html"||p.type==="svg")&&Vq(f.current,n,s,g);const y=B.useRef(!1);B.useInsertionEffect(()=>{p&&y.current&&p.update(n,c)});const b=n[f8],w=B.useRef(!!b&&!((C=window.MotionHandoffIsComplete)!=null&&C.call(window,b))&&((v=window.MotionHasOptimisedAnimation)==null?void 0:v.call(window,b)));return NE(()=>{h.current=!0,p&&(y.current=!0,window.MotionIsMounted=!0,p.updateFeatures(),p.scheduleRenderMicrotask(),w.current&&p.animationState&&p.animationState.animateChanges())}),B.useEffect(()=>{p&&(!w.current&&p.animationState&&p.animationState.animateChanges(),w.current&&(queueMicrotask(()=>{var x;(x=window.MotionHandoffMarkAsComplete)==null||x.call(window,b)}),w.current=!1),p.enteringChildren=void 0)}),p}function Vq(e,t,n,r){const{layoutId:s,layout:o,drag:i,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutCrossfade:f}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:iB(e.parent)),e.projection.setOptions({layoutId:s,layout:o,alwaysMeasureLayout:!!i||a&&zd(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:r,crossfade:f,layoutScroll:c,layoutRoot:u})}function iB(e){if(e)return e.options.allowProjection!==!1?e.projection:iB(e.parent)}function _b(e,{forwardMotionProps:t=!1,type:n}={},r,s){r&&kq(r);const o=n?n==="svg":mC(e),i=o?Oq:jq;function a(u,f){let h;const p={...B.useContext(hC),...u,layoutId:Hq(u)},{isStatic:g}=p,y=Tq(u),b=i(u,g);if(!g&&BT){Wq();const w=qq(p);h=w.MeasureLayout,y.visualElement=zq(e,b,p,s,w.ProjectionNode,o)}return P.jsxs(ly.Provider,{value:y,children:[h&&y.visualElement?P.jsx(h,{visualElement:y.visualElement,...p}):null,Lq(e,u,Uq(b,y.visualElement,f),b,g,t,o)]})}a.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const c=B.forwardRef(a);return c[$q]=e,c}function Hq({layoutId:e}){const t=B.useContext(Af).id;return t&&e!==void 0?t+"-"+e:e}function Wq(e,t){B.useContext(Z8).strict}function qq(e){const t=eB(),{drag:n,layout:r}=t;if(!n&&!r)return{};const s={...n,...r};return{MeasureLayout:n!=null&&n.isEnabled(e)||r!=null&&r.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Gq(e,t){if(typeof Proxy>"u")return _b;const n=new Map,r=(o,i)=>_b(o,i,e,t),s=(o,i)=>r(o,i);return new Proxy(s,{get:(o,i)=>i==="create"?r:(n.has(i)||n.set(i,_b(i,void 0,e,t)),n.get(i))})}const Kq=(e,t)=>t.isSVG??mC(e)?new vW(t):new hW(t,{allowProjection:e!==B.Fragment});class Yq extends Ya{constructor(t){super(t),t.animationState||(t.animationState=kW(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();iy(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let Qq=0;class Xq extends Ya{constructor(){super(...arguments),this.id=Qq++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;const s=this.node.animationState.setActive("exit",!t);n&&!t&&s.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Jq={animation:{Feature:Yq},exit:{Feature:Xq}};function eh(e){return{point:{x:e.pageX,y:e.pageY}}}const Zq=e=>t=>aC(t)&&e(t,eh(t));function pf(e,t,n,r){return Pf(e,t,Zq(n),r)}const aB=({current:e})=>e?e.ownerDocument.defaultView:null,L5=(e,t)=>Math.abs(e-t);function eG(e,t){const n=L5(e.x,t.x),r=L5(e.y,t.y);return Math.sqrt(n**2+r**2)}const I5=new Set(["auto","scroll"]);class lB{constructor(t,n,{transformPagePoint:r,contextWindow:s=window,dragSnapToOrigin:o=!1,distanceThreshold:i=3,element:a}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=g=>{this.handleScroll(g.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const g=Tb(this.lastMoveEventInfo,this.history),y=this.startEvent!==null,b=eG(g.offset,{x:0,y:0})>=this.distanceThreshold;if(!y&&!b)return;const{point:w}=g,{timestamp:C}=Nr;this.history.push({...w,timestamp:C});const{onStart:v,onMove:x}=this.handlers;y||(v&&v(this.lastMoveEvent,g),this.startEvent=this.lastMoveEvent),x&&x(this.lastMoveEvent,g)},this.handlePointerMove=(g,y)=>{this.lastMoveEvent=g,this.lastMoveEventInfo=Db(y,this.transformPagePoint),An.update(this.updatePoint,!0)},this.handlePointerUp=(g,y)=>{this.end();const{onEnd:b,onSessionEnd:w,resumeAnimation:C}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&C&&C(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=Tb(g.type==="pointercancel"?this.lastMoveEventInfo:Db(y,this.transformPagePoint),this.history);this.startEvent&&b&&b(g,v),w&&w(g,v)},!aC(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=i,this.contextWindow=s||window;const c=eh(t),u=Db(c,this.transformPagePoint),{point:f}=u,{timestamp:h}=Nr;this.history=[{...f,timestamp:h}];const{onSessionStart:p}=n;p&&p(t,Tb(u,this.history)),this.removeListeners=Xf(pf(this.contextWindow,"pointermove",this.handlePointerMove),pf(this.contextWindow,"pointerup",this.handlePointerUp),pf(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(t){let n=t.parentElement;for(;n;){const r=getComputedStyle(n);(I5.has(r.overflowX)||I5.has(r.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const r=t===window,s=r?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},o={x:s.x-n.x,y:s.y-n.y};o.x===0&&o.y===0||(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(t,s),An.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Ha(this.updatePoint)}}function Db(e,t){return t?{point:t(e.point)}:e}function N5(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Tb({point:e},t){return{point:e,delta:N5(e,cB(t)),offset:N5(e,tG(t)),velocity:nG(t,.1)}}function tG(e){return e[0]}function cB(e){return e[e.length-1]}function nG(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const s=cB(e);for(;n>=0&&(r=e[n],!(s.timestamp-r.timestamp>ji(t)));)n--;if(!r)return{x:0,y:0};const o=fo(s.timestamp-r.timestamp);if(o===0)return{x:0,y:0};const i={x:(s.x-r.x)/o,y:(s.y-r.y)/o};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function rG(e,{min:t,max:n},r){return t!==void 0&&en&&(e=r?Wn(n,e,r.max):Math.min(e,n)),e}function j5(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function sG(e,{top:t,left:n,bottom:r,right:s}){return{x:j5(e.x,n,s),y:j5(e.y,t,r)}}function O5(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.minr?n=_f(t.min,t.max-r,e.min):r>s&&(n=_f(e.min,e.max-s,t.min)),li(0,1,n)}function aG(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const bv=.35;function lG(e=bv){return e===!1?e=0:e===!0&&(e=bv),{x:$5(e,"left","right"),y:$5(e,"top","bottom")}}function $5(e,t,n){return{min:U5(e,t),max:U5(e,n)}}function U5(e,t){return typeof e=="number"?e:e[t]||0}const cG=new WeakMap;class uG{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=vr(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const o=h=>{n?(this.stopAnimation(),this.snapToCursor(eh(h).point)):this.pauseAnimation()},i=(h,p)=>{this.stopAnimation();const{drag:g,dragPropagation:y,onDragStart:b}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=WH(g),!this.openDragLock))return;this.latestPointerEvent=h,this.latestPanInfo=p,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),lo(C=>{let v=this.getAxisMotionValue(C).get()||0;if(ii.test(v)){const{projection:x}=this.visualElement;if(x&&x.layout){const _=x.layout.layoutBox[C];_&&(v=hs(_)*(parseFloat(v)/100))}}this.originPoint[C]=v}),b&&An.postRender(()=>b(h,p)),fv(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},a=(h,p)=>{this.latestPointerEvent=h,this.latestPanInfo=p;const{dragPropagation:g,dragDirectionLock:y,onDirectionLock:b,onDrag:w}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:C}=p;if(y&&this.currentDirection===null){this.currentDirection=dG(C),this.currentDirection!==null&&b&&b(this.currentDirection);return}this.updateAxis("x",p.point,C),this.updateAxis("y",p.point,C),this.visualElement.render(),w&&w(h,p)},c=(h,p)=>{this.latestPointerEvent=h,this.latestPanInfo=p,this.stop(h,p),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>lo(h=>{var p;return this.getAnimationState(h)==="paused"&&((p=this.getAxisMotionValue(h).animation)==null?void 0:p.play())}),{dragSnapToOrigin:f}=this.getProps();this.panSession=new lB(t,{onSessionStart:o,onStart:i,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:f,distanceThreshold:r,contextWindow:aB(this.visualElement),element:this.visualElement.current})}stop(t,n){const r=t||this.latestPointerEvent,s=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!s||!r)return;const{velocity:i}=s;this.startAnimation(i);const{onDragEnd:a}=this.getProps();a&&An.postRender(()=>a(r,s))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,r){const{drag:s}=this.getProps();if(!r||!Np(t,s,this.currentDirection))return;const o=this.getAxisMotionValue(t);let i=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(i=rG(i,this.constraints[t],this.elastic[t])),o.set(i)}resolveConstraints(){var o;const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(o=this.visualElement.projection)==null?void 0:o.layout,s=this.constraints;t&&zd(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=sG(r.layoutBox,t):this.constraints=!1,this.elastic=lG(n),s!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&lo(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=aG(r.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!zd(t))return!1;const r=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const o=aW(r,s.root,this.visualElement.getTransformPagePoint());let i=oG(s.layout.layoutBox,o);if(n){const a=n(sW(i));this.hasMutatedConstraints=!!a,a&&(i=T8(a))}return i}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:s,dragTransition:o,dragSnapToOrigin:i,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=lo(f=>{if(!Np(f,n,this.currentDirection))return;let h=c&&c[f]||{};i&&(h={min:0,max:0});const p=s?200:1e6,g=s?40:1e7,y={type:"inertia",velocity:r?t[f]:0,bounceStiffness:p,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...h};return this.startAxisValueAnimation(f,y)});return Promise.all(u).then(a)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return fv(this.visualElement,t),r.start(nC(t,r,0,n,this.visualElement,!1))}stopAnimation(){lo(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){lo(t=>{var n;return(n=this.getAxisMotionValue(t).animation)==null?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)==null?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps(),s=r[n];return s||this.visualElement.getValue(t,(r.initial?r.initial[t]:void 0)||0)}snapToCursor(t){lo(n=>{const{drag:r}=this.getProps();if(!Np(n,r,this.currentDirection))return;const{projection:s}=this.visualElement,o=this.getAxisMotionValue(n);if(s&&s.layout){const{min:i,max:a}=s.layout.layoutBox[n],c=o.get()||0;o.set(t[n]-Wn(i,a,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!zd(n)||!r||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};lo(i=>{const a=this.getAxisMotionValue(i);if(a&&this.constraints!==!1){const c=a.get();s[i]=iG({min:c,max:c},this.constraints[i])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),lo(i=>{if(!Np(i,t,null))return;const a=this.getAxisMotionValue(i),{min:c,max:u}=this.constraints[i];a.set(Wn(c,u,s[i]))})}addListeners(){if(!this.visualElement.current)return;cG.set(this.visualElement,this);const t=this.visualElement.current,n=pf(t,"pointerdown",c=>{const{drag:u,dragListener:f=!0}=this.getProps(),h=c.target,p=h!==t&&x8(h);u&&f&&!p&&this.start(c)}),r=()=>{const{dragConstraints:c}=this.getProps();zd(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:s}=this.visualElement,o=s.addEventListener("measure",r);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),An.read(r);const i=Pf(window,"resize",()=>this.scalePositionWithinConstraints()),a=s.addEventListener("didUpdate",(({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(lo(f=>{const h=this.getAxisMotionValue(f);h&&(this.originPoint[f]+=c[f].translate,h.set(h.get()+c[f].translate))}),this.visualElement.render())}));return()=>{i(),n(),o(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:s=!1,dragConstraints:o=!1,dragElastic:i=bv,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:s,dragConstraints:o,dragElastic:i,dragMomentum:a}}}function Np(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function dG(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class fG extends Ya{constructor(t){super(t),this.removeGroupControls=ho,this.removeListeners=ho,this.controls=new uG(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ho}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const z5=e=>(t,n)=>{e&&An.postRender(()=>e(t,n))};class hG extends Ya{constructor(){super(...arguments),this.removePointerDownListener=ho}onPointerDown(t){this.session=new lB(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:aB(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:s}=this.node.getProps();return{onSessionStart:z5(t),onStart:z5(n),onMove:r,onEnd:(o,i)=>{delete this.session,s&&An.postRender(()=>s(o,i))}}}mount(){this.removePointerDownListener=pf(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Bb=!1;class pG extends B.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:s}=this.props,{projection:o}=t;o&&(n.group&&n.group.add(o),r&&r.register&&s&&r.register(o),Bb&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),xm.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:s,isPresent:o}=this.props,{projection:i}=r;return i&&(i.isPresent=o,t.layoutDependency!==n&&i.setOptions({...i.options,layoutDependency:n}),Bb=!0,s||t.layoutDependency!==n||n===void 0||t.isPresent!==o?i.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?i.promote():i.relegate()||An.postRender(()=>{const a=i.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),iC.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:s}=t;Bb=!0,s&&(s.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(s),r&&r.deregister&&r.deregister(s))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function uB(e){const[t,n]=X8(),r=B.useContext(Af);return P.jsx(pG,{...e,layoutGroup:r,switchLayoutGroup:B.useContext(oB),isPresent:t,safeToRemove:n})}const mG={pan:{Feature:hG},drag:{Feature:fG,ProjectionNode:Q8,MeasureLayout:uB}};function V5(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const s="onHover"+n,o=r[s];o&&An.postRender(()=>o(t,eh(t)))}class gG extends Ya{mount(){const{current:t}=this.node;t&&(this.unmount=qH(t,(n,r)=>(V5(this.node,r,"Start"),s=>V5(this.node,s,"End"))))}unmount(){}}class yG extends Ya{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Xf(Pf(this.node.current,"focus",()=>this.onFocus()),Pf(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function H5(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const s="onTap"+(n==="End"?"":n),o=r[s];o&&An.postRender(()=>o(t,eh(t)))}class bG extends Ya{mount(){const{current:t}=this.node;t&&(this.unmount=YH(t,(n,r)=>(H5(this.node,r,"Start"),(s,{success:o})=>H5(this.node,s,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const vv=new WeakMap,Fb=new WeakMap,vG=e=>{const t=vv.get(e.target);t&&t(e)},wG=e=>{e.forEach(vG)};function EG({root:e,...t}){const n=e||document;Fb.has(n)||Fb.set(n,{});const r=Fb.get(n),s=JSON.stringify(t);return r[s]||(r[s]=new IntersectionObserver(wG,{root:e,...t})),r[s]}function CG(e,t,n){const r=EG(t);return vv.set(e,n),r.observe(e),()=>{vv.delete(e),r.unobserve(e)}}const xG={some:0,all:1};class kG extends Ya{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:s="some",once:o}=t,i={root:n?n.current:void 0,rootMargin:r,threshold:typeof s=="number"?s:xG[s]},a=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:f,onViewportLeave:h}=this.node.getProps(),p=u?f:h;p&&p(c)};return CG(this.node.current,i,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(SG(t,n))&&this.startObserver()}unmount(){}}function SG({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const AG={inView:{Feature:kG},tap:{Feature:bG},focus:{Feature:yG},hover:{Feature:gG}},_G={layout:{ProjectionNode:Q8,MeasureLayout:uB}},DG={...Jq,...AG,...mG,..._G},jr=Gq(DG,Kq);function TG(){!lC.current&&S8();const[e]=B.useState(vg.current);return e}const BG=350,FG={duration:.15,ease:[.4,0,.2,1]},PG={type:"tween",duration:.25,ease:[.4,0,.2,1]},MG={type:"tween",duration:.3,ease:[.4,0,.2,1]},dB=B.createContext(!1);function Kie(){return B.useContext(dB)}const fB=B.createContext(void 0);function hB(){return B.useContext(fB)}const Bi={bg:"#F8F8F8",border:"rgba(0, 0, 0, 0.12)",text:"#1A1A1A",textSecondary:"#4A4A4A",textMuted:"#737373",hoverBg:"rgba(0, 0, 0, 0.06)",ring:"rgba(0, 0, 0, 0.08)"},RG={xs:"sm:max-w-xs",sm:"sm:max-w-sm",md:"sm:max-w-md",lg:"sm:max-w-lg",xl:"sm:max-w-xl","2xl":"sm:max-w-2xl","3xl":"sm:max-w-3xl","4xl":"sm:max-w-4xl","5xl":"sm:max-w-5xl",full:"sm:max-w-[calc(100vw-2rem)]"};function pB({open:e,onClose:t,size:n="md",className:r,children:s,bottomSheet:o=!0,motionPlus:i=!1,basemapMode:a,solid:c=!1}){const u=a==="light",[f,h]=B.useState(!1),p=B.useRef(null);B.useEffect(()=>(p.current&&(clearTimeout(p.current),p.current=null),e?p.current=setTimeout(()=>{h(!0)},BG):queueMicrotask(()=>h(!1)),()=>{p.current&&(clearTimeout(p.current),p.current=null)}),[e]);const g=B.useCallback((C,v)=>{(v.offset.y>100||v.velocity.y>500)&&t()},[t]),y=i?MG:PG,b=i?.98:.99,w=o?8:4;return P.jsx(Iu,{mode:"wait",children:e&&P.jsxs(fT,{static:!0,open:e,onClose:t,className:"relative z-[10010]",children:[P.jsx(jr.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:FG,className:"fixed inset-0 bg-black/50 backdrop-blur-sm","aria-hidden":"true"}),P.jsx("div",{className:"fixed inset-0 overflow-y-auto",children:P.jsx("div",{className:qe("flex min-h-full justify-center",o?"items-end sm:items-center sm:p-4":"items-center p-4"),children:P.jsx(jr.div,{drag:o?"y":!1,dragConstraints:{top:0,bottom:0},dragElastic:{top:0,bottom:.4},onDragEnd:g,initial:{opacity:0,scale:b,y:w},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.99,y:o?40:4},transition:y,style:{willChange:"transform, opacity"},className:qe(o&&"w-full sm:w-auto"),children:P.jsx(_E,{className:qe("relative w-full shadow-2xl flex flex-col",!a&&!c&&"bg-surface/80 backdrop-blur-xl",!a&&c&&"bg-surface",!a&&"ring-1 ring-inset ring-edge-subtle",RG[n],o?"radius-card overflow-hidden pb-safe":"radius-card overflow-hidden",r),style:a?{backgroundColor:u?Bi.bg:"var(--surface)",boxShadow:`inset 0 0 0 1px ${u?Bi.ring:"rgba(255, 255, 255, 0.1)"}`}:void 0,children:P.jsx(fB.Provider,{value:a,children:P.jsx(dB.Provider,{value:f,children:s})})})})})})]})})}function LG({className:e,...t}){const n=hB(),r=n==="light";return P.jsx(dT,{...t,className:qe("text-base font-semibold sm:text-lg",!n&&"text-fg-primary",e),style:n?{color:r?Bi.text:"var(--fg-primary)"}:void 0})}function km({icon:e,title:t,onClose:n,className:r}){const s=hB(),o=s==="light";return P.jsxs("div",{className:qe("flex items-center justify-between px-4 sm:px-6 py-3 sm:py-4 border-b",!s&&"border-edge-subtle",r),style:s?{borderColor:o?Bi.border:"var(--edge-subtle)"}:void 0,children:[P.jsxs("div",{className:"flex items-center gap-3",children:[e&&P.jsx("div",{className:qe(!s&&"text-icon-card-title"),style:s?{color:o?Bi.textSecondary:"var(--icon-card-title)"}:void 0,children:e}),P.jsx(LG,{children:t})]}),n&&P.jsxs(P.Fragment,{children:[P.jsx("button",{onClick:n,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),P.jsx("button",{onClick:n,className:qe("hidden sm:flex items-center justify-center p-2 radius-inner transition-colors",!s&&"text-fg-muted hover:text-fg-primary hover:bg-subtle"),style:s?{color:o?Bi.textMuted:"var(--fg-muted)"}:void 0,onMouseEnter:i=>{s&&(i.currentTarget.style.color=o?Bi.text:"var(--fg-primary)",i.currentTarget.style.backgroundColor=o?Bi.hoverBg:"var(--subtle)")},onMouseLeave:i=>{s&&(i.currentTarget.style.color=o?Bi.textMuted:"var(--fg-muted)",i.currentTarget.style.backgroundColor="transparent")},"aria-label":"Close",children:P.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:P.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}function Vd({className:e,...t}){return P.jsx("div",{...t,className:qe("px-6 py-5",e)})}function wv({className:e,...t}){return P.jsx("div",{...t,className:qe("flex flex-col-reverse gap-3 px-6 pb-6 pt-0","sm:flex-row sm:justify-end","*:w-full sm:*:w-auto",e)})}const Sm={snappy:{type:"spring",stiffness:500,damping:30},smooth:{type:"spring",stiffness:300,damping:30},gentle:{type:"spring",stiffness:200,damping:25}},IG={fast:.15,normal:.2,medium:.3},NG={easeOut:[0,0,.2,1],easeIn:[.4,0,1,1]},jG={dropdown:{type:"spring",stiffness:500,damping:30},fade:{duration:IG.fast,ease:NG.easeOut},layoutResize:{duration:.25,ease:[.25,1,.5,1]},numberTicker:{type:"spring",visualDuration:.4,bounce:.15,opacity:{duration:.15,ease:"linear"}},numberReveal:{type:"spring",visualDuration:.6,bounce:.25,opacity:{duration:.2,ease:"linear"}}},Yie={normal:.05};function OG({className:e,...t}){return P.jsx("nav",{...t,className:qe(e,"flex h-full min-h-0 flex-col")})}function $G({className:e,...t}){return P.jsx("div",{...t,className:qe(e,"flex flex-col border-b border-edge-subtle p-4","[&>[data-slot=section]+[data-slot=section]]:mt-2.5")})}function UG({className:e,...t}){return P.jsx("div",{...t,className:qe(e,"flex flex-1 flex-col p-3","overflow-y-auto sidebar-scroll","[&>[data-slot=section]+[data-slot=section]]:mt-6")})}function zG({className:e,...t}){return P.jsx("div",{...t,className:qe(e,"mt-auto flex flex-col","[&>[data-slot=section]+[data-slot=section]]:mt-2.5")})}function VG({className:e,...t}){const n=B.useId();return P.jsx(Cq,{id:n,children:P.jsx("div",{...t,"data-slot":"section",className:qe(e,"flex flex-col gap-0.5")})})}const HG=B.forwardRef(function(t,n){const{current:r,className:s,children:o,accentColor:i,...a}=t,c=!!i,u=qe("relative isolate flex w-full items-center gap-3 radius-inner px-3 py-1.5 text-left","min-h-[34px]","text-sm font-medium","[&>svg]:w-4 [&>svg]:h-4 [&>svg]:flex-shrink-0",r?c?"text-white":"text-fg-primary [&_svg]:text-sys-blue":"text-fg-muted hover:text-fg-primary hover:bg-elevated [&_svg]:text-fg-muted hover:[&_svg]:text-fg-primary","transition-all duration-150"),f=c?{willChange:"transform",backgroundColor:i,boxShadow:[`0 0 10px 2px color-mix(in oklch, ${i} 50%, transparent)`,`0 0 4px 0 color-mix(in oklch, ${i} 70%, transparent)`].join(", ")}:{willChange:"transform"},h=c?{willChange:"transform",background:"transparent",boxShadow:[`inset 0 0 0 1.5px ${i}`,`inset 0 0 3px 0.5px color-mix(in oklch, ${i} 30%, transparent)`,`inset 0 0 6px 1px color-mix(in oklch, ${i} 14%, transparent)`,`inset 0 0 10px 2px color-mix(in oklch, ${i} 5%, transparent)`,`0 0 20px -4px color-mix(in oklch, ${i} 22%, transparent)`,`0 0 8px -2px color-mix(in oklch, ${i} 14%, transparent)`].join(", ")}:{willChange:"transform"};return P.jsxs("span",{className:qe(s,"relative"),children:[r&&P.jsx(jr.span,{layout:"position",layoutId:"sidebar-current-indicator",className:qe("absolute inset-y-1.5 -left-3 w-0.5 rounded-full",!c&&"bg-sys-blue sidebar-neo-indicator"),style:f,transition:Sm.snappy}),typeof a.href=="string"?P.jsxs(jg,{to:a.href,onClick:a.onClick,onMouseEnter:a.onMouseEnter,onMouseLeave:a.onMouseLeave,className:u,"data-current":r?"true":void 0,ref:n,children:[r&&P.jsx(jr.span,{layout:"position",layoutId:"sidebar-current-highlight",className:qe("absolute inset-0 radius-inner z-[-1]",!c&&"sidebar-neo-highlight"),style:h,transition:Sm.snappy}),o]}):P.jsxs(Yg,{...a,className:qe("cursor-default",u),"data-current":r?"true":void 0,ref:n,children:[r&&P.jsx(jr.span,{layout:"position",layoutId:"sidebar-current-highlight",className:qe("absolute inset-0 radius-inner z-[-1]",!c&&"sidebar-neo-highlight"),style:h,transition:Sm.snappy}),o]})]})});function WG({className:e,...t}){return P.jsx("span",{...t,className:qe(e,"truncate")})}function Am({className:e,variant:t="default",...n}){const r={default:"bg-subtle text-fg-muted",accent:"bg-sys-blue/20 text-sys-blue",success:"bg-sys-green/20 text-sys-green",warning:"bg-sys-indigo/20 text-sys-indigo",danger:"bg-sys-red/20 text-sys-red"};return P.jsx("span",{...n,className:qe("ml-auto flex items-center gap-1 px-1.5 py-0.5 rounded-full","text-xs font-medium",r[t],e)})}const W5=e=>{let t;const n=new Set,r=(u,f)=>{const h=typeof u=="function"?u(t):u;if(!Object.is(h,t)){const p=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(g=>g(t,p))}},s=()=>t,a={setState:r,getState:s,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u))},c=t=e(r,s,a);return a},qG=(e=>e?W5(e):W5),GG=e=>e;function KG(e,t=GG){const n=at.useSyncExternalStore(e.subscribe,at.useCallback(()=>t(e.getState()),[e,t]),at.useCallback(()=>t(e.getInitialState()),[e,t]));return at.useDebugValue(n),n}const q5=e=>{const t=qG(e),n=r=>KG(t,r);return Object.assign(n,t),n},xr=(e=>e?q5(e):q5),mB="pymc_focus_mode";function YG(){try{return localStorage.getItem(mB)==="1"}catch{return!1}}function G5(e){try{localStorage.setItem(mB,e?"1":"0")}catch{}}const gB=xr()(e=>({focusMode:YG(),toggleFocusMode:()=>e(t=>{const n=!t.focusMode;return G5(n),{focusMode:n}}),setFocusMode:t=>{G5(t),e({focusMode:t})}})),QG=()=>gB(e=>e.focusMode),yB=B.createContext(null);function XG(){const e=B.useContext(yB);if(!e)throw new Error("useSidebar must be used within a SidebarLayout");return e}const bB={type:"spring",visualDuration:.35,bounce:.15},JG=bB.visualDuration*1e3;function ZG({open:e,onClose:t,children:n}){return P.jsx(Iu,{children:e&&P.jsxs(fT,{static:!0,open:e,onClose:t,className:"lg:hidden relative z-[10002]",children:[P.jsx(jr.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25,ease:"easeOut"},className:"fixed inset-0 bg-black/60 backdrop-blur-sm","aria-hidden":"true"}),P.jsx(jr.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:bB,className:"fixed inset-y-0 left-0 w-72 max-w-[85vw] z-[10003]",children:P.jsx(_E,{className:"h-full",children:P.jsxs("div",{className:"flex h-full flex-col sidebar-panel",children:[P.jsx("div",{className:"absolute top-4 right-4 z-10",children:P.jsx(Qj,{className:"p-2 rounded-lg text-fg-muted hover:text-fg-primary hover:bg-subtle-fill transition-colors","aria-label":"Close navigation",children:P.jsx(TT,{className:"w-5 h-5"})})}),n]})})})]})})}function eK({sidebar:e,navbar:t,children:n,className:r}){const[s,o]=B.useState(!1),i=QG(),a=TG(),c=yo();B.useEffect(()=>{i&&!c.pathname.startsWith("/companion")&&gB.getState().setFocusMode(!1)},[c.pathname,i]);const u=()=>o(!0),f=()=>o(!1),h={isOpen:s,open:u,close:f,toggle:()=>o(p=>!p)};return P.jsx(yB.Provider,{value:h,children:P.jsxs("div",{className:"flex h-screen overflow-hidden bg-body",children:[P.jsx(jr.aside,{className:"hidden lg:flex flex-col flex-shrink-0 h-full relative sidebar-panel overflow-hidden",animate:{width:i?0:256},transition:a?{duration:0}:Sm.smooth,children:P.jsx(jr.div,{className:"flex flex-col h-full min-w-[256px]",animate:{opacity:i?0:1},transition:a?{duration:0}:jG.fade,children:e})}),P.jsx(ZG,{open:s,onClose:f,children:e}),P.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[P.jsx("header",{className:"lg:hidden sticky top-0 z-[10001] h-14 mobile-header",children:P.jsxs("div",{className:"flex items-center h-full px-4",children:[P.jsx("button",{onClick:u,className:"w-10 h-10 flex items-center justify-center rounded-lg hover:bg-subtle-fill active:bg-subtle-fill transition-colors mr-2","aria-label":"Open navigation",children:P.jsx(KU,{className:"w-5 h-5 text-fg-primary"})}),P.jsx("div",{className:"flex-1 min-w-0",children:t})]})}),P.jsx("main",{className:qe("flex-1 overflow-y-auto main-content",r),children:n})]})]})})}function tK({className:e,...t}){return P.jsx("nav",{...t,className:qe(e,"flex flex-1 items-center gap-3")})}function K5({className:e,...t}){return P.jsx("div",{...t,className:qe(e,"flex items-center gap-3")})}function nK({className:e,...t}){return P.jsx("div",{"aria-hidden":"true",...t,className:qe(e,"flex-1")})}const rK=[45,72,33,58,80,42,65,28,55,75,38,62];function Nt({className:e,style:t}){return P.jsx("div",{className:qe("animate-pulse bg-subtle-fill radius-badge",e),style:t})}function sK(){return P.jsx("div",{className:"p-3 radius-inner border-card bg-subtle",children:P.jsxs("div",{className:"flex items-start gap-3",children:[P.jsx(Nt,{className:"w-14 h-6 rounded shrink-0"}),P.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[P.jsx(Nt,{className:"h-4 w-full"}),P.jsx(Nt,{className:"h-4 w-3/4"}),P.jsx(Nt,{className:"h-3 w-32 mt-1"})]})]})})}function Qie({count:e=8}){return P.jsx("div",{className:"space-y-2",children:Array.from({length:e}).map((t,n)=>P.jsx(sK,{},n))})}function oK(){return P.jsxs("div",{className:"flex flex-col gap-3 h-full","aria-hidden":"true",children:[P.jsxs("div",{className:"flex items-center gap-2",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-24"})]}),P.jsx(Nt,{className:"h-8 w-20"}),P.jsxs("div",{className:"flex-1 flex flex-col justify-end gap-2",children:[P.jsx(Nt,{className:"h-3 w-full"}),P.jsx(Nt,{className:"h-3 w-3/4"})]})]})}function iK(){return P.jsxs("div",{className:"flex flex-col gap-3 h-full","aria-hidden":"true",children:[P.jsxs("div",{className:"flex items-center gap-2",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-24"})]}),P.jsx("div",{className:"flex-1 flex items-end gap-1",children:rK.slice(0,8).map((e,t)=>P.jsx(Nt,{className:"flex-1",style:{height:`${e}%`}},t))})]})}function aK({rows:e=5}){return P.jsxs("div",{className:"flex flex-col h-full","aria-hidden":"true",children:[P.jsx("div",{className:"pb-3 border-b border-edge-subtle",children:P.jsxs("div",{className:"flex items-center gap-2",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-24"})]})}),P.jsx("div",{className:"flex-1 pt-3 flex flex-col gap-3",children:Array.from({length:e}).map((t,n)=>P.jsx(Nt,{className:"h-6 w-full"},n))})]})}const vB=B.createContext(void 0);function Xie(){return B.useContext(vB)}const lK={sm:"radius-inner",md:"radius-inset",lg:"radius-card",xl:"radius-hero",full:"radius-pill",none:"radius-none"},Jie=B.forwardRef(function({children:t,elevated:n,compact:r,noPadding:s,radius:o="lg",glass:i=!0,stroke:a=!0,shadow:c,reflex:u=!1,glow:f=!1,neomorphic:h=!0,onClick:p,className:g,style:y,isLoaded:b,skeletonType:w="card",...C},v){const x=B.useContext(vB),[_,S]=B.useState(!1);B.useEffect(()=>{let I=!1;return requestAnimationFrame(()=>{requestAnimationFrame(()=>{I||S(!0)})}),()=>{I=!0}},[]);const k=b??x??_,F=c??n??!1,A=a,D={...y,...u?{"--surface-reflex":"1"}:{}},L=()=>{switch(w){case"chart":return P.jsx(iK,{});case"list":return P.jsx(aK,{});default:return P.jsx(oK,{})}},N=qe(lK[o],i&&(n?"bg-surface/85 backdrop-blur-xl":"bg-surface/80 backdrop-blur-lg"),!i&&"bg-surface",h&&"depth-raised",A&&!h&&!f&&"ring-1 ring-inset ring-edge-subtle",f&&"ring-1 ring-inset ring-sys-blue/40",F&&(n?"shadow-xl":"shadow-lg"),u&&"surface-reflex","h-full flex flex-col relative",!s&&(r?"p-3 sm:p-4":"p-4 sm:p-5"),p&&"cursor-pointer",g);return k?P.jsx("div",{ref:v,"data-card-surface":!0,className:N,style:D,onClick:p,...C,children:t}):P.jsx("div",{ref:v,"data-card-surface":!0,className:N,style:D,...C,children:L()})});function Zie({title:e,icon:t,badge:n,badgeColor:r="teal",subtitle:s,actions:o,iconColor:i="text-icon-card-title",listHeader:a=!1,stackActionsOnMobile:c=!1,stackBreakpoint:u="sm",titleExtra:f,onClick:h,className:p}){const g="px-5 py-4 border-b border-edge-subtle",y={sm:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 min-h-[32px]",md:"flex flex-col md:flex-row md:items-center md:justify-between gap-2 min-h-[32px]",lg:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-2 min-h-[32px]"},b=P.jsxs(P.Fragment,{children:[t&&P.jsx("span",{className:qe("icon-md flex items-center justify-center",i),children:t}),P.jsx("span",{className:"type-micro",children:e}),n&&P.jsx(aU,{color:r,children:n}),f]}),w=h?"button":"div",C=h?{onClick:h,type:"button"}:{};return c&&o?P.jsxs(w,{...C,className:qe("flex flex-col gap-1 flex-shrink-0",a?g:"mb-3",h&&"w-full text-left cursor-pointer",p),children:[P.jsxs("div",{className:y[u],children:[P.jsx("div",{className:"flex items-center gap-3",children:b}),P.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:o})]}),s&&P.jsx("p",{className:"type-label text-fg-muted ml-8",children:s})]}):P.jsxs(w,{...C,className:qe("flex flex-col gap-1 flex-shrink-0",a?g:"mb-3",h&&"w-full text-left cursor-pointer",p),children:[P.jsxs("div",{className:"flex items-center justify-between gap-2 min-h-[32px]",children:[P.jsx("div",{className:"flex items-center gap-3",children:b}),o&&P.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:o})]}),s&&P.jsx("p",{className:"type-label text-fg-muted ml-8",children:s})]})}B.forwardRef(function({children:t,icon:n,className:r,...s},o){return P.jsxs("h3",{ref:o,className:qe("flex items-center gap-2","text-base font-semibold text-fg-primary",r),...s,children:[n&&P.jsx("span",{className:"text-icon-card-title w-5 h-5 flex-shrink-0",children:n}),t]})});B.forwardRef(function({children:t,className:n,...r},s){return P.jsx("p",{ref:s,className:qe("text-sm text-fg-muted",n),...r,children:t})});const eae=B.forwardRef(function({children:t,centered:n,className:r,...s},o){return P.jsx("div",{ref:o,className:qe("flex-1 min-h-0",n&&"flex items-center justify-center",r),...s,children:t})});B.forwardRef(function({children:t,className:n,...r},s){return P.jsx("div",{ref:s,className:qe("flex items-center justify-end gap-3","pt-4 mt-4","border-t border-edge-subtle",n),...r,children:t})});B.forwardRef(function({children:t,border:n,className:r,...s},o){return P.jsx("div",{ref:o,className:qe(n&&"pt-4 mt-4 border-t border-edge-subtle",r),...s,children:t})});function cK({defaultOpen:e=!1,className:t,children:n}){return P.jsx(pT,{defaultOpen:e,children:P.jsx("div",{className:qe("flex flex-col",t),children:n})})}const uK=B.forwardRef(function({className:t,icon:n,children:r,...s},o){return P.jsx(mg,{ref:o,className:qe("flex w-full items-center justify-between gap-3","px-3 py-2 radius-inner","text-sm font-medium text-fg-muted","row-hover hover:text-fg-primary","ring-focus",t),...s,children:({open:i})=>P.jsxs(P.Fragment,{children:[r,P.jsx("span",{className:qe("transition-transform duration-200",i?"rotate-180":"rotate-0"),children:n||P.jsx(J1,{className:"w-4 h-4"})})]})})});function dK({direction:e="down",className:t,children:n}){const r={hidden:{height:0,opacity:0,y:e==="up"?8:-8},visible:{height:"auto",opacity:1,y:0}};return P.jsx(PE,{static:!0,children:({open:s})=>P.jsx(Iu,{initial:!1,children:s&&P.jsx(jr.div,{initial:"hidden",animate:"visible",exit:"hidden",variants:r,transition:{height:{duration:.2,ease:[.4,0,.2,1]},opacity:{duration:.15},y:{duration:.15}},className:qe("overflow-hidden",t),children:P.jsx("div",{className:qe(e==="up"?"pb-2":"pt-2"),children:n})})})})}function fK({label:e,icon:t,defaultOpen:n=!0,direction:r="down",className:s,triggerStyle:o,dataId:i,children:a}){const c=i?{[`data-${i}-disclosure`]:!0}:{},u=P.jsxs("span",{className:"flex items-center gap-3",children:[t&&P.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title",children:t}),P.jsx("span",{className:"type-micro",children:e})]});return r==="up"?P.jsx(pT,{defaultOpen:n,children:({open:f})=>P.jsxs("div",{className:qe("relative",s),children:[P.jsx(PE,{static:!0,className:"relative z-50",children:P.jsx(Iu,{initial:!1,mode:"wait",children:f&&P.jsxs(jr.div,{initial:{y:12,scale:.97,opacity:0},animate:{y:0,scale:1,opacity:1},exit:{y:6,scale:.98,opacity:0},transition:{type:"spring",stiffness:400,damping:32,mass:.8,opacity:{duration:.15,ease:[.4,0,.2,1]}},className:"absolute bottom-full left-0 right-0 z-50 mb-1 origin-bottom radius-inset shadow-lg border-card bg-surface",children:[P.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[P.jsxs("span",{className:"flex items-center gap-3",children:[t&&P.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title",children:t}),P.jsx("span",{className:"type-micro",children:e})]}),P.jsx(mg,{className:"p-1 rounded hover:bg-subtle-fill-strong transition-colors",children:P.jsx(jr.span,{initial:{rotate:0},animate:{rotate:180},exit:{rotate:0},transition:{type:"spring",stiffness:400,damping:25},children:P.jsx(J1,{className:"w-4 h-4"})})})]}),P.jsx("div",{className:"px-3 pb-3",children:a})]})})}),P.jsx(jr.div,{animate:{opacity:f?.4:1,scale:f?.98:1},transition:{type:"spring",stiffness:500,damping:35},children:P.jsxs(mg,{...c,style:o,className:qe("flex w-full items-center justify-between gap-3","px-3 py-2 rounded-none rounded-t-lg","bg-surface depth-stroke-raised","text-sm font-medium text-fg-muted","hover:bg-elevated hover:text-fg-primary transition-colors","ring-focus"),children:[u,P.jsx(jr.span,{animate:{rotate:f?180:0},transition:{type:"spring",stiffness:400,damping:25},children:P.jsx(J1,{className:"w-4 h-4"})})]})})]})}):P.jsxs(cK,{defaultOpen:n,className:s,children:[P.jsx(uK,{...c,children:u}),P.jsx(dK,{direction:"down",children:P.jsx("div",{className:"bg-subtle-fill radius-inset mx-1 mt-1",children:a})})]})}const jp=8;function hK(e,t,n){const r=window.scrollY,s=window.scrollX;switch(n){case"top":return{top:e.top+r-t.height-jp,left:e.left+s+(e.width-t.width)/2};case"bottom":return{top:e.bottom+r+jp,left:e.left+s+(e.width-t.width)/2};case"left":return{top:e.top+r+(e.height-t.height)/2,left:e.left+s-t.width-jp};case"right":return{top:e.top+r+(e.height-t.height)/2,left:e.right+s+jp}}}const pK=e=>({hidden:{opacity:0,scale:.96,...{top:{y:4},bottom:{y:-4},left:{x:4},right:{x:-4}}[e]},visible:{opacity:1,scale:1,x:0,y:0}});function mK({placement:e}){const t=qe("absolute w-2 h-2 rotate-45",e==="top"&&"bottom-[-4px] left-1/2 -translate-x-1/2",e==="bottom"&&"top-[-4px] left-1/2 -translate-x-1/2",e==="left"&&"right-[-4px] top-1/2 -translate-y-1/2",e==="right"&&"left-[-4px] top-1/2 -translate-y-1/2");return P.jsx("span",{className:t,style:{backgroundColor:"var(--tooltip-bg)"}})}function gK({content:e,children:t,placement:n="top",delay:r=200,arrow:s=!0,disabled:o=!1,className:i}){const[a,c]=B.useState(!1),[u,f]=B.useState({top:0,left:0}),[h,p]=B.useState(!1),g=B.useRef(null),y=B.useRef(null),b=B.useRef();B.useEffect(()=>{p(!0)},[]),B.useEffect(()=>{if(!a||!g.current||!y.current)return;const S=g.current.getBoundingClientRect(),k=y.current.getBoundingClientRect(),F=hK(S,k,n),A=window.innerWidth-k.width-8,D=window.innerHeight+window.scrollY-k.height-8;f({top:Math.max(8,Math.min(F.top,D)),left:Math.max(8,Math.min(F.left,A))})},[a,n]);const w=B.useCallback(()=>{o||(b.current=setTimeout(()=>{c(!0)},r))},[r,o]),C=B.useCallback(()=>{b.current&&clearTimeout(b.current),c(!1)},[]);if(B.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]),!B.isValidElement(t))return t;const v=B.cloneElement(t,{ref:g,onMouseEnter:S=>{var k,F;w(),(F=(k=t.props).onMouseEnter)==null||F.call(k,S)},onMouseLeave:S=>{var k,F;C(),(F=(k=t.props).onMouseLeave)==null||F.call(k,S)},onFocus:S=>{var k,F;w(),(F=(k=t.props).onFocus)==null||F.call(k,S)},onBlur:S=>{var k,F;C(),(F=(k=t.props).onBlur)==null||F.call(k,S)}}),x=pK(n),_=P.jsx(Iu,{children:a&&P.jsxs(jr.div,{ref:y,initial:"hidden",animate:"visible",exit:"hidden",variants:x,transition:{duration:.15,ease:"easeOut"},className:qe("fixed z-[10020] px-2.5 py-1.5 text-xs font-medium","rounded-lg","pointer-events-none",i),style:{top:u.top,left:u.left,backgroundColor:"var(--tooltip-bg)",color:"var(--tooltip-fg)",border:"1px solid var(--tooltip-border)",boxShadow:"var(--tooltip-shadow)"},role:"tooltip",children:[e,s&&P.jsx(mK,{placement:n})]})});return P.jsxs(P.Fragment,{children:[v,h&&Au.createPortal(_,document.body)]})}const wB={sm:{track:"h-5 w-9",thumb:"h-3.5 w-3.5",translate:"translate-x-[18px]",icon:"w-3 h-3",dot:"w-2 h-2"},md:{track:"h-6 w-11",thumb:"h-4 w-4",translate:"translate-x-[22px]",icon:"w-4 h-4",dot:"w-2.5 h-2.5"},lg:{track:"h-7 w-14",thumb:"h-5 w-5",translate:"translate-x-[30px]",icon:"w-4 h-4",dot:"w-3 h-3"}},tae=B.forwardRef(function({enabled:t,onChange:n,label:r,description:s,tooltip:o,size:i="md",color:a="muted",dangerOff:c=!1,disabled:u=!1,status:f="idle",name:h,className:p},g){const y=wB[i],b=f==="loading",w=a==="muted";return P.jsxs(sy,{disabled:u||b,className:qe("flex items-center gap-3",p),children:[P.jsx(mT,{ref:g,checked:t,onChange:n,name:h,className:qe(w?"toggle-switch-track":"group relative inline-flex shrink-0 items-center rounded-full border-2",y.track,!w&&(t?"bg-toggle-on border-toggle-on":"bg-toggle-off border-edge-subtle"),"disabled:opacity-50 disabled:cursor-not-allowed","ring-focus","transition-all duration-200"),"data-size":i,children:P.jsx("span",{className:qe(w?"toggle-switch-thumb":"relative inline-flex items-center justify-center bg-white shadow-lg","transform rounded-full transition-transform duration-200",y.thumb,t?y.translate:"translate-x-[4px]"),children:w&&P.jsx("span",{className:qe("toggle-switch-dot",y.dot,c?qe("opacity-100",!t&&"toggle-switch-dot-danger"):t?"opacity-100":"opacity-0")})})}),(r||s||o)&&P.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r&&P.jsx(Gf,{className:qe("text-sm font-medium cursor-pointer select-none",u?"text-fg-muted":"text-fg-primary"),children:r}),o&&P.jsx(gK,{content:o,placement:"top",children:P.jsx("span",{className:"text-fg-muted hover:text-fg-secondary cursor-help transition-colors",children:P.jsx(NU,{className:"w-3.5 h-3.5"})})}),s&&!o&&P.jsx(Pu,{className:"text-xs text-fg-muted",children:s})]}),f!=="idle"&&P.jsxs("div",{className:"flex items-center shrink-0",children:[f==="loading"&&P.jsx(DT,{className:qe(y.icon,"text-fg-muted animate-spin")}),f==="success"&&P.jsx(oy,{className:qe(y.icon,"text-sys-green")}),f==="error"&&P.jsx(TT,{className:qe(y.icon,"text-sys-red")})]})]})}),nae=B.forwardRef(function({enabled:t,onChange:n,size:r="md",disabled:s=!1,"aria-label":o,className:i},a){const c=wB[r];return P.jsx(mT,{ref:a,checked:t,onChange:n,disabled:s,"aria-label":o,className:qe("toggle-switch-track",c.track,"disabled:opacity-50 disabled:cursor-not-allowed","ring-focus","transition-all duration-200",i),"data-size":r,children:P.jsx("span",{className:qe("toggle-switch-thumb","transform rounded-full transition-transform duration-200",c.thumb,t?c.translate:"translate-x-[4px]"),children:P.jsx("span",{className:qe("toggle-switch-dot",c.dot,t?"opacity-100":"opacity-0")})})})}),yK={sm:{input:"h-8 text-sm px-3",icon:"w-4 h-4",iconPadding:"pl-8",trailingIconPadding:"pr-8"},md:{input:"h-[38px] text-sm px-4",icon:"w-4 h-4",iconPadding:"pl-10",trailingIconPadding:"pr-10"},lg:{input:"h-11 text-base px-4",icon:"w-5 h-5",iconPadding:"pl-11",trailingIconPadding:"pr-11"}},EB=B.forwardRef(function({type:t="text",size:n="md",invalid:r=!1,leadingIcon:s,trailingIcon:o,leadingAddon:i,trailingAddon:a,className:c,disabled:u,...f},h){const p=yK[n],g=s||i,y=o||a;return i||a?P.jsxs("div",{className:qe("flex",c),children:[i&&P.jsx("span",{className:qe("inline-flex items-center px-3 rounded-l-lg border border-r-0","bg-input-bg text-fg-muted text-sm",r?"border-sys-red":"border-input-border"),children:i}),P.jsx("input",{ref:h,type:t,disabled:u,className:qe("flex-1 min-w-0 font-mono",p.input,"bg-input-bg",r?"border border-sys-red":"border border-input-border","text-fg-primary placeholder:text-fg-muted",r?"ring-focus-error":"ring-focus-inset",!u&&"hover:border-edge-strong","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors",i&&!a&&"rounded-r-lg",a&&!i&&"rounded-l-lg",!i&&!a&&"radius-inner"),...f}),a&&P.jsx("span",{className:qe("inline-flex items-center px-3 rounded-r-lg border border-l-0","bg-input-bg text-fg-muted text-sm",r?"border-sys-red":"border-input-border"),children:a})]}):P.jsxs("div",{className:qe("relative",c),children:[s&&P.jsx("div",{className:qe("absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none","text-fg-muted"),children:P.jsx("span",{className:p.icon,children:s})}),P.jsx("input",{ref:h,type:t,disabled:u,className:qe("w-full radius-inner font-mono",p.input,g&&p.iconPadding,y&&p.trailingIconPadding,"bg-input-bg",r?"border border-sys-red":"border border-input-border","text-fg-primary placeholder:text-fg-muted",r?"ring-focus-error":"ring-focus-inset",!u&&"hover:border-edge-strong","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors"),...f}),o&&P.jsx("div",{className:qe("absolute inset-y-0 right-0 flex items-center pr-3","text-fg-muted"),children:P.jsx("span",{className:p.icon,children:o})})]})}),rae=B.forwardRef(function({label:t,description:n,errorMessage:r,required:s,invalid:o,className:i,...a},c){const u=o&&r;return P.jsxs(sy,{className:qe("flex flex-col gap-1.5",i),children:[t&&P.jsxs(Gf,{className:"text-sm font-medium text-fg-primary",children:[t,s&&P.jsx("span",{className:"text-sys-red ml-0.5",children:"*"})]}),n&&!u&&P.jsx(Pu,{className:"text-xs text-fg-muted -mt-0.5",children:n}),P.jsx(EB,{ref:c,invalid:o,...a}),u&&P.jsx("p",{className:"text-xs text-sys-red",children:r})]})});B.forwardRef(function({value:t,onChange:n,min:r,max:s,step:o=1,precision:i,...a},c){const u=h=>{const p=h.target.value;if(p===""||p==="-"){n(0);return}const g=parseFloat(p);if(!isNaN(g)){const y=r!==void 0&&s!==void 0?Math.min(Math.max(g,r),s):r!==void 0?Math.max(g,r):s!==void 0?Math.min(g,s):g;n(y)}},f=i!==void 0&&typeof t=="number"?t.toFixed(i):t;return P.jsx(EB,{ref:c,type:"number",value:f,onChange:u,min:r,max:s,step:o,...a})});const bK={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"},vK=B.forwardRef(function({rows:t=3,resize:n="vertical",invalid:r=!1,disabled:s,className:o,...i},a){return P.jsx("textarea",{ref:a,rows:t,disabled:s,className:qe("w-full radius-inner px-4 py-3 text-sm",bK[n],"bg-subtle",r?"border border-sys-red":"border-control","text-fg-primary placeholder:text-fg-muted",r?"ring-focus-error":"ring-focus-inset",!s&&"hover:border-edge-strong","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors",o),...i})});B.forwardRef(function({label:t,description:n,errorMessage:r,required:s,invalid:o,showCount:i,maxLength:a,value:c,className:u,...f},h){const p=o&&r,g=typeof c=="string"?c.length:0;return P.jsxs(sy,{className:qe("flex flex-col gap-1.5",u),children:[t&&P.jsxs(Gf,{className:"text-sm font-medium text-fg-primary",children:[t,s&&P.jsx("span",{className:"text-sys-red ml-0.5",children:"*"})]}),n&&!p&&P.jsx(Pu,{className:"text-xs text-fg-muted -mt-0.5",children:n}),P.jsx(vK,{ref:h,invalid:o,maxLength:a,value:c,...f}),P.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p?P.jsx("p",{className:"text-xs text-sys-red flex-1",children:r}):P.jsx("span",{}),i&&a&&P.jsxs("span",{className:qe("text-xs",g>a?"text-sys-red":"text-fg-muted"),children:[g,"/",a]})]})]})});const wK={sm:{box:"h-4 w-4",icon:"h-3 w-3",radius:"rounded"},md:{box:"h-5 w-5",icon:"h-3.5 w-3.5",radius:"rounded-md"},lg:{box:"h-6 w-6",icon:"h-4 w-4",radius:"rounded-md"}},sae=B.forwardRef(function({checked:t,onChange:n,indeterminate:r=!1,label:s,description:o,size:i="md",disabled:a=!1,name:c,value:u,className:f},h){const p=wK[i];return P.jsxs(sy,{disabled:a,className:qe("flex items-start gap-3",f),children:[P.jsxs(Gj,{ref:h,checked:t,onChange:n,name:c,value:u,className:qe("group relative flex shrink-0 items-center justify-center",p.box,p.radius,"border-2 transition-all duration-150",!t&&!r&&"border-edge-subtle bg-subtle",(t||r)&&"border-sys-blue bg-sys-blue",!t&&!r&&!a&&"hover:border-edge-strong","ring-focus","disabled:opacity-50 disabled:cursor-not-allowed"),children:[t&&!r&&P.jsx(oy,{className:qe(p.icon,"text-white stroke-[3]")}),r&&P.jsx(JU,{className:qe(p.icon,"text-white stroke-[3]")})]}),(s||o)&&P.jsxs("div",{className:"flex-1 min-w-0 select-none",children:[s&&P.jsx(Gf,{className:qe("text-sm font-medium cursor-pointer",a?"text-fg-muted":"text-fg-primary"),children:s}),o&&P.jsx(Pu,{className:"text-xs text-fg-muted mt-0.5",children:o})]})]})});B.createContext({variant:"default",divider:"subtle",grid:!0});const Ev="0.9.318",Y5="'JetBrains Mono', monospace";function EK({height:e=16,responsive:t=!1,className:n=""}){const r="var(--sys-blue)",s="var(--fg-primary)";if(t)return P.jsxs("svg",{className:n,viewBox:"0 0 145 24",preserveAspectRatio:"xMidYMid meet",role:"img","aria-label":"pyMC:Console",style:{display:"block",width:"80%",height:"auto"},children:[P.jsx("style",{children:` + `),()=>{S.contains(_)&&S.removeChild(_)}},[t]),P.jsx(hq,{isPresent:t,childRef:i,sizeRef:a,children:B.cloneElement(e,{ref:f})})}const mq=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:s,presenceAffectsLayout:o,mode:i,anchorX:a,anchorY:c,root:u})=>{const f=IE(gq),h=B.useId();let p=!0,g=B.useMemo(()=>(p=!1,{id:h,initial:t,isPresent:n,custom:s,onExitComplete:y=>{f.set(y,!0);for(const b of f.values())if(!b)return;r&&r()},register:y=>(f.set(y,!1),()=>f.delete(y))}),[n,f,r]);return o&&p&&(g={...g}),B.useMemo(()=>{f.forEach((y,b)=>f.set(b,!1))},[n]),B.useEffect(()=>{!n&&!f.size&&r&&r()},[n]),i==="popLayout"&&(e=P.jsx(pq,{isPresent:n,anchorX:a,anchorY:c,root:u,children:e})),P.jsx(Qf.Provider,{value:g,children:e})};function gq(){return new Map}function X8(e=!0){const t=B.useContext(Qf);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:s}=t,o=B.useId();B.useEffect(()=>{if(e)return s(o)},[e]);const i=B.useCallback(()=>e&&r&&r(o),[o,r,e]);return!n&&r?[!1,i]:[!0]}function Gie(){return yq(B.useContext(Qf))}function yq(e){return e===null?!0:e.isPresent}const Ip=e=>e.key||"";function F5(e){const t=[];return B.Children.forEach(e,n=>{B.isValidElement(n)&&t.push(n)}),t}const Iu=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:s=!0,mode:o="sync",propagate:i=!1,anchorX:a="left",anchorY:c="top",root:u})=>{const[f,h]=X8(i),p=B.useMemo(()=>F5(e),[e]),g=i&&!f?[]:p.map(Ip),y=B.useRef(!0),b=B.useRef(p),w=IE(()=>new Map),C=B.useRef(new Set),[v,x]=B.useState(p),[_,S]=B.useState(p);NE(()=>{y.current=!1,b.current=p;for(let A=0;A<_.length;A++){const D=Ip(_[A]);g.includes(D)?(w.delete(D),C.current.delete(D)):w.get(D)!==!0&&w.set(D,!1)}},[_,g.length,g.join("-")]);const k=[];if(p!==v){let A=[...p];for(let D=0;D<_.length;D++){const L=_[D],N=Ip(L);g.includes(N)||(A.splice(D,0,L),k.push(L))}return o==="wait"&&k.length&&(A=k),S(F5(A)),x(p),null}const{forceRender:F}=B.useContext(Af);return P.jsx(P.Fragment,{children:_.map(A=>{const D=Ip(A),L=i&&!f?!1:p===_||g.includes(D),N=()=>{if(C.current.has(D))return;if(C.current.add(D),w.has(D))w.set(D,!0);else return;let I=!0;w.forEach(U=>{U||(I=!1)}),I&&(F==null||F(),S(b.current),i&&(h==null||h()),r&&r())};return P.jsx(mq,{isPresent:L,initial:!y.current||n?void 0:!1,custom:t,presenceAffectsLayout:s,mode:o,root:u,onExitComplete:L?void 0:N,anchorX:a,anchorY:c,children:A},D)})})},bq=B.createContext(null);function vq(){const e=B.useRef(!1);return NE(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function wq(){const e=vq(),[t,n]=B.useState(0),r=B.useCallback(()=>{e.current&&n(t+1)},[t]);return[B.useCallback(()=>An.postRender(r),[r]),t]}const J8=e=>e===!0,Eq=e=>J8(e===!0)||e==="id",Cq=({children:e,id:t,inherit:n=!0})=>{const r=B.useContext(Af),s=B.useContext(bq),[o,i]=wq(),a=B.useRef(null),c=r.id||s;a.current===null&&(Eq(n)&&c&&(t=t?c+"-"+t:c),a.current={id:t,group:J8(n)&&r.group||T5()});const u=B.useMemo(()=>({...a.current,forceRender:o}),[i]);return P.jsx(Af.Provider,{value:u,children:e})},Z8=B.createContext({strict:!1}),P5={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let M5=!1;function xq(){if(M5)return;const e={};for(const t in P5)e[t]={isEnabled:n=>P5[t].some(r=>!!n[r])};_8(e),M5=!0}function eB(){return xq(),nW()}function kq(e){const t=eB();for(const n in e)t[n]={...t[n],...e[n]};_8(t)}const Sq=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function xg(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Sq.has(e)}let tB=e=>!xg(e);function Aq(e){typeof e=="function"&&(tB=t=>t.startsWith("on")?!xg(t):e(t))}try{Aq(require("@emotion/is-prop-valid").default)}catch{}function _q(e,t,n){const r={};for(const s in e)s==="values"&&typeof e.values=="object"||(tB(s)||n===!0&&xg(s)||!t&&!xg(s)||e.draggable&&s.startsWith("onDrag"))&&(r[s]=e[s]);return r}const ly=B.createContext({});function Dq(e,t){if(ay(e)){const{initial:n,animate:r}=e;return{initial:n===!1||Bf(n)?n:void 0,animate:Bf(r)?r:void 0}}return e.inherit!==!1?t:{}}function Tq(e){const{initial:t,animate:n}=Dq(e,B.useContext(ly));return B.useMemo(()=>({initial:t,animate:n}),[R5(t),R5(n)])}function R5(e){return Array.isArray(e)?e.join(" "):e}const pC=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function nB(e,t,n){for(const r in t)!Jr(t[r])&&!R8(r,n)&&(e[r]=t[r])}function Bq({transformTemplate:e},t){return B.useMemo(()=>{const n=pC();return dC(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Fq(e,t){const n=e.style||{},r={};return nB(r,n,e),Object.assign(r,Bq(e,t)),r}function Pq(e,t){const n={},r=Fq(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const rB=()=>({...pC(),attrs:{}});function Mq(e,t,n,r){const s=B.useMemo(()=>{const o=rB();return L8(o,t,N8(r),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};nB(o,e.style,e),s.style={...o,...s.style}}return s}const Rq=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function mC(e){return typeof e!="string"||e.includes("-")?!1:!!(Rq.indexOf(e)>-1||/[A-Z]/u.test(e))}function Lq(e,t,n,{latestValues:r},s,o=!1,i){const c=(i??mC(e)?Mq:Pq)(t,r,s,e),u=_q(t,typeof e=="string",o),f=e!==B.Fragment?{...u,...c,ref:n}:{},{children:h}=t,p=B.useMemo(()=>Jr(h)?h.get():h,[h]);return B.createElement(e,{...f,children:p})}function Iq({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,s){return{latestValues:Nq(n,r,s,e),renderState:t()}}function Nq(e,t,n,r){const s={},o=r(e,{});for(const p in o)s[p]=Cm(o[p]);let{initial:i,animate:a}=e;const c=ay(e),u=A8(e);t&&u&&!c&&e.inherit!==!1&&(i===void 0&&(i=t.initial),a===void 0&&(a=t.animate));let f=n?n.initial===!1:!1;f=f||i===!1;const h=f?a:i;if(h&&typeof h!="boolean"&&!iy(h)){const p=Array.isArray(h)?h:[h];for(let g=0;g(t,n)=>{const r=B.useContext(ly),s=B.useContext(Qf),o=()=>Iq(e,t,r,s);return n?o():IE(o)},jq=sB({scrapeMotionValuesFromProps:fC,createRenderState:pC}),Oq=sB({scrapeMotionValuesFromProps:j8,createRenderState:rB}),$q=Symbol.for("motionComponentSymbol");function Uq(e,t,n){const r=B.useRef(n);B.useInsertionEffect(()=>{r.current=n});const s=B.useRef(null);return B.useCallback(o=>{var a;o&&((a=e.onMount)==null||a.call(e,o)),t&&(o?t.mount(o):t.unmount());const i=r.current;if(typeof i=="function")if(o){const c=i(o);typeof c=="function"&&(s.current=c)}else s.current?(s.current(),s.current=null):i(o);else i&&(i.current=o)},[t])}const oB=B.createContext({});function zd(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function zq(e,t,n,r,s,o){var C,v;const{visualElement:i}=B.useContext(ly),a=B.useContext(Z8),c=B.useContext(Qf),u=B.useContext(hC).reducedMotion,f=B.useRef(null),h=B.useRef(!1);r=r||a.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:i,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,isSVG:o}),h.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));const p=f.current,g=B.useContext(oB);p&&!p.projection&&s&&(p.type==="html"||p.type==="svg")&&Vq(f.current,n,s,g);const y=B.useRef(!1);B.useInsertionEffect(()=>{p&&y.current&&p.update(n,c)});const b=n[f8],w=B.useRef(!!b&&!((C=window.MotionHandoffIsComplete)!=null&&C.call(window,b))&&((v=window.MotionHasOptimisedAnimation)==null?void 0:v.call(window,b)));return NE(()=>{h.current=!0,p&&(y.current=!0,window.MotionIsMounted=!0,p.updateFeatures(),p.scheduleRenderMicrotask(),w.current&&p.animationState&&p.animationState.animateChanges())}),B.useEffect(()=>{p&&(!w.current&&p.animationState&&p.animationState.animateChanges(),w.current&&(queueMicrotask(()=>{var x;(x=window.MotionHandoffMarkAsComplete)==null||x.call(window,b)}),w.current=!1),p.enteringChildren=void 0)}),p}function Vq(e,t,n,r){const{layoutId:s,layout:o,drag:i,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutCrossfade:f}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:iB(e.parent)),e.projection.setOptions({layoutId:s,layout:o,alwaysMeasureLayout:!!i||a&&zd(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:r,crossfade:f,layoutScroll:c,layoutRoot:u})}function iB(e){if(e)return e.options.allowProjection!==!1?e.projection:iB(e.parent)}function _b(e,{forwardMotionProps:t=!1,type:n}={},r,s){r&&kq(r);const o=n?n==="svg":mC(e),i=o?Oq:jq;function a(u,f){let h;const p={...B.useContext(hC),...u,layoutId:Hq(u)},{isStatic:g}=p,y=Tq(u),b=i(u,g);if(!g&&BT){Wq();const w=qq(p);h=w.MeasureLayout,y.visualElement=zq(e,b,p,s,w.ProjectionNode,o)}return P.jsxs(ly.Provider,{value:y,children:[h&&y.visualElement?P.jsx(h,{visualElement:y.visualElement,...p}):null,Lq(e,u,Uq(b,y.visualElement,f),b,g,t,o)]})}a.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const c=B.forwardRef(a);return c[$q]=e,c}function Hq({layoutId:e}){const t=B.useContext(Af).id;return t&&e!==void 0?t+"-"+e:e}function Wq(e,t){B.useContext(Z8).strict}function qq(e){const t=eB(),{drag:n,layout:r}=t;if(!n&&!r)return{};const s={...n,...r};return{MeasureLayout:n!=null&&n.isEnabled(e)||r!=null&&r.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Gq(e,t){if(typeof Proxy>"u")return _b;const n=new Map,r=(o,i)=>_b(o,i,e,t),s=(o,i)=>r(o,i);return new Proxy(s,{get:(o,i)=>i==="create"?r:(n.has(i)||n.set(i,_b(i,void 0,e,t)),n.get(i))})}const Kq=(e,t)=>t.isSVG??mC(e)?new vW(t):new hW(t,{allowProjection:e!==B.Fragment});class Yq extends Ya{constructor(t){super(t),t.animationState||(t.animationState=kW(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();iy(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let Qq=0;class Xq extends Ya{constructor(){super(...arguments),this.id=Qq++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;const s=this.node.animationState.setActive("exit",!t);n&&!t&&s.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Jq={animation:{Feature:Yq},exit:{Feature:Xq}};function eh(e){return{point:{x:e.pageX,y:e.pageY}}}const Zq=e=>t=>aC(t)&&e(t,eh(t));function pf(e,t,n,r){return Pf(e,t,Zq(n),r)}const aB=({current:e})=>e?e.ownerDocument.defaultView:null,L5=(e,t)=>Math.abs(e-t);function eG(e,t){const n=L5(e.x,t.x),r=L5(e.y,t.y);return Math.sqrt(n**2+r**2)}const I5=new Set(["auto","scroll"]);class lB{constructor(t,n,{transformPagePoint:r,contextWindow:s=window,dragSnapToOrigin:o=!1,distanceThreshold:i=3,element:a}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=g=>{this.handleScroll(g.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const g=Tb(this.lastMoveEventInfo,this.history),y=this.startEvent!==null,b=eG(g.offset,{x:0,y:0})>=this.distanceThreshold;if(!y&&!b)return;const{point:w}=g,{timestamp:C}=Nr;this.history.push({...w,timestamp:C});const{onStart:v,onMove:x}=this.handlers;y||(v&&v(this.lastMoveEvent,g),this.startEvent=this.lastMoveEvent),x&&x(this.lastMoveEvent,g)},this.handlePointerMove=(g,y)=>{this.lastMoveEvent=g,this.lastMoveEventInfo=Db(y,this.transformPagePoint),An.update(this.updatePoint,!0)},this.handlePointerUp=(g,y)=>{this.end();const{onEnd:b,onSessionEnd:w,resumeAnimation:C}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&C&&C(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=Tb(g.type==="pointercancel"?this.lastMoveEventInfo:Db(y,this.transformPagePoint),this.history);this.startEvent&&b&&b(g,v),w&&w(g,v)},!aC(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=i,this.contextWindow=s||window;const c=eh(t),u=Db(c,this.transformPagePoint),{point:f}=u,{timestamp:h}=Nr;this.history=[{...f,timestamp:h}];const{onSessionStart:p}=n;p&&p(t,Tb(u,this.history)),this.removeListeners=Xf(pf(this.contextWindow,"pointermove",this.handlePointerMove),pf(this.contextWindow,"pointerup",this.handlePointerUp),pf(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(t){let n=t.parentElement;for(;n;){const r=getComputedStyle(n);(I5.has(r.overflowX)||I5.has(r.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const r=t===window,s=r?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},o={x:s.x-n.x,y:s.y-n.y};o.x===0&&o.y===0||(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(t,s),An.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Ha(this.updatePoint)}}function Db(e,t){return t?{point:t(e.point)}:e}function N5(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Tb({point:e},t){return{point:e,delta:N5(e,cB(t)),offset:N5(e,tG(t)),velocity:nG(t,.1)}}function tG(e){return e[0]}function cB(e){return e[e.length-1]}function nG(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const s=cB(e);for(;n>=0&&(r=e[n],!(s.timestamp-r.timestamp>ji(t)));)n--;if(!r)return{x:0,y:0};const o=fo(s.timestamp-r.timestamp);if(o===0)return{x:0,y:0};const i={x:(s.x-r.x)/o,y:(s.y-r.y)/o};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function rG(e,{min:t,max:n},r){return t!==void 0&&en&&(e=r?Wn(n,e,r.max):Math.min(e,n)),e}function j5(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function sG(e,{top:t,left:n,bottom:r,right:s}){return{x:j5(e.x,n,s),y:j5(e.y,t,r)}}function O5(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.minr?n=_f(t.min,t.max-r,e.min):r>s&&(n=_f(e.min,e.max-s,t.min)),li(0,1,n)}function aG(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const bv=.35;function lG(e=bv){return e===!1?e=0:e===!0&&(e=bv),{x:$5(e,"left","right"),y:$5(e,"top","bottom")}}function $5(e,t,n){return{min:U5(e,t),max:U5(e,n)}}function U5(e,t){return typeof e=="number"?e:e[t]||0}const cG=new WeakMap;class uG{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=vr(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const o=h=>{n?(this.stopAnimation(),this.snapToCursor(eh(h).point)):this.pauseAnimation()},i=(h,p)=>{this.stopAnimation();const{drag:g,dragPropagation:y,onDragStart:b}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=WH(g),!this.openDragLock))return;this.latestPointerEvent=h,this.latestPanInfo=p,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),lo(C=>{let v=this.getAxisMotionValue(C).get()||0;if(ii.test(v)){const{projection:x}=this.visualElement;if(x&&x.layout){const _=x.layout.layoutBox[C];_&&(v=hs(_)*(parseFloat(v)/100))}}this.originPoint[C]=v}),b&&An.postRender(()=>b(h,p)),fv(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},a=(h,p)=>{this.latestPointerEvent=h,this.latestPanInfo=p;const{dragPropagation:g,dragDirectionLock:y,onDirectionLock:b,onDrag:w}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:C}=p;if(y&&this.currentDirection===null){this.currentDirection=dG(C),this.currentDirection!==null&&b&&b(this.currentDirection);return}this.updateAxis("x",p.point,C),this.updateAxis("y",p.point,C),this.visualElement.render(),w&&w(h,p)},c=(h,p)=>{this.latestPointerEvent=h,this.latestPanInfo=p,this.stop(h,p),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>lo(h=>{var p;return this.getAnimationState(h)==="paused"&&((p=this.getAxisMotionValue(h).animation)==null?void 0:p.play())}),{dragSnapToOrigin:f}=this.getProps();this.panSession=new lB(t,{onSessionStart:o,onStart:i,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:f,distanceThreshold:r,contextWindow:aB(this.visualElement),element:this.visualElement.current})}stop(t,n){const r=t||this.latestPointerEvent,s=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!s||!r)return;const{velocity:i}=s;this.startAnimation(i);const{onDragEnd:a}=this.getProps();a&&An.postRender(()=>a(r,s))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,r){const{drag:s}=this.getProps();if(!r||!Np(t,s,this.currentDirection))return;const o=this.getAxisMotionValue(t);let i=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(i=rG(i,this.constraints[t],this.elastic[t])),o.set(i)}resolveConstraints(){var o;const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(o=this.visualElement.projection)==null?void 0:o.layout,s=this.constraints;t&&zd(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=sG(r.layoutBox,t):this.constraints=!1,this.elastic=lG(n),s!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&lo(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=aG(r.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!zd(t))return!1;const r=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const o=aW(r,s.root,this.visualElement.getTransformPagePoint());let i=oG(s.layout.layoutBox,o);if(n){const a=n(sW(i));this.hasMutatedConstraints=!!a,a&&(i=T8(a))}return i}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:s,dragTransition:o,dragSnapToOrigin:i,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=lo(f=>{if(!Np(f,n,this.currentDirection))return;let h=c&&c[f]||{};i&&(h={min:0,max:0});const p=s?200:1e6,g=s?40:1e7,y={type:"inertia",velocity:r?t[f]:0,bounceStiffness:p,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...h};return this.startAxisValueAnimation(f,y)});return Promise.all(u).then(a)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return fv(this.visualElement,t),r.start(nC(t,r,0,n,this.visualElement,!1))}stopAnimation(){lo(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){lo(t=>{var n;return(n=this.getAxisMotionValue(t).animation)==null?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)==null?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps(),s=r[n];return s||this.visualElement.getValue(t,(r.initial?r.initial[t]:void 0)||0)}snapToCursor(t){lo(n=>{const{drag:r}=this.getProps();if(!Np(n,r,this.currentDirection))return;const{projection:s}=this.visualElement,o=this.getAxisMotionValue(n);if(s&&s.layout){const{min:i,max:a}=s.layout.layoutBox[n],c=o.get()||0;o.set(t[n]-Wn(i,a,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!zd(n)||!r||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};lo(i=>{const a=this.getAxisMotionValue(i);if(a&&this.constraints!==!1){const c=a.get();s[i]=iG({min:c,max:c},this.constraints[i])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),lo(i=>{if(!Np(i,t,null))return;const a=this.getAxisMotionValue(i),{min:c,max:u}=this.constraints[i];a.set(Wn(c,u,s[i]))})}addListeners(){if(!this.visualElement.current)return;cG.set(this.visualElement,this);const t=this.visualElement.current,n=pf(t,"pointerdown",c=>{const{drag:u,dragListener:f=!0}=this.getProps(),h=c.target,p=h!==t&&x8(h);u&&f&&!p&&this.start(c)}),r=()=>{const{dragConstraints:c}=this.getProps();zd(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:s}=this.visualElement,o=s.addEventListener("measure",r);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),An.read(r);const i=Pf(window,"resize",()=>this.scalePositionWithinConstraints()),a=s.addEventListener("didUpdate",(({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(lo(f=>{const h=this.getAxisMotionValue(f);h&&(this.originPoint[f]+=c[f].translate,h.set(h.get()+c[f].translate))}),this.visualElement.render())}));return()=>{i(),n(),o(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:s=!1,dragConstraints:o=!1,dragElastic:i=bv,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:s,dragConstraints:o,dragElastic:i,dragMomentum:a}}}function Np(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function dG(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class fG extends Ya{constructor(t){super(t),this.removeGroupControls=ho,this.removeListeners=ho,this.controls=new uG(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ho}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const z5=e=>(t,n)=>{e&&An.postRender(()=>e(t,n))};class hG extends Ya{constructor(){super(...arguments),this.removePointerDownListener=ho}onPointerDown(t){this.session=new lB(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:aB(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:s}=this.node.getProps();return{onSessionStart:z5(t),onStart:z5(n),onMove:r,onEnd:(o,i)=>{delete this.session,s&&An.postRender(()=>s(o,i))}}}mount(){this.removePointerDownListener=pf(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Bb=!1;class pG extends B.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:s}=this.props,{projection:o}=t;o&&(n.group&&n.group.add(o),r&&r.register&&s&&r.register(o),Bb&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),xm.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:s,isPresent:o}=this.props,{projection:i}=r;return i&&(i.isPresent=o,t.layoutDependency!==n&&i.setOptions({...i.options,layoutDependency:n}),Bb=!0,s||t.layoutDependency!==n||n===void 0||t.isPresent!==o?i.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?i.promote():i.relegate()||An.postRender(()=>{const a=i.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),iC.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:s}=t;Bb=!0,s&&(s.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(s),r&&r.deregister&&r.deregister(s))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function uB(e){const[t,n]=X8(),r=B.useContext(Af);return P.jsx(pG,{...e,layoutGroup:r,switchLayoutGroup:B.useContext(oB),isPresent:t,safeToRemove:n})}const mG={pan:{Feature:hG},drag:{Feature:fG,ProjectionNode:Q8,MeasureLayout:uB}};function V5(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const s="onHover"+n,o=r[s];o&&An.postRender(()=>o(t,eh(t)))}class gG extends Ya{mount(){const{current:t}=this.node;t&&(this.unmount=qH(t,(n,r)=>(V5(this.node,r,"Start"),s=>V5(this.node,s,"End"))))}unmount(){}}class yG extends Ya{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Xf(Pf(this.node.current,"focus",()=>this.onFocus()),Pf(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function H5(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const s="onTap"+(n==="End"?"":n),o=r[s];o&&An.postRender(()=>o(t,eh(t)))}class bG extends Ya{mount(){const{current:t}=this.node;t&&(this.unmount=YH(t,(n,r)=>(H5(this.node,r,"Start"),(s,{success:o})=>H5(this.node,s,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const vv=new WeakMap,Fb=new WeakMap,vG=e=>{const t=vv.get(e.target);t&&t(e)},wG=e=>{e.forEach(vG)};function EG({root:e,...t}){const n=e||document;Fb.has(n)||Fb.set(n,{});const r=Fb.get(n),s=JSON.stringify(t);return r[s]||(r[s]=new IntersectionObserver(wG,{root:e,...t})),r[s]}function CG(e,t,n){const r=EG(t);return vv.set(e,n),r.observe(e),()=>{vv.delete(e),r.unobserve(e)}}const xG={some:0,all:1};class kG extends Ya{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:s="some",once:o}=t,i={root:n?n.current:void 0,rootMargin:r,threshold:typeof s=="number"?s:xG[s]},a=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:f,onViewportLeave:h}=this.node.getProps(),p=u?f:h;p&&p(c)};return CG(this.node.current,i,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(SG(t,n))&&this.startObserver()}unmount(){}}function SG({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const AG={inView:{Feature:kG},tap:{Feature:bG},focus:{Feature:yG},hover:{Feature:gG}},_G={layout:{ProjectionNode:Q8,MeasureLayout:uB}},DG={...Jq,...AG,...mG,..._G},jr=Gq(DG,Kq);function TG(){!lC.current&&S8();const[e]=B.useState(vg.current);return e}const BG=350,FG={duration:.15,ease:[.4,0,.2,1]},PG={type:"tween",duration:.25,ease:[.4,0,.2,1]},MG={type:"tween",duration:.3,ease:[.4,0,.2,1]},dB=B.createContext(!1);function Kie(){return B.useContext(dB)}const fB=B.createContext(void 0);function hB(){return B.useContext(fB)}const Bi={bg:"#F8F8F8",border:"rgba(0, 0, 0, 0.12)",text:"#1A1A1A",textSecondary:"#4A4A4A",textMuted:"#737373",hoverBg:"rgba(0, 0, 0, 0.06)",ring:"rgba(0, 0, 0, 0.08)"},RG={xs:"sm:max-w-xs",sm:"sm:max-w-sm",md:"sm:max-w-md",lg:"sm:max-w-lg",xl:"sm:max-w-xl","2xl":"sm:max-w-2xl","3xl":"sm:max-w-3xl","4xl":"sm:max-w-4xl","5xl":"sm:max-w-5xl",full:"sm:max-w-[calc(100vw-2rem)]"};function pB({open:e,onClose:t,size:n="md",className:r,children:s,bottomSheet:o=!0,motionPlus:i=!1,basemapMode:a,solid:c=!1}){const u=a==="light",[f,h]=B.useState(!1),p=B.useRef(null);B.useEffect(()=>(p.current&&(clearTimeout(p.current),p.current=null),e?p.current=setTimeout(()=>{h(!0)},BG):queueMicrotask(()=>h(!1)),()=>{p.current&&(clearTimeout(p.current),p.current=null)}),[e]);const g=B.useCallback((C,v)=>{(v.offset.y>100||v.velocity.y>500)&&t()},[t]),y=i?MG:PG,b=i?.98:.99,w=o?8:4;return P.jsx(Iu,{mode:"wait",children:e&&P.jsxs(fT,{static:!0,open:e,onClose:t,className:"relative z-[10010]",children:[P.jsx(jr.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:FG,className:"fixed inset-0 bg-black/50 backdrop-blur-sm","aria-hidden":"true"}),P.jsx("div",{className:"fixed inset-0 overflow-y-auto",children:P.jsx("div",{className:qe("flex min-h-full justify-center",o?"items-end sm:items-center sm:p-4":"items-center p-4"),children:P.jsx(jr.div,{drag:o?"y":!1,dragConstraints:{top:0,bottom:0},dragElastic:{top:0,bottom:.4},onDragEnd:g,initial:{opacity:0,scale:b,y:w},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.99,y:o?40:4},transition:y,style:{willChange:"transform, opacity"},className:qe(o&&"w-full sm:w-auto"),children:P.jsx(_E,{className:qe("relative w-full shadow-2xl flex flex-col",!a&&!c&&"bg-surface/80 backdrop-blur-xl",!a&&c&&"bg-surface",!a&&"ring-1 ring-inset ring-edge-subtle",RG[n],o?"radius-card overflow-hidden pb-safe":"radius-card overflow-hidden",r),style:a?{backgroundColor:u?Bi.bg:"var(--surface)",boxShadow:`inset 0 0 0 1px ${u?Bi.ring:"rgba(255, 255, 255, 0.1)"}`}:void 0,children:P.jsx(fB.Provider,{value:a,children:P.jsx(dB.Provider,{value:f,children:s})})})})})})]})})}function LG({className:e,...t}){const n=hB(),r=n==="light";return P.jsx(dT,{...t,className:qe("text-base font-semibold sm:text-lg",!n&&"text-fg-primary",e),style:n?{color:r?Bi.text:"var(--fg-primary)"}:void 0})}function km({icon:e,title:t,onClose:n,className:r}){const s=hB(),o=s==="light";return P.jsxs("div",{className:qe("flex items-center justify-between px-4 sm:px-6 py-3 sm:py-4 border-b",!s&&"border-edge-subtle",r),style:s?{borderColor:o?Bi.border:"var(--edge-subtle)"}:void 0,children:[P.jsxs("div",{className:"flex items-center gap-3",children:[e&&P.jsx("div",{className:qe(!s&&"text-icon-card-title"),style:s?{color:o?Bi.textSecondary:"var(--icon-card-title)"}:void 0,children:e}),P.jsx(LG,{children:t})]}),n&&P.jsxs(P.Fragment,{children:[P.jsx("button",{onClick:n,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),P.jsx("button",{onClick:n,className:qe("hidden sm:flex items-center justify-center p-2 radius-inner transition-colors",!s&&"text-fg-muted hover:text-fg-primary hover:bg-subtle"),style:s?{color:o?Bi.textMuted:"var(--fg-muted)"}:void 0,onMouseEnter:i=>{s&&(i.currentTarget.style.color=o?Bi.text:"var(--fg-primary)",i.currentTarget.style.backgroundColor=o?Bi.hoverBg:"var(--subtle)")},onMouseLeave:i=>{s&&(i.currentTarget.style.color=o?Bi.textMuted:"var(--fg-muted)",i.currentTarget.style.backgroundColor="transparent")},"aria-label":"Close",children:P.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:P.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}function Vd({className:e,...t}){return P.jsx("div",{...t,className:qe("px-6 py-5",e)})}function wv({className:e,...t}){return P.jsx("div",{...t,className:qe("flex flex-col-reverse gap-3 px-6 pb-6 pt-0","sm:flex-row sm:justify-end","*:w-full sm:*:w-auto",e)})}const Sm={snappy:{type:"spring",stiffness:500,damping:30},smooth:{type:"spring",stiffness:300,damping:30},gentle:{type:"spring",stiffness:200,damping:25}},IG={fast:.15,normal:.2,medium:.3},NG={easeOut:[0,0,.2,1],easeIn:[.4,0,1,1]},jG={dropdown:{type:"spring",stiffness:500,damping:30},fade:{duration:IG.fast,ease:NG.easeOut},layoutResize:{duration:.25,ease:[.25,1,.5,1]},numberTicker:{type:"spring",visualDuration:.4,bounce:.15,opacity:{duration:.15,ease:"linear"}},numberReveal:{type:"spring",visualDuration:.6,bounce:.25,opacity:{duration:.2,ease:"linear"}}},Yie={normal:.05};function OG({className:e,...t}){return P.jsx("nav",{...t,className:qe(e,"flex h-full min-h-0 flex-col")})}function $G({className:e,...t}){return P.jsx("div",{...t,className:qe(e,"flex flex-col border-b border-edge-subtle p-4","[&>[data-slot=section]+[data-slot=section]]:mt-2.5")})}function UG({className:e,...t}){return P.jsx("div",{...t,className:qe(e,"flex flex-1 flex-col p-3","overflow-y-auto sidebar-scroll","[&>[data-slot=section]+[data-slot=section]]:mt-6")})}function zG({className:e,...t}){return P.jsx("div",{...t,className:qe(e,"mt-auto flex flex-col","[&>[data-slot=section]+[data-slot=section]]:mt-2.5")})}function VG({className:e,...t}){const n=B.useId();return P.jsx(Cq,{id:n,children:P.jsx("div",{...t,"data-slot":"section",className:qe(e,"flex flex-col gap-0.5")})})}const HG=B.forwardRef(function(t,n){const{current:r,className:s,children:o,accentColor:i,...a}=t,c=!!i,u=qe("relative isolate flex w-full items-center gap-3 radius-inner px-3 py-1.5 text-left","min-h-[34px]","text-sm font-medium","[&>svg]:w-4 [&>svg]:h-4 [&>svg]:flex-shrink-0",r?c?"text-white":"text-fg-primary [&_svg]:text-sys-blue":"text-fg-muted hover:text-fg-primary hover:bg-elevated [&_svg]:text-fg-muted hover:[&_svg]:text-fg-primary","transition-all duration-150"),f=c?{willChange:"transform",backgroundColor:i,boxShadow:[`0 0 10px 2px color-mix(in oklch, ${i} 50%, transparent)`,`0 0 4px 0 color-mix(in oklch, ${i} 70%, transparent)`].join(", ")}:{willChange:"transform"},h=c?{willChange:"transform",background:"transparent",boxShadow:[`inset 0 0 0 1.5px ${i}`,`inset 0 0 3px 0.5px color-mix(in oklch, ${i} 30%, transparent)`,`inset 0 0 6px 1px color-mix(in oklch, ${i} 14%, transparent)`,`inset 0 0 10px 2px color-mix(in oklch, ${i} 5%, transparent)`,`0 0 20px -4px color-mix(in oklch, ${i} 22%, transparent)`,`0 0 8px -2px color-mix(in oklch, ${i} 14%, transparent)`].join(", ")}:{willChange:"transform"};return P.jsxs("span",{className:qe(s,"relative"),children:[r&&P.jsx(jr.span,{layout:"position",layoutId:"sidebar-current-indicator",className:qe("absolute inset-y-1.5 -left-3 w-0.5 rounded-full",!c&&"bg-sys-blue sidebar-neo-indicator"),style:f,transition:Sm.snappy}),typeof a.href=="string"?P.jsxs(jg,{to:a.href,onClick:a.onClick,onMouseEnter:a.onMouseEnter,onMouseLeave:a.onMouseLeave,className:u,"data-current":r?"true":void 0,ref:n,children:[r&&P.jsx(jr.span,{layout:"position",layoutId:"sidebar-current-highlight",className:qe("absolute inset-0 radius-inner z-[-1]",!c&&"sidebar-neo-highlight"),style:h,transition:Sm.snappy}),o]}):P.jsxs(Yg,{...a,className:qe("cursor-default",u),"data-current":r?"true":void 0,ref:n,children:[r&&P.jsx(jr.span,{layout:"position",layoutId:"sidebar-current-highlight",className:qe("absolute inset-0 radius-inner z-[-1]",!c&&"sidebar-neo-highlight"),style:h,transition:Sm.snappy}),o]})]})});function WG({className:e,...t}){return P.jsx("span",{...t,className:qe(e,"truncate")})}function Am({className:e,variant:t="default",...n}){const r={default:"bg-subtle text-fg-muted",accent:"bg-sys-blue/20 text-sys-blue",success:"bg-sys-green/20 text-sys-green",warning:"bg-sys-indigo/20 text-sys-indigo",danger:"bg-sys-red/20 text-sys-red"};return P.jsx("span",{...n,className:qe("ml-auto flex items-center gap-1 px-1.5 py-0.5 rounded-full","text-xs font-medium",r[t],e)})}const W5=e=>{let t;const n=new Set,r=(u,f)=>{const h=typeof u=="function"?u(t):u;if(!Object.is(h,t)){const p=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(g=>g(t,p))}},s=()=>t,a={setState:r,getState:s,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u))},c=t=e(r,s,a);return a},qG=(e=>e?W5(e):W5),GG=e=>e;function KG(e,t=GG){const n=at.useSyncExternalStore(e.subscribe,at.useCallback(()=>t(e.getState()),[e,t]),at.useCallback(()=>t(e.getInitialState()),[e,t]));return at.useDebugValue(n),n}const q5=e=>{const t=qG(e),n=r=>KG(t,r);return Object.assign(n,t),n},xr=(e=>e?q5(e):q5),mB="pymc_focus_mode";function YG(){try{return localStorage.getItem(mB)==="1"}catch{return!1}}function G5(e){try{localStorage.setItem(mB,e?"1":"0")}catch{}}const gB=xr()(e=>({focusMode:YG(),toggleFocusMode:()=>e(t=>{const n=!t.focusMode;return G5(n),{focusMode:n}}),setFocusMode:t=>{G5(t),e({focusMode:t})}})),QG=()=>gB(e=>e.focusMode),yB=B.createContext(null);function XG(){const e=B.useContext(yB);if(!e)throw new Error("useSidebar must be used within a SidebarLayout");return e}const bB={type:"spring",visualDuration:.35,bounce:.15},JG=bB.visualDuration*1e3;function ZG({open:e,onClose:t,children:n}){return P.jsx(Iu,{children:e&&P.jsxs(fT,{static:!0,open:e,onClose:t,className:"lg:hidden relative z-[10002]",children:[P.jsx(jr.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25,ease:"easeOut"},className:"fixed inset-0 bg-black/60 backdrop-blur-sm","aria-hidden":"true"}),P.jsx(jr.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:bB,className:"fixed inset-y-0 left-0 w-72 max-w-[85vw] z-[10003]",children:P.jsx(_E,{className:"h-full",children:P.jsxs("div",{className:"flex h-full flex-col sidebar-panel",children:[P.jsx("div",{className:"absolute top-4 right-4 z-10",children:P.jsx(Qj,{className:"p-2 rounded-lg text-fg-muted hover:text-fg-primary hover:bg-subtle-fill transition-colors","aria-label":"Close navigation",children:P.jsx(TT,{className:"w-5 h-5"})})}),n]})})})]})})}function eK({sidebar:e,navbar:t,children:n,className:r}){const[s,o]=B.useState(!1),i=QG(),a=TG(),c=yo();B.useEffect(()=>{i&&!c.pathname.startsWith("/companion")&&gB.getState().setFocusMode(!1)},[c.pathname,i]);const u=()=>o(!0),f=()=>o(!1),h={isOpen:s,open:u,close:f,toggle:()=>o(p=>!p)};return P.jsx(yB.Provider,{value:h,children:P.jsxs("div",{className:"flex h-screen overflow-hidden bg-body",children:[P.jsx(jr.aside,{className:"hidden lg:flex flex-col flex-shrink-0 h-full relative sidebar-panel overflow-hidden",animate:{width:i?0:256},transition:a?{duration:0}:Sm.smooth,children:P.jsx(jr.div,{className:"flex flex-col h-full min-w-[256px]",animate:{opacity:i?0:1},transition:a?{duration:0}:jG.fade,children:e})}),P.jsx(ZG,{open:s,onClose:f,children:e}),P.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[P.jsx("header",{className:"lg:hidden sticky top-0 z-[10001] h-14 mobile-header",children:P.jsxs("div",{className:"flex items-center h-full px-4",children:[P.jsx("button",{onClick:u,className:"w-10 h-10 flex items-center justify-center rounded-lg hover:bg-subtle-fill active:bg-subtle-fill transition-colors mr-2","aria-label":"Open navigation",children:P.jsx(KU,{className:"w-5 h-5 text-fg-primary"})}),P.jsx("div",{className:"flex-1 min-w-0",children:t})]})}),P.jsx("main",{className:qe("flex-1 overflow-y-auto main-content",r),children:n})]})]})})}function tK({className:e,...t}){return P.jsx("nav",{...t,className:qe(e,"flex flex-1 items-center gap-3")})}function K5({className:e,...t}){return P.jsx("div",{...t,className:qe(e,"flex items-center gap-3")})}function nK({className:e,...t}){return P.jsx("div",{"aria-hidden":"true",...t,className:qe(e,"flex-1")})}const rK=[45,72,33,58,80,42,65,28,55,75,38,62];function Nt({className:e,style:t}){return P.jsx("div",{className:qe("animate-pulse bg-subtle-fill radius-badge",e),style:t})}function sK(){return P.jsx("div",{className:"p-3 radius-inner border-card bg-subtle",children:P.jsxs("div",{className:"flex items-start gap-3",children:[P.jsx(Nt,{className:"w-14 h-6 rounded shrink-0"}),P.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[P.jsx(Nt,{className:"h-4 w-full"}),P.jsx(Nt,{className:"h-4 w-3/4"}),P.jsx(Nt,{className:"h-3 w-32 mt-1"})]})]})})}function Qie({count:e=8}){return P.jsx("div",{className:"space-y-2",children:Array.from({length:e}).map((t,n)=>P.jsx(sK,{},n))})}function oK(){return P.jsxs("div",{className:"flex flex-col gap-3 h-full","aria-hidden":"true",children:[P.jsxs("div",{className:"flex items-center gap-2",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-24"})]}),P.jsx(Nt,{className:"h-8 w-20"}),P.jsxs("div",{className:"flex-1 flex flex-col justify-end gap-2",children:[P.jsx(Nt,{className:"h-3 w-full"}),P.jsx(Nt,{className:"h-3 w-3/4"})]})]})}function iK(){return P.jsxs("div",{className:"flex flex-col gap-3 h-full","aria-hidden":"true",children:[P.jsxs("div",{className:"flex items-center gap-2",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-24"})]}),P.jsx("div",{className:"flex-1 flex items-end gap-1",children:rK.slice(0,8).map((e,t)=>P.jsx(Nt,{className:"flex-1",style:{height:`${e}%`}},t))})]})}function aK({rows:e=5}){return P.jsxs("div",{className:"flex flex-col h-full","aria-hidden":"true",children:[P.jsx("div",{className:"pb-3 border-b border-edge-subtle",children:P.jsxs("div",{className:"flex items-center gap-2",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-24"})]})}),P.jsx("div",{className:"flex-1 pt-3 flex flex-col gap-3",children:Array.from({length:e}).map((t,n)=>P.jsx(Nt,{className:"h-6 w-full"},n))})]})}const vB=B.createContext(void 0);function Xie(){return B.useContext(vB)}const lK={sm:"radius-inner",md:"radius-inset",lg:"radius-card",xl:"radius-hero",full:"radius-pill",none:"radius-none"},Jie=B.forwardRef(function({children:t,elevated:n,compact:r,noPadding:s,radius:o="lg",glass:i=!0,stroke:a=!0,shadow:c,reflex:u=!1,glow:f=!1,neomorphic:h=!0,onClick:p,className:g,style:y,isLoaded:b,skeletonType:w="card",...C},v){const x=B.useContext(vB),[_,S]=B.useState(!1);B.useEffect(()=>{let I=!1;return requestAnimationFrame(()=>{requestAnimationFrame(()=>{I||S(!0)})}),()=>{I=!0}},[]);const k=b??x??_,F=c??n??!1,A=a,D={...y,...u?{"--surface-reflex":"1"}:{}},L=()=>{switch(w){case"chart":return P.jsx(iK,{});case"list":return P.jsx(aK,{});default:return P.jsx(oK,{})}},N=qe(lK[o],i&&(n?"bg-surface/85 backdrop-blur-xl":"bg-surface/80 backdrop-blur-lg"),!i&&"bg-surface",h&&"depth-raised",A&&!h&&!f&&"ring-1 ring-inset ring-edge-subtle",f&&"ring-1 ring-inset ring-sys-blue/40",F&&(n?"shadow-xl":"shadow-lg"),u&&"surface-reflex","h-full flex flex-col relative",!s&&(r?"p-3 sm:p-4":"p-4 sm:p-5"),p&&"cursor-pointer",g);return k?P.jsx("div",{ref:v,"data-card-surface":!0,className:N,style:D,onClick:p,...C,children:t}):P.jsx("div",{ref:v,"data-card-surface":!0,className:N,style:D,...C,children:L()})});function Zie({title:e,icon:t,badge:n,badgeColor:r="teal",subtitle:s,actions:o,iconColor:i="text-icon-card-title",listHeader:a=!1,stackActionsOnMobile:c=!1,stackBreakpoint:u="sm",titleExtra:f,onClick:h,className:p}){const g="px-5 py-4 border-b border-edge-subtle",y={sm:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 min-h-[32px]",md:"flex flex-col md:flex-row md:items-center md:justify-between gap-2 min-h-[32px]",lg:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-2 min-h-[32px]"},b=P.jsxs(P.Fragment,{children:[t&&P.jsx("span",{className:qe("icon-md flex items-center justify-center",i),children:t}),P.jsx("span",{className:"type-micro",children:e}),n&&P.jsx(aU,{color:r,children:n}),f]}),w=h?"button":"div",C=h?{onClick:h,type:"button"}:{};return c&&o?P.jsxs(w,{...C,className:qe("flex flex-col gap-1 flex-shrink-0",a?g:"mb-3",h&&"w-full text-left cursor-pointer",p),children:[P.jsxs("div",{className:y[u],children:[P.jsx("div",{className:"flex items-center gap-3",children:b}),P.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:o})]}),s&&P.jsx("p",{className:"type-label text-fg-muted ml-8",children:s})]}):P.jsxs(w,{...C,className:qe("flex flex-col gap-1 flex-shrink-0",a?g:"mb-3",h&&"w-full text-left cursor-pointer",p),children:[P.jsxs("div",{className:"flex items-center justify-between gap-2 min-h-[32px]",children:[P.jsx("div",{className:"flex items-center gap-3",children:b}),o&&P.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:o})]}),s&&P.jsx("p",{className:"type-label text-fg-muted ml-8",children:s})]})}B.forwardRef(function({children:t,icon:n,className:r,...s},o){return P.jsxs("h3",{ref:o,className:qe("flex items-center gap-2","text-base font-semibold text-fg-primary",r),...s,children:[n&&P.jsx("span",{className:"text-icon-card-title w-5 h-5 flex-shrink-0",children:n}),t]})});B.forwardRef(function({children:t,className:n,...r},s){return P.jsx("p",{ref:s,className:qe("text-sm text-fg-muted",n),...r,children:t})});const eae=B.forwardRef(function({children:t,centered:n,className:r,...s},o){return P.jsx("div",{ref:o,className:qe("flex-1 min-h-0",n&&"flex items-center justify-center",r),...s,children:t})});B.forwardRef(function({children:t,className:n,...r},s){return P.jsx("div",{ref:s,className:qe("flex items-center justify-end gap-3","pt-4 mt-4","border-t border-edge-subtle",n),...r,children:t})});B.forwardRef(function({children:t,border:n,className:r,...s},o){return P.jsx("div",{ref:o,className:qe(n&&"pt-4 mt-4 border-t border-edge-subtle",r),...s,children:t})});function cK({defaultOpen:e=!1,className:t,children:n}){return P.jsx(pT,{defaultOpen:e,children:P.jsx("div",{className:qe("flex flex-col",t),children:n})})}const uK=B.forwardRef(function({className:t,icon:n,children:r,...s},o){return P.jsx(mg,{ref:o,className:qe("flex w-full items-center justify-between gap-3","px-3 py-2 radius-inner","text-sm font-medium text-fg-muted","row-hover hover:text-fg-primary","ring-focus",t),...s,children:({open:i})=>P.jsxs(P.Fragment,{children:[r,P.jsx("span",{className:qe("transition-transform duration-200",i?"rotate-180":"rotate-0"),children:n||P.jsx(J1,{className:"w-4 h-4"})})]})})});function dK({direction:e="down",className:t,children:n}){const r={hidden:{height:0,opacity:0,y:e==="up"?8:-8},visible:{height:"auto",opacity:1,y:0}};return P.jsx(PE,{static:!0,children:({open:s})=>P.jsx(Iu,{initial:!1,children:s&&P.jsx(jr.div,{initial:"hidden",animate:"visible",exit:"hidden",variants:r,transition:{height:{duration:.2,ease:[.4,0,.2,1]},opacity:{duration:.15},y:{duration:.15}},className:qe("overflow-hidden",t),children:P.jsx("div",{className:qe(e==="up"?"pb-2":"pt-2"),children:n})})})})}function fK({label:e,icon:t,defaultOpen:n=!0,direction:r="down",className:s,triggerStyle:o,dataId:i,children:a}){const c=i?{[`data-${i}-disclosure`]:!0}:{},u=P.jsxs("span",{className:"flex items-center gap-3",children:[t&&P.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title",children:t}),P.jsx("span",{className:"type-micro",children:e})]});return r==="up"?P.jsx(pT,{defaultOpen:n,children:({open:f})=>P.jsxs("div",{className:qe("relative",s),children:[P.jsx(PE,{static:!0,className:"relative z-50",children:P.jsx(Iu,{initial:!1,mode:"wait",children:f&&P.jsxs(jr.div,{initial:{y:12,scale:.97,opacity:0},animate:{y:0,scale:1,opacity:1},exit:{y:6,scale:.98,opacity:0},transition:{type:"spring",stiffness:400,damping:32,mass:.8,opacity:{duration:.15,ease:[.4,0,.2,1]}},className:"absolute bottom-full left-0 right-0 z-50 mb-1 origin-bottom radius-inset shadow-lg border-card bg-surface",children:[P.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[P.jsxs("span",{className:"flex items-center gap-3",children:[t&&P.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title",children:t}),P.jsx("span",{className:"type-micro",children:e})]}),P.jsx(mg,{className:"p-1 rounded hover:bg-subtle-fill-strong transition-colors",children:P.jsx(jr.span,{initial:{rotate:0},animate:{rotate:180},exit:{rotate:0},transition:{type:"spring",stiffness:400,damping:25},children:P.jsx(J1,{className:"w-4 h-4"})})})]}),P.jsx("div",{className:"px-3 pb-3",children:a})]})})}),P.jsx(jr.div,{animate:{opacity:f?.4:1,scale:f?.98:1},transition:{type:"spring",stiffness:500,damping:35},children:P.jsxs(mg,{...c,style:o,className:qe("flex w-full items-center justify-between gap-3","px-3 py-2 rounded-none rounded-t-lg","bg-surface depth-stroke-raised","text-sm font-medium text-fg-muted","hover:bg-elevated hover:text-fg-primary transition-colors","ring-focus"),children:[u,P.jsx(jr.span,{animate:{rotate:f?180:0},transition:{type:"spring",stiffness:400,damping:25},children:P.jsx(J1,{className:"w-4 h-4"})})]})})]})}):P.jsxs(cK,{defaultOpen:n,className:s,children:[P.jsx(uK,{...c,children:u}),P.jsx(dK,{direction:"down",children:P.jsx("div",{className:"bg-subtle-fill radius-inset mx-1 mt-1",children:a})})]})}const jp=8;function hK(e,t,n){const r=window.scrollY,s=window.scrollX;switch(n){case"top":return{top:e.top+r-t.height-jp,left:e.left+s+(e.width-t.width)/2};case"bottom":return{top:e.bottom+r+jp,left:e.left+s+(e.width-t.width)/2};case"left":return{top:e.top+r+(e.height-t.height)/2,left:e.left+s-t.width-jp};case"right":return{top:e.top+r+(e.height-t.height)/2,left:e.right+s+jp}}}const pK=e=>({hidden:{opacity:0,scale:.96,...{top:{y:4},bottom:{y:-4},left:{x:4},right:{x:-4}}[e]},visible:{opacity:1,scale:1,x:0,y:0}});function mK({placement:e}){const t=qe("absolute w-2 h-2 rotate-45",e==="top"&&"bottom-[-4px] left-1/2 -translate-x-1/2",e==="bottom"&&"top-[-4px] left-1/2 -translate-x-1/2",e==="left"&&"right-[-4px] top-1/2 -translate-y-1/2",e==="right"&&"left-[-4px] top-1/2 -translate-y-1/2");return P.jsx("span",{className:t,style:{backgroundColor:"var(--tooltip-bg)"}})}function gK({content:e,children:t,placement:n="top",delay:r=200,arrow:s=!0,disabled:o=!1,className:i}){const[a,c]=B.useState(!1),[u,f]=B.useState({top:0,left:0}),[h,p]=B.useState(!1),g=B.useRef(null),y=B.useRef(null),b=B.useRef();B.useEffect(()=>{p(!0)},[]),B.useEffect(()=>{if(!a||!g.current||!y.current)return;const S=g.current.getBoundingClientRect(),k=y.current.getBoundingClientRect(),F=hK(S,k,n),A=window.innerWidth-k.width-8,D=window.innerHeight+window.scrollY-k.height-8;f({top:Math.max(8,Math.min(F.top,D)),left:Math.max(8,Math.min(F.left,A))})},[a,n]);const w=B.useCallback(()=>{o||(b.current=setTimeout(()=>{c(!0)},r))},[r,o]),C=B.useCallback(()=>{b.current&&clearTimeout(b.current),c(!1)},[]);if(B.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]),!B.isValidElement(t))return t;const v=B.cloneElement(t,{ref:g,onMouseEnter:S=>{var k,F;w(),(F=(k=t.props).onMouseEnter)==null||F.call(k,S)},onMouseLeave:S=>{var k,F;C(),(F=(k=t.props).onMouseLeave)==null||F.call(k,S)},onFocus:S=>{var k,F;w(),(F=(k=t.props).onFocus)==null||F.call(k,S)},onBlur:S=>{var k,F;C(),(F=(k=t.props).onBlur)==null||F.call(k,S)}}),x=pK(n),_=P.jsx(Iu,{children:a&&P.jsxs(jr.div,{ref:y,initial:"hidden",animate:"visible",exit:"hidden",variants:x,transition:{duration:.15,ease:"easeOut"},className:qe("fixed z-[10020] px-2.5 py-1.5 text-xs font-medium","rounded-lg","pointer-events-none",i),style:{top:u.top,left:u.left,backgroundColor:"var(--tooltip-bg)",color:"var(--tooltip-fg)",border:"1px solid var(--tooltip-border)",boxShadow:"var(--tooltip-shadow)"},role:"tooltip",children:[e,s&&P.jsx(mK,{placement:n})]})});return P.jsxs(P.Fragment,{children:[v,h&&Au.createPortal(_,document.body)]})}const wB={sm:{track:"h-5 w-9",thumb:"h-3.5 w-3.5",translate:"translate-x-[18px]",icon:"w-3 h-3",dot:"w-2 h-2"},md:{track:"h-6 w-11",thumb:"h-4 w-4",translate:"translate-x-[22px]",icon:"w-4 h-4",dot:"w-2.5 h-2.5"},lg:{track:"h-7 w-14",thumb:"h-5 w-5",translate:"translate-x-[30px]",icon:"w-4 h-4",dot:"w-3 h-3"}},tae=B.forwardRef(function({enabled:t,onChange:n,label:r,description:s,tooltip:o,size:i="md",color:a="muted",dangerOff:c=!1,disabled:u=!1,status:f="idle",name:h,className:p},g){const y=wB[i],b=f==="loading",w=a==="muted";return P.jsxs(sy,{disabled:u||b,className:qe("flex items-center gap-3",p),children:[P.jsx(mT,{ref:g,checked:t,onChange:n,name:h,className:qe(w?"toggle-switch-track":"group relative inline-flex shrink-0 items-center rounded-full border-2",y.track,!w&&(t?"bg-toggle-on border-toggle-on":"bg-toggle-off border-edge-subtle"),"disabled:opacity-50 disabled:cursor-not-allowed","ring-focus","transition-all duration-200"),"data-size":i,children:P.jsx("span",{className:qe(w?"toggle-switch-thumb":"relative inline-flex items-center justify-center bg-white shadow-lg","transform rounded-full transition-transform duration-200",y.thumb,t?y.translate:"translate-x-[4px]"),children:w&&P.jsx("span",{className:qe("toggle-switch-dot",y.dot,c?qe("opacity-100",!t&&"toggle-switch-dot-danger"):t?"opacity-100":"opacity-0")})})}),(r||s||o)&&P.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r&&P.jsx(Gf,{className:qe("text-sm font-medium cursor-pointer select-none",u?"text-fg-muted":"text-fg-primary"),children:r}),o&&P.jsx(gK,{content:o,placement:"top",children:P.jsx("span",{className:"text-fg-muted hover:text-fg-secondary cursor-help transition-colors",children:P.jsx(NU,{className:"w-3.5 h-3.5"})})}),s&&!o&&P.jsx(Pu,{className:"text-xs text-fg-muted",children:s})]}),f!=="idle"&&P.jsxs("div",{className:"flex items-center shrink-0",children:[f==="loading"&&P.jsx(DT,{className:qe(y.icon,"text-fg-muted animate-spin")}),f==="success"&&P.jsx(oy,{className:qe(y.icon,"text-sys-green")}),f==="error"&&P.jsx(TT,{className:qe(y.icon,"text-sys-red")})]})]})}),nae=B.forwardRef(function({enabled:t,onChange:n,size:r="md",disabled:s=!1,"aria-label":o,className:i},a){const c=wB[r];return P.jsx(mT,{ref:a,checked:t,onChange:n,disabled:s,"aria-label":o,className:qe("toggle-switch-track",c.track,"disabled:opacity-50 disabled:cursor-not-allowed","ring-focus","transition-all duration-200",i),"data-size":r,children:P.jsx("span",{className:qe("toggle-switch-thumb","transform rounded-full transition-transform duration-200",c.thumb,t?c.translate:"translate-x-[4px]"),children:P.jsx("span",{className:qe("toggle-switch-dot",c.dot,t?"opacity-100":"opacity-0")})})})}),yK={sm:{input:"h-8 text-sm px-3",icon:"w-4 h-4",iconPadding:"pl-8",trailingIconPadding:"pr-8"},md:{input:"h-[38px] text-sm px-4",icon:"w-4 h-4",iconPadding:"pl-10",trailingIconPadding:"pr-10"},lg:{input:"h-11 text-base px-4",icon:"w-5 h-5",iconPadding:"pl-11",trailingIconPadding:"pr-11"}},EB=B.forwardRef(function({type:t="text",size:n="md",invalid:r=!1,leadingIcon:s,trailingIcon:o,leadingAddon:i,trailingAddon:a,className:c,disabled:u,...f},h){const p=yK[n],g=s||i,y=o||a;return i||a?P.jsxs("div",{className:qe("flex",c),children:[i&&P.jsx("span",{className:qe("inline-flex items-center px-3 rounded-l-lg border border-r-0","bg-input-bg text-fg-muted text-sm",r?"border-sys-red":"border-input-border"),children:i}),P.jsx("input",{ref:h,type:t,disabled:u,className:qe("flex-1 min-w-0 font-mono",p.input,"bg-input-bg",r?"border border-sys-red":"border border-input-border","text-fg-primary placeholder:text-fg-muted",r?"ring-focus-error":"ring-focus-inset",!u&&"hover:border-edge-strong","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors",i&&!a&&"rounded-r-lg",a&&!i&&"rounded-l-lg",!i&&!a&&"radius-inner"),...f}),a&&P.jsx("span",{className:qe("inline-flex items-center px-3 rounded-r-lg border border-l-0","bg-input-bg text-fg-muted text-sm",r?"border-sys-red":"border-input-border"),children:a})]}):P.jsxs("div",{className:qe("relative",c),children:[s&&P.jsx("div",{className:qe("absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none","text-fg-muted"),children:P.jsx("span",{className:p.icon,children:s})}),P.jsx("input",{ref:h,type:t,disabled:u,className:qe("w-full radius-inner font-mono",p.input,g&&p.iconPadding,y&&p.trailingIconPadding,"bg-input-bg",r?"border border-sys-red":"border border-input-border","text-fg-primary placeholder:text-fg-muted",r?"ring-focus-error":"ring-focus-inset",!u&&"hover:border-edge-strong","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors"),...f}),o&&P.jsx("div",{className:qe("absolute inset-y-0 right-0 flex items-center pr-3","text-fg-muted"),children:P.jsx("span",{className:p.icon,children:o})})]})}),rae=B.forwardRef(function({label:t,description:n,errorMessage:r,required:s,invalid:o,className:i,...a},c){const u=o&&r;return P.jsxs(sy,{className:qe("flex flex-col gap-1.5",i),children:[t&&P.jsxs(Gf,{className:"text-sm font-medium text-fg-primary",children:[t,s&&P.jsx("span",{className:"text-sys-red ml-0.5",children:"*"})]}),n&&!u&&P.jsx(Pu,{className:"text-xs text-fg-muted -mt-0.5",children:n}),P.jsx(EB,{ref:c,invalid:o,...a}),u&&P.jsx("p",{className:"text-xs text-sys-red",children:r})]})});B.forwardRef(function({value:t,onChange:n,min:r,max:s,step:o=1,precision:i,...a},c){const u=h=>{const p=h.target.value;if(p===""||p==="-"){n(0);return}const g=parseFloat(p);if(!isNaN(g)){const y=r!==void 0&&s!==void 0?Math.min(Math.max(g,r),s):r!==void 0?Math.max(g,r):s!==void 0?Math.min(g,s):g;n(y)}},f=i!==void 0&&typeof t=="number"?t.toFixed(i):t;return P.jsx(EB,{ref:c,type:"number",value:f,onChange:u,min:r,max:s,step:o,...a})});const bK={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"},vK=B.forwardRef(function({rows:t=3,resize:n="vertical",invalid:r=!1,disabled:s,className:o,...i},a){return P.jsx("textarea",{ref:a,rows:t,disabled:s,className:qe("w-full radius-inner px-4 py-3 text-sm",bK[n],"bg-subtle",r?"border border-sys-red":"border-control","text-fg-primary placeholder:text-fg-muted",r?"ring-focus-error":"ring-focus-inset",!s&&"hover:border-edge-strong","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors",o),...i})});B.forwardRef(function({label:t,description:n,errorMessage:r,required:s,invalid:o,showCount:i,maxLength:a,value:c,className:u,...f},h){const p=o&&r,g=typeof c=="string"?c.length:0;return P.jsxs(sy,{className:qe("flex flex-col gap-1.5",u),children:[t&&P.jsxs(Gf,{className:"text-sm font-medium text-fg-primary",children:[t,s&&P.jsx("span",{className:"text-sys-red ml-0.5",children:"*"})]}),n&&!p&&P.jsx(Pu,{className:"text-xs text-fg-muted -mt-0.5",children:n}),P.jsx(vK,{ref:h,invalid:o,maxLength:a,value:c,...f}),P.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p?P.jsx("p",{className:"text-xs text-sys-red flex-1",children:r}):P.jsx("span",{}),i&&a&&P.jsxs("span",{className:qe("text-xs",g>a?"text-sys-red":"text-fg-muted"),children:[g,"/",a]})]})]})});const wK={sm:{box:"h-4 w-4",icon:"h-3 w-3",radius:"rounded"},md:{box:"h-5 w-5",icon:"h-3.5 w-3.5",radius:"rounded-md"},lg:{box:"h-6 w-6",icon:"h-4 w-4",radius:"rounded-md"}},sae=B.forwardRef(function({checked:t,onChange:n,indeterminate:r=!1,label:s,description:o,size:i="md",disabled:a=!1,name:c,value:u,className:f},h){const p=wK[i];return P.jsxs(sy,{disabled:a,className:qe("flex items-start gap-3",f),children:[P.jsxs(Gj,{ref:h,checked:t,onChange:n,name:c,value:u,className:qe("group relative flex shrink-0 items-center justify-center",p.box,p.radius,"border-2 transition-all duration-150",!t&&!r&&"border-edge-subtle bg-subtle",(t||r)&&"border-sys-blue bg-sys-blue",!t&&!r&&!a&&"hover:border-edge-strong","ring-focus","disabled:opacity-50 disabled:cursor-not-allowed"),children:[t&&!r&&P.jsx(oy,{className:qe(p.icon,"text-white stroke-[3]")}),r&&P.jsx(JU,{className:qe(p.icon,"text-white stroke-[3]")})]}),(s||o)&&P.jsxs("div",{className:"flex-1 min-w-0 select-none",children:[s&&P.jsx(Gf,{className:qe("text-sm font-medium cursor-pointer",a?"text-fg-muted":"text-fg-primary"),children:s}),o&&P.jsx(Pu,{className:"text-xs text-fg-muted mt-0.5",children:o})]})]})});B.createContext({variant:"default",divider:"subtle",grid:!0});const Ev="0.9.319",Y5="'JetBrains Mono', monospace";function EK({height:e=16,responsive:t=!1,className:n=""}){const r="var(--sys-blue)",s="var(--fg-primary)";if(t)return P.jsxs("svg",{className:n,viewBox:"0 0 145 24",preserveAspectRatio:"xMidYMid meet",role:"img","aria-label":"pyMC:Console",style:{display:"block",width:"80%",height:"auto"},children:[P.jsx("style",{children:` .logo-text { font-family: ${Y5}; } @@ -348,4 +348,4 @@ safe-buffer/index.js: ${t.visible?"opacity-100":"opacity-0"} `,style:{left:s.x,top:s.y,visibility:t.visible?"visible":"hidden"},children:t.content}),document.body)]})}function Dce({content:e,children:t,delay:n=150}){const{show:r,hide:s,updatePosition:o}=soe(),i=B.useRef(null),a=B.useRef(null),c=B.useRef(!1),u=()=>{a.current&&(clearTimeout(a.current),a.current=null)},f=B.useCallback(b=>{u(),a.current=setTimeout(()=>{c.current=!0,r(e,b.clientX,b.clientY)},n)},[r,e,n]),h=B.useCallback(b=>{c.current&&o(b.clientX,b.clientY)},[o]),p=B.useCallback(()=>{u(),c.current=!1,s()},[s]),g=B.useCallback(()=>{if(u(),!i.current)return;const b=i.current.getBoundingClientRect();a.current=setTimeout(()=>{c.current=!0,r(e,b.left+b.width/2,b.top)},n)},[r,e,n]),y=B.useCallback(()=>{u(),c.current=!1,s()},[s]);return B.useEffect(()=>()=>{u(),c.current&&(c.current=!1,s())},[s]),B.useEffect(()=>{const b=()=>{c.current&&(u(),c.current=!1,s())};return document.addEventListener("click",b,!0),()=>document.removeEventListener("click",b,!0)},[s]),P.jsx("span",{ref:i,onMouseEnter:f,onMouseMove:h,onMouseLeave:p,onFocus:g,onBlur:y,className:"contents",children:t})}const _D=15e3,ioe=40,aoe=60,loe=.6,coe=.4;function uoe(e){return e.payload_type??e.type}const Zl=xr()((e,t)=>({liveStats:null,history:[],available:!0,initialized:!1,clientRate:0,serverEwma:0,_prevAllowed:null,_prevDropped:null,_prevPenaltyKeys:null,_advertRing:[],_wsUnsub:null,_intervalId:null,_refCount:0,startPolling:()=>{const n=t(),r=n._refCount+1;if(e({_refCount:r}),n._intervalId)return;const s=Xr.onPacket(i=>{if(uoe(i)!==cs.ADVERT)return;const a=Date.now()/1e3,{_advertRing:c}=t(),u=c.filter(f=>a-f{t()._poll()},_D);e({_intervalId:o})},stopPolling:()=>{const n=t(),r=Math.max(0,n._refCount-1);e({_refCount:r}),r===0&&(n._intervalId&&(clearInterval(n._intervalId),e({_intervalId:null})),n._wsUnsub&&(n._wsUnsub(),e({_wsUnsub:null})))},_poll:async()=>{var n,r,s;try{const o=await jQ(),i=t();if(!o.success||!((r=(n=o.data)==null?void 0:n.adaptive)!=null&&r.current_tier)){i.available&&e({available:!1});return}const a=o.data,c=Date.now()/1e3,u=Object.keys(a.active_penalties??{});let f=null;const h=Object.entries(a.active_penalties??{}).map(([C,v])=>({pubkey:C,remaining:Math.round(v)})).sort((C,v)=>v.remaining-C.remaining),p=(a.recent_drops??[]).filter(C=>C.seconds_ago<=_D/1e3+5).map(C=>({pubkey:C.pubkey,name:C.name,reason:C.reason})),g=a.tracked_pubkeys??Object.keys(a.bucket_states??{}).length,y=new Set(i._prevPenaltyKeys??[]),b=u.filter(C=>!y.has(C)).map(C=>({pubkey:C,remaining:Math.round((a.active_penalties??{})[C])}));if(i._prevAllowed!==null&&i._prevDropped!==null){const C=Math.max(0,a.stats.adverts_allowed-i._prevAllowed),v=Math.max(0,a.stats.adverts_dropped-i._prevDropped);f={ts:c,allowedDelta:C,droppedDelta:v,newlyGuarded:b,penalties:h,drops:p,trackedCount:g}}const w=f?[...i.history,f].slice(-ioe):i.history;e({liveStats:a,history:w,available:!0,initialized:!0,serverEwma:((s=a.metrics)==null?void 0:s.adverts_per_min_ewma)??0,_prevAllowed:a.stats.adverts_allowed,_prevDropped:a.stats.adverts_dropped,_prevPenaltyKeys:u})}catch{t().available&&e({available:!1})}}})),Tce=()=>Zl(e=>e.liveStats),Bce=()=>Zl(e=>e.history),Fce=()=>Zl(e=>e.available),Pce=()=>Zl(e=>e.initialized),Mce=()=>Zl(e=>{const t=e.serverEwma,n=e.clientRate;return t>0&&n>0?t*loe+n*coe:t||n}),doe="";async function Gi(e,t){const n=`${doe}${e}`;vC()&&await Xl();const r=Or(),s=r?{Authorization:`Bearer ${r}`}:{},o=await fetch(n,{...t,headers:{...s,...t==null?void 0:t.headers}});if(!o.ok)throw new Error(`Analytics API error: ${o.status} ${o.statusText}`);return o.json()}async function DD(e=!1){return Gi(`/api/analytics/topology${e?"?rebuild=true":""}`)}async function foe(){return Gi("/api/analytics/disambiguation")}async function hoe(e=168){return Gi(`/api/analytics/last_hop_neighbors?hours=${e}`)}async function poe(e=168){return Gi(`/api/analytics/neighbor_affinity?hours=${e}`)}async function moe(e=168){return Gi(`/api/analytics/mobile_nodes?hours=${e}`)}async function goe(e=20){return Gi(`/api/analytics/path_health?limit=${e}`)}async function yoe(e=24){return Gi(`/api/analytics/tx_recommendations?hours=${e}`)}async function boe(e=168){return Gi(`/api/analytics/sparklines?hours=${e}`)}async function voe(e){return Gi(`/api/analytics/bucketed_stats?preset=${e}`)}const g1={topology:6e4,neighbors:3e4,bucketedStats:3e4};let j2=[];xr((e,t)=>({backendAvailable:null,checkingBackend:!1,topology:null,topologyLoading:!1,topologyError:null,topologyLastUpdated:0,disambiguationStats:null,disambiguationLoading:!1,lastHopNeighbors:null,neighborsLoading:!1,neighborAffinity:null,affinityLoading:!1,mobileNodes:null,mobileLoading:!1,pathHealth:null,pathHealthLoading:!1,txRecommendation:null,txRecommendationLoading:!1,sparklines:new Map,sparklinesLoading:!1,sparklineHours:168,bucketedStats:null,bucketedStatsPreset:"1h",bucketedStatsLoading:!1,checkBackendAvailability:async()=>{e({checkingBackend:!0});try{const r=await DD(),s=r.success!==!1&&!r.error;return e({backendAvailable:s,checkingBackend:!1}),s}catch{return e({backendAvailable:!1,checkingBackend:!1}),!1}},fetchTopology:async(n=!1)=>{e({topologyLoading:!0,topologyError:null});try{const r=await DD(n);if(r.success===!1){e({topologyError:r.error||"Failed to fetch topology",topologyLoading:!1});return}e({topology:r||r,topologyLoading:!1,topologyLastUpdated:Date.now()})}catch(r){e({topologyError:r instanceof Error?r.message:"Failed to fetch topology",topologyLoading:!1})}},fetchDisambiguationStats:async()=>{e({disambiguationLoading:!0});try{const n=await foe();n.success!==!1?e({disambiguationStats:n,disambiguationLoading:!1}):e({disambiguationLoading:!1})}catch{e({disambiguationLoading:!1})}},fetchLastHopNeighbors:async(n=168)=>{e({neighborsLoading:!0});try{const r=await hoe(n);r.success!==!1?e({lastHopNeighbors:r,neighborsLoading:!1}):e({neighborsLoading:!1})}catch{e({neighborsLoading:!1})}},fetchNeighborAffinity:async(n=168)=>{e({affinityLoading:!0});try{const r=await poe(n);r.success!==!1?e({neighborAffinity:r,affinityLoading:!1}):e({affinityLoading:!1})}catch{e({affinityLoading:!1})}},fetchMobileNodes:async(n=168)=>{e({mobileLoading:!0});try{const r=await moe(n);r.success!==!1?e({mobileNodes:r,mobileLoading:!1}):e({mobileLoading:!1})}catch{e({mobileLoading:!1})}},fetchPathHealth:async(n=20)=>{e({pathHealthLoading:!0});try{const r=await goe(n);r.success!==!1?e({pathHealth:r.paths??[],pathHealthLoading:!1}):e({pathHealthLoading:!1})}catch{e({pathHealthLoading:!1})}},fetchTxRecommendation:async(n=24)=>{e({txRecommendationLoading:!0});try{const r=await yoe(n);r.success!==!1?e({txRecommendation:r,txRecommendationLoading:!1}):e({txRecommendationLoading:!1})}catch{e({txRecommendationLoading:!1})}},fetchSparklines:async(n=168)=>{e({sparklinesLoading:!0,sparklineHours:n});try{const r=await boe(n);if(r.success!==!1){const s=r,o=new Map;if(s.sparklines)for(const[i,a]of Object.entries(s.sparklines))o.set(i,a);e({sparklines:o,sparklinesLoading:!1})}else e({sparklinesLoading:!1})}catch{e({sparklinesLoading:!1})}},fetchBucketedStats:async n=>{e({bucketedStatsLoading:!0,bucketedStatsPreset:n});try{const r=await voe(n);r.success!==!1?e({bucketedStats:r,bucketedStatsLoading:!1}):e({bucketedStatsLoading:!1})}catch{e({bucketedStatsLoading:!1})}},initialize:async()=>{if(await t().checkBackendAvailability()&&(await Promise.all([t().fetchTopology(),t().fetchDisambiguationStats(),t().fetchLastHopNeighbors(),t().fetchMobileNodes(),t().fetchPathHealth(),t().fetchSparklines(),t().fetchBucketedStats("1h")]),typeof window<"u")){const r=setInterval(()=>{t().backendAvailable&&t().fetchTopology()},g1.topology),s=setInterval(()=>{t().backendAvailable&&t().fetchLastHopNeighbors()},g1.neighbors),o=setInterval(()=>{t().backendAvailable&&t().fetchBucketedStats(t().bucketedStatsPreset)},g1.bucketedStats);j2=[r,s,o]}},refreshAll:async()=>{const{backendAvailable:n}=t();n&&await Promise.all([t().fetchTopology(!0),t().fetchDisambiguationStats(),t().fetchLastHopNeighbors(),t().fetchNeighborAffinity(),t().fetchMobileNodes(),t().fetchPathHealth(),t().fetchTxRecommendation(),t().fetchSparklines(),t().fetchBucketedStats(t().bucketedStatsPreset)])}}));function woe(){for(const e of j2)clearInterval(e);j2=[]}const X9="pymc-basemap-mode",TD="dark";function Eoe(){if(typeof window>"u")return TD;try{const e=localStorage.getItem(X9);if(e==="light"||e==="dark")return e}catch{}return TD}function BD(e){if(!(typeof window>"u"))try{localStorage.setItem(X9,e)}catch{}}const ex=xr(e=>({mode:Eoe(),toggle:()=>e(t=>{const n=t.mode==="light"?"dark":"light";return BD(n),{mode:n}}),setMode:t=>{BD(t),e({mode:t})}})),Rce=()=>ex(e=>e.mode),Lce=()=>ex(e=>e.toggle);function Coe(){const e=ci(n=>n.blockedTierRequest),t=ci(n=>n.dismissBlockedTier);return e?P.jsxs(pB,{open:!0,onClose:t,size:"sm",children:[P.jsx(km,{icon:P.jsx(gz,{className:"w-5 h-5 text-sys-amber"}),title:"Time Range Limited",onClose:t}),P.jsx(Vd,{children:P.jsxs("div",{className:"flex items-start gap-3",children:[P.jsx(LU,{className:"w-5 h-5 text-sys-indigo flex-shrink-0 mt-0.5"}),P.jsxs("div",{className:"text-sm text-fg-secondary space-y-2",children:[P.jsxs("p",{children:["An external database source is active. Remote sources are limited to ",P.jsx("strong",{className:"text-fg-primary",children:GJ})," of historical data."]}),P.jsxs("p",{children:["You selected ",P.jsx("strong",{className:"text-fg-primary",children:e}),", which exceeds this limit. Disconnect the remote source first to access longer local time ranges."]})]})]})}),P.jsx(wv,{children:P.jsx(Vl,{color:"muted",onClick:t,className:"flex-1",children:"Got it"})})]}):null}const xoe=B.memo(Coe),koe={standard:"w-3 h-3",compact:"w-2.5 h-2.5",responsive:"w-2.5 h-2.5 sm:w-3 sm:h-3"};function FD({children:e,copyValue:t,copy:n=!1,size:r="standard",className:s,title:o,color:i,truncate:a}){const[c,u]=B.useState(!1),f=B.useRef(null),h=t??(typeof e=="string"?e:""),p=koe[r],g=(()=>{if(!a||a==="css"||typeof e!="string")return e;const C=e,[v,x]=a===!0?[6,4]:a;return C.length<=v+x+3?C:`${C.slice(0,v)}…${C.slice(-x)}`})(),y=B.useCallback(async C=>{if(!n)return;C.preventDefault(),C.stopPropagation(),f.current&&clearTimeout(f.current);const v=await xB(h);u(!0),f.current=setTimeout(()=>u(!1),2e3),v||console.warn("Copy may have failed for:",h.slice(0,16)+"...")},[n,h]),b=r==="compact"?"data-box-compact":r==="responsive"?"data-box-responsive":"",w=n?o||`Click to copy: ${h}`:o;return n?P.jsxs("button",{type:"button",onClick:y,className:qe("data-box interactive group",b,"cursor-pointer select-none gap-1","hover-bg",i,a==="css"&&"max-w-full flex justify-between",s),title:w,"aria-label":`Copy ${h}`,children:[P.jsx("span",{className:qe("transition-colors duration-200",c?"text-sys-green":"",a==="css"&&"truncate"),children:g}),P.jsx("span",{className:qe("flex items-center justify-center flex-shrink-0",r==="compact"?"w-3 h-3":"w-3.5 h-3.5"),children:c?P.jsx(oy,{className:qe("text-sys-green",p)}):P.jsx(AT,{className:qe("opacity-40 group-hover:opacity-70 transition-opacity duration-200",p)})})]}):P.jsx("span",{className:qe("data-box",b,i,a==="css"&&"truncate block max-w-full",s),title:w,children:g})}const dh="\x1B[",Soe=`${dh}0m`,ur=`${dh}1m`,PD=`${dh}2m`;function Lo(e,t,n){return`${dh}38;2;${e};${t};${n}m`}const MD=" . ˙',·∙⁺˚°:;~*+✧✩×✴░✦✶✳oO▒#%&xX▓@MW8B█████",RD="✦✶✳✧✴✩×";function Aoe(e,t=.08){const n=e+(Math.random()-.5)*t*2,r=Math.max(0,Math.min(.999,n));return MD[Math.floor(r*MD.length)]}function LD(){return RD[Math.floor(Math.random()*RD.length)]}const _o=[[6,4,28],[14,10,60],[30,24,105],[50,45,160],[72,70,200],[91,91,214],[150,150,245]];function y1(e){const n=Math.max(0,Math.min(1,e))*(_o.length-1),r=Math.floor(n),s=Math.min(r+1,_o.length-1),o=n-r;return Lo(Math.round(_o[r][0]+(_o[s][0]-_o[r][0])*o),Math.round(_o[r][1]+(_o[s][1]-_o[r][1])*o),Math.round(_o[r][2]+(_o[s][2]-_o[r][2])*o))}const Md=Lo(0,240,255),b1=Lo(255,50,180),v1=Lo(255,252,255),_oe=Lo(80,255,180),ID=Lo(255,180,120),Rd=`${dh}38;2;91;91;214m`;function Doe(e){return 1-Math.pow(1-e,3)}function Toe(e){return e*.3+e*e*e*.7}const Boe=80,Ma=14,ag=12,Foe=1,Poe=Ma+ag+Foe;function Moe(e){var a;const t=e.length,n=Math.max(...e.map(c=>c.length)),r=t/2,s=n/2,o=new Float32Array(t*n);let i=0;for(let c=0;ci&&(i=p)}return{dist:o,maxDist:i,cols:n,rows:t}}let O2=null,$2=null;function Roe(){O2=null,$2=null}function ND(e,t){$2!==e&&(O2=Moe(e),$2=e);const{dist:n,maxDist:r,cols:s,rows:o}=O2,i=t=Ma&&t=Ma+ag,u=Math.min(1,t/Ma),f=a?Math.min(1,(t-Ma)/Math.max(1,ag-1)):c?1:0,h=a||c?r*(1-Toe(f)):Doe(u)*r,p=h*.72,g=h*.45,y=i?-.6:.9,b=[],w=o/2,C=s/2,v=5,x=Ma,_=19,S=t>=v&&t<=_,k=S?t<=x?(t-v)/(x-v):1-(t-x)/(_-x):0,F=Math.sin(t*3.4)*.28+Math.sin(t*5.9)*.24+Math.sin(t*9.7)*.18+Math.sin(t*14.3)*.12,A=Math.max(.12,.55+F*.55),D=Math.sin(t*.85),L=.5+.5*D,N=.5-.5*D,I=(.3+2.7*L)*Math.max(0,k)*A,U=(.5+3.5*N)*Math.max(0,k)*A;for(let $=0;$.2||U>.3)){const V=Math.abs($-w),K=Math.abs(G-C);if(V.8?"█":ee||ye>.6?"✦":ye>.3?"✶":"✴",ne=ke==="█"?v1+ur:ee||ke==="✦"?(ye>.5?v1:Md)+ur:(ye>.65?Md:Rd)+ur;ne!==W&&(Z+=ne,W=ne),Z+=ke;continue}}if(Y){Z+=" ",W="";continue}if(c){const V=Rd+ur;V!==W&&(Z+=V,W=V),Z+=oe}else if(a&&q>h){const V=q-h;if(V.85){const ne=(ye-.85)/.15;ke=Lo(Math.round(190+65*ne),Math.round(210+42*ne),255)+ur}else if(ye>.6)if(ee<.1)ke=Md+ur;else if(ee<.16)ke=b1+ur;else{const ne=(ye-.6)/.25;ke=Lo(Math.round(120+70*ne),Math.round(150+60*ne),255)+ur}else ke=y1(.7+ye*.3)+ur;ke!==W&&(Z+=ke,W=ke)}else if(Math.random()<.008){const ye=ID;ye!==W&&(Z+=ye,W=ye)}else Rd!==W&&(Z+=Rd,W=Rd);Z+=oe}else if(q>h)Z+=" ",W="";else{const V=h-q,K=Math.exp(-V/(r*.22)),ye=Math.max(0,1-V/(r*.55)),ee=K*.7+ye*.3,ke=Math.max(0,1-Math.abs(q-p)/(r*.18)),ne=Math.max(0,1-Math.abs(q-g)/(r*.22)),re=Math.sin(G*.3)*.8,xe=Math.sin($*.4+G*.15)*.5,te=Math.sin(q*3+t*y+re)*.5+.5,de=Math.sin(q*6.5+t*y*1.8+re*.5+xe)*.5+.5,ge=Math.sin(q*1.3-t*y*.35+re*1.5+$*.08)*.5+.5,Fe=te*te*.5+de*.28+ge*.22,Te=t<2&&q.2)ve<.35?Me=v1+ur:ve<.55?Me=b1+ur:ve<.7?Me=Md+ur:Me=y1(.95)+ur;else if(Ne>.8)if(ve<.08)Me=b1+ur;else if(ve<.14)Me=Md+ur;else{const Ge=(Ne-.8)/.2;Me=Lo(Math.round(190+65*Ge),Math.round(210+42*Ge),255)+ur}else if(Ne>.55)if(ve<.05)Me=_oe+ur;else{const Ge=(Ne-.55)/.25;Me=Lo(Math.round(110+80*Ge),Math.round(140+70*Ge),Math.round(245+10*Ge))+ur}else if(Ne>.32){const Ge=(Ne-.32)/.23;Me=Lo(Math.round(91+19*Ge),Math.round(91+49*Ge),Math.round(214+31*Ge))+(Ge>.5?ur:"")}else Pe<.12&&Fe>.65&&ve<.08?Me=ID+PD:Me=y1(Oe)+(Pe>.4?ur:Pe<.12?PD:"");if(Me!==W&&(Z+=Me,W=Me),Pe>.82&&ee>.7)Z+=LD();else if(Pe>.7&&ke>.5&&Math.random()<.2)Z+=LD();else{const Ge=.02+(1-Pe)*.05;Z+=Aoe(Pe,Ge)}}}}b.push(Z+Soe)}return b}const Nf=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "],Loe=Poe-1,Ioe=Nf.length,Noe=Math.max(...Nf.map(e=>e.length)),joe=.994,Ooe=.08,$oe=.25,Uoe=8,zoe=9.6,Voe=20,J9=.008,jD=20,OD=" . ˙·∙⁺˚°:;~*+✧✩×✴░✦✶✳oO▒#%&xX▓@MW8B█████",Hoe={" ":0,".":.08,":":.15,"!":.5,"@":.85,"#":.6,$:.7,"%":.65,"&":.6,"*":.3,"+":.25,"-":.1,"=":.2,_:.05,"~":.2,"^":.15,"|":.4,"/":.3,"\\":.3,"(":.35,")":.35,"[":.4,"]":.4,"{":.45,"}":.45,"<":.3,">":.3,"?":.4,";":.2,"'":.1,'"':.15,",":.08,"`":.05};function Woe(e){let t="",n=0,r=!1,s="",o=!1,i=!1,a=!1;for(;n",r=!1),s="",o=!1,i=!1,a=!1;else if(u==="1")o=!0,a=!0;else if(u==="2")i=!0,a=!0;else if(u.startsWith("38;2;")){const f=u.split(";");s=`rgb(${f[2]},${f[3]},${f[4]})`,a=!0}}else{if(a){r&&(t+="");const u=[];s&&u.push(`color:${s}`),o&&u.push("font-weight:700"),i&&u.push("opacity:0.6"),u.length>0?(t+=``,r=!0):r=!1,a=!1}const c=e[n];c==="<"?t+="<":c===">"?t+=">":c==="&"?t+="&":t+=c,n++}return r&&(t+=""),t}function $D(e){let t="";for(let n=0;n0&&(t+=` `),t+=Woe(e[n]);return t}const qoe="rgb(91,91,214)",Sa=[[91,91,214],[72,70,200],[110,110,230],[150,150,245],[190,210,255],[0,240,255],[255,50,180],[80,255,180]];function w1(e,t,n){return`rgb(${Math.round(e[0]+(t[0]-e[0])*n)},${Math.round(e[1]+(t[1]-e[1])*n)},${Math.round(e[2]+(t[2]-e[2])*n)})`}function Goe(e){const t=Math.max(0,Math.min(.999,e));return OD[Math.floor(t*OD.length)]}function Koe(e){return Hoe[e]??.5}function Yoe(e,t){const n=Math.abs(e);if(n<.3)return w1(Sa[0],Sa[2],n/.3);if(n<.6){const r=(n-.3)/.3;return w1(Sa[3],Sa[4],r)}else{const r=Math.sin(t*17.3)*.5+.5;return r<.4?w1(Sa[4],Sa[5],(n-.6)/.4):r<.6?`rgb(${Sa[6].join(",")})`:r<.7?`rgb(${Sa[7].join(",")})`:"rgb(255,252,255)"}}function UD(e){let t="";for(let n=0;n0&&(t+=` -`);const r=Nf[n]||"";for(let s=0;s0?Math.exp(-b*b/2):Math.exp(-b*b/12),C=g*$oe-f.radius*.4,v=Math.sin(C*Math.PI),x=w*f.strength;i+=w*v*f.strength,x>c&&(c=x,a=C+n*.1+s*.05)}if(i=Math.max(-1,Math.min(1,i)),Math.abs(i)${o}`;else{const h=Koe(o)+i*.5,p=Math.max(.02,Math.min(.98,h)),g=Goe(p),y=Yoe(i,a);t+=`${g}`}}}return t}function Qoe(){const e=B.useRef(null),t=B.useRef([]),n=B.useRef(0),[r,s]=B.useState(!1);B.useEffect(()=>{const h=e.current;if(!h)return;let p=0;h.innerHTML=$D(ND(Nf,0));const g=setInterval(()=>{if(p++,p>Loe){clearInterval(g),s(!0);return}h.innerHTML=$D(ND(Nf,p))},Boe);return()=>{clearInterval(g),Roe()}},[]),B.useEffect(()=>{if(!r)return;const h=e.current;if(!h)return;let p=!0;const g=()=>{if(!p)return;const y=t.current;for(const b of y)b.radius+=Ooe,b.strength*=joe;t.current=y.filter(b=>b.strength>J9),t.current.length>0?h.innerHTML=UD(t.current):h.innerHTML=UD([]),n.current=requestAnimationFrame(g)};return n.current=requestAnimationFrame(g),()=>{p=!1,cancelAnimationFrame(n.current)}},[r]);const o=B.useRef(null),i=B.useCallback((h,p,g=1)=>{const y=e.current;if(!y||!r)return;const b=y.getBoundingClientRect(),w=h-b.left,C=p-b.top,v=w/zoe,x=C/Voe;t.current.length>=Uoe&&t.current.shift(),t.current.push({cx:v,cy:x,radius:0,strength:g}),o.current={x:h,y:p}},[r]),a=B.useCallback(h=>{const p=o.current;if(p){const g=h.clientX-p.x,y=h.clientY-p.y;if(Math.sqrt(g*g+y*y){i(h.clientX,h.clientY,1)},[i]),u=B.useCallback(h=>{o.current=null,i(h.clientX,h.clientY,.6)},[i]),f=B.useCallback(h=>{if(h.touches.length>0){const p=h.touches[0],g=o.current;if(g){const y=p.clientX-g.x,b=p.clientY-g.y;if(Math.sqrt(y*y+b*b){var L;(L=f.current)==null||L.scrollIntoView({behavior:"smooth"})},[r.length]),B.useEffect(()=>{e&&!n&&!s&&(c(),p(E1))},[e]),B.useEffect(()=>{if(s!=="success")return;p(E1);const L=setInterval(()=>{p(N=>N<=1?(clearInterval(L),u(),window.location.reload(),0):N-1)},1e3);return()=>clearInterval(L)},[s,u]);const g=B.useCallback(()=>{a()},[a]),y=B.useCallback(()=>{s==="error"?u():i()},[s,u,i]),b=WF(),w=n||s!==null,C=s!==null,v=L=>L.split("+")[0],x=L=>L!=null&&L.includes("+")?L.split("+")[1]:null,_=(t==null?void 0:t.current_version)??(b==null?void 0:b.version)??"?",S=v(_),k=(t==null?void 0:t.latest_version)??"?",F=v(k),A=x(_),D=x(k);return P.jsx(pB,{open:e,onClose:w?()=>{}:y,size:"lg",bottomSheet:!0,children:w?C?s==="success"?P.jsx(P.Fragment,{children:P.jsxs(Vd,{className:"!py-6",children:[P.jsx("div",{className:"flex justify-center mb-4 overflow-hidden",children:P.jsx(Xoe,{})}),P.jsxs("div",{className:"text-center space-y-2",children:[P.jsxs("div",{className:"flex items-center justify-center gap-2",children:[P.jsx(CU,{className:"w-5 h-5 text-sys-green"}),P.jsx("h3",{className:"type-subheading text-fg-primary font-semibold",children:"Upgrade Complete"})]}),P.jsxs("p",{className:"type-data-xs text-fg-muted font-mono",children:["v",S," → v",F,(t==null?void 0:t.channel)&&t.channel!=="main"&&P.jsxs("span",{className:"text-sys-indigo ml-1",children:["(",t.channel,")"]})]}),P.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[P.jsx(uz,{className:"w-3.5 h-3.5 text-sys-blue animate-spin"}),P.jsxs("span",{className:"type-data-xs text-fg-muted",children:["Reloading in ",h,"s..."]})]})]})]})}):P.jsxs(P.Fragment,{children:[P.jsx(km,{icon:P.jsx(kU,{className:"w-5 h-5 text-sys-red"}),title:"Update Failed"}),P.jsxs(Vd,{className:"!py-4",children:[P.jsxs("details",{className:"mb-3",children:[P.jsxs("summary",{className:"type-data-xs text-fg-muted cursor-pointer hover:text-fg-secondary transition-colors",children:["Install log (",r.length," lines)"]}),P.jsx("div",{className:qe("bg-zinc-950 radius-inner p-3 font-mono text-xs leading-5 overflow-y-auto mt-2","border border-edge-subtle","max-h-[200px]"),children:r.map((L,N)=>P.jsx("div",{className:"text-zinc-300 whitespace-pre-wrap break-all",children:L},N))})]}),o&&P.jsx("div",{className:"bg-sys-red/10 border border-sys-red/30 radius-inner p-3",children:P.jsx("p",{className:"text-sm text-sys-red",children:o})})]}),P.jsx(wv,{children:P.jsx(Vl,{color:"muted",onClick:y,children:"Close"})})]}):P.jsxs(P.Fragment,{children:[P.jsx(km,{icon:P.jsx(mb,{className:"w-5 h-5"}),title:"Updating pyMC Repeater"}),P.jsxs(Vd,{className:"!py-4",children:[P.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[P.jsx(DT,{className:"w-4 h-4 text-sys-blue animate-spin"}),P.jsx("span",{className:"type-data-xs text-sys-blue font-medium",children:(t==null?void 0:t.state)==="restarting"?"Restarting service...":"Installing update..."})]}),P.jsxs("div",{className:qe("bg-zinc-950 radius-inner p-3 font-mono text-xs leading-5 overflow-y-auto","border border-edge-subtle","min-h-[120px] max-h-[300px]"),children:[r.length===0&&P.jsx("span",{className:"text-zinc-500",children:"Waiting for output..."}),r.map((L,N)=>P.jsx("div",{className:"text-zinc-300 whitespace-pre-wrap break-all",children:L},N)),P.jsx("div",{ref:f})]})]})]}):P.jsxs(P.Fragment,{children:[P.jsx(km,{icon:P.jsx(mb,{className:"w-5 h-5"}),title:"Update pyMC Repeater",onClose:y}),P.jsxs(Vd,{children:[P.jsxs("p",{className:"text-sm text-fg-secondary mb-4",children:["This will upgrade from"," ",P.jsxs("span",{className:"font-mono font-medium text-fg-primary",children:["v",S]}),A&&P.jsxs(P.Fragment,{children:[" ",P.jsx(FD,{size:"compact",copy:!0,copyValue:A,children:A})]})," → ",P.jsxs("span",{className:"font-mono font-medium text-sys-green",children:["v",F]}),D&&P.jsxs(P.Fragment,{children:[" ",P.jsx(FD,{size:"compact",copy:!0,copyValue:D,children:D})]}),(t==null?void 0:t.channel)&&t.channel!=="main"&&P.jsxs(P.Fragment,{children:[" on ",P.jsx("span",{className:"font-mono font-medium text-sys-indigo",children:t.channel})]}),". The service will restart automatically."]}),P.jsx("div",{className:"bg-sys-amber/10 border border-sys-amber/30 radius-inner p-3",children:P.jsxs("div",{className:"flex gap-2",children:[P.jsx(Rz,{className:"w-4 h-4 text-sys-amber flex-shrink-0 mt-0.5"}),P.jsxs("p",{className:"text-sm text-fg-secondary",children:["The repeater will be ",P.jsx("strong",{className:"text-fg-primary",children:"offline for ~30 seconds"})," during the update. Active mesh traffic will resume once the service restarts."]})]})})]}),P.jsxs(wv,{children:[P.jsx(Vl,{color:"muted",onClick:y,children:"Cancel"}),P.jsxs(Vl,{color:"danger",onClick:g,children:[P.jsx(mb,{"data-slot":"icon"}),"Update Now"]})]})]})})}function Uu({withControls:e=!1}){return P.jsxs("div",{className:"flex items-center justify-between gap-3 min-h-9",children:[P.jsx(Nt,{className:"h-7 w-40 sm:w-52"}),e&&P.jsx(Nt,{className:"h-8 w-48 sm:w-56 radius-inner"})]})}function jo({className:e,children:t}){return P.jsx("div",{className:`bg-surface/80 radius-card depth-raised h-full flex flex-col p-4 sm:p-5 ${e??""}`,children:t})}const Zoe=[45,72,33,58,80,42,65,28,55,75,38,62];function tx(){return P.jsx("div",{className:"flex-1 flex items-end gap-1",children:Zoe.map((e,t)=>P.jsx(Nt,{className:"flex-1",style:{height:`${e}%`}},t))})}function eie(){return P.jsxs("div",{className:"section-gap","aria-label":"Loading dashboard","aria-busy":"true",children:[P.jsx(Uu,{withControls:!0}),P.jsxs("div",{className:"bento-section",children:[P.jsx("div",{className:"bento-row-hero-auto grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsxs(jo,{children:[P.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-36"})]}),P.jsx(tx,{})]})})}),P.jsx("div",{className:"bento-row-compact grid-12 bento-gap",children:[1,2,3].map(e=>P.jsx("div",{className:"col-span-6 lg:col-span-4",children:P.jsxs(jo,{children:[P.jsx(Nt,{className:"h-4 w-24 mb-3"}),P.jsx(Nt,{className:"h-8 w-16"})]})},e))}),P.jsx("div",{className:"bento-row-widget grid-12 bento-gap",children:[1,2,3,4].map(e=>P.jsx("div",{className:"col-span-6 sm:col-span-4 md:col-span-3",children:P.jsxs(jo,{children:[P.jsx(Nt,{className:"h-3 w-20 mb-2"}),P.jsx(Nt,{className:"h-6 w-12"})]})},e))})]})]})}function Yc(){return P.jsxs("div",{className:"section-gap","aria-label":"Loading list","aria-busy":"true",children:[P.jsx(Uu,{withControls:!0}),P.jsxs("div",{className:"bento-section",children:[P.jsx("div",{className:"bento-row-auto grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsx(jo,{className:"!py-3",children:P.jsxs("div",{className:"flex gap-3",children:[P.jsx(Nt,{className:"h-8 w-28 radius-inner"}),P.jsx(Nt,{className:"h-8 w-28 radius-inner"}),P.jsx(Nt,{className:"h-8 w-28 radius-inner hidden sm:block"})]})})})}),P.jsx("div",{className:"bento-row-auto grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsx(jo,{children:P.jsx("div",{className:"space-y-4",children:Array.from({length:8}).map((e,t)=>P.jsxs("div",{className:"flex items-center gap-4",children:[P.jsx(Nt,{className:"w-10 h-10 radius-inner shrink-0"}),P.jsxs("div",{className:"flex-1 space-y-2",children:[P.jsx(Nt,{className:"h-4 w-48"}),P.jsx(Nt,{className:"h-3 w-32"})]}),P.jsx(Nt,{className:"w-16 h-4 hidden sm:block"})]},t))})})})})]})]})}function tie(){return P.jsxs("div",{className:"section-gap","aria-label":"Loading map","aria-busy":"true",children:[P.jsx(Uu,{withControls:!0}),P.jsx("div",{className:"bento-section",children:P.jsx("div",{className:"grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsx(jo,{className:"!min-h-[60vh]",children:P.jsx(Nt,{className:"flex-1 w-full radius-inset"})})})})})]})}function C1(){return P.jsxs("div",{className:"section-gap","aria-label":"Loading charts","aria-busy":"true",children:[P.jsx(Uu,{withControls:!0}),P.jsxs("div",{className:"bento-section",children:[P.jsx("div",{className:"bento-row-hero-auto grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsxs(jo,{children:[P.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-32"})]}),P.jsx(tx,{})]})})}),P.jsx("div",{className:"bento-row-panel grid-12 bento-gap",children:[1,2].map(e=>P.jsx("div",{className:"col-span-12 md:col-span-6",children:P.jsxs(jo,{children:[P.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-28"})]}),P.jsx(Nt,{className:"flex-1 w-full radius-inset"})]})},e))})]})]})}function nie(){return P.jsxs("div",{className:"section-gap","aria-label":"Loading system","aria-busy":"true",children:[P.jsx(Uu,{withControls:!0}),P.jsxs("div",{className:"bento-section",children:[P.jsx("div",{className:"bento-row-hero grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsxs(jo,{children:[P.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-36"})]}),P.jsx(tx,{})]})})}),P.jsx("div",{className:"bento-row-compact grid-12 bento-gap",children:[1,2,3,4].map(e=>P.jsx("div",{className:"col-span-12 sm:col-span-6",children:P.jsxs(jo,{children:[P.jsx(Nt,{className:"h-4 w-28 mb-3"}),P.jsx(Nt,{className:"h-6 w-20 mb-2"}),P.jsx(Nt,{className:"flex-1 w-full radius-inset"})]})},e))})]})]})}function x1(){return P.jsxs("div",{className:"section-gap","aria-label":"Loading settings","aria-busy":"true",children:[P.jsx(Uu,{}),P.jsx("div",{className:"bento-section",children:P.jsx("div",{className:"bento-row-auto grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsx(jo,{children:P.jsx("div",{className:"space-y-6",children:[.6,.8,.5,.7,.4].map((e,t)=>P.jsxs("div",{className:"space-y-2",children:[P.jsx(Nt,{className:"h-3 w-24"}),P.jsx(Nt,{className:"h-10 radius-inner",style:{width:`${e*100}%`}})]},t))})})})})})]})}const rie=1024;function ls({children:e,fallback:t}){const[n,r]=B.useState(!1);return B.useEffect(()=>{let s=!1;const o=window.innerWidth{o?setTimeout(()=>{s||B.startTransition(()=>r(!0))},JG):requestAnimationFrame(()=>{s||B.startTransition(()=>r(!0))})}),()=>{s=!0}},[]),n?P.jsx(B.Suspense,{fallback:t,children:e}):P.jsx(P.Fragment,{children:t})}function sie(e){e();const t=Jl.getState().initialize(),n=fi.getState().initialize(),r=ln.getState().initialize(),s=oee.getState().initialize();Zl.getState().startPolling();const o=ac.getState().initialize();X5();const i=setInterval(()=>{X5()},3e4),a=_K();return()=>{t(),s(),n==null||n(),r==null||r(),Zl.getState().stopPolling(),o(),a(),clearInterval(i),ZF(),woe()}}const oie=B.lazy(()=>Gn(()=>import("./Login-BbzCGlZ1.js"),[])),iie=B.lazy(()=>Gn(()=>import("./Dashboard-TId1VvOA.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40]))),aie=B.lazy(()=>Gn(()=>import("./Packets-DkmiTj3L.js"),__vite__mapDeps([41,6,9,42,19,43,44,8,10,2,11,12,13,14,15,16,17,18,20,21,22,23,24,25,26,27,4,5,28,29,30,31,45,46,47,1]))),lie=B.lazy(()=>Gn(()=>import("./Contacts-CTRl8l-x.js").then(e=>e.C),__vite__mapDeps([48,31,6,1,49,42,19,50,44,29,17,2,12,13,51,52,53,54,20,55,25,56,57,47,23,58]))),cie=B.lazy(()=>Gn(()=>import("./Statistics-B5Y-pM3d.js"),__vite__mapDeps([59,21,2,60,61,29,17,19,1,3,4,5,51,52,53,22,32,25,45,6,20,46,47,31,40,62,63,58]))),uie=B.lazy(()=>Gn(()=>import("./MeshGraph-D_cqlL51.js").then(e=>e.M),__vite__mapDeps([64,65,2,66,67,23,26,11,7,54,21,47,62,68,17,63]))),die=B.lazy(()=>Gn(()=>import("./System-C3tiCIme.js"),__vite__mapDeps([69,1,14,63,16,70,25,71,40]))),fie=B.lazy(()=>Gn(()=>import("./Logs-DyZ7duPG.js"),__vite__mapDeps([72,1,73]))),hie=B.lazy(()=>Gn(()=>import("./Terminal-CrgP7ye2.js"),__vite__mapDeps([74,75,1,76,77,47,17,78]))),pie=B.lazy(()=>Gn(()=>import("./Configuration-BmeDX9th.js"),__vite__mapDeps([79,75,57,34,1,35,15,80,77,56,68,28,81,67,23,17,40,82,83,84]))),mie=B.lazy(()=>Gn(()=>import("./RoomServer-BLm1y_Ek.js"),__vite__mapDeps([85,1,40,6,81,49,42,19,50,44,83,86,56,76,77,57,36,12,87,37,84]))),gie=B.lazy(()=>Gn(()=>import("./PacketObservatory-CBpUbS9G.js"),__vite__mapDeps([88,31,6,10,18]))),yie=B.lazy(()=>Gn(()=>import("./Sessions-CB2LEa_r.js"),__vite__mapDeps([89,57,1,40,39,20,28,82,56]))),bie=B.lazy(()=>Gn(()=>import("./Mqtt-DF6wnkuy.js"),__vite__mapDeps([90,1,49,42,19,50,44,62,83,91,30,47,17,22,9,46,73,56,38,71,40,87,92,26,23]))),vie=B.lazy(()=>Gn(()=>import("./Companion-DeUMmHbn.js"),__vite__mapDeps([93,1,12,13,19,42,50,43,5,47,53,24,68,56,22,91,83,36,18,16,17,94,66,23,25,70,39,35,61,67,86,57,84,80]))),wie=B.lazy(()=>Gn(()=>import("./Test-BEpj0lEQ.js"),__vite__mapDeps([95,1,31,6,17,40])));function Eie({children:e}){const t=yo(),n=Of();return B.useEffect(()=>(CK(n),()=>xK()),[n]),yC()?P.jsx(P.Fragment,{children:e}):P.jsx(qR,{to:"/login",state:{from:t},replace:!0})}class Cie extends B.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){var t;return this.state.hasError?P.jsxs("div",{className:"surface-base rounded-2xl p-8 text-center",children:[P.jsx("p",{className:"type-subheading text-sys-red mb-2",children:"Page failed to render"}),P.jsx("p",{className:"type-body text-fg-muted mb-4",children:((t=this.state.error)==null?void 0:t.message)||"Unknown error"}),P.jsx("button",{onClick:()=>this.setState({hasError:!1}),className:"px-4 py-2 bg-sys-blue/20 text-sys-blue rounded-lg hover:bg-sys-blue/30 transition-colors",children:"Try Again"})]}):this.props.children}}function xie(){const e=YF(),t=yC(),{theme:n}=pE();B.useEffect(()=>{if(t)return sie(e)},[e,t]);const r=B.useRef(!0);return B.useEffect(()=>{if(r.current){r.current=!1;return}const s=Uf(n.themeId);s&&ex.getState().setMode(s.meta.isDark?"dark":"light")},[n.themeId]),P.jsxs(ooe,{children:[P.jsx(roe,{}),P.jsx(xoe,{}),P.jsx(Joe,{}),P.jsxs(fS,{children:[P.jsx(Dr,{path:"/login",element:P.jsx(B.Suspense,{fallback:P.jsx("div",{className:"min-h-screen bg-body"}),children:P.jsx(oie,{})})}),P.jsx(Dr,{path:"/*",element:P.jsx(Eie,{children:P.jsx(eK,{sidebar:P.jsx(toe,{}),navbar:P.jsx(noe,{}),children:P.jsx("div",{className:"px-1 sm:px-4 lg:px-4 pt-5 pb-4 sm:pb-6 lg:pb-8 max-w-7xl mx-auto",children:P.jsx(Cie,{children:P.jsxs(fS,{children:[P.jsx(Dr,{path:"/",element:P.jsx(ls,{fallback:P.jsx(eie,{}),children:P.jsx(iie,{})})}),P.jsx(Dr,{path:"/packets",element:P.jsx(ls,{fallback:P.jsx(Yc,{}),children:P.jsx(aie,{})})}),P.jsx(Dr,{path:"/contacts",element:P.jsx(ls,{fallback:P.jsx(tie,{}),children:P.jsx(lie,{})})}),P.jsx(Dr,{path:"/statistics",element:P.jsx(ls,{fallback:P.jsx(C1,{}),children:P.jsx(cie,{})})}),P.jsx(Dr,{path:"/meshgraph",element:P.jsx(ls,{fallback:P.jsx(C1,{}),children:P.jsx(uie,{})})}),P.jsx(Dr,{path:"/system",element:P.jsx(ls,{fallback:P.jsx(nie,{}),children:P.jsx(die,{})})}),P.jsx(Dr,{path:"/logs",element:P.jsx(ls,{fallback:P.jsx(Yc,{}),children:P.jsx(fie,{})})}),P.jsx(Dr,{path:"/terminal",element:P.jsx(ls,{fallback:P.jsx(Yc,{}),children:P.jsx(hie,{})})}),P.jsx(Dr,{path:"/room-server",element:P.jsx(ls,{fallback:P.jsx(Yc,{}),children:P.jsx(mie,{})})}),P.jsx(Dr,{path:"/configuration",element:P.jsx(ls,{fallback:P.jsx(x1,{}),children:P.jsx(pie,{})})}),P.jsx(Dr,{path:"/raw",element:P.jsx(ls,{fallback:P.jsx(Yc,{}),children:P.jsx(gie,{})})}),P.jsx(Dr,{path:"/sessions",element:P.jsx(ls,{fallback:P.jsx(x1,{}),children:P.jsx(yie,{})})}),P.jsx(Dr,{path:"/mqtt",element:P.jsx(ls,{fallback:P.jsx(Yc,{}),children:P.jsx(bie,{})})}),P.jsx(Dr,{path:"/companion",element:P.jsx(ls,{fallback:P.jsx(x1,{}),children:P.jsx(vie,{})})}),P.jsx(Dr,{path:"/test",element:P.jsx(ls,{fallback:P.jsx(C1,{}),children:P.jsx(wie,{})})})]})})})})})})]})]})}const kie=console.warn;console.warn=(...e)=>{const t=e[0];typeof t=="string"&&t.includes("Unable to load glyph range")||kie.apply(console,e)};tR.createRoot(document.getElementById("root")).render(P.jsx(B.StrictMode,{children:P.jsx(NN,{children:P.jsx(y7,{children:P.jsx(xie,{})})})}));export{oK as $,Xoe as A,Vl as B,sae as C,X6 as D,nz as E,Fie as F,fE as G,qa as H,EB as I,ZE as J,lf as K,qn as L,hC as M,zf as N,Le as O,pN as P,qF as Q,ule as R,Bz as S,cle as T,Pie as U,aU as V,Aae as W,zae as X,Jie as Y,pt as Z,Gn as _,Yie as a,bO as a$,oy as a0,AT as a1,DT as a2,xB as a3,iZ as a4,cZ as a5,WF as a6,Zie as a7,tae as a8,oP as a9,FZ as aA,E3 as aB,pB as aC,Vd as aD,J1 as aE,Tce as aF,Bce as aG,soe as aH,fZ as aI,_ie as aJ,km as aK,Fce as aL,Pce as aM,Mce as aN,_T as aO,oZ as aP,jZ as aQ,RC as aR,bz as aS,Lt as aT,W4 as aU,k4 as aV,mj as aW,eO as aX,po as aY,j4 as aZ,rO as a_,lz as aa,SZ as ab,EZ as ac,XF as ad,za as ae,rQ as af,nQ as ag,JZ as ah,hle as ai,see as aj,dle as ak,fle as al,lle as am,_Z as an,Er as ao,Dce as ap,Nt as aq,Xie as ar,Az as as,Tr as at,qX as au,VX as av,HX as aw,Av as ax,GX as ay,tce as az,Sm as b,Kie as b$,X4 as b0,Nn as b1,Gf as b2,bE as b3,ms as b4,O4 as b5,Ka as b6,xE as b7,Ro as b8,Au as b9,g4 as bA,m4 as bB,wO as bC,F4 as bD,Y4 as bE,C4 as bF,bu as bG,kU as bH,Iz as bI,Die as bJ,Tie as bK,HU as bL,TT as bM,MH as bN,DH as bO,Sv as bP,zie as bQ,Rf as bR,PX as bS,oce as bT,mae as bU,pae as bV,xT as bW,Z5 as bX,Rz as bY,BB as bZ,OK as b_,Ia as ba,EE as bb,T4 as bc,Wf as bd,Hf as be,Bs as bf,Yl as bg,er as bh,ai as bi,qf as bj,q4 as bk,CE as bl,Yf as bm,K4 as bn,ds as bo,dO as bp,_O as bq,uO as br,ps as bs,G4 as bt,at as bu,HO as bv,nc as bw,Oo as bx,gA as by,Fu as bz,qe as c,Rce as c$,Yae as c0,Qae as c1,Cq as c2,FD as c3,SC as c4,rce as c5,oh as c6,CU as c7,BC as c8,Kae as c9,gle as cA,UZ as cB,uae as cC,yF as cD,ez as cE,gne as cF,jY as cG,xce as cH,Uie as cI,cce as cJ,jz as cK,Mie as cL,vce as cM,dce as cN,fce as cO,Ece as cP,tJ as cQ,_ae as cR,Tae as cS,NU as cT,eae as cU,QX as cV,ZX as cW,Gte as cX,Jae as cY,jG as cZ,fae as c_,fz as ca,$Z as cb,hae as cc,f_ as cd,wce as ce,sce as cf,HY as cg,Eae as ch,vae as ci,Bae as cj,zX as ck,Hie as cl,lce as cm,cs as cn,Qa as co,Dae as cp,Fae as cq,Vie as cr,QU as cs,cQ as ct,Dg as cu,CZ as cv,yae as cw,bae as cx,xae as cy,kae as cz,Iu as d,mZ as d$,tc as d0,$4 as d1,yE as d2,vE as d3,XO as d4,uu as d5,$d as d6,Mi as d7,K1 as d8,Sf as d9,Pae as dA,Lae as dB,Rae as dC,Sae as dD,Cae as dE,ple as dF,$z as dG,sz as dH,iz as dI,gz as dJ,mb as dK,nce as dL,sy as dM,nae as dN,Cce as dO,DU as dP,JX as dQ,pJ as dR,gJ as dS,bJ as dT,yJ as dU,uz as dV,gte as dW,oQ as dX,aZ as dY,lZ as dZ,pZ as d_,vu as da,Ql as db,Q4 as dc,M4 as dd,_4 as de,$ie as df,zO as dg,rT as dh,YO as di,Io as dj,z4 as dk,U4 as dl,xA as dm,_ce as dn,FY as dp,wae as dq,pee as dr,Ev as ds,iae as dt,Hd as du,cae as dv,mN as dw,JU as dx,gae as dy,Mae as dz,Ot as e,rY as e$,MC as e0,BU as e1,Qie as e2,sJ as e3,OC as e4,Sg as e5,DC as e6,dQ as e7,XZ as e8,Vae as e9,jQ as eA,Gae as eB,ac as eC,NZ as eD,pz as eE,kz as eF,ice as eG,ace as eH,rae as eI,wv as eJ,fi as eK,qae as eL,ble as eM,vle as eN,kle as eO,Sle as eP,wle as eQ,Ele as eR,Cle as eS,xle as eT,oY as eU,iY as eV,fY as eW,aY as eX,KZ as eY,tY as eZ,nY as e_,hQ as ea,fQ as eb,Uae as ec,UX as ed,jt as ee,mQ as ef,wQ as eg,SQ as eh,dF as ei,ND as ej,Boe as ek,Roe as el,Poe as em,NG as en,IG as eo,pT as ep,mg as eq,PE as er,MY as es,SK as et,Jl as eu,gK as ev,St as ew,pE as ex,Q2 as ey,Dm as ez,MV as f,Hle as f$,aae as f0,ale as f1,cK as f2,uK as f3,dK as f4,Xr as f5,rh as f6,hy as f7,PC as f8,kX as f9,ile as fA,Nie as fB,w4 as fC,Oie as fD,jie as fE,B4 as fF,wE as fG,Pu as fH,Ol as fI,ln as fJ,Zle as fK,ece as fL,hee as fM,jle as fN,Mle as fO,Xd as fP,Vle as fQ,Qle as fR,zU as fS,Xle as fT,Jle as fU,Kle as fV,Yle as fW,bQ as fX,Ile as fY,_le as fZ,lte as f_,sh as fa,uF as fb,Nae as fc,jae as fd,Oae as fe,mle as ff,yn as fg,GF as fh,FX as fi,gY as fj,Hae as fk,Wae as fl,No as fm,Pse as fn,Ace as fo,kce as fp,LU as fq,Sce as fr,ci as fs,ele as ft,ole as fu,nle as fv,tle as fw,rle as fx,sle as fy,VF as fz,AB as g,HH as g$,Lle as g0,yQ as g1,gQ as g2,yX as g3,Mf as g4,LG as g5,Ale as g6,Wle as g7,Dle as g8,Tle as g9,pce as gA,mce as gB,hce as gC,Iae as gD,ah as gE,LC as gF,Pz as gG,yle as gH,gee as gI,yce as gJ,UK as gK,dae as gL,Lg as gM,$ae as gN,AZ as gO,QQ as gP,Lce as gQ,Jf as gR,Aq as gS,wu as gT,Wie as gU,Gie as gV,Gz as gW,HW as gX,Kz as gY,rW as gZ,vr as g_,Ple as ga,Ble as gb,Fle as gc,zle as gd,Rle as ge,qle as gf,Nle as gg,Ule as gh,Gle as gi,Ole as gj,$le as gk,Aie as gl,QG as gm,gB as gn,gN as go,Mp as gp,Mj as gq,tS as gr,sQ as gs,Bv as gt,PU as gu,K9 as gv,vB as gw,bce as gx,uce as gy,Pt as gz,An as h,Wn as h0,OE as h1,LV as h2,kV as h3,RV as h4,a8 as h5,ji as h6,_f as h7,k8 as h8,QH as h9,vW as ha,hW as hb,eW as hc,UW as hd,p8 as he,bg as hf,_X as hg,NX as hh,$X as hi,GM as hj,lae as hk,Zae as hl,YX as hm,Xae as hn,eP as ho,yC as i,P as j,Jr as k,oae as l,jr as m,NE as n,Ha as o,VA as p,IE as q,B as r,kK as s,xr as t,Of as u,fF as v,$Y as w,gce as x,Bie as y,J6 as z}; +`);const r=Nf[n]||"";for(let s=0;s0?Math.exp(-b*b/2):Math.exp(-b*b/12),C=g*$oe-f.radius*.4,v=Math.sin(C*Math.PI),x=w*f.strength;i+=w*v*f.strength,x>c&&(c=x,a=C+n*.1+s*.05)}if(i=Math.max(-1,Math.min(1,i)),Math.abs(i)${o}`;else{const h=Koe(o)+i*.5,p=Math.max(.02,Math.min(.98,h)),g=Goe(p),y=Yoe(i,a);t+=`${g}`}}}return t}function Qoe(){const e=B.useRef(null),t=B.useRef([]),n=B.useRef(0),[r,s]=B.useState(!1);B.useEffect(()=>{const h=e.current;if(!h)return;let p=0;h.innerHTML=$D(ND(Nf,0));const g=setInterval(()=>{if(p++,p>Loe){clearInterval(g),s(!0);return}h.innerHTML=$D(ND(Nf,p))},Boe);return()=>{clearInterval(g),Roe()}},[]),B.useEffect(()=>{if(!r)return;const h=e.current;if(!h)return;let p=!0;const g=()=>{if(!p)return;const y=t.current;for(const b of y)b.radius+=Ooe,b.strength*=joe;t.current=y.filter(b=>b.strength>J9),t.current.length>0?h.innerHTML=UD(t.current):h.innerHTML=UD([]),n.current=requestAnimationFrame(g)};return n.current=requestAnimationFrame(g),()=>{p=!1,cancelAnimationFrame(n.current)}},[r]);const o=B.useRef(null),i=B.useCallback((h,p,g=1)=>{const y=e.current;if(!y||!r)return;const b=y.getBoundingClientRect(),w=h-b.left,C=p-b.top,v=w/zoe,x=C/Voe;t.current.length>=Uoe&&t.current.shift(),t.current.push({cx:v,cy:x,radius:0,strength:g}),o.current={x:h,y:p}},[r]),a=B.useCallback(h=>{const p=o.current;if(p){const g=h.clientX-p.x,y=h.clientY-p.y;if(Math.sqrt(g*g+y*y){i(h.clientX,h.clientY,1)},[i]),u=B.useCallback(h=>{o.current=null,i(h.clientX,h.clientY,.6)},[i]),f=B.useCallback(h=>{if(h.touches.length>0){const p=h.touches[0],g=o.current;if(g){const y=p.clientX-g.x,b=p.clientY-g.y;if(Math.sqrt(y*y+b*b){var L;(L=f.current)==null||L.scrollIntoView({behavior:"smooth"})},[r.length]),B.useEffect(()=>{e&&!n&&!s&&(c(),p(E1))},[e]),B.useEffect(()=>{if(s!=="success")return;p(E1);const L=setInterval(()=>{p(N=>N<=1?(clearInterval(L),u(),window.location.reload(),0):N-1)},1e3);return()=>clearInterval(L)},[s,u]);const g=B.useCallback(()=>{a()},[a]),y=B.useCallback(()=>{s==="error"?u():i()},[s,u,i]),b=WF(),w=n||s!==null,C=s!==null,v=L=>L.split("+")[0],x=L=>L!=null&&L.includes("+")?L.split("+")[1]:null,_=(t==null?void 0:t.current_version)??(b==null?void 0:b.version)??"?",S=v(_),k=(t==null?void 0:t.latest_version)??"?",F=v(k),A=x(_),D=x(k);return P.jsx(pB,{open:e,onClose:w?()=>{}:y,size:"lg",bottomSheet:!0,children:w?C?s==="success"?P.jsx(P.Fragment,{children:P.jsxs(Vd,{className:"!py-6",children:[P.jsx("div",{className:"flex justify-center mb-4 overflow-hidden",children:P.jsx(Xoe,{})}),P.jsxs("div",{className:"text-center space-y-2",children:[P.jsxs("div",{className:"flex items-center justify-center gap-2",children:[P.jsx(CU,{className:"w-5 h-5 text-sys-green"}),P.jsx("h3",{className:"type-subheading text-fg-primary font-semibold",children:"Upgrade Complete"})]}),P.jsxs("p",{className:"type-data-xs text-fg-muted font-mono",children:["v",S," → v",F,(t==null?void 0:t.channel)&&t.channel!=="main"&&P.jsxs("span",{className:"text-sys-indigo ml-1",children:["(",t.channel,")"]})]}),P.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[P.jsx(uz,{className:"w-3.5 h-3.5 text-sys-blue animate-spin"}),P.jsxs("span",{className:"type-data-xs text-fg-muted",children:["Reloading in ",h,"s..."]})]})]})]})}):P.jsxs(P.Fragment,{children:[P.jsx(km,{icon:P.jsx(kU,{className:"w-5 h-5 text-sys-red"}),title:"Update Failed"}),P.jsxs(Vd,{className:"!py-4",children:[P.jsxs("details",{className:"mb-3",children:[P.jsxs("summary",{className:"type-data-xs text-fg-muted cursor-pointer hover:text-fg-secondary transition-colors",children:["Install log (",r.length," lines)"]}),P.jsx("div",{className:qe("bg-zinc-950 radius-inner p-3 font-mono text-xs leading-5 overflow-y-auto mt-2","border border-edge-subtle","max-h-[200px]"),children:r.map((L,N)=>P.jsx("div",{className:"text-zinc-300 whitespace-pre-wrap break-all",children:L},N))})]}),o&&P.jsx("div",{className:"bg-sys-red/10 border border-sys-red/30 radius-inner p-3",children:P.jsx("p",{className:"text-sm text-sys-red",children:o})})]}),P.jsx(wv,{children:P.jsx(Vl,{color:"muted",onClick:y,children:"Close"})})]}):P.jsxs(P.Fragment,{children:[P.jsx(km,{icon:P.jsx(mb,{className:"w-5 h-5"}),title:"Updating pyMC Repeater"}),P.jsxs(Vd,{className:"!py-4",children:[P.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[P.jsx(DT,{className:"w-4 h-4 text-sys-blue animate-spin"}),P.jsx("span",{className:"type-data-xs text-sys-blue font-medium",children:(t==null?void 0:t.state)==="restarting"?"Restarting service...":"Installing update..."})]}),P.jsxs("div",{className:qe("bg-zinc-950 radius-inner p-3 font-mono text-xs leading-5 overflow-y-auto","border border-edge-subtle","min-h-[120px] max-h-[300px]"),children:[r.length===0&&P.jsx("span",{className:"text-zinc-500",children:"Waiting for output..."}),r.map((L,N)=>P.jsx("div",{className:"text-zinc-300 whitespace-pre-wrap break-all",children:L},N)),P.jsx("div",{ref:f})]})]})]}):P.jsxs(P.Fragment,{children:[P.jsx(km,{icon:P.jsx(mb,{className:"w-5 h-5"}),title:"Update pyMC Repeater",onClose:y}),P.jsxs(Vd,{children:[P.jsxs("p",{className:"text-sm text-fg-secondary mb-4",children:["This will upgrade from"," ",P.jsxs("span",{className:"font-mono font-medium text-fg-primary",children:["v",S]}),A&&P.jsxs(P.Fragment,{children:[" ",P.jsx(FD,{size:"compact",copy:!0,copyValue:A,children:A})]})," → ",P.jsxs("span",{className:"font-mono font-medium text-sys-green",children:["v",F]}),D&&P.jsxs(P.Fragment,{children:[" ",P.jsx(FD,{size:"compact",copy:!0,copyValue:D,children:D})]}),(t==null?void 0:t.channel)&&t.channel!=="main"&&P.jsxs(P.Fragment,{children:[" on ",P.jsx("span",{className:"font-mono font-medium text-sys-indigo",children:t.channel})]}),". The service will restart automatically."]}),P.jsx("div",{className:"bg-sys-amber/10 border border-sys-amber/30 radius-inner p-3",children:P.jsxs("div",{className:"flex gap-2",children:[P.jsx(Rz,{className:"w-4 h-4 text-sys-amber flex-shrink-0 mt-0.5"}),P.jsxs("p",{className:"text-sm text-fg-secondary",children:["The repeater will be ",P.jsx("strong",{className:"text-fg-primary",children:"offline for ~30 seconds"})," during the update. Active mesh traffic will resume once the service restarts."]})]})})]}),P.jsxs(wv,{children:[P.jsx(Vl,{color:"muted",onClick:y,children:"Cancel"}),P.jsxs(Vl,{color:"danger",onClick:g,children:[P.jsx(mb,{"data-slot":"icon"}),"Update Now"]})]})]})})}function Uu({withControls:e=!1}){return P.jsxs("div",{className:"flex items-center justify-between gap-3 min-h-9",children:[P.jsx(Nt,{className:"h-7 w-40 sm:w-52"}),e&&P.jsx(Nt,{className:"h-8 w-48 sm:w-56 radius-inner"})]})}function jo({className:e,children:t}){return P.jsx("div",{className:`bg-surface/80 radius-card depth-raised h-full flex flex-col p-4 sm:p-5 ${e??""}`,children:t})}const Zoe=[45,72,33,58,80,42,65,28,55,75,38,62];function tx(){return P.jsx("div",{className:"flex-1 flex items-end gap-1",children:Zoe.map((e,t)=>P.jsx(Nt,{className:"flex-1",style:{height:`${e}%`}},t))})}function eie(){return P.jsxs("div",{className:"section-gap","aria-label":"Loading dashboard","aria-busy":"true",children:[P.jsx(Uu,{withControls:!0}),P.jsxs("div",{className:"bento-section",children:[P.jsx("div",{className:"bento-row-hero-auto grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsxs(jo,{children:[P.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-36"})]}),P.jsx(tx,{})]})})}),P.jsx("div",{className:"bento-row-compact grid-12 bento-gap",children:[1,2,3].map(e=>P.jsx("div",{className:"col-span-6 lg:col-span-4",children:P.jsxs(jo,{children:[P.jsx(Nt,{className:"h-4 w-24 mb-3"}),P.jsx(Nt,{className:"h-8 w-16"})]})},e))}),P.jsx("div",{className:"bento-row-widget grid-12 bento-gap",children:[1,2,3,4].map(e=>P.jsx("div",{className:"col-span-6 sm:col-span-4 md:col-span-3",children:P.jsxs(jo,{children:[P.jsx(Nt,{className:"h-3 w-20 mb-2"}),P.jsx(Nt,{className:"h-6 w-12"})]})},e))})]})]})}function Yc(){return P.jsxs("div",{className:"section-gap","aria-label":"Loading list","aria-busy":"true",children:[P.jsx(Uu,{withControls:!0}),P.jsxs("div",{className:"bento-section",children:[P.jsx("div",{className:"bento-row-auto grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsx(jo,{className:"!py-3",children:P.jsxs("div",{className:"flex gap-3",children:[P.jsx(Nt,{className:"h-8 w-28 radius-inner"}),P.jsx(Nt,{className:"h-8 w-28 radius-inner"}),P.jsx(Nt,{className:"h-8 w-28 radius-inner hidden sm:block"})]})})})}),P.jsx("div",{className:"bento-row-auto grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsx(jo,{children:P.jsx("div",{className:"space-y-4",children:Array.from({length:8}).map((e,t)=>P.jsxs("div",{className:"flex items-center gap-4",children:[P.jsx(Nt,{className:"w-10 h-10 radius-inner shrink-0"}),P.jsxs("div",{className:"flex-1 space-y-2",children:[P.jsx(Nt,{className:"h-4 w-48"}),P.jsx(Nt,{className:"h-3 w-32"})]}),P.jsx(Nt,{className:"w-16 h-4 hidden sm:block"})]},t))})})})})]})]})}function tie(){return P.jsxs("div",{className:"section-gap","aria-label":"Loading map","aria-busy":"true",children:[P.jsx(Uu,{withControls:!0}),P.jsx("div",{className:"bento-section",children:P.jsx("div",{className:"grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsx(jo,{className:"!min-h-[60vh]",children:P.jsx(Nt,{className:"flex-1 w-full radius-inset"})})})})})]})}function C1(){return P.jsxs("div",{className:"section-gap","aria-label":"Loading charts","aria-busy":"true",children:[P.jsx(Uu,{withControls:!0}),P.jsxs("div",{className:"bento-section",children:[P.jsx("div",{className:"bento-row-hero-auto grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsxs(jo,{children:[P.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-32"})]}),P.jsx(tx,{})]})})}),P.jsx("div",{className:"bento-row-panel grid-12 bento-gap",children:[1,2].map(e=>P.jsx("div",{className:"col-span-12 md:col-span-6",children:P.jsxs(jo,{children:[P.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-28"})]}),P.jsx(Nt,{className:"flex-1 w-full radius-inset"})]})},e))})]})]})}function nie(){return P.jsxs("div",{className:"section-gap","aria-label":"Loading system","aria-busy":"true",children:[P.jsx(Uu,{withControls:!0}),P.jsxs("div",{className:"bento-section",children:[P.jsx("div",{className:"bento-row-hero grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsxs(jo,{children:[P.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[P.jsx(Nt,{className:"w-5 h-5"}),P.jsx(Nt,{className:"h-4 w-36"})]}),P.jsx(tx,{})]})})}),P.jsx("div",{className:"bento-row-compact grid-12 bento-gap",children:[1,2,3,4].map(e=>P.jsx("div",{className:"col-span-12 sm:col-span-6",children:P.jsxs(jo,{children:[P.jsx(Nt,{className:"h-4 w-28 mb-3"}),P.jsx(Nt,{className:"h-6 w-20 mb-2"}),P.jsx(Nt,{className:"flex-1 w-full radius-inset"})]})},e))})]})]})}function x1(){return P.jsxs("div",{className:"section-gap","aria-label":"Loading settings","aria-busy":"true",children:[P.jsx(Uu,{}),P.jsx("div",{className:"bento-section",children:P.jsx("div",{className:"bento-row-auto grid-12",children:P.jsx("div",{className:"col-span-full",children:P.jsx(jo,{children:P.jsx("div",{className:"space-y-6",children:[.6,.8,.5,.7,.4].map((e,t)=>P.jsxs("div",{className:"space-y-2",children:[P.jsx(Nt,{className:"h-3 w-24"}),P.jsx(Nt,{className:"h-10 radius-inner",style:{width:`${e*100}%`}})]},t))})})})})})]})}const rie=1024;function ls({children:e,fallback:t}){const[n,r]=B.useState(!1);return B.useEffect(()=>{let s=!1;const o=window.innerWidth{o?setTimeout(()=>{s||B.startTransition(()=>r(!0))},JG):requestAnimationFrame(()=>{s||B.startTransition(()=>r(!0))})}),()=>{s=!0}},[]),n?P.jsx(B.Suspense,{fallback:t,children:e}):P.jsx(P.Fragment,{children:t})}function sie(e){e();const t=Jl.getState().initialize(),n=fi.getState().initialize(),r=ln.getState().initialize(),s=oee.getState().initialize();Zl.getState().startPolling();const o=ac.getState().initialize();X5();const i=setInterval(()=>{X5()},3e4),a=_K();return()=>{t(),s(),n==null||n(),r==null||r(),Zl.getState().stopPolling(),o(),a(),clearInterval(i),ZF(),woe()}}const oie=B.lazy(()=>Gn(()=>import("./Login-roDFdIby.js"),[])),iie=B.lazy(()=>Gn(()=>import("./Dashboard-Bn3hcO_4.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40]))),aie=B.lazy(()=>Gn(()=>import("./Packets-DmI71CFc.js"),__vite__mapDeps([41,6,9,42,19,43,44,8,10,2,11,12,13,14,15,16,17,18,20,21,22,23,24,25,26,27,4,5,28,29,30,31,45,46,47,1]))),lie=B.lazy(()=>Gn(()=>import("./Contacts-2M50JufT.js").then(e=>e.C),__vite__mapDeps([48,31,6,1,49,42,19,50,44,29,17,2,12,13,51,52,53,54,20,55,25,56,57,47,23,58]))),cie=B.lazy(()=>Gn(()=>import("./Statistics-C8dae4fy.js"),__vite__mapDeps([59,21,2,60,61,29,17,19,1,3,4,5,51,52,53,22,32,25,45,6,20,46,47,31,40,62,63,58]))),uie=B.lazy(()=>Gn(()=>import("./MeshGraph-DJIb7g1_.js").then(e=>e.M),__vite__mapDeps([64,65,2,66,67,23,26,11,7,54,21,47,62,68,17,63]))),die=B.lazy(()=>Gn(()=>import("./System-DDVQJuHy.js"),__vite__mapDeps([69,1,14,63,16,70,25,71,40]))),fie=B.lazy(()=>Gn(()=>import("./Logs-Dy7jDjKn.js"),__vite__mapDeps([72,1,73]))),hie=B.lazy(()=>Gn(()=>import("./Terminal-DLdeTxtN.js"),__vite__mapDeps([74,75,1,76,77,47,17,78]))),pie=B.lazy(()=>Gn(()=>import("./Configuration-BMVfY1Wg.js"),__vite__mapDeps([79,75,57,34,1,35,15,80,77,56,68,28,81,67,23,17,40,82,83,84]))),mie=B.lazy(()=>Gn(()=>import("./RoomServer-D7QRe_4I.js"),__vite__mapDeps([85,1,40,6,81,49,42,19,50,44,83,86,56,76,77,57,36,12,87,37,84]))),gie=B.lazy(()=>Gn(()=>import("./PacketObservatory-Dkvi-AKO.js"),__vite__mapDeps([88,31,6,10,18]))),yie=B.lazy(()=>Gn(()=>import("./Sessions-ChDjzsGf.js"),__vite__mapDeps([89,57,1,40,39,20,28,82,56]))),bie=B.lazy(()=>Gn(()=>import("./Mqtt-C8Anxpfs.js"),__vite__mapDeps([90,1,49,42,19,50,44,62,83,91,30,47,17,22,9,46,73,56,38,71,40,87,92,26,23]))),vie=B.lazy(()=>Gn(()=>import("./Companion-CMsDpx5g.js"),__vite__mapDeps([93,1,12,13,19,42,50,43,5,47,53,24,68,56,22,91,83,36,18,16,17,94,66,23,25,70,39,35,61,67,86,57,84,80]))),wie=B.lazy(()=>Gn(()=>import("./Test-DjOBviXb.js"),__vite__mapDeps([95,1,31,6,17,40])));function Eie({children:e}){const t=yo(),n=Of();return B.useEffect(()=>(CK(n),()=>xK()),[n]),yC()?P.jsx(P.Fragment,{children:e}):P.jsx(qR,{to:"/login",state:{from:t},replace:!0})}class Cie extends B.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){var t;return this.state.hasError?P.jsxs("div",{className:"surface-base rounded-2xl p-8 text-center",children:[P.jsx("p",{className:"type-subheading text-sys-red mb-2",children:"Page failed to render"}),P.jsx("p",{className:"type-body text-fg-muted mb-4",children:((t=this.state.error)==null?void 0:t.message)||"Unknown error"}),P.jsx("button",{onClick:()=>this.setState({hasError:!1}),className:"px-4 py-2 bg-sys-blue/20 text-sys-blue rounded-lg hover:bg-sys-blue/30 transition-colors",children:"Try Again"})]}):this.props.children}}function xie(){const e=YF(),t=yC(),{theme:n}=pE();B.useEffect(()=>{if(t)return sie(e)},[e,t]);const r=B.useRef(!0);return B.useEffect(()=>{if(r.current){r.current=!1;return}const s=Uf(n.themeId);s&&ex.getState().setMode(s.meta.isDark?"dark":"light")},[n.themeId]),P.jsxs(ooe,{children:[P.jsx(roe,{}),P.jsx(xoe,{}),P.jsx(Joe,{}),P.jsxs(fS,{children:[P.jsx(Dr,{path:"/login",element:P.jsx(B.Suspense,{fallback:P.jsx("div",{className:"min-h-screen bg-body"}),children:P.jsx(oie,{})})}),P.jsx(Dr,{path:"/*",element:P.jsx(Eie,{children:P.jsx(eK,{sidebar:P.jsx(toe,{}),navbar:P.jsx(noe,{}),children:P.jsx("div",{className:"px-1 sm:px-4 lg:px-4 pt-5 pb-4 sm:pb-6 lg:pb-8 max-w-7xl mx-auto",children:P.jsx(Cie,{children:P.jsxs(fS,{children:[P.jsx(Dr,{path:"/",element:P.jsx(ls,{fallback:P.jsx(eie,{}),children:P.jsx(iie,{})})}),P.jsx(Dr,{path:"/packets",element:P.jsx(ls,{fallback:P.jsx(Yc,{}),children:P.jsx(aie,{})})}),P.jsx(Dr,{path:"/contacts",element:P.jsx(ls,{fallback:P.jsx(tie,{}),children:P.jsx(lie,{})})}),P.jsx(Dr,{path:"/statistics",element:P.jsx(ls,{fallback:P.jsx(C1,{}),children:P.jsx(cie,{})})}),P.jsx(Dr,{path:"/meshgraph",element:P.jsx(ls,{fallback:P.jsx(C1,{}),children:P.jsx(uie,{})})}),P.jsx(Dr,{path:"/system",element:P.jsx(ls,{fallback:P.jsx(nie,{}),children:P.jsx(die,{})})}),P.jsx(Dr,{path:"/logs",element:P.jsx(ls,{fallback:P.jsx(Yc,{}),children:P.jsx(fie,{})})}),P.jsx(Dr,{path:"/terminal",element:P.jsx(ls,{fallback:P.jsx(Yc,{}),children:P.jsx(hie,{})})}),P.jsx(Dr,{path:"/room-server",element:P.jsx(ls,{fallback:P.jsx(Yc,{}),children:P.jsx(mie,{})})}),P.jsx(Dr,{path:"/configuration",element:P.jsx(ls,{fallback:P.jsx(x1,{}),children:P.jsx(pie,{})})}),P.jsx(Dr,{path:"/raw",element:P.jsx(ls,{fallback:P.jsx(Yc,{}),children:P.jsx(gie,{})})}),P.jsx(Dr,{path:"/sessions",element:P.jsx(ls,{fallback:P.jsx(x1,{}),children:P.jsx(yie,{})})}),P.jsx(Dr,{path:"/mqtt",element:P.jsx(ls,{fallback:P.jsx(Yc,{}),children:P.jsx(bie,{})})}),P.jsx(Dr,{path:"/companion",element:P.jsx(ls,{fallback:P.jsx(x1,{}),children:P.jsx(vie,{})})}),P.jsx(Dr,{path:"/test",element:P.jsx(ls,{fallback:P.jsx(C1,{}),children:P.jsx(wie,{})})})]})})})})})})]})]})}const kie=console.warn;console.warn=(...e)=>{const t=e[0];typeof t=="string"&&t.includes("Unable to load glyph range")||kie.apply(console,e)};tR.createRoot(document.getElementById("root")).render(P.jsx(B.StrictMode,{children:P.jsx(NN,{children:P.jsx(y7,{children:P.jsx(xie,{})})})}));export{oK as $,Xoe as A,Vl as B,sae as C,X6 as D,nz as E,Fie as F,fE as G,qa as H,EB as I,ZE as J,lf as K,qn as L,hC as M,zf as N,Le as O,pN as P,qF as Q,ule as R,Bz as S,cle as T,Pie as U,aU as V,Aae as W,zae as X,Jie as Y,pt as Z,Gn as _,Yie as a,rO as a$,oy as a0,AT as a1,DT as a2,xB as a3,iZ as a4,cZ as a5,WF as a6,Zie as a7,tae as a8,oP as a9,FZ as aA,E3 as aB,pB as aC,Vd as aD,mb as aE,J1 as aF,Tce as aG,Bce as aH,soe as aI,fZ as aJ,_ie as aK,km as aL,Fce as aM,Pce as aN,Mce as aO,_T as aP,oZ as aQ,jZ as aR,RC as aS,bz as aT,Lt as aU,W4 as aV,k4 as aW,mj as aX,eO as aY,po as aZ,j4 as a_,lz as aa,SZ as ab,EZ as ac,XF as ad,za as ae,rQ as af,nQ as ag,JZ as ah,hle as ai,see as aj,dle as ak,fle as al,lle as am,_Z as an,Er as ao,Dce as ap,Nt as aq,Xie as ar,Az as as,Tr as at,qX as au,VX as av,HX as aw,Av as ax,GX as ay,tce as az,Sm as b,OK as b$,bO as b0,X4 as b1,Nn as b2,Gf as b3,bE as b4,ms as b5,O4 as b6,Ka as b7,xE as b8,Ro as b9,Fu as bA,g4 as bB,m4 as bC,wO as bD,F4 as bE,Y4 as bF,C4 as bG,bu as bH,kU as bI,Iz as bJ,Die as bK,Tie as bL,HU as bM,TT as bN,MH as bO,DH as bP,Sv as bQ,zie as bR,Rf as bS,PX as bT,oce as bU,mae as bV,pae as bW,xT as bX,Z5 as bY,Rz as bZ,BB as b_,Au as ba,Ia as bb,EE as bc,T4 as bd,Wf as be,Hf as bf,Bs as bg,Yl as bh,er as bi,ai as bj,qf as bk,q4 as bl,CE as bm,Yf as bn,K4 as bo,ds as bp,dO as bq,_O as br,uO as bs,ps as bt,G4 as bu,at as bv,HO as bw,nc as bx,Oo as by,gA as bz,qe as c,fae as c$,Kie as c0,Yae as c1,Qae as c2,Cq as c3,FD as c4,SC as c5,rce as c6,oh as c7,CU as c8,BC as c9,kae as cA,gle as cB,UZ as cC,uae as cD,yF as cE,ez as cF,gne as cG,jY as cH,xce as cI,Uie as cJ,cce as cK,jz as cL,Mie as cM,vce as cN,dce as cO,fce as cP,Ece as cQ,tJ as cR,_ae as cS,Tae as cT,NU as cU,eae as cV,QX as cW,ZX as cX,Gte as cY,Jae as cZ,jG as c_,Kae as ca,fz as cb,$Z as cc,hae as cd,f_ as ce,wce as cf,sce as cg,HY as ch,Eae as ci,vae as cj,Bae as ck,zX as cl,Hie as cm,lce as cn,cs as co,Qa as cp,Dae as cq,Fae as cr,Vie as cs,QU as ct,cQ as cu,Dg as cv,CZ as cw,yae as cx,bae as cy,xae as cz,Iu as d,mZ as d$,Rce as d0,tc as d1,$4 as d2,yE as d3,vE as d4,XO as d5,uu as d6,$d as d7,Mi as d8,K1 as d9,Mae as dA,Pae as dB,Lae as dC,Rae as dD,Sae as dE,Cae as dF,ple as dG,$z as dH,sz as dI,iz as dJ,gz as dK,nce as dL,sy as dM,nae as dN,Cce as dO,DU as dP,JX as dQ,pJ as dR,gJ as dS,bJ as dT,yJ as dU,uz as dV,gte as dW,oQ as dX,aZ as dY,lZ as dZ,pZ as d_,Sf as da,vu as db,Ql as dc,Q4 as dd,M4 as de,_4 as df,$ie as dg,zO as dh,rT as di,YO as dj,Io as dk,z4 as dl,U4 as dm,xA as dn,_ce as dp,FY as dq,wae as dr,pee as ds,Ev as dt,iae as du,Hd as dv,cae as dw,mN as dx,JU as dy,gae as dz,Ot as e,rY as e$,MC as e0,BU as e1,Qie as e2,sJ as e3,OC as e4,Sg as e5,DC as e6,dQ as e7,XZ as e8,Vae as e9,jQ as eA,Gae as eB,ac as eC,NZ as eD,pz as eE,kz as eF,ice as eG,ace as eH,rae as eI,wv as eJ,fi as eK,qae as eL,ble as eM,vle as eN,kle as eO,Sle as eP,wle as eQ,Ele as eR,Cle as eS,xle as eT,oY as eU,iY as eV,fY as eW,aY as eX,KZ as eY,tY as eZ,nY as e_,hQ as ea,fQ as eb,Uae as ec,UX as ed,jt as ee,mQ as ef,wQ as eg,SQ as eh,dF as ei,ND as ej,Boe as ek,Roe as el,Poe as em,NG as en,IG as eo,pT as ep,mg as eq,PE as er,MY as es,SK as et,Jl as eu,gK as ev,St as ew,pE as ex,Q2 as ey,Dm as ez,MV as f,Hle as f$,aae as f0,ale as f1,cK as f2,uK as f3,dK as f4,Xr as f5,rh as f6,hy as f7,PC as f8,kX as f9,ile as fA,Nie as fB,w4 as fC,Oie as fD,jie as fE,B4 as fF,wE as fG,Pu as fH,Ol as fI,ln as fJ,Zle as fK,ece as fL,hee as fM,jle as fN,Mle as fO,Xd as fP,Vle as fQ,Qle as fR,zU as fS,Xle as fT,Jle as fU,Kle as fV,Yle as fW,bQ as fX,Ile as fY,_le as fZ,lte as f_,sh as fa,uF as fb,Nae as fc,jae as fd,Oae as fe,mle as ff,yn as fg,GF as fh,FX as fi,gY as fj,Hae as fk,Wae as fl,No as fm,Pse as fn,Ace as fo,kce as fp,LU as fq,Sce as fr,ci as fs,ele as ft,ole as fu,nle as fv,tle as fw,rle as fx,sle as fy,VF as fz,AB as g,HH as g$,Lle as g0,yQ as g1,gQ as g2,yX as g3,Mf as g4,LG as g5,Ale as g6,Wle as g7,Dle as g8,Tle as g9,pce as gA,mce as gB,hce as gC,Iae as gD,ah as gE,LC as gF,Pz as gG,yle as gH,gee as gI,yce as gJ,UK as gK,dae as gL,Lg as gM,$ae as gN,AZ as gO,QQ as gP,Lce as gQ,Jf as gR,Aq as gS,wu as gT,Wie as gU,Gie as gV,Gz as gW,HW as gX,Kz as gY,rW as gZ,vr as g_,Ple as ga,Ble as gb,Fle as gc,zle as gd,Rle as ge,qle as gf,Nle as gg,Ule as gh,Gle as gi,Ole as gj,$le as gk,Aie as gl,QG as gm,gB as gn,gN as go,Mp as gp,Mj as gq,tS as gr,sQ as gs,Bv as gt,PU as gu,K9 as gv,vB as gw,bce as gx,uce as gy,Pt as gz,An as h,Wn as h0,OE as h1,LV as h2,kV as h3,RV as h4,a8 as h5,ji as h6,_f as h7,k8 as h8,QH as h9,vW as ha,hW as hb,eW as hc,UW as hd,p8 as he,bg as hf,_X as hg,NX as hh,$X as hi,GM as hj,lae as hk,Zae as hl,YX as hm,Xae as hn,eP as ho,yC as i,P as j,Jr as k,oae as l,jr as m,NE as n,Ha as o,VA as p,IE as q,B as r,kK as s,xr as t,Of as u,fF as v,$Y as w,gce as x,Bie as y,J6 as z}; diff --git a/frontend/dist/assets/index-wtt5rE5a.js b/frontend/dist/assets/index-DuiHY5wq.js similarity index 98% rename from frontend/dist/assets/index-wtt5rE5a.js rename to frontend/dist/assets/index-DuiHY5wq.js index 9499661e..eb823c7b 100644 --- a/frontend/dist/assets/index-wtt5rE5a.js +++ b/frontend/dist/assets/index-DuiHY5wq.js @@ -1 +1 @@ -import{gY as tt,gZ as et,g_ as nt,g$ as it,h0 as st,h1 as at,k as J,h2 as rt,h3 as ot,h4 as lt,h5 as ut,h6 as ct,h7 as ft,h8 as ht,h9 as mt,ha as pt,hb as gt,hc as C,hd as dt,he as yt,hf as At}from"./index-C2xvS0Jd.js";const St=(t,e,n)=>{const i=e-t;return((n-t)%i+i)%i+t};function Q(t,e){return tt(t)?t[St(0,t.length,e)]:t}class Et{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,n){for(let i=0;ii.attachTimeline(e));return()=>{n.forEach((i,s)=>{i&&i(),this.animations[s].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return Y(this.animations,"duration")}get iterationDuration(){return Y(this.animations,"iterationDuration")}runAll(e){this.animations.forEach(n=>n[e]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function Y(t,e){let n=0;for(let i=0;in&&(n=s)}return n}class Vt extends Et{then(e,n){return this.finished.finally(e).then(()=>{})}}function vt(t,e){return t in e}class Dt extends et{constructor(){super(...arguments),this.type="object"}readValueFromInstance(e,n){if(vt(n,e)){const i=e[n];if(typeof i=="string"||typeof i=="number")return i}}getBaseTargetFromProps(){}removeValueFromRenderState(e,n){delete n.output[e]}measureInstanceViewportBox(){return nt()}build(e,n){Object.assign(e.output,n)}renderInstance(e,{output:n}){Object.assign(e,n)}sortInstanceNodePosition(){return 0}}function j(t){return typeof t=="object"&&!Array.isArray(t)}function U(t,e,n,i){return t==null?[]:typeof t=="string"&&j(e)?it(t,n,i):t instanceof NodeList?Array.from(t):Array.isArray(t)?t.filter(s=>s!=null):[t]}function Tt(t,e,n){return t*(e+1)}function Z(t,e,n,i){return typeof e=="number"?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):e==="<"?n:e.startsWith("<")?Math.max(0,n+parseFloat(e.slice(1))):i.get(e)??t}function bt(t,e,n){for(let i=0;ie&&s.at{const r=It(g),{delay:x=0,times:d=rt(r),type:L=e.type||"keyframes",repeat:K,repeatType:Pt,repeatDelay:Rt=0,...q}=b;let{ease:E=e.ease||"easeOut",duration:y}=b;const W=typeof x=="function"?x(v,O):x,_=r.length,P=ut(L)?L:s==null?void 0:s[L||"keyframes"];if(_<=2&&P){let w=100;if(_===2&&Nt(r)){const G=r[1]-r[0];w=Math.abs(G)}const N={...e,...q};y!==void 0&&(N.duration=ct(y));const B=ot(N,w,P);E=B.ease,y=B.duration}y??(y=o);const R=u+W;d.length===1&&d[0]===0&&(d[1]=1);const z=d.length-r.length;if(z>0&<(d,z),r.length===1&&r.unshift(null),K){y=Tt(y,K);const w=[...r],N=[...d];E=Array.isArray(E)?[...E]:[E];const B=[...E];for(let G=0;G{for(const V in D){const m=D[V];m.sort(xt);const c=[],f=[],T=[];for(let v=0;vtypeof t=="number",Nt=t=>t.every(Kt);function Bt(t){const e={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=ht(t)&&!mt(t)?new pt(e):new gt(e);n.mount(t),C.set(t,n)}function Ct(t){const e={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},n=new Dt(e);n.mount(t),C.set(t,n)}function Lt(t,e){return J(t)||typeof t=="number"||typeof t=="string"&&!j(e)}function X(t,e,n,i){const s=[];if(Lt(t,e))s.push(dt(t,j(e)&&e.default||e,n&&(n.default||n)));else{if(t==null)return s;const o=U(t,e,i),a=o.length;for(let l=0;l{i.push(...X(l,o,a))}),i}function Wt(t){return Array.isArray(t)&&t.some(Array.isArray)}function _t(t){function e(n,i,s){let o=[],a;if(Wt(n))o=jt(n,i,t);else{const{onComplete:p,...A}=s||{};typeof p=="function"&&(a=p),o=X(n,i,A,t)}const l=new Vt(o);return a&&l.finished.then(a),l}return e}const Ht=_t();export{Ht as a}; +import{gY as tt,gZ as et,g_ as nt,g$ as it,h0 as st,h1 as at,k as J,h2 as rt,h3 as ot,h4 as lt,h5 as ut,h6 as ct,h7 as ft,h8 as ht,h9 as mt,ha as pt,hb as gt,hc as C,hd as dt,he as yt,hf as At}from"./index-D33fcA3L.js";const St=(t,e,n)=>{const i=e-t;return((n-t)%i+i)%i+t};function Q(t,e){return tt(t)?t[St(0,t.length,e)]:t}class Et{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,n){for(let i=0;ii.attachTimeline(e));return()=>{n.forEach((i,s)=>{i&&i(),this.animations[s].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return Y(this.animations,"duration")}get iterationDuration(){return Y(this.animations,"iterationDuration")}runAll(e){this.animations.forEach(n=>n[e]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function Y(t,e){let n=0;for(let i=0;in&&(n=s)}return n}class Vt extends Et{then(e,n){return this.finished.finally(e).then(()=>{})}}function vt(t,e){return t in e}class Dt extends et{constructor(){super(...arguments),this.type="object"}readValueFromInstance(e,n){if(vt(n,e)){const i=e[n];if(typeof i=="string"||typeof i=="number")return i}}getBaseTargetFromProps(){}removeValueFromRenderState(e,n){delete n.output[e]}measureInstanceViewportBox(){return nt()}build(e,n){Object.assign(e.output,n)}renderInstance(e,{output:n}){Object.assign(e,n)}sortInstanceNodePosition(){return 0}}function j(t){return typeof t=="object"&&!Array.isArray(t)}function U(t,e,n,i){return t==null?[]:typeof t=="string"&&j(e)?it(t,n,i):t instanceof NodeList?Array.from(t):Array.isArray(t)?t.filter(s=>s!=null):[t]}function Tt(t,e,n){return t*(e+1)}function Z(t,e,n,i){return typeof e=="number"?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):e==="<"?n:e.startsWith("<")?Math.max(0,n+parseFloat(e.slice(1))):i.get(e)??t}function bt(t,e,n){for(let i=0;ie&&s.at{const r=It(g),{delay:x=0,times:d=rt(r),type:L=e.type||"keyframes",repeat:K,repeatType:Pt,repeatDelay:Rt=0,...q}=b;let{ease:E=e.ease||"easeOut",duration:y}=b;const W=typeof x=="function"?x(v,O):x,_=r.length,P=ut(L)?L:s==null?void 0:s[L||"keyframes"];if(_<=2&&P){let w=100;if(_===2&&Nt(r)){const G=r[1]-r[0];w=Math.abs(G)}const N={...e,...q};y!==void 0&&(N.duration=ct(y));const B=ot(N,w,P);E=B.ease,y=B.duration}y??(y=o);const R=u+W;d.length===1&&d[0]===0&&(d[1]=1);const z=d.length-r.length;if(z>0&<(d,z),r.length===1&&r.unshift(null),K){y=Tt(y,K);const w=[...r],N=[...d];E=Array.isArray(E)?[...E]:[E];const B=[...E];for(let G=0;G{for(const V in D){const m=D[V];m.sort(xt);const c=[],f=[],T=[];for(let v=0;vtypeof t=="number",Nt=t=>t.every(Kt);function Bt(t){const e={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=ht(t)&&!mt(t)?new pt(e):new gt(e);n.mount(t),C.set(t,n)}function Ct(t){const e={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},n=new Dt(e);n.mount(t),C.set(t,n)}function Lt(t,e){return J(t)||typeof t=="number"||typeof t=="string"&&!j(e)}function X(t,e,n,i){const s=[];if(Lt(t,e))s.push(dt(t,j(e)&&e.default||e,n&&(n.default||n)));else{if(t==null)return s;const o=U(t,e,i),a=o.length;for(let l=0;l{i.push(...X(l,o,a))}),i}function Wt(t){return Array.isArray(t)&&t.some(Array.isArray)}function _t(t){function e(n,i,s){let o=[],a;if(Wt(n))o=jt(n,i,t);else{const{onComplete:p,...A}=s||{};typeof p=="function"&&(a=p),o=X(n,i,A,t)}const l=new Vt(o);return a&&l.finished.then(a),l}return e}const Ht=_t();export{Ht as a}; diff --git a/frontend/dist/assets/key-round-DBZOsqH6.js b/frontend/dist/assets/key-round-n5zCigFv.js similarity index 92% rename from frontend/dist/assets/key-round-DBZOsqH6.js rename to frontend/dist/assets/key-round-n5zCigFv.js index a5ff9e6c..69109ce0 100644 --- a/frontend/dist/assets/key-round-DBZOsqH6.js +++ b/frontend/dist/assets/key-round-n5zCigFv.js @@ -1,4 +1,4 @@ -import{e}from"./index-C2xvS0Jd.js";/** +import{e}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/layers-BICmdhXR.js b/frontend/dist/assets/layers-DguV5fdN.js similarity index 92% rename from frontend/dist/assets/layers-BICmdhXR.js rename to frontend/dist/assets/layers-DguV5fdN.js index 5277ee82..0e785d38 100644 --- a/frontend/dist/assets/layers-BICmdhXR.js +++ b/frontend/dist/assets/layers-DguV5fdN.js @@ -1,4 +1,4 @@ -import{e as a}from"./index-C2xvS0Jd.js";/** +import{e as a}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/link-scoring-BjtZpDDb.js b/frontend/dist/assets/link-scoring-Chr3N5ba.js similarity index 78% rename from frontend/dist/assets/link-scoring-BjtZpDDb.js rename to frontend/dist/assets/link-scoring-Chr3N5ba.js index 015feee9..b2c7bc16 100644 --- a/frontend/dist/assets/link-scoring-BjtZpDDb.js +++ b/frontend/dist/assets/link-scoring-Chr3N5ba.js @@ -1 +1 @@ -import{gL as L,dw as w,bP as y,O as g}from"./index-C2xvS0Jd.js";function A(r){if(Array.isArray(r))return r;if(typeof r=="string"&&r.startsWith("["))try{const s=JSON.parse(r);return Array.isArray(s)?s:[]}catch{return[]}return[]}function C(r,s,x){const M=L(Array.from(s,t=>[t,t])),c=new Map,i=new Map;for(const t of r){const p=t.route??t.route_type;if(!w(p))continue;const a=A(t.original_path);if(a.length===0)continue;const o=a.map(e=>e.toUpperCase());if(!t.transmitted&&o.length>=2){const e=o[o.length-2];if(e){const n=M.get(e);n&&i.set(n,(i.get(n)??0)+1)}}if(o.some(e=>y(e,x)))for(const e of o){if(e===x)continue;const n=M.get(e);n&&c.set(n,(c.get(n)??0)+1)}}let u=0,f=0;for(const t of s)u=Math.max(u,c.get(t)??0),f=Math.max(f,i.get(t)??0);const S=new Map;let h=0,m=0,d=0;for(const t of s){const p=c.get(t)??0,a=i.get(t)??0,o=u>0?Math.round(p/u*100):0,l=f>0?Math.round(a/f*100):0,e=o+l;S.set(t,{hash:t,listenerCount:p,loudCount:a,listenerScore:o,loudScore:l,blendedScore:e}),h=Math.max(h,o),m=Math.max(m,l),d=Math.max(d,e)}return{scores:S,maxListenerScore:h,maxLoudScore:m,maxBlendedScore:d}}const O={YELLOW:g.amber,GREEN:g.green,RED:g.red,GRAY:"#505050"};export{O as L,C as c}; +import{gL as L,dx as y,bQ as A,O as g}from"./index-D33fcA3L.js";function R(r){if(Array.isArray(r))return r;if(typeof r=="string"&&r.startsWith("["))try{const s=JSON.parse(r);return Array.isArray(s)?s:[]}catch{return[]}return[]}function C(r,s,x){const M=L(Array.from(s,t=>[t,t])),c=new Map,i=new Map;for(const t of r){const p=t.route??t.route_type;if(!y(p))continue;const a=R(t.original_path);if(a.length===0)continue;const o=a.map(e=>e.toUpperCase());if(!t.transmitted&&o.length>=2){const e=o[o.length-2];if(e){const n=M.get(e);n&&i.set(n,(i.get(n)??0)+1)}}if(o.some(e=>A(e,x)))for(const e of o){if(e===x)continue;const n=M.get(e);n&&c.set(n,(c.get(n)??0)+1)}}let u=0,f=0;for(const t of s)u=Math.max(u,c.get(t)??0),f=Math.max(f,i.get(t)??0);const S=new Map;let h=0,m=0,d=0;for(const t of s){const p=c.get(t)??0,a=i.get(t)??0,o=u>0?Math.round(p/u*100):0,l=f>0?Math.round(a/f*100):0,e=o+l;S.set(t,{hash:t,listenerCount:p,loudCount:a,listenerScore:o,loudScore:l,blendedScore:e}),h=Math.max(h,o),m=Math.max(m,l),d=Math.max(d,e)}return{scores:S,maxListenerScore:h,maxLoudScore:m,maxBlendedScore:d}}const O={YELLOW:g.amber,GREEN:g.green,RED:g.red,GRAY:"#505050"};export{O as L,C as c}; diff --git a/frontend/dist/assets/listbox-DnHpTyQt.js b/frontend/dist/assets/listbox-DkfYDEqr.js similarity index 83% rename from frontend/dist/assets/listbox-DnHpTyQt.js rename to frontend/dist/assets/listbox-DkfYDEqr.js index 9106ce86..7117068b 100644 --- a/frontend/dist/assets/listbox-DnHpTyQt.js +++ b/frontend/dist/assets/listbox-DkfYDEqr.js @@ -1 +1 @@ -import{aX as De,fB as de,aY as K,aZ as Se,a_ as Ae,a$ as Ne,r as f,b0 as Fe,b1 as W,b2 as _e,b3 as je,b4 as Z,b5 as w,bi as Ve,aT as F,b8 as O,fC as Be,bb as ze,bc as Qe,bd as Ue,be as He,bj as Ke,bf as q,bg as $e,bk as qe,bh as Y,bu as M,bl as me,bm as Ge,bn as We,bo as se,bp as Ze,bq as Ye,br as Xe,b6 as Je,aW as et,b9 as pe,fD as tt,d7 as xe,bt as nt,bv as ot,bw as st,bs as fe,bx as it,bz as at,bA as lt,bB as rt,bC as ut,dk as ct,dl as dt,bD as pt,bE as ft,bF as bt,bG as he,j as I,c as H,aE as vt,d as mt,m as xt,cZ as ht,a0 as gt}from"./index-C2xvS0Jd.js";import{p as Ot,a as ne,c as x,f as ee,b as St,L as $t,S as te,s as yt,u as It,d as Et}from"./element-movement-CSQuYFsD.js";import{F as wt,b as Rt,y as Pt,R as Lt,T as kt,w as Mt,A as Ct}from"./map-pin-CQk00ph2.js";import{s as Tt}from"./use-text-value-CU5Ho7TY.js";import{u as Dt}from"./frozen-Cx4cJH6f.js";var At=Object.defineProperty,Nt=(e,s,t)=>s in e?At(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ge=(e,s,t)=>(Nt(e,typeof s!="symbol"?s+"":s,t),t),S=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(S||{}),B=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(B||{}),oe=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(oe||{}),ye=(e=>(e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.GoToOption=2]="GoToOption",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.SelectOption=5]="SelectOption",e[e.RegisterOptions=6]="RegisterOptions",e[e.UnregisterOptions=7]="UnregisterOptions",e[e.SetButtonElement=8]="SetButtonElement",e[e.SetOptionsElement=9]="SetOptionsElement",e[e.SortOptions=10]="SortOptions",e[e.MarkButtonAsMoved=11]="MarkButtonAsMoved",e))(ye||{});function Oe(e,s=t=>t){let t=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,n=Ne(s(e.options.slice()),i=>i.dataRef.current.domRef.current),o=t?n.indexOf(t):null;return o===-1&&(o=null),{options:n,activeOptionIndex:o}}let Ft={1(e){if(e.dataRef.current.disabled||e.listboxState===1)return e;let s=e.buttonElement?ne.Tracked(St(e.buttonElement)):e.buttonPositionState;return{...e,activeOptionIndex:null,pendingFocus:{focus:x.Nothing},listboxState:1,__demoMode:!1,buttonPositionState:s}},0(e,s){if(e.dataRef.current.disabled||e.listboxState===0)return e;let t=e.activeOptionIndex,{isSelected:n}=e.dataRef.current,o=e.options.findIndex(i=>n(i.dataRef.current.value));return o!==-1&&(t=o),{...e,frozenValue:!1,pendingFocus:s.focus,listboxState:0,activeOptionIndex:t,__demoMode:!1,buttonPositionState:ne.Idle}},2(e,s){var t,n,o,i,u;if(e.dataRef.current.disabled||e.listboxState===1)return e;let r={...e,searchQuery:"",activationTrigger:(t=s.trigger)!=null?t:1,__demoMode:!1};if(s.focus===x.Nothing)return{...r,activeOptionIndex:null};if(s.focus===x.Specific)return{...r,activeOptionIndex:e.options.findIndex(v=>v.id===s.id)};if(s.focus===x.Previous){let v=e.activeOptionIndex;if(v!==null){let g=e.options[v].dataRef.current.domRef,d=ee(s,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:a=>a.id,resolveDisabled:a=>a.dataRef.current.disabled});if(d!==null){let a=e.options[d].dataRef.current.domRef;if(((n=g.current)==null?void 0:n.previousElementSibling)===a.current||((o=a.current)==null?void 0:o.previousElementSibling)===null)return{...r,activeOptionIndex:d}}}}else if(s.focus===x.Next){let v=e.activeOptionIndex;if(v!==null){let g=e.options[v].dataRef.current.domRef,d=ee(s,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:a=>a.id,resolveDisabled:a=>a.dataRef.current.disabled});if(d!==null){let a=e.options[d].dataRef.current.domRef;if(((i=g.current)==null?void 0:i.nextElementSibling)===a.current||((u=a.current)==null?void 0:u.nextElementSibling)===null)return{...r,activeOptionIndex:d}}}}let m=Oe(e),c=ee(s,{resolveItems:()=>m.options,resolveActiveIndex:()=>m.activeOptionIndex,resolveId:v=>v.id,resolveDisabled:v=>v.dataRef.current.disabled});return{...r,...m,activeOptionIndex:c}},3:(e,s)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let t=e.searchQuery!==""?0:1,n=e.searchQuery+s.value.toLowerCase(),o=(e.activeOptionIndex!==null?e.options.slice(e.activeOptionIndex+t).concat(e.options.slice(0,e.activeOptionIndex+t)):e.options).find(u=>{var r;return!u.dataRef.current.disabled&&((r=u.dataRef.current.textValue)==null?void 0:r.startsWith(n))}),i=o?e.options.indexOf(o):-1;return i===-1||i===e.activeOptionIndex?{...e,searchQuery:n}:{...e,searchQuery:n,activeOptionIndex:i,activationTrigger:1}},4(e){return e.dataRef.current.disabled||e.listboxState===1||e.searchQuery===""?e:{...e,searchQuery:""}},5(e){return e.dataRef.current.mode===0?{...e,frozenValue:!0}:{...e}},6:(e,s)=>{let t=e.options.concat(s.options),n=e.activeOptionIndex;if(e.pendingFocus.focus!==x.Nothing&&(n=ee(e.pendingFocus,{resolveItems:()=>t,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:o=>o.id,resolveDisabled:o=>o.dataRef.current.disabled})),e.activeOptionIndex===null){let{isSelected:o}=e.dataRef.current;if(o){let i=t.findIndex(u=>o==null?void 0:o(u.dataRef.current.value));i!==-1&&(n=i)}}return{...e,options:t,activeOptionIndex:n,pendingFocus:{focus:x.Nothing},pendingShouldSort:!0}},7:(e,s)=>{let t=e.options,n=[],o=new Set(s.options);for(let[i,u]of t.entries())if(o.has(u.id)&&(n.push(i),o.delete(u.id),o.size===0))break;if(n.length>0){t=t.slice();for(let i of n.reverse())t.splice(i,1)}return{...e,options:t,activationTrigger:1}},8:(e,s)=>e.buttonElement===s.element?e:{...e,buttonElement:s.element},9:(e,s)=>e.optionsElement===s.element?e:{...e,optionsElement:s.element},10:e=>e.pendingShouldSort?{...e,...Oe(e),pendingShouldSort:!1}:e,11(e){return e.buttonPositionState.kind!=="Tracked"?e:{...e,buttonPositionState:ne.Moved}}};class be extends De{constructor(s){super(s),ge(this,"actions",{onChange:t=>{let{onChange:n,compare:o,mode:i,value:u}=this.state.dataRef.current;return K(i,{0:()=>n==null?void 0:n(t),1:()=>{let r=u.slice(),m=r.findIndex(c=>o(c,t));return m===-1?r.push(t):r.splice(m,1),n==null?void 0:n(r)}})},registerOption:de(()=>{let t=[],n=new Set;return[(o,i)=>{n.has(i)||(n.add(i),t.push({id:o,dataRef:i}))},()=>(n.clear(),this.send({type:6,options:t.splice(0)}))]}),unregisterOption:de(()=>{let t=[];return[n=>t.push(n),()=>{this.send({type:7,options:t.splice(0)})}]}),goToOption:de(()=>{let t=null;return[(n,o)=>{t={type:2,...n,trigger:o}},()=>t&&this.send(t)]}),closeListbox:()=>{this.send({type:1})},openListbox:t=>{this.send({type:0,focus:t})},selectActiveOption:()=>{var t;if(this.state.activeOptionIndex!==null){let{dataRef:n}=this.state.options[this.state.activeOptionIndex];this.actions.selectOption(n.current.value)}else this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(t=this.state.buttonElement)==null||t.focus({preventScroll:!0}))},selectOption:t=>{this.send({type:5,value:t})},search:t=>{this.send({type:3,value:t})},clearSearch:()=>{this.send({type:4})},setButtonElement:t=>{this.send({type:8,element:t})},setOptionsElement:t=>{this.send({type:9,element:t})}}),ge(this,"selectors",{activeDescendantId(t){var n;let o=t.activeOptionIndex,i=t.options;return o===null||(n=i[o])==null?void 0:n.id},isActive(t,n){var o;let i=t.activeOptionIndex,u=t.options;return i!==null?((o=u[i])==null?void 0:o.id)===n:!1},hasFrozenValue(t){return t.frozenValue},shouldScrollIntoView(t,n){return t.__demoMode||t.listboxState!==0||t.activationTrigger===0?!1:this.isActive(t,n)},didButtonMove(t){return t.buttonPositionState.kind==="Moved"}}),this.on(6,()=>{requestAnimationFrame(()=>{this.send({type:10})})});{let t=this.state.id,n=Se.get(null);this.disposables.add(n.on(Ae.Push,o=>{!n.selectors.isTop(o,t)&&this.state.listboxState===0&&this.actions.closeListbox()})),this.on(0,()=>n.actions.push(t)),this.on(1,()=>n.actions.pop(t))}this.disposables.group(t=>{this.on(1,n=>{n.buttonElement&&(t.dispose(),t.add(Ot(n.buttonElement,n.buttonPositionState,()=>{this.send({type:11})})))})}),this.on(5,(t,n)=>{var o;this.actions.onChange(n.value),this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(o=this.state.buttonElement)==null||o.focus({preventScroll:!0}))})}static new({id:s,__demoMode:t=!1}){return new be({id:s,dataRef:{current:{}},listboxState:t?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:x.Nothing},frozenValue:!1,__demoMode:t,buttonPositionState:ne.Idle})}reduce(s,t){return K(t.type,Ft,s,t)}}const Ie=f.createContext(null);function ve(e){let s=f.useContext(Ie);if(s===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,Ee),t}return s}function Ee({id:e,__demoMode:s=!1}){let t=f.useMemo(()=>be.new({id:e,__demoMode:s}),[]);return Fe(()=>t.dispose()),t}let ie=f.createContext(null);ie.displayName="ListboxDataContext";function X(e){let s=f.useContext(ie);if(s===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,X),t}return s}let _t=f.Fragment;function jt(e,s){let t=f.useId(),n=at(),{value:o,defaultValue:i,form:u,name:r,onChange:m,by:c,invalid:v=!1,disabled:g=n||!1,horizontal:d=!1,multiple:a=!1,__demoMode:h=!1,...L}=e;const R=d?"horizontal":"vertical";let _=Z(s),C=lt(i),[$=a?[]:void 0,P]=rt(o,m,C),y=Ee({id:t,__demoMode:h}),j=f.useRef({static:!1,hold:!1}),z=f.useRef(new Map),T=Et(c),Q=f.useCallback(E=>K(p.mode,{[B.Multi]:()=>$.some(G=>T(G,E)),[B.Single]:()=>T($,E)}),[$]),p=q({value:$,disabled:g,invalid:v,mode:a?B.Multi:B.Single,orientation:R,onChange:P,compare:T,isSelected:Q,optionsPropsRef:j,listRef:z});fe(()=>{y.state.dataRef.current=p},[p]);let k=w(y,E=>E.listboxState),D=Se.get(null),U=w(D,f.useCallback(E=>D.selectors.isTop(E,t),[D,t])),[A,b]=w(y,E=>[E.buttonElement,E.optionsElement]);ut(U,[A,b],(E,G)=>{y.send({type:ye.CloseListbox}),ct(G,dt.Loose)||(E.preventDefault(),A==null||A.focus())});let N=q({open:k===S.Open,disabled:g,invalid:v,value:$}),[ae,le]=pt({inherit:!0}),J={ref:_},re=f.useCallback(()=>{if(C!==void 0)return P==null?void 0:P(C)},[P,C]),ue=Y();return M.createElement(le,{value:ae,props:{htmlFor:A==null?void 0:A.id},slot:{open:k===S.Open,disabled:g}},M.createElement(Ct,null,M.createElement(Ie.Provider,{value:y},M.createElement(ie.Provider,{value:p},M.createElement(ft,{value:K(k,{[S.Open]:se.Open,[S.Closed]:se.Closed})},r!=null&&$!=null&&M.createElement(bt,{disabled:g,data:{[r]:$},form:u,onReset:re}),ue({ourProps:J,theirProps:L,slot:N,defaultTag:_t,name:"Listbox"}))))))}let Vt="button";function Bt(e,s){let t=f.useId(),n=je(),o=X("Listbox.Button"),i=ve("Listbox.Button"),{id:u=n||`headlessui-listbox-button-${t}`,disabled:r=o.disabled||!1,autoFocus:m=!1,...c}=e,v=Z(s,wt(),i.actions.setButtonElement),g=Rt(),[d,a,h]=w(i,b=>[b.listboxState,b.buttonElement,b.optionsElement]),L=d===S.Open;$t(L,{trigger:a,action:f.useCallback(b=>{if(a!=null&&a.contains(b.target))return te.Ignore;let N=b.target.closest('[role="option"]:not([data-disabled])');return Ve(N)?te.Select(N):h!=null&&h.contains(b.target)?te.Ignore:te.Close},[a,h]),close:i.actions.closeListbox,select:i.actions.selectActiveOption});let R=F(b=>{switch(b.key){case O.Enter:Be(b.currentTarget);break;case O.Space:case O.ArrowDown:b.preventDefault(),i.actions.openListbox({focus:o.value?x.Nothing:x.First});break;case O.ArrowUp:b.preventDefault(),i.actions.openListbox({focus:o.value?x.Nothing:x.Last});break}}),_=F(b=>{switch(b.key){case O.Space:b.preventDefault();break}}),C=yt(b=>{var N;i.state.listboxState===S.Open?(pe.flushSync(()=>i.actions.closeListbox()),(N=i.state.buttonElement)==null||N.focus({preventScroll:!0})):(b.preventDefault(),i.actions.openListbox({focus:x.Nothing}))}),$=F(b=>b.preventDefault()),P=ze([u]),y=Qe(),{isFocusVisible:j,focusProps:z}=Ue({autoFocus:m}),{isHovered:T,hoverProps:Q}=He({isDisabled:r}),{pressed:p,pressProps:k}=Ke({disabled:r}),D=q({open:d===S.Open,active:p||d===S.Open,disabled:r,invalid:o.invalid,value:o.value,hover:T,focus:j,autofocus:m}),U=w(i,b=>b.listboxState===S.Open),A=$e(g(),{ref:v,id:u,type:qe(e,a),"aria-haspopup":"listbox","aria-controls":h==null?void 0:h.id,"aria-expanded":U,"aria-labelledby":P,"aria-describedby":y,disabled:r||void 0,autoFocus:m,onKeyDown:R,onKeyUp:_,onKeyPress:$},C,z,Q,k);return Y()({ourProps:A,theirProps:c,slot:D,defaultTag:Vt,name:"Listbox.Button"})}let we=f.createContext(!1),zt="div",Qt=he.RenderStrategy|he.Static;function Ut(e,s){let t=f.useId(),{id:n=`headlessui-listbox-options-${t}`,anchor:o,portal:i=!1,modal:u=!0,transition:r=!1,...m}=e,c=Pt(o),[v,g]=f.useState(null);c&&(i=!0);let d=X("Listbox.Options"),a=ve("Listbox.Options"),[h,L,R,_]=w(a,l=>[l.listboxState,l.buttonElement,l.optionsElement,l.__demoMode]),C=me(L),$=me(R),P=Ge(),[y,j]=We(r,v,P!==null?(P&se.Open)===se.Open:h===S.Open);Ze(y,L,a.actions.closeListbox);let z=_?!1:u&&h===S.Open;Ye(z,$);let T=_?!1:u&&h===S.Open;Xe(T,{allowed:f.useCallback(()=>[L,R],[L,R])});let Q=w(a,a.selectors.didButtonMove)?!1:y,p=w(a,a.selectors.hasFrozenValue)&&!e.static,k=Dt(p,d.value),D=f.useCallback(l=>d.compare(k,l),[d.compare,k]),U=w(a,l=>{var V;if(c==null||!((V=c==null?void 0:c.to)!=null&&V.includes("selection")))return null;let ce=l.options.findIndex(Te=>D(Te.dataRef.current.value));return ce===-1&&(ce=0),ce}),A=(()=>{if(c==null)return;if(U===null)return{...c,inner:void 0};let l=Array.from(d.listRef.current.values());return{...c,inner:{listRef:{current:l},index:U}}})(),[b,N]=Lt(A),ae=kt(),le=Z(s,c?b:null,a.actions.setOptionsElement,g),J=Je();f.useEffect(()=>{let l=R;l&&h===S.Open&&(et(l)||l==null||l.focus({preventScroll:!0}))},[h,R]);let re=F(l=>{var V;switch(J.dispose(),l.key){case O.Space:if(a.state.searchQuery!=="")return l.preventDefault(),l.stopPropagation(),a.actions.search(l.key);case O.Enter:l.preventDefault(),l.stopPropagation(),a.actions.selectActiveOption();break;case K(d.orientation,{vertical:O.ArrowDown,horizontal:O.ArrowRight}):return l.preventDefault(),l.stopPropagation(),a.actions.goToOption({focus:x.Next});case K(d.orientation,{vertical:O.ArrowUp,horizontal:O.ArrowLeft}):return l.preventDefault(),l.stopPropagation(),a.actions.goToOption({focus:x.Previous});case O.Home:case O.PageUp:return l.preventDefault(),l.stopPropagation(),a.actions.goToOption({focus:x.First});case O.End:case O.PageDown:return l.preventDefault(),l.stopPropagation(),a.actions.goToOption({focus:x.Last});case O.Escape:l.preventDefault(),l.stopPropagation(),pe.flushSync(()=>a.actions.closeListbox()),(V=a.state.buttonElement)==null||V.focus({preventScroll:!0});return;case O.Tab:l.preventDefault(),l.stopPropagation(),pe.flushSync(()=>a.actions.closeListbox()),tt(a.state.buttonElement,l.shiftKey?xe.Previous:xe.Next);break;default:l.key.length===1&&(a.actions.search(l.key),J.setTimeout(()=>a.actions.clearSearch(),350));break}}),ue=w(a,l=>{var V;return(V=l.buttonElement)==null?void 0:V.id}),E=q({open:h===S.Open}),G=$e(c?ae():{},{id:n,ref:le,"aria-activedescendant":w(a,a.selectors.activeDescendantId),"aria-multiselectable":d.mode===B.Multi?!0:void 0,"aria-labelledby":ue,"aria-orientation":d.orientation,onKeyDown:re,role:"listbox",tabIndex:h===S.Open?0:void 0,style:{...m.style,...N,"--button-width":Mt(y,L,!0).width},...nt(j)}),Me=Y(),Ce=f.useMemo(()=>d.mode===B.Multi?d:{...d,isSelected:D},[d,D]);return M.createElement(ot,{enabled:i?e.static||y:!1,ownerDocument:C},M.createElement(ie.Provider,{value:Ce},Me({ourProps:G,theirProps:m,slot:E,defaultTag:zt,features:Qt,visible:Q,name:"Listbox.Options"})))}let Ht="div";function Kt(e,s){let t=f.useId(),{id:n=`headlessui-listbox-option-${t}`,disabled:o=!1,value:i,...u}=e,r=f.useContext(we)===!0,m=X("Listbox.Option"),c=ve("Listbox.Option"),v=w(c,p=>c.selectors.isActive(p,n)),g=m.isSelected(i),d=f.useRef(null),a=Tt(d),h=st({disabled:o,value:i,domRef:d,get textValue(){return a()}}),L=Z(s,d,p=>{p?m.listRef.current.set(n,p):m.listRef.current.delete(n)}),R=w(c,p=>c.selectors.shouldScrollIntoView(p,n));fe(()=>{if(R)return it().requestAnimationFrame(()=>{var p,k;(k=(p=d.current)==null?void 0:p.scrollIntoView)==null||k.call(p,{block:"nearest"})})},[R,d]),fe(()=>{if(!r)return c.actions.registerOption(n,h),()=>c.actions.unregisterOption(n)},[h,n,r]);let _=F(p=>{if(o)return p.preventDefault();c.actions.selectOption(i)}),C=F(()=>{if(o)return c.actions.goToOption({focus:x.Nothing});c.actions.goToOption({focus:x.Specific,id:n})}),$=It(),P=F(p=>$.update(p)),y=F(p=>{$.wasMoved(p)&&(o||v&&c.state.activationTrigger===oe.Pointer||c.actions.goToOption({focus:x.Specific,id:n},oe.Pointer))}),j=F(p=>{$.wasMoved(p)&&(o||v&&c.state.activationTrigger===oe.Pointer&&c.actions.goToOption({focus:x.Nothing}))}),z=q({active:v,focus:v,selected:g,disabled:o,selectedOption:g&&r}),T=r?{}:{id:n,ref:L,role:"option",tabIndex:o===!0?void 0:-1,"aria-disabled":o===!0?!0:void 0,"aria-selected":g,disabled:void 0,onClick:_,onFocus:C,onPointerEnter:P,onMouseEnter:P,onPointerMove:y,onMouseMove:y,onPointerLeave:j,onMouseLeave:j},Q=Y();return!g&&r?null:Q({ourProps:T,theirProps:u,slot:z,defaultTag:Ht,name:"Listbox.Option"})}let qt=f.Fragment;function Gt(e,s){let{options:t,placeholder:n,...o}=e,i={ref:Z(s)},u=X("ListboxSelectedOption"),r=q({}),m=u.value===void 0||u.value===null||u.mode===B.Multi&&Array.isArray(u.value)&&u.value.length===0,c=Y();return M.createElement(we.Provider,{value:!0},c({ourProps:i,theirProps:{...o,children:M.createElement(M.Fragment,null,n&&m?n:t)},slot:r,defaultTag:qt,name:"ListboxSelectedOption"}))}let Wt=W(jt),Re=W(Bt),Zt=_e,Pe=W(Ut),Le=W(Kt),ke=W(Gt),Yt=Object.assign(Wt,{Button:Re,Label:Zt,Options:Pe,Option:Le,SelectedOption:ke});function on({value:e,onChange:s,className:t,placeholder:n,disabled:o,"aria-label":i,children:u}){return I.jsx(Yt,{value:e,onChange:s,disabled:o,children:({open:r})=>I.jsxs("div",{className:H("relative",t),children:[I.jsxs(Re,{"aria-label":i,className:H(["relative flex w-full items-center justify-between gap-2","radius-inner px-3 py-2","text-left text-sm text-fg-primary","bg-input-bg border border-input-border","ring-focus-inset","hover:border-edge-strong","disabled:opacity-40 disabled:pointer-events-none disabled:cursor-not-allowed","transition-colors"]),children:[I.jsx(ke,{as:"span",options:u,placeholder:n&&I.jsx("span",{className:"text-fg-muted",children:n}),className:"block truncate"}),I.jsx(vt,{className:H("w-4 h-4 text-fg-muted transition-transform duration-200",r&&"rotate-180")})]}),I.jsx(mt,{children:r&&I.jsx(xt.div,{initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:ht.dropdown,className:"absolute z-50 mt-1",children:I.jsx(Pe,{static:!0,anchor:"bottom start",className:H(["w-[var(--button-width)] min-w-[180px]","max-h-60 overflow-y-auto overscroll-contain scroll-py-1","radius-inset p-1","surface-elevated","focus:outline-none"]),children:u})})})]})})}function sn({value:e,disabled:s,className:t,children:n}){return I.jsx(Le,{as:f.Fragment,value:e,disabled:s,children:({selected:o,focus:i})=>I.jsxs("div",{className:H("flex items-center gap-2 px-3 py-2 radius-control cursor-default","text-sm",i&&"bg-sys-blue text-white",!i&&"text-fg-primary",o&&!i&&"text-sys-blue",s&&"opacity-50 cursor-not-allowed",t),children:[I.jsx("span",{className:"w-4 flex-shrink-0",children:o&&I.jsx(gt,{className:"w-4 h-4"})}),I.jsx("span",{className:"truncate",children:n})]})})}function an({className:e,...s}){return I.jsx("span",{...s,className:H("truncate",e)})}export{on as L,sn as a,an as b}; +import{aY as De,fB as de,aZ as K,a_ as Se,a$ as Ae,b0 as Fe,r as f,b1 as Ne,b2 as W,b3 as _e,b4 as je,b5 as Y,b6 as w,bj as Ve,aU as N,b9 as O,fC as Be,bc as ze,bd as Qe,be as Ue,bf as He,bk as Ke,bg as q,bh as $e,bl as qe,bi as Z,bv as M,bm as me,bn as Ge,bo as We,bp as se,bq as Ye,br as Ze,bs as Xe,b7 as Je,aX as et,ba as pe,fD as tt,d8 as xe,bu as nt,bw as ot,bx as st,bt as fe,by as it,bA as at,bB as lt,bC as rt,bD as ut,dl as ct,dm as dt,bE as pt,bF as ft,bG as bt,bH as he,j as I,c as H,aF as vt,d as mt,m as xt,c_ as ht,a0 as gt}from"./index-D33fcA3L.js";import{p as Ot,a as ne,c as x,f as ee,b as St,L as $t,S as te,s as yt,u as It,d as Et}from"./element-movement-BL6huHzq.js";import{F as wt,b as Rt,y as Pt,R as Lt,T as kt,w as Mt,A as Ct}from"./map-pin-B_Rx-xpd.js";import{s as Tt}from"./use-text-value-iYUkduzo.js";import{u as Dt}from"./frozen-C10EXZ59.js";var At=Object.defineProperty,Ft=(e,s,t)=>s in e?At(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ge=(e,s,t)=>(Ft(e,typeof s!="symbol"?s+"":s,t),t),S=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(S||{}),B=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(B||{}),oe=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(oe||{}),ye=(e=>(e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.GoToOption=2]="GoToOption",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.SelectOption=5]="SelectOption",e[e.RegisterOptions=6]="RegisterOptions",e[e.UnregisterOptions=7]="UnregisterOptions",e[e.SetButtonElement=8]="SetButtonElement",e[e.SetOptionsElement=9]="SetOptionsElement",e[e.SortOptions=10]="SortOptions",e[e.MarkButtonAsMoved=11]="MarkButtonAsMoved",e))(ye||{});function Oe(e,s=t=>t){let t=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,n=Fe(s(e.options.slice()),i=>i.dataRef.current.domRef.current),o=t?n.indexOf(t):null;return o===-1&&(o=null),{options:n,activeOptionIndex:o}}let Nt={1(e){if(e.dataRef.current.disabled||e.listboxState===1)return e;let s=e.buttonElement?ne.Tracked(St(e.buttonElement)):e.buttonPositionState;return{...e,activeOptionIndex:null,pendingFocus:{focus:x.Nothing},listboxState:1,__demoMode:!1,buttonPositionState:s}},0(e,s){if(e.dataRef.current.disabled||e.listboxState===0)return e;let t=e.activeOptionIndex,{isSelected:n}=e.dataRef.current,o=e.options.findIndex(i=>n(i.dataRef.current.value));return o!==-1&&(t=o),{...e,frozenValue:!1,pendingFocus:s.focus,listboxState:0,activeOptionIndex:t,__demoMode:!1,buttonPositionState:ne.Idle}},2(e,s){var t,n,o,i,u;if(e.dataRef.current.disabled||e.listboxState===1)return e;let r={...e,searchQuery:"",activationTrigger:(t=s.trigger)!=null?t:1,__demoMode:!1};if(s.focus===x.Nothing)return{...r,activeOptionIndex:null};if(s.focus===x.Specific)return{...r,activeOptionIndex:e.options.findIndex(v=>v.id===s.id)};if(s.focus===x.Previous){let v=e.activeOptionIndex;if(v!==null){let g=e.options[v].dataRef.current.domRef,d=ee(s,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:a=>a.id,resolveDisabled:a=>a.dataRef.current.disabled});if(d!==null){let a=e.options[d].dataRef.current.domRef;if(((n=g.current)==null?void 0:n.previousElementSibling)===a.current||((o=a.current)==null?void 0:o.previousElementSibling)===null)return{...r,activeOptionIndex:d}}}}else if(s.focus===x.Next){let v=e.activeOptionIndex;if(v!==null){let g=e.options[v].dataRef.current.domRef,d=ee(s,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:a=>a.id,resolveDisabled:a=>a.dataRef.current.disabled});if(d!==null){let a=e.options[d].dataRef.current.domRef;if(((i=g.current)==null?void 0:i.nextElementSibling)===a.current||((u=a.current)==null?void 0:u.nextElementSibling)===null)return{...r,activeOptionIndex:d}}}}let m=Oe(e),c=ee(s,{resolveItems:()=>m.options,resolveActiveIndex:()=>m.activeOptionIndex,resolveId:v=>v.id,resolveDisabled:v=>v.dataRef.current.disabled});return{...r,...m,activeOptionIndex:c}},3:(e,s)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let t=e.searchQuery!==""?0:1,n=e.searchQuery+s.value.toLowerCase(),o=(e.activeOptionIndex!==null?e.options.slice(e.activeOptionIndex+t).concat(e.options.slice(0,e.activeOptionIndex+t)):e.options).find(u=>{var r;return!u.dataRef.current.disabled&&((r=u.dataRef.current.textValue)==null?void 0:r.startsWith(n))}),i=o?e.options.indexOf(o):-1;return i===-1||i===e.activeOptionIndex?{...e,searchQuery:n}:{...e,searchQuery:n,activeOptionIndex:i,activationTrigger:1}},4(e){return e.dataRef.current.disabled||e.listboxState===1||e.searchQuery===""?e:{...e,searchQuery:""}},5(e){return e.dataRef.current.mode===0?{...e,frozenValue:!0}:{...e}},6:(e,s)=>{let t=e.options.concat(s.options),n=e.activeOptionIndex;if(e.pendingFocus.focus!==x.Nothing&&(n=ee(e.pendingFocus,{resolveItems:()=>t,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:o=>o.id,resolveDisabled:o=>o.dataRef.current.disabled})),e.activeOptionIndex===null){let{isSelected:o}=e.dataRef.current;if(o){let i=t.findIndex(u=>o==null?void 0:o(u.dataRef.current.value));i!==-1&&(n=i)}}return{...e,options:t,activeOptionIndex:n,pendingFocus:{focus:x.Nothing},pendingShouldSort:!0}},7:(e,s)=>{let t=e.options,n=[],o=new Set(s.options);for(let[i,u]of t.entries())if(o.has(u.id)&&(n.push(i),o.delete(u.id),o.size===0))break;if(n.length>0){t=t.slice();for(let i of n.reverse())t.splice(i,1)}return{...e,options:t,activationTrigger:1}},8:(e,s)=>e.buttonElement===s.element?e:{...e,buttonElement:s.element},9:(e,s)=>e.optionsElement===s.element?e:{...e,optionsElement:s.element},10:e=>e.pendingShouldSort?{...e,...Oe(e),pendingShouldSort:!1}:e,11(e){return e.buttonPositionState.kind!=="Tracked"?e:{...e,buttonPositionState:ne.Moved}}};class be extends De{constructor(s){super(s),ge(this,"actions",{onChange:t=>{let{onChange:n,compare:o,mode:i,value:u}=this.state.dataRef.current;return K(i,{0:()=>n==null?void 0:n(t),1:()=>{let r=u.slice(),m=r.findIndex(c=>o(c,t));return m===-1?r.push(t):r.splice(m,1),n==null?void 0:n(r)}})},registerOption:de(()=>{let t=[],n=new Set;return[(o,i)=>{n.has(i)||(n.add(i),t.push({id:o,dataRef:i}))},()=>(n.clear(),this.send({type:6,options:t.splice(0)}))]}),unregisterOption:de(()=>{let t=[];return[n=>t.push(n),()=>{this.send({type:7,options:t.splice(0)})}]}),goToOption:de(()=>{let t=null;return[(n,o)=>{t={type:2,...n,trigger:o}},()=>t&&this.send(t)]}),closeListbox:()=>{this.send({type:1})},openListbox:t=>{this.send({type:0,focus:t})},selectActiveOption:()=>{var t;if(this.state.activeOptionIndex!==null){let{dataRef:n}=this.state.options[this.state.activeOptionIndex];this.actions.selectOption(n.current.value)}else this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(t=this.state.buttonElement)==null||t.focus({preventScroll:!0}))},selectOption:t=>{this.send({type:5,value:t})},search:t=>{this.send({type:3,value:t})},clearSearch:()=>{this.send({type:4})},setButtonElement:t=>{this.send({type:8,element:t})},setOptionsElement:t=>{this.send({type:9,element:t})}}),ge(this,"selectors",{activeDescendantId(t){var n;let o=t.activeOptionIndex,i=t.options;return o===null||(n=i[o])==null?void 0:n.id},isActive(t,n){var o;let i=t.activeOptionIndex,u=t.options;return i!==null?((o=u[i])==null?void 0:o.id)===n:!1},hasFrozenValue(t){return t.frozenValue},shouldScrollIntoView(t,n){return t.__demoMode||t.listboxState!==0||t.activationTrigger===0?!1:this.isActive(t,n)},didButtonMove(t){return t.buttonPositionState.kind==="Moved"}}),this.on(6,()=>{requestAnimationFrame(()=>{this.send({type:10})})});{let t=this.state.id,n=Se.get(null);this.disposables.add(n.on(Ae.Push,o=>{!n.selectors.isTop(o,t)&&this.state.listboxState===0&&this.actions.closeListbox()})),this.on(0,()=>n.actions.push(t)),this.on(1,()=>n.actions.pop(t))}this.disposables.group(t=>{this.on(1,n=>{n.buttonElement&&(t.dispose(),t.add(Ot(n.buttonElement,n.buttonPositionState,()=>{this.send({type:11})})))})}),this.on(5,(t,n)=>{var o;this.actions.onChange(n.value),this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(o=this.state.buttonElement)==null||o.focus({preventScroll:!0}))})}static new({id:s,__demoMode:t=!1}){return new be({id:s,dataRef:{current:{}},listboxState:t?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:x.Nothing},frozenValue:!1,__demoMode:t,buttonPositionState:ne.Idle})}reduce(s,t){return K(t.type,Nt,s,t)}}const Ie=f.createContext(null);function ve(e){let s=f.useContext(Ie);if(s===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,Ee),t}return s}function Ee({id:e,__demoMode:s=!1}){let t=f.useMemo(()=>be.new({id:e,__demoMode:s}),[]);return Ne(()=>t.dispose()),t}let ie=f.createContext(null);ie.displayName="ListboxDataContext";function X(e){let s=f.useContext(ie);if(s===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,X),t}return s}let _t=f.Fragment;function jt(e,s){let t=f.useId(),n=at(),{value:o,defaultValue:i,form:u,name:r,onChange:m,by:c,invalid:v=!1,disabled:g=n||!1,horizontal:d=!1,multiple:a=!1,__demoMode:h=!1,...L}=e;const R=d?"horizontal":"vertical";let _=Y(s),C=lt(i),[$=a?[]:void 0,P]=rt(o,m,C),y=Ee({id:t,__demoMode:h}),j=f.useRef({static:!1,hold:!1}),z=f.useRef(new Map),T=Et(c),Q=f.useCallback(E=>K(p.mode,{[B.Multi]:()=>$.some(G=>T(G,E)),[B.Single]:()=>T($,E)}),[$]),p=q({value:$,disabled:g,invalid:v,mode:a?B.Multi:B.Single,orientation:R,onChange:P,compare:T,isSelected:Q,optionsPropsRef:j,listRef:z});fe(()=>{y.state.dataRef.current=p},[p]);let k=w(y,E=>E.listboxState),D=Se.get(null),U=w(D,f.useCallback(E=>D.selectors.isTop(E,t),[D,t])),[A,b]=w(y,E=>[E.buttonElement,E.optionsElement]);ut(U,[A,b],(E,G)=>{y.send({type:ye.CloseListbox}),ct(G,dt.Loose)||(E.preventDefault(),A==null||A.focus())});let F=q({open:k===S.Open,disabled:g,invalid:v,value:$}),[ae,le]=pt({inherit:!0}),J={ref:_},re=f.useCallback(()=>{if(C!==void 0)return P==null?void 0:P(C)},[P,C]),ue=Z();return M.createElement(le,{value:ae,props:{htmlFor:A==null?void 0:A.id},slot:{open:k===S.Open,disabled:g}},M.createElement(Ct,null,M.createElement(Ie.Provider,{value:y},M.createElement(ie.Provider,{value:p},M.createElement(ft,{value:K(k,{[S.Open]:se.Open,[S.Closed]:se.Closed})},r!=null&&$!=null&&M.createElement(bt,{disabled:g,data:{[r]:$},form:u,onReset:re}),ue({ourProps:J,theirProps:L,slot:F,defaultTag:_t,name:"Listbox"}))))))}let Vt="button";function Bt(e,s){let t=f.useId(),n=je(),o=X("Listbox.Button"),i=ve("Listbox.Button"),{id:u=n||`headlessui-listbox-button-${t}`,disabled:r=o.disabled||!1,autoFocus:m=!1,...c}=e,v=Y(s,wt(),i.actions.setButtonElement),g=Rt(),[d,a,h]=w(i,b=>[b.listboxState,b.buttonElement,b.optionsElement]),L=d===S.Open;$t(L,{trigger:a,action:f.useCallback(b=>{if(a!=null&&a.contains(b.target))return te.Ignore;let F=b.target.closest('[role="option"]:not([data-disabled])');return Ve(F)?te.Select(F):h!=null&&h.contains(b.target)?te.Ignore:te.Close},[a,h]),close:i.actions.closeListbox,select:i.actions.selectActiveOption});let R=N(b=>{switch(b.key){case O.Enter:Be(b.currentTarget);break;case O.Space:case O.ArrowDown:b.preventDefault(),i.actions.openListbox({focus:o.value?x.Nothing:x.First});break;case O.ArrowUp:b.preventDefault(),i.actions.openListbox({focus:o.value?x.Nothing:x.Last});break}}),_=N(b=>{switch(b.key){case O.Space:b.preventDefault();break}}),C=yt(b=>{var F;i.state.listboxState===S.Open?(pe.flushSync(()=>i.actions.closeListbox()),(F=i.state.buttonElement)==null||F.focus({preventScroll:!0})):(b.preventDefault(),i.actions.openListbox({focus:x.Nothing}))}),$=N(b=>b.preventDefault()),P=ze([u]),y=Qe(),{isFocusVisible:j,focusProps:z}=Ue({autoFocus:m}),{isHovered:T,hoverProps:Q}=He({isDisabled:r}),{pressed:p,pressProps:k}=Ke({disabled:r}),D=q({open:d===S.Open,active:p||d===S.Open,disabled:r,invalid:o.invalid,value:o.value,hover:T,focus:j,autofocus:m}),U=w(i,b=>b.listboxState===S.Open),A=$e(g(),{ref:v,id:u,type:qe(e,a),"aria-haspopup":"listbox","aria-controls":h==null?void 0:h.id,"aria-expanded":U,"aria-labelledby":P,"aria-describedby":y,disabled:r||void 0,autoFocus:m,onKeyDown:R,onKeyUp:_,onKeyPress:$},C,z,Q,k);return Z()({ourProps:A,theirProps:c,slot:D,defaultTag:Vt,name:"Listbox.Button"})}let we=f.createContext(!1),zt="div",Qt=he.RenderStrategy|he.Static;function Ut(e,s){let t=f.useId(),{id:n=`headlessui-listbox-options-${t}`,anchor:o,portal:i=!1,modal:u=!0,transition:r=!1,...m}=e,c=Pt(o),[v,g]=f.useState(null);c&&(i=!0);let d=X("Listbox.Options"),a=ve("Listbox.Options"),[h,L,R,_]=w(a,l=>[l.listboxState,l.buttonElement,l.optionsElement,l.__demoMode]),C=me(L),$=me(R),P=Ge(),[y,j]=We(r,v,P!==null?(P&se.Open)===se.Open:h===S.Open);Ye(y,L,a.actions.closeListbox);let z=_?!1:u&&h===S.Open;Ze(z,$);let T=_?!1:u&&h===S.Open;Xe(T,{allowed:f.useCallback(()=>[L,R],[L,R])});let Q=w(a,a.selectors.didButtonMove)?!1:y,p=w(a,a.selectors.hasFrozenValue)&&!e.static,k=Dt(p,d.value),D=f.useCallback(l=>d.compare(k,l),[d.compare,k]),U=w(a,l=>{var V;if(c==null||!((V=c==null?void 0:c.to)!=null&&V.includes("selection")))return null;let ce=l.options.findIndex(Te=>D(Te.dataRef.current.value));return ce===-1&&(ce=0),ce}),A=(()=>{if(c==null)return;if(U===null)return{...c,inner:void 0};let l=Array.from(d.listRef.current.values());return{...c,inner:{listRef:{current:l},index:U}}})(),[b,F]=Lt(A),ae=kt(),le=Y(s,c?b:null,a.actions.setOptionsElement,g),J=Je();f.useEffect(()=>{let l=R;l&&h===S.Open&&(et(l)||l==null||l.focus({preventScroll:!0}))},[h,R]);let re=N(l=>{var V;switch(J.dispose(),l.key){case O.Space:if(a.state.searchQuery!=="")return l.preventDefault(),l.stopPropagation(),a.actions.search(l.key);case O.Enter:l.preventDefault(),l.stopPropagation(),a.actions.selectActiveOption();break;case K(d.orientation,{vertical:O.ArrowDown,horizontal:O.ArrowRight}):return l.preventDefault(),l.stopPropagation(),a.actions.goToOption({focus:x.Next});case K(d.orientation,{vertical:O.ArrowUp,horizontal:O.ArrowLeft}):return l.preventDefault(),l.stopPropagation(),a.actions.goToOption({focus:x.Previous});case O.Home:case O.PageUp:return l.preventDefault(),l.stopPropagation(),a.actions.goToOption({focus:x.First});case O.End:case O.PageDown:return l.preventDefault(),l.stopPropagation(),a.actions.goToOption({focus:x.Last});case O.Escape:l.preventDefault(),l.stopPropagation(),pe.flushSync(()=>a.actions.closeListbox()),(V=a.state.buttonElement)==null||V.focus({preventScroll:!0});return;case O.Tab:l.preventDefault(),l.stopPropagation(),pe.flushSync(()=>a.actions.closeListbox()),tt(a.state.buttonElement,l.shiftKey?xe.Previous:xe.Next);break;default:l.key.length===1&&(a.actions.search(l.key),J.setTimeout(()=>a.actions.clearSearch(),350));break}}),ue=w(a,l=>{var V;return(V=l.buttonElement)==null?void 0:V.id}),E=q({open:h===S.Open}),G=$e(c?ae():{},{id:n,ref:le,"aria-activedescendant":w(a,a.selectors.activeDescendantId),"aria-multiselectable":d.mode===B.Multi?!0:void 0,"aria-labelledby":ue,"aria-orientation":d.orientation,onKeyDown:re,role:"listbox",tabIndex:h===S.Open?0:void 0,style:{...m.style,...F,"--button-width":Mt(y,L,!0).width},...nt(j)}),Me=Z(),Ce=f.useMemo(()=>d.mode===B.Multi?d:{...d,isSelected:D},[d,D]);return M.createElement(ot,{enabled:i?e.static||y:!1,ownerDocument:C},M.createElement(ie.Provider,{value:Ce},Me({ourProps:G,theirProps:m,slot:E,defaultTag:zt,features:Qt,visible:Q,name:"Listbox.Options"})))}let Ht="div";function Kt(e,s){let t=f.useId(),{id:n=`headlessui-listbox-option-${t}`,disabled:o=!1,value:i,...u}=e,r=f.useContext(we)===!0,m=X("Listbox.Option"),c=ve("Listbox.Option"),v=w(c,p=>c.selectors.isActive(p,n)),g=m.isSelected(i),d=f.useRef(null),a=Tt(d),h=st({disabled:o,value:i,domRef:d,get textValue(){return a()}}),L=Y(s,d,p=>{p?m.listRef.current.set(n,p):m.listRef.current.delete(n)}),R=w(c,p=>c.selectors.shouldScrollIntoView(p,n));fe(()=>{if(R)return it().requestAnimationFrame(()=>{var p,k;(k=(p=d.current)==null?void 0:p.scrollIntoView)==null||k.call(p,{block:"nearest"})})},[R,d]),fe(()=>{if(!r)return c.actions.registerOption(n,h),()=>c.actions.unregisterOption(n)},[h,n,r]);let _=N(p=>{if(o)return p.preventDefault();c.actions.selectOption(i)}),C=N(()=>{if(o)return c.actions.goToOption({focus:x.Nothing});c.actions.goToOption({focus:x.Specific,id:n})}),$=It(),P=N(p=>$.update(p)),y=N(p=>{$.wasMoved(p)&&(o||v&&c.state.activationTrigger===oe.Pointer||c.actions.goToOption({focus:x.Specific,id:n},oe.Pointer))}),j=N(p=>{$.wasMoved(p)&&(o||v&&c.state.activationTrigger===oe.Pointer&&c.actions.goToOption({focus:x.Nothing}))}),z=q({active:v,focus:v,selected:g,disabled:o,selectedOption:g&&r}),T=r?{}:{id:n,ref:L,role:"option",tabIndex:o===!0?void 0:-1,"aria-disabled":o===!0?!0:void 0,"aria-selected":g,disabled:void 0,onClick:_,onFocus:C,onPointerEnter:P,onMouseEnter:P,onPointerMove:y,onMouseMove:y,onPointerLeave:j,onMouseLeave:j},Q=Z();return!g&&r?null:Q({ourProps:T,theirProps:u,slot:z,defaultTag:Ht,name:"Listbox.Option"})}let qt=f.Fragment;function Gt(e,s){let{options:t,placeholder:n,...o}=e,i={ref:Y(s)},u=X("ListboxSelectedOption"),r=q({}),m=u.value===void 0||u.value===null||u.mode===B.Multi&&Array.isArray(u.value)&&u.value.length===0,c=Z();return M.createElement(we.Provider,{value:!0},c({ourProps:i,theirProps:{...o,children:M.createElement(M.Fragment,null,n&&m?n:t)},slot:r,defaultTag:qt,name:"ListboxSelectedOption"}))}let Wt=W(jt),Re=W(Bt),Yt=_e,Pe=W(Ut),Le=W(Kt),ke=W(Gt),Zt=Object.assign(Wt,{Button:Re,Label:Yt,Options:Pe,Option:Le,SelectedOption:ke});function on({value:e,onChange:s,className:t,placeholder:n,disabled:o,"aria-label":i,children:u}){return I.jsx(Zt,{value:e,onChange:s,disabled:o,children:({open:r})=>I.jsxs("div",{className:H("relative",t),children:[I.jsxs(Re,{"aria-label":i,className:H(["relative flex w-full items-center justify-between gap-2","radius-inner px-3 py-2","text-left text-sm text-fg-primary","bg-input-bg border border-input-border","ring-focus-inset","hover:border-edge-strong","disabled:opacity-40 disabled:pointer-events-none disabled:cursor-not-allowed","transition-colors"]),children:[I.jsx(ke,{as:"span",options:u,placeholder:n&&I.jsx("span",{className:"text-fg-muted",children:n}),className:"block truncate"}),I.jsx(vt,{className:H("w-4 h-4 text-fg-muted transition-transform duration-200",r&&"rotate-180")})]}),I.jsx(mt,{children:r&&I.jsx(xt.div,{initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:ht.dropdown,className:"absolute z-50 mt-1",children:I.jsx(Pe,{static:!0,anchor:"bottom start",className:H(["w-[var(--button-width)] min-w-[180px]","max-h-60 overflow-y-auto overscroll-contain scroll-py-1","radius-inset p-1","surface-elevated","focus:outline-none"]),children:u})})})]})})}function sn({value:e,disabled:s,className:t,children:n}){return I.jsx(Le,{as:f.Fragment,value:e,disabled:s,children:({selected:o,focus:i})=>I.jsxs("div",{className:H("flex items-center gap-2 px-3 py-2 radius-control cursor-default","text-sm",i&&"bg-sys-blue text-white",!i&&"text-fg-primary",o&&!i&&"text-sys-blue",s&&"opacity-50 cursor-not-allowed",t),children:[I.jsx("span",{className:"w-4 flex-shrink-0",children:o&&I.jsx(gt,{className:"w-4 h-4"})}),I.jsx("span",{className:"truncate",children:n})]})})}function an({className:e,...s}){return I.jsx("span",{...s,className:H("truncate",e)})}export{on as L,sn as a,an as b}; diff --git a/frontend/dist/assets/map-pin-CQk00ph2.js b/frontend/dist/assets/map-pin-B_Rx-xpd.js similarity index 88% rename from frontend/dist/assets/map-pin-CQk00ph2.js rename to frontend/dist/assets/map-pin-B_Rx-xpd.js index e073b925..f7ab0a96 100644 --- a/frontend/dist/assets/map-pin-CQk00ph2.js +++ b/frontend/dist/assets/map-pin-B_Rx-xpd.js @@ -1,6 +1,6 @@ -import{r as g,bs as ot,bx as de,b9 as ct,gr as me,bi as ge,aT as Kt,b6 as he,e as pe}from"./index-C2xvS0Jd.js";function Dt(t){if(t===null)return{width:0,height:0};let{width:e,height:n}=t.getBoundingClientRect();return{width:e,height:n}}function Vn(t,e,n=!1){let[o,r]=g.useState(()=>Dt(e));return ot(()=>{if(!e||!t)return;let i=de();return i.requestAnimationFrame(function s(){i.requestAnimationFrame(s),r(l=>{let c=Dt(e);return c.width===l.width&&c.height===l.height?l:c})}),()=>{i.dispose()}},[e,t]),n?{width:`${o.width}px`,height:`${o.height}px`}:o}function dt(){return typeof window<"u"}function Q(t){return Gt(t)?(t.nodeName||"").toLowerCase():"#document"}function B(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function z(t){var e;return(e=(Gt(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Gt(t){return dt()?t instanceof Node||t instanceof B(t).Node:!1}function k(t){return dt()?t instanceof Element||t instanceof B(t).Element:!1}function _(t){return dt()?t instanceof HTMLElement||t instanceof B(t).HTMLElement:!1}function Lt(t){return!dt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof B(t).ShadowRoot}const we=new Set(["inline","contents"]);function rt(t){const{overflow:e,overflowX:n,overflowY:o,display:r}=W(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!we.has(r)}const xe=new Set(["table","td","th"]);function ye(t){return xe.has(Q(t))}const ve=[":popover-open",":modal"];function mt(t){return ve.some(e=>{try{return t.matches(e)}catch{return!1}})}const be=["transform","translate","scale","rotate","perspective"],Re=["transform","translate","scale","rotate","perspective","filter"],Ce=["paint","layout","strict","content"];function Et(t){const e=Ot(),n=k(t)?W(t):t;return be.some(o=>n[o]?n[o]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||Re.some(o=>(n.willChange||"").includes(o))||Ce.some(o=>(n.contain||"").includes(o))}function Se(t){let e=q(t);for(;_(e)&&!J(e);){if(Et(e))return e;if(mt(e))return null;e=q(e)}return null}function Ot(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ae=new Set(["html","body","#document"]);function J(t){return Ae.has(Q(t))}function W(t){return B(t).getComputedStyle(t)}function gt(t){return k(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function q(t){if(Q(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Lt(t)&&t.host||z(t);return Lt(e)?e.host:e}function Jt(t){const e=q(t);return J(e)?t.ownerDocument?t.ownerDocument.body:t.body:_(e)&&rt(e)?e:Jt(e)}function et(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=Jt(t),i=r===((o=t.ownerDocument)==null?void 0:o.body),s=B(r);if(i){const l=Ct(s);return e.concat(s,s.visualViewport||[],rt(r)?r:[],l&&n?et(l):[])}return e.concat(r,et(r,[],n))}function Ct(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Ee(){const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?t.brands.map(e=>{let{brand:n,version:o}=e;return n+"/"+o}).join(" "):navigator.userAgent}const U=Math.min,D=Math.max,nt=Math.round,st=Math.floor,V=t=>({x:t,y:t}),Oe={left:"right",right:"left",bottom:"top",top:"bottom"},Te={start:"end",end:"start"};function Ht(t,e,n){return D(t,U(e,n))}function Z(t,e){return typeof t=="function"?t(e):t}function X(t){return t.split("-")[0]}function it(t){return t.split("-")[1]}function Qt(t){return t==="x"?"y":"x"}function Zt(t){return t==="y"?"height":"width"}const Me=new Set(["top","bottom"]);function Y(t){return Me.has(X(t))?"y":"x"}function te(t){return Qt(Y(t))}function Fe(t,e,n){n===void 0&&(n=!1);const o=it(t),r=te(t),i=Zt(r);let s=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=ft(s)),[s,ft(s)]}function Pe(t){const e=ft(t);return[St(t),e,St(e)]}function St(t){return t.replace(/start|end/g,e=>Te[e])}const kt=["left","right"],$t=["right","left"],De=["top","bottom"],Le=["bottom","top"];function He(t,e,n){switch(t){case"top":case"bottom":return n?e?$t:kt:e?kt:$t;case"left":case"right":return e?De:Le;default:return[]}}function ke(t,e,n,o){const r=it(t);let i=He(X(t),n==="start",o);return r&&(i=i.map(s=>s+"-"+r),e&&(i=i.concat(i.map(St)))),i}function ft(t){return t.replace(/left|right|bottom|top/g,e=>Oe[e])}function $e(t){return{top:0,right:0,bottom:0,left:0,...t}}function Ie(t){return typeof t!="number"?$e(t):{top:t,right:t,bottom:t,left:t}}function at(t){const{x:e,y:n,width:o,height:r}=t;return{width:o,height:r,top:n,left:e,right:e+o,bottom:n+r,x:e,y:n}}function It(t,e,n){let{reference:o,floating:r}=t;const i=Y(e),s=te(e),l=Zt(s),c=X(e),f=i==="y",a=o.x+o.width/2-r.width/2,m=o.y+o.height/2-r.height/2,h=o[l]/2-r[l]/2;let u;switch(c){case"top":u={x:a,y:o.y-r.height};break;case"bottom":u={x:a,y:o.y+o.height};break;case"right":u={x:o.x+o.width,y:m};break;case"left":u={x:o.x-r.width,y:m};break;default:u={x:o.x,y:o.y}}switch(it(e)){case"start":u[s]-=h*(n&&f?-1:1);break;case"end":u[s]+=h*(n&&f?-1:1);break}return u}const Be=async(t,e,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:s}=n,l=i.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(e));let f=await s.getElementRects({reference:t,floating:e,strategy:r}),{x:a,y:m}=It(f,o,c),h=o,u={},d=0;for(let p=0;pM<=0)){var O,$;const M=(((O=i.flip)==null?void 0:O.index)||0)+1,j=A[M];if(j&&(!(m==="alignment"?v!==Y(j):!1)||T.every(C=>Y(C.placement)===v?C.overflows[0]>0:!0)))return{data:{index:M,overflows:T},reset:{placement:j}};let F=($=T.filter(I=>I.overflows[0]<=0).sort((I,C)=>I.overflows[1]-C.overflows[1])[0])==null?void 0:$.placement;if(!F)switch(u){case"bestFit":{var P;const I=(P=T.filter(C=>{if(S){const E=Y(C.placement);return E===v||E==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(E=>E>0).reduce((E,H)=>E+H,0)]).sort((C,E)=>C[1]-E[1])[0])==null?void 0:P[0];I&&(F=I);break}case"initialPlacement":F=l;break}if(r!==F)return{reset:{placement:F}}}return{}}}},We=new Set(["left","top"]);async function Ve(t,e){const{placement:n,platform:o,elements:r}=t,i=await(o.isRTL==null?void 0:o.isRTL(r.floating)),s=X(n),l=it(n),c=Y(n)==="y",f=We.has(s)?-1:1,a=i&&c?-1:1,m=Z(e,t);let{mainAxis:h,crossAxis:u,alignmentAxis:d}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return l&&typeof d=="number"&&(u=l==="end"?d*-1:d),c?{x:u*a,y:h*f}:{x:h*f,y:u*a}}const _e=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:r,y:i,placement:s,middlewareData:l}=e,c=await Ve(e,t);return s===((n=l.offset)==null?void 0:n.placement)&&(o=l.arrow)!=null&&o.alignmentOffset?{}:{x:r+c.x,y:i+c.y,data:{...c,placement:s}}}}},ze=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:r}=e,{mainAxis:i=!0,crossAxis:s=!1,limiter:l={fn:w=>{let{x:y,y:v}=w;return{x:y,y:v}}},...c}=Z(t,e),f={x:n,y:o},a=await ht(e,c),m=Y(X(r)),h=Qt(m);let u=f[h],d=f[m];if(i){const w=h==="y"?"top":"left",y=h==="y"?"bottom":"right",v=u+a[w],x=u-a[y];u=Ht(v,u,x)}if(s){const w=m==="y"?"top":"left",y=m==="y"?"bottom":"right",v=d+a[w],x=d-a[y];d=Ht(v,d,x)}const p=l.fn({...e,[h]:u,[m]:d});return{...p,data:{x:p.x-n,y:p.y-o,enabled:{[h]:i,[m]:s}}}}}},je=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,o;const{placement:r,rects:i,platform:s,elements:l}=e,{apply:c=()=>{},...f}=Z(t,e),a=await ht(e,f),m=X(r),h=it(r),u=Y(r)==="y",{width:d,height:p}=i.floating;let w,y;m==="top"||m==="bottom"?(w=m,y=h===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(y=m,w=h==="end"?"top":"bottom");const v=p-a.top-a.bottom,x=d-a.left-a.right,b=U(p-a[w],v),R=U(d-a[y],x),S=!e.middlewareData.shift;let A=b,L=R;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(L=x),(o=e.middlewareData.shift)!=null&&o.enabled.y&&(A=v),S&&!h){const T=D(a.left,0),O=D(a.right,0),$=D(a.top,0),P=D(a.bottom,0);u?L=d-2*(T!==0||O!==0?T+O:D(a.left,a.right)):A=p-2*($!==0||P!==0?$+P:D(a.top,a.bottom))}await c({...e,availableWidth:L,availableHeight:A});const N=await s.getDimensions(l.floating);return d!==N.width||p!==N.height?{reset:{rects:!0}}:{}}}};function ee(t){const e=W(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=_(t),i=r?t.offsetWidth:n,s=r?t.offsetHeight:o,l=nt(n)!==i||nt(o)!==s;return l&&(n=i,o=s),{width:n,height:o,$:l}}function Tt(t){return k(t)?t:t.contextElement}function G(t){const e=Tt(t);if(!_(e))return V(1);const n=e.getBoundingClientRect(),{width:o,height:r,$:i}=ee(e);let s=(i?nt(n.width):n.width)/o,l=(i?nt(n.height):n.height)/r;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const Ye=V(0);function ne(t){const e=B(t);return!Ot()||!e.visualViewport?Ye:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function qe(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==B(t)?!1:e}function K(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),i=Tt(t);let s=V(1);e&&(o?k(o)&&(s=G(o)):s=G(t));const l=qe(i,n,o)?ne(i):V(0);let c=(r.left+l.x)/s.x,f=(r.top+l.y)/s.y,a=r.width/s.x,m=r.height/s.y;if(i){const h=B(i),u=o&&k(o)?B(o):o;let d=h,p=Ct(d);for(;p&&o&&u!==d;){const w=G(p),y=p.getBoundingClientRect(),v=W(p),x=y.left+(p.clientLeft+parseFloat(v.paddingLeft))*w.x,b=y.top+(p.clientTop+parseFloat(v.paddingTop))*w.y;c*=w.x,f*=w.y,a*=w.x,m*=w.y,c+=x,f+=b,d=B(p),p=Ct(d)}}return at({width:a,height:m,x:c,y:f})}function pt(t,e){const n=gt(t).scrollLeft;return e?e.left+n:K(z(t)).left+n}function oe(t,e){const n=t.getBoundingClientRect(),o=n.left+e.scrollLeft-pt(t,n),r=n.top+e.scrollTop;return{x:o,y:r}}function Xe(t){let{elements:e,rect:n,offsetParent:o,strategy:r}=t;const i=r==="fixed",s=z(o),l=e?mt(e.floating):!1;if(o===s||l&&i)return n;let c={scrollLeft:0,scrollTop:0},f=V(1);const a=V(0),m=_(o);if((m||!m&&!i)&&((Q(o)!=="body"||rt(s))&&(c=gt(o)),_(o))){const u=K(o);f=G(o),a.x=u.x+o.clientLeft,a.y=u.y+o.clientTop}const h=s&&!m&&!i?oe(s,c):V(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-c.scrollLeft*f.x+a.x+h.x,y:n.y*f.y-c.scrollTop*f.y+a.y+h.y}}function Ue(t){return Array.from(t.getClientRects())}function Ke(t){const e=z(t),n=gt(t),o=t.ownerDocument.body,r=D(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),i=D(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let s=-n.scrollLeft+pt(t);const l=-n.scrollTop;return W(o).direction==="rtl"&&(s+=D(e.clientWidth,o.clientWidth)-r),{width:r,height:i,x:s,y:l}}const Bt=25;function Ge(t,e){const n=B(t),o=z(t),r=n.visualViewport;let i=o.clientWidth,s=o.clientHeight,l=0,c=0;if(r){i=r.width,s=r.height;const a=Ot();(!a||a&&e==="fixed")&&(l=r.offsetLeft,c=r.offsetTop)}const f=pt(o);if(f<=0){const a=o.ownerDocument,m=a.body,h=getComputedStyle(m),u=a.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,d=Math.abs(o.clientWidth-m.clientWidth-u);d<=Bt&&(i-=d)}else f<=Bt&&(i+=f);return{width:i,height:s,x:l,y:c}}const Je=new Set(["absolute","fixed"]);function Qe(t,e){const n=K(t,!0,e==="fixed"),o=n.top+t.clientTop,r=n.left+t.clientLeft,i=_(t)?G(t):V(1),s=t.clientWidth*i.x,l=t.clientHeight*i.y,c=r*i.x,f=o*i.y;return{width:s,height:l,x:c,y:f}}function Nt(t,e,n){let o;if(e==="viewport")o=Ge(t,n);else if(e==="document")o=Ke(z(t));else if(k(e))o=Qe(e,n);else{const r=ne(t);o={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return at(o)}function re(t,e){const n=q(t);return n===e||!k(n)||J(n)?!1:W(n).position==="fixed"||re(n,e)}function Ze(t,e){const n=e.get(t);if(n)return n;let o=et(t,[],!1).filter(l=>k(l)&&Q(l)!=="body"),r=null;const i=W(t).position==="fixed";let s=i?q(t):t;for(;k(s)&&!J(s);){const l=W(s),c=Et(s);!c&&l.position==="fixed"&&(r=null),(i?!c&&!r:!c&&l.position==="static"&&!!r&&Je.has(r.position)||rt(s)&&!c&&re(t,s))?o=o.filter(a=>a!==s):r=l,s=q(s)}return e.set(t,o),o}function tn(t){let{element:e,boundary:n,rootBoundary:o,strategy:r}=t;const s=[...n==="clippingAncestors"?mt(e)?[]:Ze(e,this._c):[].concat(n),o],l=s[0],c=s.reduce((f,a)=>{const m=Nt(e,a,r);return f.top=D(m.top,f.top),f.right=U(m.right,f.right),f.bottom=U(m.bottom,f.bottom),f.left=D(m.left,f.left),f},Nt(e,l,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function en(t){const{width:e,height:n}=ee(t);return{width:e,height:n}}function nn(t,e,n){const o=_(e),r=z(e),i=n==="fixed",s=K(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const c=V(0);function f(){c.x=pt(r)}if(o||!o&&!i)if((Q(e)!=="body"||rt(r))&&(l=gt(e)),o){const u=K(e,!0,i,e);c.x=u.x+e.clientLeft,c.y=u.y+e.clientTop}else r&&f();i&&!o&&r&&f();const a=r&&!o&&!i?oe(r,l):V(0),m=s.left+l.scrollLeft-c.x-a.x,h=s.top+l.scrollTop-c.y-a.y;return{x:m,y:h,width:s.width,height:s.height}}function xt(t){return W(t).position==="static"}function Wt(t,e){if(!_(t)||W(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return z(t)===n&&(n=n.ownerDocument.body),n}function ie(t,e){const n=B(t);if(mt(t))return n;if(!_(t)){let r=q(t);for(;r&&!J(r);){if(k(r)&&!xt(r))return r;r=q(r)}return n}let o=Wt(t,e);for(;o&&ye(o)&&xt(o);)o=Wt(o,e);return o&&J(o)&&xt(o)&&!Et(o)?n:o||Se(t)||n}const on=async function(t){const e=this.getOffsetParent||ie,n=this.getDimensions,o=await n(t.floating);return{reference:nn(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function rn(t){return W(t).direction==="rtl"}const sn={convertOffsetParentRelativeRectToViewportRelativeRect:Xe,getDocumentElement:z,getClippingRect:tn,getOffsetParent:ie,getElementRects:on,getClientRects:Ue,getDimensions:en,getScale:G,isElement:k,isRTL:rn};function se(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function ln(t,e){let n=null,o;const r=z(t);function i(){var l;clearTimeout(o),(l=n)==null||l.disconnect(),n=null}function s(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),i();const f=t.getBoundingClientRect(),{left:a,top:m,width:h,height:u}=f;if(l||e(),!h||!u)return;const d=st(m),p=st(r.clientWidth-(a+h)),w=st(r.clientHeight-(m+u)),y=st(a),x={rootMargin:-d+"px "+-p+"px "+-w+"px "+-y+"px",threshold:D(0,U(1,c))||1};let b=!0;function R(S){const A=S[0].intersectionRatio;if(A!==c){if(!b)return s();A?s(!1,A):o=setTimeout(()=>{s(!1,1e-7)},1e3)}A===1&&!se(f,t.getBoundingClientRect())&&s(),b=!1}try{n=new IntersectionObserver(R,{...x,root:r.ownerDocument})}catch{n=new IntersectionObserver(R,x)}n.observe(t)}return s(!0),i}function cn(t,e,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,f=Tt(t),a=r||i?[...f?et(f):[],...et(e)]:[];a.forEach(y=>{r&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const m=f&&l?ln(f,n):null;let h=-1,u=null;s&&(u=new ResizeObserver(y=>{let[v]=y;v&&v.target===f&&u&&(u.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=u)==null||x.observe(e)})),n()}),f&&!c&&u.observe(f),u.observe(e));let d,p=c?K(t):null;c&&w();function w(){const y=K(t);p&&!se(p,y)&&n(),p=y,d=requestAnimationFrame(w)}return n(),()=>{var y;a.forEach(v=>{r&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),m==null||m(),(y=u)==null||y.disconnect(),u=null,c&&cancelAnimationFrame(d)}}const yt=ht,fn=_e,an=ze,un=Ne,dn=je,mn=(t,e,n)=>{const o=new Map,r={platform:sn,...n},i={...r.platform,_c:o};return Be(t,e,{...r,platform:i})};var gn=typeof document<"u",hn=function(){},lt=gn?g.useLayoutEffect:hn;function ut(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,o,r;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(o=n;o--!==0;)if(!ut(t[o],e[o]))return!1;return!0}if(r=Object.keys(t),n=r.length,n!==Object.keys(e).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(e,r[o]))return!1;for(o=n;o--!==0;){const i=r[o];if(!(i==="_owner"&&t.$$typeof)&&!ut(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function le(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Vt(t,e){const n=le(t);return Math.round(e*n)/n}function vt(t){const e=g.useRef(t);return lt(()=>{e.current=t}),e}function pn(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:o=[],platform:r,elements:{reference:i,floating:s}={},transform:l=!0,whileElementsMounted:c,open:f}=t,[a,m]=g.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,u]=g.useState(o);ut(h,o)||u(o);const[d,p]=g.useState(null),[w,y]=g.useState(null),v=g.useCallback(C=>{C!==S.current&&(S.current=C,p(C))},[]),x=g.useCallback(C=>{C!==A.current&&(A.current=C,y(C))},[]),b=i||d,R=s||w,S=g.useRef(null),A=g.useRef(null),L=g.useRef(a),N=c!=null,T=vt(c),O=vt(r),$=vt(f),P=g.useCallback(()=>{if(!S.current||!A.current)return;const C={placement:e,strategy:n,middleware:h};O.current&&(C.platform=O.current),mn(S.current,A.current,C).then(E=>{const H={...E,isPositioned:$.current!==!1};M.current&&!ut(L.current,H)&&(L.current=H,ct.flushSync(()=>{m(H)}))})},[h,e,n,O,$]);lt(()=>{f===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,m(C=>({...C,isPositioned:!1})))},[f]);const M=g.useRef(!1);lt(()=>(M.current=!0,()=>{M.current=!1}),[]),lt(()=>{if(b&&(S.current=b),R&&(A.current=R),b&&R){if(T.current)return T.current(b,R,P);P()}},[b,R,P,T,N]);const j=g.useMemo(()=>({reference:S,floating:A,setReference:v,setFloating:x}),[v,x]),F=g.useMemo(()=>({reference:b,floating:R}),[b,R]),I=g.useMemo(()=>{const C={position:n,left:0,top:0};if(!F.floating)return C;const E=Vt(F.floating,a.x),H=Vt(F.floating,a.y);return l?{...C,transform:"translate("+E+"px, "+H+"px)",...le(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:E,top:H}},[n,l,F.floating,a.x,a.y]);return g.useMemo(()=>({...a,update:P,refs:j,elements:F,floatingStyles:I}),[a,P,j,F,I])}const ce=(t,e)=>({...fn(t),options:[t,e]}),wn=(t,e)=>({...an(t),options:[t,e]}),xn=(t,e)=>({...un(t),options:[t,e]}),yn=(t,e)=>({...dn(t),options:[t,e]}),fe={...me},vn=fe.useInsertionEffect,bn=vn||(t=>t());function ae(t){const e=g.useRef(()=>{});return bn(()=>{e.current=t}),g.useCallback(function(){for(var n=arguments.length,o=new Array(n),r=0;r"floating-ui-"+Math.random().toString(36).slice(2,6)+Rn++;function Cn(){const[t,e]=g.useState(()=>_t?zt():void 0);return At(()=>{t==null&&e(zt())},[]),g.useEffect(()=>{_t=!0},[]),t}const Sn=fe.useId,An=Sn||Cn;function En(){const t=new Map;return{emit(e,n){var o;(o=t.get(e))==null||o.forEach(r=>r(n))},on(e,n){t.set(e,[...t.get(e)||[],n])},off(e,n){var o;t.set(e,((o=t.get(e))==null?void 0:o.filter(r=>r!==n))||[])}}}const On=g.createContext(null),Tn=g.createContext(null),Mn=()=>{var t;return((t=g.useContext(On))==null?void 0:t.id)||null},Fn=()=>g.useContext(Tn),Pn="data-floating-ui-focusable";function Dn(t){const{open:e=!1,onOpenChange:n,elements:o}=t,r=An(),i=g.useRef({}),[s]=g.useState(()=>En()),l=Mn()!=null,[c,f]=g.useState(o.reference),a=ae((u,d,p)=>{i.current.openEvent=u?d:void 0,s.emit("openchange",{open:u,event:d,reason:p,nested:l}),n==null||n(u,d,p)}),m=g.useMemo(()=>({setPositionReference:f}),[]),h=g.useMemo(()=>({reference:c||o.reference||null,floating:o.floating||null,domReference:o.reference}),[c,o.reference,o.floating]);return g.useMemo(()=>({dataRef:i,open:e,onOpenChange:a,elements:h,events:s,floatingId:r,refs:m}),[e,a,h,s,r,m])}function Ln(t){t===void 0&&(t={});const{nodeId:e}=t,n=Dn({...t,elements:{reference:null,floating:null,...t.elements}}),o=t.rootContext||n,r=o.elements,[i,s]=g.useState(null),[l,c]=g.useState(null),a=(r==null?void 0:r.domReference)||i,m=g.useRef(null),h=Fn();At(()=>{a&&(m.current=a)},[a]);const u=pn({...t,elements:{...r,...l&&{reference:l}}}),d=g.useCallback(x=>{const b=k(x)?{getBoundingClientRect:()=>x.getBoundingClientRect(),contextElement:x}:x;c(b),u.refs.setReference(b)},[u.refs]),p=g.useCallback(x=>{(k(x)||x===null)&&(m.current=x,s(x)),(k(u.refs.reference.current)||u.refs.reference.current===null||x!==null&&!k(x))&&u.refs.setReference(x)},[u.refs]),w=g.useMemo(()=>({...u.refs,setReference:p,setPositionReference:d,domReference:m}),[u.refs,p,d]),y=g.useMemo(()=>({...u.elements,domReference:a}),[u.elements,a]),v=g.useMemo(()=>({...u,...o,refs:w,elements:y,nodeId:e}),[u,w,y,e,o]);return At(()=>{o.dataRef.current.floatingContext=v;const x=h==null?void 0:h.nodesRef.current.find(b=>b.id===e);x&&(x.context=v)}),g.useMemo(()=>({...u,context:v,refs:w,elements:y}),[u,w,y,v])}const jt="active",Yt="selected";function bt(t,e,n){const o=new Map,r=n==="item";let i=t;if(r&&t){const{[jt]:s,[Yt]:l,...c}=t;i=c}return{...n==="floating"&&{tabIndex:-1,[Pn]:""},...i,...e.map(s=>{const l=s?s[n]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((s,l)=>(l&&Object.entries(l).forEach(c=>{let[f,a]=c;if(!(r&&[jt,Yt].includes(f)))if(f.indexOf("on")===0){if(o.has(f)||o.set(f,[]),typeof a=="function"){var m;(m=o.get(f))==null||m.push(a),s[f]=function(){for(var h,u=arguments.length,d=new Array(u),p=0;pw(...d)).find(w=>w!==void 0)}}}else s[f]=a}),s),{})}}function Hn(t){t===void 0&&(t=[]);const e=t.map(l=>l==null?void 0:l.reference),n=t.map(l=>l==null?void 0:l.floating),o=t.map(l=>l==null?void 0:l.item),r=g.useCallback(l=>bt(l,t,"reference"),e),i=g.useCallback(l=>bt(l,t,"floating"),n),s=g.useCallback(l=>bt(l,t,"item"),o);return g.useMemo(()=>({getReferenceProps:r,getFloatingProps:i,getItemProps:s}),[r,i,s])}function qt(t,e){return{...t,rects:{...t.rects,floating:{...t.rects.floating,height:e}}}}const kn=t=>({name:"inner",options:t,async fn(e){const{listRef:n,overflowRef:o,onFallbackChange:r,offset:i=0,index:s=0,minItemsVisible:l=4,referenceOverflowThreshold:c=0,scrollRef:f,...a}=Z(t,e),{rects:m,elements:{floating:h}}=e,u=n.current[s],d=(f==null?void 0:f.current)||h,p=h.clientTop||d.clientTop,w=h.clientTop!==0,y=d.clientTop!==0,v=h===d;if(!u)return{};const x={...e,...await ce(-u.offsetTop-h.clientTop-m.reference.height/2-u.offsetHeight/2-i).fn(e)},b=await yt(qt(x,d.scrollHeight+p+h.clientTop),a),R=await yt(x,{...a,elementContext:"reference"}),S=D(0,b.top),A=x.y+S,T=(d.scrollHeight>d.clientHeight?O=>O:nt)(D(0,d.scrollHeight+(w&&v||y?p*2:0)-S-D(0,b.bottom)));if(d.style.maxHeight=T+"px",d.scrollTop=S,r){const O=d.offsetHeight=-c||R.bottom>=-c;ct.flushSync(()=>r(O))}return o&&(o.current=await yt(qt({...x,y:A},d.offsetHeight+p+h.clientTop),a)),{y:A}}});function $n(t,e){const{open:n,elements:o}=t,{enabled:r=!0,overflowRef:i,scrollRef:s,onChange:l}=e,c=ae(l),f=g.useRef(!1),a=g.useRef(null),m=g.useRef(null);g.useEffect(()=>{if(!r)return;function u(p){if(p.ctrlKey||!d||i.current==null)return;const w=p.deltaY,y=i.current.top>=-.5,v=i.current.bottom>=-.5,x=d.scrollHeight-d.clientHeight,b=w<0?-1:1,R=w<0?"max":"min";d.scrollHeight<=d.clientHeight||(!y&&w>0||!v&&w<0?(p.preventDefault(),ct.flushSync(()=>{c(S=>S+Math[R](w,x*b))})):/firefox/i.test(Ee())&&(d.scrollTop+=w))}const d=(s==null?void 0:s.current)||o.floating;if(n&&d)return d.addEventListener("wheel",u),requestAnimationFrame(()=>{a.current=d.scrollTop,i.current!=null&&(m.current={...i.current})}),()=>{a.current=null,m.current=null,d.removeEventListener("wheel",u)}},[r,n,o.floating,i,s,c]);const h=g.useMemo(()=>({onKeyDown(){f.current=!0},onWheel(){f.current=!1},onPointerMove(){f.current=!1},onScroll(){const u=(s==null?void 0:s.current)||o.floating;if(!(!i.current||!u||!f.current)){if(a.current!==null){const d=u.scrollTop-a.current;(i.current.bottom<-.5&&d<-1||i.current.top<-.5&&d>1)&&ct.flushSync(()=>c(p=>p+d))}requestAnimationFrame(()=>{a.current=u.scrollTop})}}}),[o.floating,c,i,s]);return g.useMemo(()=>r?{floating:h}:{},[r,h])}let tt=g.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});tt.displayName="FloatingContext";let Mt=g.createContext(null);Mt.displayName="PlacementContext";function _n(t){return g.useMemo(()=>t?typeof t=="string"?{to:t}:t:null,[t])}function zn(){return g.useContext(tt).setReference}function jn(){return g.useContext(tt).getReferenceProps}function Yn(){let{getFloatingProps:t,slot:e}=g.useContext(tt);return g.useCallback((...n)=>Object.assign({},t(...n),{"data-anchor":e.anchor}),[t,e])}function qn(t=null){t===!1&&(t=null),typeof t=="string"&&(t={to:t});let e=g.useContext(Mt),n=g.useMemo(()=>t,[JSON.stringify(t,(r,i)=>{var s;return(s=i==null?void 0:i.outerHTML)!=null?s:i})]);ot(()=>{e==null||e(n??null)},[e,n]);let o=g.useContext(tt);return g.useMemo(()=>[o.setFloating,t?o.styles:{}],[o.setFloating,t,o.styles])}let Xt=4;function Xn({children:t,enabled:e=!0}){let[n,o]=g.useState(null),[r,i]=g.useState(0),s=g.useRef(null),[l,c]=g.useState(null);In(l);let f=e&&n!==null&&l!==null,{to:a="bottom",gap:m=0,offset:h=0,padding:u=0,inner:d}=Bn(n,l),[p,w="center"]=a.split(" ");ot(()=>{f&&i(0)},[f]);let{refs:y,floatingStyles:v,context:x}=Ln({open:f,placement:p==="selection"?w==="center"?"bottom":`bottom-${w}`:w==="center"?`${p}`:`${p}-${w}`,strategy:"absolute",transform:!1,middleware:[ce({mainAxis:p==="selection"?0:m,crossAxis:h}),wn({padding:u}),p!=="selection"&&xn({padding:u}),p==="selection"&&d?kn({...d,padding:u,overflowRef:s,offset:r,minItemsVisible:Xt,referenceOverflowThreshold:u,onFallbackChange(O){var $,P;if(!O)return;let M=x.elements.floating;if(!M)return;let j=parseFloat(getComputedStyle(M).scrollPaddingBottom)||0,F=Math.min(Xt,M.childElementCount),I=0,C=0;for(let E of(P=($=x.elements.floating)==null?void 0:$.childNodes)!=null?P:[])if(ge(E)){let H=E.offsetTop,Ft=H+E.clientHeight+j,wt=M.scrollTop,Pt=wt+M.clientHeight;if(H>=wt&&Ft<=Pt)F--;else{C=Math.max(0,Math.min(Ft,Pt)-Math.max(H,wt)),I=E.clientHeight;break}}F>=1&&i(E=>{let H=I*F-C+j;return E>=H?E:H})}}):null,yn({padding:u,apply({availableWidth:O,availableHeight:$,elements:P}){Object.assign(P.floating.style,{overflow:"auto",maxWidth:`${O}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${$}px)`})}})].filter(Boolean),whileElementsMounted:cn}),[b=p,R=w]=x.placement.split("-");p==="selection"&&(b="selection");let S=g.useMemo(()=>({anchor:[b,R].filter(Boolean).join(" ")}),[b,R]),A=$n(x,{overflowRef:s,onChange:i}),{getReferenceProps:L,getFloatingProps:N}=Hn([A]),T=Kt(O=>{c(O),y.setFloating(O)});return g.createElement(Mt.Provider,{value:o},g.createElement(tt.Provider,{value:{setFloating:T,setReference:y.setReference,styles:v,getReferenceProps:L,getFloatingProps:N,slot:S}},t))}function In(t){ot(()=>{if(!t)return;let e=new MutationObserver(()=>{let n=window.getComputedStyle(t).maxHeight,o=parseFloat(n);if(isNaN(o))return;let r=parseInt(n);isNaN(r)||o!==r&&(t.style.maxHeight=`${Math.ceil(o)}px`)});return e.observe(t,{attributes:!0,attributeFilter:["style"]}),()=>{e.disconnect()}},[t])}function Bn(t,e){var n,o,r;let i=Rt((n=t==null?void 0:t.gap)!=null?n:"var(--anchor-gap, 0)",e),s=Rt((o=t==null?void 0:t.offset)!=null?o:"var(--anchor-offset, 0)",e),l=Rt((r=t==null?void 0:t.padding)!=null?r:"var(--anchor-padding, 0)",e);return{...t,gap:i,offset:s,padding:l}}function Rt(t,e,n=void 0){let o=he(),r=Kt((c,f)=>{if(c==null)return[n,null];if(typeof c=="number")return[c,null];if(typeof c=="string"){if(!f)return[n,null];let a=Ut(c,f);return[a,m=>{let h=ue(c);{let u=h.map(d=>window.getComputedStyle(f).getPropertyValue(d));o.requestAnimationFrame(function d(){o.nextFrame(d);let p=!1;for(let[y,v]of h.entries()){let x=window.getComputedStyle(f).getPropertyValue(v);if(u[y]!==x){u[y]=x,p=!0;break}}if(!p)return;let w=Ut(c,f);a!==w&&(m(w),a=w)})}return o.dispose}]}return[n,null]}),i=g.useMemo(()=>r(t,e)[0],[t,e]),[s=i,l]=g.useState();return ot(()=>{let[c,f]=r(t,e);if(l(c),!!f)return f(l)},[t,e]),s}function ue(t){let e=/var\((.*)\)/.exec(t);if(e){let n=e[1].indexOf(",");if(n===-1)return[e[1]];let o=e[1].slice(0,n).trim(),r=e[1].slice(n+1).trim();return r?[o,...ue(r)]:[o]}return[]}function Ut(t,e){let n=document.createElement("div");e.appendChild(n),n.style.setProperty("margin-top","0px","important"),n.style.setProperty("margin-top",t,"important");let o=parseFloat(window.getComputedStyle(n).marginTop)||0;return e.removeChild(n),o}/** +import{r as g,bt as ot,by as de,ba as ct,gr as me,bj as ge,aU as Kt,b7 as he,e as pe}from"./index-D33fcA3L.js";function Dt(t){if(t===null)return{width:0,height:0};let{width:e,height:n}=t.getBoundingClientRect();return{width:e,height:n}}function Vn(t,e,n=!1){let[o,r]=g.useState(()=>Dt(e));return ot(()=>{if(!e||!t)return;let i=de();return i.requestAnimationFrame(function s(){i.requestAnimationFrame(s),r(l=>{let c=Dt(e);return c.width===l.width&&c.height===l.height?l:c})}),()=>{i.dispose()}},[e,t]),n?{width:`${o.width}px`,height:`${o.height}px`}:o}function dt(){return typeof window<"u"}function Q(t){return Gt(t)?(t.nodeName||"").toLowerCase():"#document"}function B(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function j(t){var e;return(e=(Gt(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Gt(t){return dt()?t instanceof Node||t instanceof B(t).Node:!1}function k(t){return dt()?t instanceof Element||t instanceof B(t).Element:!1}function _(t){return dt()?t instanceof HTMLElement||t instanceof B(t).HTMLElement:!1}function Lt(t){return!dt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof B(t).ShadowRoot}const we=new Set(["inline","contents"]);function rt(t){const{overflow:e,overflowX:n,overflowY:o,display:r}=W(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!we.has(r)}const xe=new Set(["table","td","th"]);function ye(t){return xe.has(Q(t))}const ve=[":popover-open",":modal"];function mt(t){return ve.some(e=>{try{return t.matches(e)}catch{return!1}})}const be=["transform","translate","scale","rotate","perspective"],Re=["transform","translate","scale","rotate","perspective","filter"],Ce=["paint","layout","strict","content"];function Et(t){const e=Ot(),n=k(t)?W(t):t;return be.some(o=>n[o]?n[o]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||Re.some(o=>(n.willChange||"").includes(o))||Ce.some(o=>(n.contain||"").includes(o))}function Se(t){let e=q(t);for(;_(e)&&!J(e);){if(Et(e))return e;if(mt(e))return null;e=q(e)}return null}function Ot(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ae=new Set(["html","body","#document"]);function J(t){return Ae.has(Q(t))}function W(t){return B(t).getComputedStyle(t)}function gt(t){return k(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function q(t){if(Q(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Lt(t)&&t.host||j(t);return Lt(e)?e.host:e}function Jt(t){const e=q(t);return J(e)?t.ownerDocument?t.ownerDocument.body:t.body:_(e)&&rt(e)?e:Jt(e)}function et(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=Jt(t),i=r===((o=t.ownerDocument)==null?void 0:o.body),s=B(r);if(i){const l=Ct(s);return e.concat(s,s.visualViewport||[],rt(r)?r:[],l&&n?et(l):[])}return e.concat(r,et(r,[],n))}function Ct(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Ee(){const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?t.brands.map(e=>{let{brand:n,version:o}=e;return n+"/"+o}).join(" "):navigator.userAgent}const X=Math.min,D=Math.max,nt=Math.round,st=Math.floor,V=t=>({x:t,y:t}),Oe={left:"right",right:"left",bottom:"top",top:"bottom"},Te={start:"end",end:"start"};function Ht(t,e,n){return D(t,X(e,n))}function Z(t,e){return typeof t=="function"?t(e):t}function U(t){return t.split("-")[0]}function it(t){return t.split("-")[1]}function Qt(t){return t==="x"?"y":"x"}function Zt(t){return t==="y"?"height":"width"}const Me=new Set(["top","bottom"]);function Y(t){return Me.has(U(t))?"y":"x"}function te(t){return Qt(Y(t))}function Fe(t,e,n){n===void 0&&(n=!1);const o=it(t),r=te(t),i=Zt(r);let s=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=ft(s)),[s,ft(s)]}function Pe(t){const e=ft(t);return[St(t),e,St(e)]}function St(t){return t.replace(/start|end/g,e=>Te[e])}const kt=["left","right"],$t=["right","left"],De=["top","bottom"],Le=["bottom","top"];function He(t,e,n){switch(t){case"top":case"bottom":return n?e?$t:kt:e?kt:$t;case"left":case"right":return e?De:Le;default:return[]}}function ke(t,e,n,o){const r=it(t);let i=He(U(t),n==="start",o);return r&&(i=i.map(s=>s+"-"+r),e&&(i=i.concat(i.map(St)))),i}function ft(t){return t.replace(/left|right|bottom|top/g,e=>Oe[e])}function $e(t){return{top:0,right:0,bottom:0,left:0,...t}}function Ie(t){return typeof t!="number"?$e(t):{top:t,right:t,bottom:t,left:t}}function at(t){const{x:e,y:n,width:o,height:r}=t;return{width:o,height:r,top:n,left:e,right:e+o,bottom:n+r,x:e,y:n}}function It(t,e,n){let{reference:o,floating:r}=t;const i=Y(e),s=te(e),l=Zt(s),c=U(e),f=i==="y",a=o.x+o.width/2-r.width/2,m=o.y+o.height/2-r.height/2,h=o[l]/2-r[l]/2;let u;switch(c){case"top":u={x:a,y:o.y-r.height};break;case"bottom":u={x:a,y:o.y+o.height};break;case"right":u={x:o.x+o.width,y:m};break;case"left":u={x:o.x-r.width,y:m};break;default:u={x:o.x,y:o.y}}switch(it(e)){case"start":u[s]-=h*(n&&f?-1:1);break;case"end":u[s]+=h*(n&&f?-1:1);break}return u}const Be=async(t,e,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:s}=n,l=i.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(e));let f=await s.getElementRects({reference:t,floating:e,strategy:r}),{x:a,y:m}=It(f,o,c),h=o,u={},d=0;for(let p=0;pM<=0)){var O,$;const M=(((O=i.flip)==null?void 0:O.index)||0)+1,z=A[M];if(z&&(!(m==="alignment"?v!==Y(z):!1)||T.every(C=>Y(C.placement)===v?C.overflows[0]>0:!0)))return{data:{index:M,overflows:T},reset:{placement:z}};let F=($=T.filter(I=>I.overflows[0]<=0).sort((I,C)=>I.overflows[1]-C.overflows[1])[0])==null?void 0:$.placement;if(!F)switch(u){case"bestFit":{var P;const I=(P=T.filter(C=>{if(S){const E=Y(C.placement);return E===v||E==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(E=>E>0).reduce((E,H)=>E+H,0)]).sort((C,E)=>C[1]-E[1])[0])==null?void 0:P[0];I&&(F=I);break}case"initialPlacement":F=l;break}if(r!==F)return{reset:{placement:F}}}return{}}}},We=new Set(["left","top"]);async function Ve(t,e){const{placement:n,platform:o,elements:r}=t,i=await(o.isRTL==null?void 0:o.isRTL(r.floating)),s=U(n),l=it(n),c=Y(n)==="y",f=We.has(s)?-1:1,a=i&&c?-1:1,m=Z(e,t);let{mainAxis:h,crossAxis:u,alignmentAxis:d}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return l&&typeof d=="number"&&(u=l==="end"?d*-1:d),c?{x:u*a,y:h*f}:{x:h*f,y:u*a}}const _e=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:r,y:i,placement:s,middlewareData:l}=e,c=await Ve(e,t);return s===((n=l.offset)==null?void 0:n.placement)&&(o=l.arrow)!=null&&o.alignmentOffset?{}:{x:r+c.x,y:i+c.y,data:{...c,placement:s}}}}},je=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:r}=e,{mainAxis:i=!0,crossAxis:s=!1,limiter:l={fn:w=>{let{x:y,y:v}=w;return{x:y,y:v}}},...c}=Z(t,e),f={x:n,y:o},a=await ht(e,c),m=Y(U(r)),h=Qt(m);let u=f[h],d=f[m];if(i){const w=h==="y"?"top":"left",y=h==="y"?"bottom":"right",v=u+a[w],x=u-a[y];u=Ht(v,u,x)}if(s){const w=m==="y"?"top":"left",y=m==="y"?"bottom":"right",v=d+a[w],x=d-a[y];d=Ht(v,d,x)}const p=l.fn({...e,[h]:u,[m]:d});return{...p,data:{x:p.x-n,y:p.y-o,enabled:{[h]:i,[m]:s}}}}}},ze=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,o;const{placement:r,rects:i,platform:s,elements:l}=e,{apply:c=()=>{},...f}=Z(t,e),a=await ht(e,f),m=U(r),h=it(r),u=Y(r)==="y",{width:d,height:p}=i.floating;let w,y;m==="top"||m==="bottom"?(w=m,y=h===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(y=m,w=h==="end"?"top":"bottom");const v=p-a.top-a.bottom,x=d-a.left-a.right,b=X(p-a[w],v),R=X(d-a[y],x),S=!e.middlewareData.shift;let A=b,L=R;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(L=x),(o=e.middlewareData.shift)!=null&&o.enabled.y&&(A=v),S&&!h){const T=D(a.left,0),O=D(a.right,0),$=D(a.top,0),P=D(a.bottom,0);u?L=d-2*(T!==0||O!==0?T+O:D(a.left,a.right)):A=p-2*($!==0||P!==0?$+P:D(a.top,a.bottom))}await c({...e,availableWidth:L,availableHeight:A});const N=await s.getDimensions(l.floating);return d!==N.width||p!==N.height?{reset:{rects:!0}}:{}}}};function ee(t){const e=W(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=_(t),i=r?t.offsetWidth:n,s=r?t.offsetHeight:o,l=nt(n)!==i||nt(o)!==s;return l&&(n=i,o=s),{width:n,height:o,$:l}}function Tt(t){return k(t)?t:t.contextElement}function G(t){const e=Tt(t);if(!_(e))return V(1);const n=e.getBoundingClientRect(),{width:o,height:r,$:i}=ee(e);let s=(i?nt(n.width):n.width)/o,l=(i?nt(n.height):n.height)/r;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const Ye=V(0);function ne(t){const e=B(t);return!Ot()||!e.visualViewport?Ye:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function qe(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==B(t)?!1:e}function K(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),i=Tt(t);let s=V(1);e&&(o?k(o)&&(s=G(o)):s=G(t));const l=qe(i,n,o)?ne(i):V(0);let c=(r.left+l.x)/s.x,f=(r.top+l.y)/s.y,a=r.width/s.x,m=r.height/s.y;if(i){const h=B(i),u=o&&k(o)?B(o):o;let d=h,p=Ct(d);for(;p&&o&&u!==d;){const w=G(p),y=p.getBoundingClientRect(),v=W(p),x=y.left+(p.clientLeft+parseFloat(v.paddingLeft))*w.x,b=y.top+(p.clientTop+parseFloat(v.paddingTop))*w.y;c*=w.x,f*=w.y,a*=w.x,m*=w.y,c+=x,f+=b,d=B(p),p=Ct(d)}}return at({width:a,height:m,x:c,y:f})}function pt(t,e){const n=gt(t).scrollLeft;return e?e.left+n:K(j(t)).left+n}function oe(t,e){const n=t.getBoundingClientRect(),o=n.left+e.scrollLeft-pt(t,n),r=n.top+e.scrollTop;return{x:o,y:r}}function Ue(t){let{elements:e,rect:n,offsetParent:o,strategy:r}=t;const i=r==="fixed",s=j(o),l=e?mt(e.floating):!1;if(o===s||l&&i)return n;let c={scrollLeft:0,scrollTop:0},f=V(1);const a=V(0),m=_(o);if((m||!m&&!i)&&((Q(o)!=="body"||rt(s))&&(c=gt(o)),_(o))){const u=K(o);f=G(o),a.x=u.x+o.clientLeft,a.y=u.y+o.clientTop}const h=s&&!m&&!i?oe(s,c):V(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-c.scrollLeft*f.x+a.x+h.x,y:n.y*f.y-c.scrollTop*f.y+a.y+h.y}}function Xe(t){return Array.from(t.getClientRects())}function Ke(t){const e=j(t),n=gt(t),o=t.ownerDocument.body,r=D(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),i=D(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let s=-n.scrollLeft+pt(t);const l=-n.scrollTop;return W(o).direction==="rtl"&&(s+=D(e.clientWidth,o.clientWidth)-r),{width:r,height:i,x:s,y:l}}const Bt=25;function Ge(t,e){const n=B(t),o=j(t),r=n.visualViewport;let i=o.clientWidth,s=o.clientHeight,l=0,c=0;if(r){i=r.width,s=r.height;const a=Ot();(!a||a&&e==="fixed")&&(l=r.offsetLeft,c=r.offsetTop)}const f=pt(o);if(f<=0){const a=o.ownerDocument,m=a.body,h=getComputedStyle(m),u=a.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,d=Math.abs(o.clientWidth-m.clientWidth-u);d<=Bt&&(i-=d)}else f<=Bt&&(i+=f);return{width:i,height:s,x:l,y:c}}const Je=new Set(["absolute","fixed"]);function Qe(t,e){const n=K(t,!0,e==="fixed"),o=n.top+t.clientTop,r=n.left+t.clientLeft,i=_(t)?G(t):V(1),s=t.clientWidth*i.x,l=t.clientHeight*i.y,c=r*i.x,f=o*i.y;return{width:s,height:l,x:c,y:f}}function Nt(t,e,n){let o;if(e==="viewport")o=Ge(t,n);else if(e==="document")o=Ke(j(t));else if(k(e))o=Qe(e,n);else{const r=ne(t);o={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return at(o)}function re(t,e){const n=q(t);return n===e||!k(n)||J(n)?!1:W(n).position==="fixed"||re(n,e)}function Ze(t,e){const n=e.get(t);if(n)return n;let o=et(t,[],!1).filter(l=>k(l)&&Q(l)!=="body"),r=null;const i=W(t).position==="fixed";let s=i?q(t):t;for(;k(s)&&!J(s);){const l=W(s),c=Et(s);!c&&l.position==="fixed"&&(r=null),(i?!c&&!r:!c&&l.position==="static"&&!!r&&Je.has(r.position)||rt(s)&&!c&&re(t,s))?o=o.filter(a=>a!==s):r=l,s=q(s)}return e.set(t,o),o}function tn(t){let{element:e,boundary:n,rootBoundary:o,strategy:r}=t;const s=[...n==="clippingAncestors"?mt(e)?[]:Ze(e,this._c):[].concat(n),o],l=s[0],c=s.reduce((f,a)=>{const m=Nt(e,a,r);return f.top=D(m.top,f.top),f.right=X(m.right,f.right),f.bottom=X(m.bottom,f.bottom),f.left=D(m.left,f.left),f},Nt(e,l,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function en(t){const{width:e,height:n}=ee(t);return{width:e,height:n}}function nn(t,e,n){const o=_(e),r=j(e),i=n==="fixed",s=K(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const c=V(0);function f(){c.x=pt(r)}if(o||!o&&!i)if((Q(e)!=="body"||rt(r))&&(l=gt(e)),o){const u=K(e,!0,i,e);c.x=u.x+e.clientLeft,c.y=u.y+e.clientTop}else r&&f();i&&!o&&r&&f();const a=r&&!o&&!i?oe(r,l):V(0),m=s.left+l.scrollLeft-c.x-a.x,h=s.top+l.scrollTop-c.y-a.y;return{x:m,y:h,width:s.width,height:s.height}}function xt(t){return W(t).position==="static"}function Wt(t,e){if(!_(t)||W(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return j(t)===n&&(n=n.ownerDocument.body),n}function ie(t,e){const n=B(t);if(mt(t))return n;if(!_(t)){let r=q(t);for(;r&&!J(r);){if(k(r)&&!xt(r))return r;r=q(r)}return n}let o=Wt(t,e);for(;o&&ye(o)&&xt(o);)o=Wt(o,e);return o&&J(o)&&xt(o)&&!Et(o)?n:o||Se(t)||n}const on=async function(t){const e=this.getOffsetParent||ie,n=this.getDimensions,o=await n(t.floating);return{reference:nn(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function rn(t){return W(t).direction==="rtl"}const sn={convertOffsetParentRelativeRectToViewportRelativeRect:Ue,getDocumentElement:j,getClippingRect:tn,getOffsetParent:ie,getElementRects:on,getClientRects:Xe,getDimensions:en,getScale:G,isElement:k,isRTL:rn};function se(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function ln(t,e){let n=null,o;const r=j(t);function i(){var l;clearTimeout(o),(l=n)==null||l.disconnect(),n=null}function s(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),i();const f=t.getBoundingClientRect(),{left:a,top:m,width:h,height:u}=f;if(l||e(),!h||!u)return;const d=st(m),p=st(r.clientWidth-(a+h)),w=st(r.clientHeight-(m+u)),y=st(a),x={rootMargin:-d+"px "+-p+"px "+-w+"px "+-y+"px",threshold:D(0,X(1,c))||1};let b=!0;function R(S){const A=S[0].intersectionRatio;if(A!==c){if(!b)return s();A?s(!1,A):o=setTimeout(()=>{s(!1,1e-7)},1e3)}A===1&&!se(f,t.getBoundingClientRect())&&s(),b=!1}try{n=new IntersectionObserver(R,{...x,root:r.ownerDocument})}catch{n=new IntersectionObserver(R,x)}n.observe(t)}return s(!0),i}function cn(t,e,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,f=Tt(t),a=r||i?[...f?et(f):[],...et(e)]:[];a.forEach(y=>{r&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const m=f&&l?ln(f,n):null;let h=-1,u=null;s&&(u=new ResizeObserver(y=>{let[v]=y;v&&v.target===f&&u&&(u.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=u)==null||x.observe(e)})),n()}),f&&!c&&u.observe(f),u.observe(e));let d,p=c?K(t):null;c&&w();function w(){const y=K(t);p&&!se(p,y)&&n(),p=y,d=requestAnimationFrame(w)}return n(),()=>{var y;a.forEach(v=>{r&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),m==null||m(),(y=u)==null||y.disconnect(),u=null,c&&cancelAnimationFrame(d)}}const yt=ht,fn=_e,an=je,un=Ne,dn=ze,mn=(t,e,n)=>{const o=new Map,r={platform:sn,...n},i={...r.platform,_c:o};return Be(t,e,{...r,platform:i})};var gn=typeof document<"u",hn=function(){},lt=gn?g.useLayoutEffect:hn;function ut(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,o,r;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(o=n;o--!==0;)if(!ut(t[o],e[o]))return!1;return!0}if(r=Object.keys(t),n=r.length,n!==Object.keys(e).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(e,r[o]))return!1;for(o=n;o--!==0;){const i=r[o];if(!(i==="_owner"&&t.$$typeof)&&!ut(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function le(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Vt(t,e){const n=le(t);return Math.round(e*n)/n}function vt(t){const e=g.useRef(t);return lt(()=>{e.current=t}),e}function pn(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:o=[],platform:r,elements:{reference:i,floating:s}={},transform:l=!0,whileElementsMounted:c,open:f}=t,[a,m]=g.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,u]=g.useState(o);ut(h,o)||u(o);const[d,p]=g.useState(null),[w,y]=g.useState(null),v=g.useCallback(C=>{C!==S.current&&(S.current=C,p(C))},[]),x=g.useCallback(C=>{C!==A.current&&(A.current=C,y(C))},[]),b=i||d,R=s||w,S=g.useRef(null),A=g.useRef(null),L=g.useRef(a),N=c!=null,T=vt(c),O=vt(r),$=vt(f),P=g.useCallback(()=>{if(!S.current||!A.current)return;const C={placement:e,strategy:n,middleware:h};O.current&&(C.platform=O.current),mn(S.current,A.current,C).then(E=>{const H={...E,isPositioned:$.current!==!1};M.current&&!ut(L.current,H)&&(L.current=H,ct.flushSync(()=>{m(H)}))})},[h,e,n,O,$]);lt(()=>{f===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,m(C=>({...C,isPositioned:!1})))},[f]);const M=g.useRef(!1);lt(()=>(M.current=!0,()=>{M.current=!1}),[]),lt(()=>{if(b&&(S.current=b),R&&(A.current=R),b&&R){if(T.current)return T.current(b,R,P);P()}},[b,R,P,T,N]);const z=g.useMemo(()=>({reference:S,floating:A,setReference:v,setFloating:x}),[v,x]),F=g.useMemo(()=>({reference:b,floating:R}),[b,R]),I=g.useMemo(()=>{const C={position:n,left:0,top:0};if(!F.floating)return C;const E=Vt(F.floating,a.x),H=Vt(F.floating,a.y);return l?{...C,transform:"translate("+E+"px, "+H+"px)",...le(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:E,top:H}},[n,l,F.floating,a.x,a.y]);return g.useMemo(()=>({...a,update:P,refs:z,elements:F,floatingStyles:I}),[a,P,z,F,I])}const ce=(t,e)=>({...fn(t),options:[t,e]}),wn=(t,e)=>({...an(t),options:[t,e]}),xn=(t,e)=>({...un(t),options:[t,e]}),yn=(t,e)=>({...dn(t),options:[t,e]}),fe={...me},vn=fe.useInsertionEffect,bn=vn||(t=>t());function ae(t){const e=g.useRef(()=>{});return bn(()=>{e.current=t}),g.useCallback(function(){for(var n=arguments.length,o=new Array(n),r=0;r"floating-ui-"+Math.random().toString(36).slice(2,6)+Rn++;function Cn(){const[t,e]=g.useState(()=>_t?jt():void 0);return At(()=>{t==null&&e(jt())},[]),g.useEffect(()=>{_t=!0},[]),t}const Sn=fe.useId,An=Sn||Cn;function En(){const t=new Map;return{emit(e,n){var o;(o=t.get(e))==null||o.forEach(r=>r(n))},on(e,n){t.set(e,[...t.get(e)||[],n])},off(e,n){var o;t.set(e,((o=t.get(e))==null?void 0:o.filter(r=>r!==n))||[])}}}const On=g.createContext(null),Tn=g.createContext(null),Mn=()=>{var t;return((t=g.useContext(On))==null?void 0:t.id)||null},Fn=()=>g.useContext(Tn),Pn="data-floating-ui-focusable";function Dn(t){const{open:e=!1,onOpenChange:n,elements:o}=t,r=An(),i=g.useRef({}),[s]=g.useState(()=>En()),l=Mn()!=null,[c,f]=g.useState(o.reference),a=ae((u,d,p)=>{i.current.openEvent=u?d:void 0,s.emit("openchange",{open:u,event:d,reason:p,nested:l}),n==null||n(u,d,p)}),m=g.useMemo(()=>({setPositionReference:f}),[]),h=g.useMemo(()=>({reference:c||o.reference||null,floating:o.floating||null,domReference:o.reference}),[c,o.reference,o.floating]);return g.useMemo(()=>({dataRef:i,open:e,onOpenChange:a,elements:h,events:s,floatingId:r,refs:m}),[e,a,h,s,r,m])}function Ln(t){t===void 0&&(t={});const{nodeId:e}=t,n=Dn({...t,elements:{reference:null,floating:null,...t.elements}}),o=t.rootContext||n,r=o.elements,[i,s]=g.useState(null),[l,c]=g.useState(null),a=(r==null?void 0:r.domReference)||i,m=g.useRef(null),h=Fn();At(()=>{a&&(m.current=a)},[a]);const u=pn({...t,elements:{...r,...l&&{reference:l}}}),d=g.useCallback(x=>{const b=k(x)?{getBoundingClientRect:()=>x.getBoundingClientRect(),contextElement:x}:x;c(b),u.refs.setReference(b)},[u.refs]),p=g.useCallback(x=>{(k(x)||x===null)&&(m.current=x,s(x)),(k(u.refs.reference.current)||u.refs.reference.current===null||x!==null&&!k(x))&&u.refs.setReference(x)},[u.refs]),w=g.useMemo(()=>({...u.refs,setReference:p,setPositionReference:d,domReference:m}),[u.refs,p,d]),y=g.useMemo(()=>({...u.elements,domReference:a}),[u.elements,a]),v=g.useMemo(()=>({...u,...o,refs:w,elements:y,nodeId:e}),[u,w,y,e,o]);return At(()=>{o.dataRef.current.floatingContext=v;const x=h==null?void 0:h.nodesRef.current.find(b=>b.id===e);x&&(x.context=v)}),g.useMemo(()=>({...u,context:v,refs:w,elements:y}),[u,w,y,v])}const zt="active",Yt="selected";function bt(t,e,n){const o=new Map,r=n==="item";let i=t;if(r&&t){const{[zt]:s,[Yt]:l,...c}=t;i=c}return{...n==="floating"&&{tabIndex:-1,[Pn]:""},...i,...e.map(s=>{const l=s?s[n]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((s,l)=>(l&&Object.entries(l).forEach(c=>{let[f,a]=c;if(!(r&&[zt,Yt].includes(f)))if(f.indexOf("on")===0){if(o.has(f)||o.set(f,[]),typeof a=="function"){var m;(m=o.get(f))==null||m.push(a),s[f]=function(){for(var h,u=arguments.length,d=new Array(u),p=0;pw(...d)).find(w=>w!==void 0)}}}else s[f]=a}),s),{})}}function Hn(t){t===void 0&&(t=[]);const e=t.map(l=>l==null?void 0:l.reference),n=t.map(l=>l==null?void 0:l.floating),o=t.map(l=>l==null?void 0:l.item),r=g.useCallback(l=>bt(l,t,"reference"),e),i=g.useCallback(l=>bt(l,t,"floating"),n),s=g.useCallback(l=>bt(l,t,"item"),o);return g.useMemo(()=>({getReferenceProps:r,getFloatingProps:i,getItemProps:s}),[r,i,s])}function qt(t,e){return{...t,rects:{...t.rects,floating:{...t.rects.floating,height:e}}}}const kn=t=>({name:"inner",options:t,async fn(e){const{listRef:n,overflowRef:o,onFallbackChange:r,offset:i=0,index:s=0,minItemsVisible:l=4,referenceOverflowThreshold:c=0,scrollRef:f,...a}=Z(t,e),{rects:m,elements:{floating:h}}=e,u=n.current[s],d=(f==null?void 0:f.current)||h,p=h.clientTop||d.clientTop,w=h.clientTop!==0,y=d.clientTop!==0,v=h===d;if(!u)return{};const x={...e,...await ce(-u.offsetTop-h.clientTop-m.reference.height/2-u.offsetHeight/2-i).fn(e)},b=await yt(qt(x,d.scrollHeight+p+h.clientTop),a),R=await yt(x,{...a,elementContext:"reference"}),S=D(0,b.top),A=x.y+S,T=(d.scrollHeight>d.clientHeight?O=>O:nt)(D(0,d.scrollHeight+(w&&v||y?p*2:0)-S-D(0,b.bottom)));if(d.style.maxHeight=T+"px",d.scrollTop=S,r){const O=d.offsetHeight=-c||R.bottom>=-c;ct.flushSync(()=>r(O))}return o&&(o.current=await yt(qt({...x,y:A},d.offsetHeight+p+h.clientTop),a)),{y:A}}});function $n(t,e){const{open:n,elements:o}=t,{enabled:r=!0,overflowRef:i,scrollRef:s,onChange:l}=e,c=ae(l),f=g.useRef(!1),a=g.useRef(null),m=g.useRef(null);g.useEffect(()=>{if(!r)return;function u(p){if(p.ctrlKey||!d||i.current==null)return;const w=p.deltaY,y=i.current.top>=-.5,v=i.current.bottom>=-.5,x=d.scrollHeight-d.clientHeight,b=w<0?-1:1,R=w<0?"max":"min";d.scrollHeight<=d.clientHeight||(!y&&w>0||!v&&w<0?(p.preventDefault(),ct.flushSync(()=>{c(S=>S+Math[R](w,x*b))})):/firefox/i.test(Ee())&&(d.scrollTop+=w))}const d=(s==null?void 0:s.current)||o.floating;if(n&&d)return d.addEventListener("wheel",u),requestAnimationFrame(()=>{a.current=d.scrollTop,i.current!=null&&(m.current={...i.current})}),()=>{a.current=null,m.current=null,d.removeEventListener("wheel",u)}},[r,n,o.floating,i,s,c]);const h=g.useMemo(()=>({onKeyDown(){f.current=!0},onWheel(){f.current=!1},onPointerMove(){f.current=!1},onScroll(){const u=(s==null?void 0:s.current)||o.floating;if(!(!i.current||!u||!f.current)){if(a.current!==null){const d=u.scrollTop-a.current;(i.current.bottom<-.5&&d<-1||i.current.top<-.5&&d>1)&&ct.flushSync(()=>c(p=>p+d))}requestAnimationFrame(()=>{a.current=u.scrollTop})}}}),[o.floating,c,i,s]);return g.useMemo(()=>r?{floating:h}:{},[r,h])}let tt=g.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});tt.displayName="FloatingContext";let Mt=g.createContext(null);Mt.displayName="PlacementContext";function _n(t){return g.useMemo(()=>t?typeof t=="string"?{to:t}:t:null,[t])}function jn(){return g.useContext(tt).setReference}function zn(){return g.useContext(tt).getReferenceProps}function Yn(){let{getFloatingProps:t,slot:e}=g.useContext(tt);return g.useCallback((...n)=>Object.assign({},t(...n),{"data-anchor":e.anchor}),[t,e])}function qn(t=null){t===!1&&(t=null),typeof t=="string"&&(t={to:t});let e=g.useContext(Mt),n=g.useMemo(()=>t,[JSON.stringify(t,(r,i)=>{var s;return(s=i==null?void 0:i.outerHTML)!=null?s:i})]);ot(()=>{e==null||e(n??null)},[e,n]);let o=g.useContext(tt);return g.useMemo(()=>[o.setFloating,t?o.styles:{}],[o.setFloating,t,o.styles])}let Ut=4;function Un({children:t,enabled:e=!0}){let[n,o]=g.useState(null),[r,i]=g.useState(0),s=g.useRef(null),[l,c]=g.useState(null);In(l);let f=e&&n!==null&&l!==null,{to:a="bottom",gap:m=0,offset:h=0,padding:u=0,inner:d}=Bn(n,l),[p,w="center"]=a.split(" ");ot(()=>{f&&i(0)},[f]);let{refs:y,floatingStyles:v,context:x}=Ln({open:f,placement:p==="selection"?w==="center"?"bottom":`bottom-${w}`:w==="center"?`${p}`:`${p}-${w}`,strategy:"absolute",transform:!1,middleware:[ce({mainAxis:p==="selection"?0:m,crossAxis:h}),wn({padding:u}),p!=="selection"&&xn({padding:u}),p==="selection"&&d?kn({...d,padding:u,overflowRef:s,offset:r,minItemsVisible:Ut,referenceOverflowThreshold:u,onFallbackChange(O){var $,P;if(!O)return;let M=x.elements.floating;if(!M)return;let z=parseFloat(getComputedStyle(M).scrollPaddingBottom)||0,F=Math.min(Ut,M.childElementCount),I=0,C=0;for(let E of(P=($=x.elements.floating)==null?void 0:$.childNodes)!=null?P:[])if(ge(E)){let H=E.offsetTop,Ft=H+E.clientHeight+z,wt=M.scrollTop,Pt=wt+M.clientHeight;if(H>=wt&&Ft<=Pt)F--;else{C=Math.max(0,Math.min(Ft,Pt)-Math.max(H,wt)),I=E.clientHeight;break}}F>=1&&i(E=>{let H=I*F-C+z;return E>=H?E:H})}}):null,yn({padding:u,apply({availableWidth:O,availableHeight:$,elements:P}){Object.assign(P.floating.style,{overflow:"auto",maxWidth:`${O}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${$}px)`})}})].filter(Boolean),whileElementsMounted:cn}),[b=p,R=w]=x.placement.split("-");p==="selection"&&(b="selection");let S=g.useMemo(()=>({anchor:[b,R].filter(Boolean).join(" ")}),[b,R]),A=$n(x,{overflowRef:s,onChange:i}),{getReferenceProps:L,getFloatingProps:N}=Hn([A]),T=Kt(O=>{c(O),y.setFloating(O)});return g.createElement(Mt.Provider,{value:o},g.createElement(tt.Provider,{value:{setFloating:T,setReference:y.setReference,styles:v,getReferenceProps:L,getFloatingProps:N,slot:S}},t))}function In(t){ot(()=>{if(!t)return;let e=new MutationObserver(()=>{let n=window.getComputedStyle(t).maxHeight,o=parseFloat(n);if(isNaN(o))return;let r=parseInt(n);isNaN(r)||o!==r&&(t.style.maxHeight=`${Math.ceil(o)}px`)});return e.observe(t,{attributes:!0,attributeFilter:["style"]}),()=>{e.disconnect()}},[t])}function Bn(t,e){var n,o,r;let i=Rt((n=t==null?void 0:t.gap)!=null?n:"var(--anchor-gap, 0)",e),s=Rt((o=t==null?void 0:t.offset)!=null?o:"var(--anchor-offset, 0)",e),l=Rt((r=t==null?void 0:t.padding)!=null?r:"var(--anchor-padding, 0)",e);return{...t,gap:i,offset:s,padding:l}}function Rt(t,e,n=void 0){let o=he(),r=Kt((c,f)=>{if(c==null)return[n,null];if(typeof c=="number")return[c,null];if(typeof c=="string"){if(!f)return[n,null];let a=Xt(c,f);return[a,m=>{let h=ue(c);{let u=h.map(d=>window.getComputedStyle(f).getPropertyValue(d));o.requestAnimationFrame(function d(){o.nextFrame(d);let p=!1;for(let[y,v]of h.entries()){let x=window.getComputedStyle(f).getPropertyValue(v);if(u[y]!==x){u[y]=x,p=!0;break}}if(!p)return;let w=Xt(c,f);a!==w&&(m(w),a=w)})}return o.dispose}]}return[n,null]}),i=g.useMemo(()=>r(t,e)[0],[t,e]),[s=i,l]=g.useState();return ot(()=>{let[c,f]=r(t,e);if(l(c),!!f)return f(l)},[t,e]),s}function ue(t){let e=/var\((.*)\)/.exec(t);if(e){let n=e[1].indexOf(",");if(n===-1)return[e[1]];let o=e[1].slice(0,n).trim(),r=e[1].slice(n+1).trim();return r?[o,...ue(r)]:[o]}return[]}function Xt(t,e){let n=document.createElement("div");e.appendChild(n),n.style.setProperty("margin-top","0px","important"),n.style.setProperty("margin-top",t,"important");let o=parseFloat(window.getComputedStyle(n).marginTop)||0;return e.removeChild(n),o}/** * @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 Nn=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Un=pe("map-pin",Nn);export{Xn as A,zn as F,Un as M,qn as R,Yn as T,jn as b,Vn as w,_n as y}; + */const Nn=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Xn=pe("map-pin",Nn);export{Un as A,jn as F,Xn as M,qn as R,Yn as T,zn as b,Vn as w,_n as y}; diff --git a/frontend/dist/assets/map-pin-off-D8fZRJ6M.js b/frontend/dist/assets/map-pin-off-V0MBukP5.js similarity index 93% rename from frontend/dist/assets/map-pin-off-D8fZRJ6M.js rename to frontend/dist/assets/map-pin-off-V0MBukP5.js index 4201afd5..2fd96293 100644 --- a/frontend/dist/assets/map-pin-off-D8fZRJ6M.js +++ b/frontend/dist/assets/map-pin-off-V0MBukP5.js @@ -1,4 +1,4 @@ -import{e as a}from"./index-C2xvS0Jd.js";/** +import{e as a}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/maplibre-gl-C9QYi5T6.js b/frontend/dist/assets/maplibre-gl-B42P8ehE.js similarity index 98% rename from frontend/dist/assets/maplibre-gl-C9QYi5T6.js rename to frontend/dist/assets/maplibre-gl-B42P8ehE.js index 74380a59..15949604 100644 --- a/frontend/dist/assets/maplibre-gl-C9QYi5T6.js +++ b/frontend/dist/assets/maplibre-gl-B42P8ehE.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C2xvS0Jd.js","assets/index-7uzBcJ1E.css"])))=>i.map(i=>d[i]); -import{r as a,_ as W,b9 as N}from"./index-C2xvS0Jd.js";const F=a.createContext(null);function he(){var i;const e=(i=a.useContext(F))==null?void 0:i.maps,t=a.useContext(S);return a.useMemo(()=>({...e,current:t==null?void 0:t.map}),[e,t])}function Z(e,t){const n=Array.isArray(e)?e[0]:e?e.x:0,i=Array.isArray(e)?e[1]:e?e.y:0,o=Array.isArray(t)?t[0]:t?t.x:0,r=Array.isArray(t)?t[1]:t?t.y:0;return n===o&&i===r}function m(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n{let o=null;"interactive"in i&&(o=Object.assign({},i),delete o.interactive);const r=t[i.ref];if(r){o=o||Object.assign({},i),delete o.ref;for(const s of V)s in r&&(o[s]=r[s])}return o||i});return{...e,layers:n}}const z={version:8,sources:{},layers:[]},I={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",click:"onClick",dblclick:"onDblClick",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseout:"onMouseOut",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchmove:"onTouchMove",touchcancel:"onTouchCancel"},O={movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd"},U={wheel:"onWheel",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",resize:"onResize",load:"onLoad",render:"onRender",idle:"onIdle",remove:"onRemove",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",error:"onError"},q=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],B=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class M{constructor(t,n,i){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=o=>{const r=this.props[U[o.type]];r?r(o):o.type==="error"&&console.error(o.error)},this._onCameraEvent=o=>{if(this._internalUpdate)return;o.viewState=this._propsedCameraUpdate||P(this._map.transform);const r=this.props[O[o.type]];r&&r(o)},this._onCameraUpdate=o=>this._internalUpdate?o:(this._propsedCameraUpdate=P(o),k(o,this.props)),this._onPointerEvent=o=>{(o.type==="mousemove"||o.type==="mouseout")&&this._updateHover(o);const r=this.props[I[o.type]];r&&(this.props.interactiveLayerIds&&o.type!=="mouseover"&&o.type!=="mouseout"&&(o.features=this._hoveredFeatures||this._queryRenderedFeatures(o.point)),r(o),delete o.features)},this._MapClass=t,this.props=n,this._initialize(i)}get map(){return this._map}setProps(t){const n=this.props;this.props=t;const i=this._updateSettings(t,n),o=this._updateSize(t),r=this._updateViewState(t);this._updateStyle(t,n),this._updateStyleComponents(t),this._updateHandlers(t,n),(i||o||r&&!this._map.isMoving())&&this.redraw()}static reuse(t,n){const i=M.savedMaps.pop();if(!i)return null;const o=i.map,r=o.getContainer();for(n.className=r.className;r.childNodes.length>0;)n.appendChild(r.childNodes[0]);o._container=n;const s=o._resizeObserver;s&&(s.disconnect(),s.observe(n)),i.setProps({...t,styleDiffing:!1}),o.resize();const{initialViewState:c}=t;return c&&(c.bounds?o.fitBounds(c.bounds,{...c.fitBoundsOptions,duration:0}):i._updateViewState(c)),o.isStyleLoaded()?o.fire("load"):o.once("style.load",()=>o.fire("load")),o._update(),i}_initialize(t){const{props:n}=this,{mapStyle:i=z}=n,o={...n,...n.initialViewState,container:t,style:T(i)},r=o.initialViewState||o.viewState||o;if(Object.assign(o,{center:[r.longitude||0,r.latitude||0],zoom:r.zoom||0,pitch:r.pitch||0,bearing:r.bearing||0}),n.gl){const c=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=c,n.gl)}const s=new this._MapClass(o);r.padding&&s.setPadding(r.padding),n.cursor&&(s.getCanvas().style.cursor=n.cursor),s.transformCameraUpdate=this._onCameraUpdate,s.on("style.load",()=>{var c;this._styleComponents={light:s.getLight(),sky:s.getSky(),projection:(c=s.getProjection)==null?void 0:c.call(s),terrain:s.getTerrain()},this._updateStyleComponents(this.props)}),s.on("sourcedata",()=>{this._updateStyleComponents(this.props)});for(const c in I)s.on(c,this._onPointerEvent);for(const c in O)s.on(c,this._onCameraEvent);for(const c in U)s.on(c,this._onEvent);this._map=s}recycle(){const n=this.map.getContainer().querySelector("[mapboxgl-children]");n==null||n.remove(),M.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const t=this._map;t.style&&(t._frame&&(t._frame.cancel(),t._frame=null),t._render())}_updateSize(t){const{viewState:n}=t;if(n){const i=this._map;if(n.width!==i.transform.width||n.height!==i.transform.height)return i.resize(),!0}return!1}_updateViewState(t){const n=this._map,i=n.transform;if(!n.isMoving()){const r=k(i,t);if(Object.keys(r).length>0)return this._internalUpdate=!0,n.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(t,n){const i=this._map;let o=!1;for(const r of q)if(r in t&&!m(t[r],n[r])){o=!0;const s=i[`set${r[0].toUpperCase()}${r.slice(1)}`];s==null||s.call(i,t[r])}return o}_updateStyle(t,n){if(t.cursor!==n.cursor&&(this._map.getCanvas().style.cursor=t.cursor||""),t.mapStyle!==n.mapStyle){const{mapStyle:i=z,styleDiffing:o=!0}=t,r={diff:o};"localIdeographFontFamily"in t&&(r.localIdeographFontFamily=t.localIdeographFontFamily),this._map.setStyle(T(i),r)}}_updateStyleComponents({light:t,projection:n,sky:i,terrain:o}){var c,l;const r=this._map,s=this._styleComponents;r.style._loaded&&(t&&!m(t,s.light)&&(s.light=t,r.setLight(t)),n&&!m(n,s.projection)&&n!==((c=s.projection)==null?void 0:c.type)&&(s.projection=typeof n=="string"?{type:n}:n,(l=r.setProjection)==null||l.call(r,s.projection)),i&&!m(i,s.sky)&&(s.sky=i,r.setSky(i)),o!==void 0&&!m(o,s.terrain)&&(!o||r.getSource(o.source))&&(s.terrain=o,r.setTerrain(o)))}_updateHandlers(t,n){const i=this._map;for(const o of B){const r=t[o]??!0,s=n[o]??!0;m(r,s)||(r?i[o].enable(r):i[o].disable())}}_queryRenderedFeatures(t){const n=this._map,{interactiveLayerIds:i=[]}=this.props;try{return n.queryRenderedFeatures(t,{layers:i.filter(n.getLayer.bind(n))})}catch{return[]}}_updateHover(t){var o;const{props:n}=this;if(n.interactiveLayerIds&&(n.onMouseMove||n.onMouseEnter||n.onMouseLeave)){const r=t.type,s=((o=this._hoveredFeatures)==null?void 0:o.length)>0,c=this._queryRenderedFeatures(t.point),l=c.length>0;!l&&s&&(t.type="mouseleave",this._onPointerEvent(t)),this._hoveredFeatures=c,l&&!s&&(t.type="mouseenter",this._onPointerEvent(t)),t.type=r}else this._hoveredFeatures=null}}M.savedMaps=[];const $=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function G(e){if(!e)return null;const t=e.map,n={getMap:()=>t};for(const i of K(t))!(i in n)&&!$.includes(i)&&(n[i]=t[i].bind(t));return n}function K(e){const t=new Set;let n=e;for(;n;){for(const i of Object.getOwnPropertyNames(n))i[0]!=="_"&&typeof e[i]=="function"&&i!=="fire"&&i!=="setEventedParent"&&t.add(i);n=Object.getPrototypeOf(n)}return Array.from(t)}const J=typeof document<"u"?a.useLayoutEffect:a.useEffect;function Y(e,t){const{RTLTextPlugin:n,maxParallelImageRequests:i,workerCount:o,workerUrl:r}=t;if(n&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()==="unavailable"){const{pluginUrl:s,lazy:c=!0}=typeof n=="string"?{pluginUrl:n}:n;e.setRTLTextPlugin(s,l=>{l&&console.error(l)},c)}i!==void 0&&e.setMaxParallelImageRequests(i),o!==void 0&&e.setWorkerCount(o),r!==void 0&&e.setWorkerUrl(r)}const S=a.createContext(null);function Q(e,t){const n=a.useContext(F),[i,o]=a.useState(null),r=a.useRef(),{current:s}=a.useRef({mapLib:null,map:null});a.useEffect(()=>{const u=e.mapLib;let d=!0,f;return Promise.resolve(u||W(()=>import("./maplibre-gl-CfJOR1BZ.js").then(h=>h.m),__vite__mapDeps([0,1]))).then(h=>{if(!d)return;if(!h)throw new Error("Invalid mapLib");const p="Map"in h?h:h.default;if(!p.Map)throw new Error("Invalid mapLib");Y(p,e),e.reuseMaps&&(f=M.reuse(e,r.current)),f||(f=new M(p.Map,e,r.current)),s.map=G(f),s.mapLib=p,o(f),n==null||n.onMapMount(s.map,e.id)}).catch(h=>{const{onError:p}=e;p?p({type:"error",target:null,originalEvent:null,error:h}):console.error(h)}),()=>{d=!1,f&&(n==null||n.onMapUnmount(e.id),e.reuseMaps?f.recycle():f.destroy())}},[]),J(()=>{i&&i.setProps(e)}),a.useImperativeHandle(t,()=>s.map,[i]);const c=a.useMemo(()=>({position:"relative",width:"100%",height:"100%",...e.style}),[e.style]),l={height:"100%"};return a.createElement("div",{id:e.id,ref:r,style:c},i&&a.createElement(S.Provider,{value:s},a.createElement("div",{"mapboxgl-children":"",style:l},e.children)))}const ge=a.forwardRef(Q),X=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function _(e,t){if(!e||!t)return;const n=e.style;for(const i in t){const o=t[i];Number.isFinite(o)&&!X.test(i)?n[i]=`${o}px`:n[i]=o}}function D(e,t){if(e===t)return null;const n=A(e),i=A(t),o=[];for(const r of i)n.has(r)||o.push(r);for(const r of n)i.has(r)||o.push(r);return o.length===0?null:o}function A(e){return new Set(e?e.trim().split(/\s+/):[])}const ye=a.memo(a.forwardRef((e,t)=>{const{map:n,mapLib:i}=a.useContext(S),o=a.useRef({props:e}),r=a.useMemo(()=>{let x=!1;a.Children.forEach(e.children,v=>{v&&(x=!0)});const H={...e,element:x?document.createElement("div"):void 0},L=new i.Marker(H);return L.setLngLat([e.longitude,e.latitude]),L.getElement().addEventListener("click",v=>{var g,y;(y=(g=o.current.props).onClick)==null||y.call(g,{type:"click",target:L,originalEvent:v})}),L.on("dragstart",v=>{var y,C;const g=v;g.lngLat=r.getLngLat(),(C=(y=o.current.props).onDragStart)==null||C.call(y,g)}),L.on("drag",v=>{var y,C;const g=v;g.lngLat=r.getLngLat(),(C=(y=o.current.props).onDrag)==null||C.call(y,g)}),L.on("dragend",v=>{var y,C;const g=v;g.lngLat=r.getLngLat(),(C=(y=o.current.props).onDragEnd)==null||C.call(y,g)}),L},[]);a.useEffect(()=>(r.addTo(n.getMap()),()=>{r.remove()}),[]);const{longitude:s,latitude:c,offset:l,style:u,draggable:d=!1,popup:f=null,rotation:h=0,rotationAlignment:p="auto",pitchAlignment:b="auto"}=e;a.useEffect(()=>{_(r.getElement(),u)},[u]),a.useImperativeHandle(t,()=>r,[]);const j=o.current.props;(r.getLngLat().lng!==s||r.getLngLat().lat!==c)&&r.setLngLat([s,c]),l&&!Z(r.getOffset(),l)&&r.setOffset(l),r.isDraggable()!==d&&r.setDraggable(d),r.getRotation()!==h&&r.setRotation(h),r.getRotationAlignment()!==p&&r.setRotationAlignment(p),r.getPitchAlignment()!==b&&r.setPitchAlignment(b),r.getPopup()!==f&&r.setPopup(f);const R=D(j.className,e.className);if(R)for(const x of R)r.toggleClassName(x);return o.current.props=e,N.createPortal(e.children,r.getElement())})),pe=a.memo(a.forwardRef((e,t)=>{const{map:n,mapLib:i}=a.useContext(S),o=a.useMemo(()=>document.createElement("div"),[]),r=a.useRef({props:e}),s=a.useMemo(()=>{const c={...e},l=new i.Popup(c);return l.setLngLat([e.longitude,e.latitude]),l.once("open",u=>{var d,f;(f=(d=r.current.props).onOpen)==null||f.call(d,u)}),l},[]);if(a.useEffect(()=>{const c=l=>{var u,d;(d=(u=r.current.props).onClose)==null||d.call(u,l)};return s.on("close",c),s.setDOMContent(o).addTo(n.getMap()),()=>{s.off("close",c),s.isOpen()&&s.remove()}},[]),a.useEffect(()=>{_(s.getElement(),e.style)},[e.style]),a.useImperativeHandle(t,()=>s,[]),s.isOpen()){const c=r.current.props;(s.getLngLat().lng!==e.longitude||s.getLngLat().lat!==e.latitude)&&s.setLngLat([e.longitude,e.latitude]),e.offset&&!m(c.offset,e.offset)&&s.setOffset(e.offset),(c.anchor!==e.anchor||c.maxWidth!==e.maxWidth)&&(s.options.anchor=e.anchor,s.setMaxWidth(e.maxWidth));const l=D(c.className,e.className);if(l)for(const u of l)s.toggleClassName(u);r.current.props=e}return N.createPortal(e.children,o)}));function E(e,t,n,i){const o=a.useContext(S),r=a.useMemo(()=>e(o),[]);return a.useEffect(()=>{const s=t,c=null,l=typeof t=="function"?t:null,{map:u}=o;return u.hasControl(r)||(u.addControl(r,s==null?void 0:s.position),c&&c(o)),()=>{l&&l(o),u.hasControl(r)&&u.removeControl(r)}},[]),r}function ee(e){const t=E(({mapLib:n})=>new n.AttributionControl(e),{position:e.position});return a.useEffect(()=>{_(t._container,e.style)},[e.style]),null}a.memo(ee);function te(e){const t=E(({mapLib:n})=>new n.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return a.useEffect(()=>{_(t._controlContainer,e.style)},[e.style]),null}a.memo(te);function ne(e,t){const n=a.useRef({props:e}),i=E(({mapLib:o})=>{const r=new o.GeolocateControl(e),s=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||s()},r.on("geolocate",c=>{var l,u;(u=(l=n.current.props).onGeolocate)==null||u.call(l,c)}),r.on("error",c=>{var l,u;(u=(l=n.current.props).onError)==null||u.call(l,c)}),r.on("outofmaxbounds",c=>{var l,u;(u=(l=n.current.props).onOutOfMaxBounds)==null||u.call(l,c)}),r.on("trackuserlocationstart",c=>{var l,u;(u=(l=n.current.props).onTrackUserLocationStart)==null||u.call(l,c)}),r.on("trackuserlocationend",c=>{var l,u;(u=(l=n.current.props).onTrackUserLocationEnd)==null||u.call(l,c)}),r},{position:e.position});return n.current.props=e,a.useImperativeHandle(t,()=>i,[]),a.useEffect(()=>{_(i._container,e.style)},[e.style]),null}a.memo(a.forwardRef(ne));function oe(e){const t=E(({mapLib:n})=>new n.NavigationControl(e),{position:e.position});return a.useEffect(()=>{_(t._container,e.style)},[e.style]),null}a.memo(oe);function re(e){const t=E(({mapLib:r})=>new r.ScaleControl(e),{position:e.position}),n=a.useRef(e),i=n.current;n.current=e;const{style:o}=e;return e.maxWidth!==void 0&&e.maxWidth!==i.maxWidth&&(t.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==i.unit&&t.setUnit(e.unit),a.useEffect(()=>{_(t._container,o)},[o]),null}const ve=a.memo(re);function ie(e){const t=E(({mapLib:n})=>new n.TerrainControl(e),{position:e.position});return a.useEffect(()=>{_(t._container,e.style)},[e.style]),null}a.memo(ie);function se(e){const t=E(({mapLib:n})=>new n.LogoControl(e),{position:e.position});return a.useEffect(()=>{_(t._container,e.style)},[e.style]),null}a.memo(se);function w(e,t){if(!e)throw new Error(t)}let ae=0;function ce(e,t,n){if(e.style&&e.style._loaded){const i={...n};return delete i.id,delete i.children,e.addSource(t,i),e.getSource(t)}return null}function le(e,t,n){var s,c,l;w(t.id===n.id,"source id changed"),w(t.type===n.type,"source type changed");let i="",o=0;for(const u in t)u!=="children"&&u!=="id"&&!m(n[u],t[u])&&(i=u,o++);if(!o)return;const r=t.type;if(r==="geojson")e.setData(t.data);else if(r==="image")e.updateImage({url:t.url,coordinates:t.coordinates});else switch(i){case"coordinates":(s=e.setCoordinates)==null||s.call(e,t.coordinates);break;case"url":(c=e.setUrl)==null||c.call(e,t.url);break;case"tiles":(l=e.setTiles)==null||l.call(e,t.tiles);break;default:console.warn(`Unable to update prop: ${i}`)}}function _e(e){const t=a.useContext(S).map.getMap(),n=a.useRef(e),[,i]=a.useState(0),o=a.useMemo(()=>e.id||`jsx-source-${ae++}`,[]);a.useEffect(()=>{if(t){const s=()=>setTimeout(()=>i(c=>c+1),0);return t.on("styledata",s),s(),()=>{var c;if(t.off("styledata",s),t.style&&t.style._loaded&&t.getSource(o)){const l=(c=t.getStyle())==null?void 0:c.layers;if(l)for(const u of l)u.source===o&&t.removeLayer(u.id);t.removeSource(o)}}}},[t]);let r=t&&t.style&&t.getSource(o);return r?le(r,e,n.current):r=ce(t,o,e),n.current=e,r&&a.Children.map(e.children,s=>s&&a.cloneElement(s,{source:o}))||null}function ue(e,t,n,i){if(w(n.id===i.id,"layer id changed"),w(n.type===i.type,"layer type changed"),n.type==="custom"||i.type==="custom")return;const{layout:o={},paint:r={},filter:s,minzoom:c,maxzoom:l,beforeId:u}=n;if(u!==i.beforeId&&e.moveLayer(t,u),o!==i.layout){const d=i.layout||{};for(const f in o)m(o[f],d[f])||e.setLayoutProperty(t,f,o[f]);for(const f in d)o.hasOwnProperty(f)||e.setLayoutProperty(t,f,void 0)}if(r!==i.paint){const d=i.paint||{};for(const f in r)m(r[f],d[f])||e.setPaintProperty(t,f,r[f]);for(const f in d)r.hasOwnProperty(f)||e.setPaintProperty(t,f,void 0)}m(s,i.filter)||e.setFilter(t,s),(c!==i.minzoom||l!==i.maxzoom)&&e.setLayerZoomRange(t,c,l)}function fe(e,t,n){if(e.style&&e.style._loaded&&(!("source"in n)||e.getSource(n.source))){const i={...n,id:t};delete i.beforeId,e.addLayer(i,n.beforeId)}}let de=0;function Ce(e){const t=a.useContext(S).map.getMap(),n=a.useRef(e),[,i]=a.useState(0),o=a.useMemo(()=>e.id||`jsx-layer-${de++}`,[]);if(a.useEffect(()=>{if(t){const s=()=>i(c=>c+1);return t.on("styledata",s),s(),()=>{t.off("styledata",s),t.style&&t.style._loaded&&t.getLayer(o)&&t.removeLayer(o)}}},[t]),t&&t.style&&t.getLayer(o))try{ue(t,o,e,n.current)}catch(s){console.warn(s)}else fe(t,o,e);return n.current=e,null}export{Ce as L,ge as M,pe as P,_e as S,ye as a,ve as b,he as u}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-D33fcA3L.js","assets/index-7uzBcJ1E.css"])))=>i.map(i=>d[i]); +import{r as a,_ as W,ba as N}from"./index-D33fcA3L.js";const F=a.createContext(null);function he(){var i;const e=(i=a.useContext(F))==null?void 0:i.maps,t=a.useContext(S);return a.useMemo(()=>({...e,current:t==null?void 0:t.map}),[e,t])}function Z(e,t){const n=Array.isArray(e)?e[0]:e?e.x:0,i=Array.isArray(e)?e[1]:e?e.y:0,o=Array.isArray(t)?t[0]:t?t.x:0,r=Array.isArray(t)?t[1]:t?t.y:0;return n===o&&i===r}function m(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n{let o=null;"interactive"in i&&(o=Object.assign({},i),delete o.interactive);const r=t[i.ref];if(r){o=o||Object.assign({},i),delete o.ref;for(const s of V)s in r&&(o[s]=r[s])}return o||i});return{...e,layers:n}}const z={version:8,sources:{},layers:[]},I={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",click:"onClick",dblclick:"onDblClick",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseout:"onMouseOut",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchmove:"onTouchMove",touchcancel:"onTouchCancel"},O={movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd"},U={wheel:"onWheel",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",resize:"onResize",load:"onLoad",render:"onRender",idle:"onIdle",remove:"onRemove",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",error:"onError"},q=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],B=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class M{constructor(t,n,i){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=o=>{const r=this.props[U[o.type]];r?r(o):o.type==="error"&&console.error(o.error)},this._onCameraEvent=o=>{if(this._internalUpdate)return;o.viewState=this._propsedCameraUpdate||P(this._map.transform);const r=this.props[O[o.type]];r&&r(o)},this._onCameraUpdate=o=>this._internalUpdate?o:(this._propsedCameraUpdate=P(o),k(o,this.props)),this._onPointerEvent=o=>{(o.type==="mousemove"||o.type==="mouseout")&&this._updateHover(o);const r=this.props[I[o.type]];r&&(this.props.interactiveLayerIds&&o.type!=="mouseover"&&o.type!=="mouseout"&&(o.features=this._hoveredFeatures||this._queryRenderedFeatures(o.point)),r(o),delete o.features)},this._MapClass=t,this.props=n,this._initialize(i)}get map(){return this._map}setProps(t){const n=this.props;this.props=t;const i=this._updateSettings(t,n),o=this._updateSize(t),r=this._updateViewState(t);this._updateStyle(t,n),this._updateStyleComponents(t),this._updateHandlers(t,n),(i||o||r&&!this._map.isMoving())&&this.redraw()}static reuse(t,n){const i=M.savedMaps.pop();if(!i)return null;const o=i.map,r=o.getContainer();for(n.className=r.className;r.childNodes.length>0;)n.appendChild(r.childNodes[0]);o._container=n;const s=o._resizeObserver;s&&(s.disconnect(),s.observe(n)),i.setProps({...t,styleDiffing:!1}),o.resize();const{initialViewState:c}=t;return c&&(c.bounds?o.fitBounds(c.bounds,{...c.fitBoundsOptions,duration:0}):i._updateViewState(c)),o.isStyleLoaded()?o.fire("load"):o.once("style.load",()=>o.fire("load")),o._update(),i}_initialize(t){const{props:n}=this,{mapStyle:i=z}=n,o={...n,...n.initialViewState,container:t,style:T(i)},r=o.initialViewState||o.viewState||o;if(Object.assign(o,{center:[r.longitude||0,r.latitude||0],zoom:r.zoom||0,pitch:r.pitch||0,bearing:r.bearing||0}),n.gl){const c=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=c,n.gl)}const s=new this._MapClass(o);r.padding&&s.setPadding(r.padding),n.cursor&&(s.getCanvas().style.cursor=n.cursor),s.transformCameraUpdate=this._onCameraUpdate,s.on("style.load",()=>{var c;this._styleComponents={light:s.getLight(),sky:s.getSky(),projection:(c=s.getProjection)==null?void 0:c.call(s),terrain:s.getTerrain()},this._updateStyleComponents(this.props)}),s.on("sourcedata",()=>{this._updateStyleComponents(this.props)});for(const c in I)s.on(c,this._onPointerEvent);for(const c in O)s.on(c,this._onCameraEvent);for(const c in U)s.on(c,this._onEvent);this._map=s}recycle(){const n=this.map.getContainer().querySelector("[mapboxgl-children]");n==null||n.remove(),M.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const t=this._map;t.style&&(t._frame&&(t._frame.cancel(),t._frame=null),t._render())}_updateSize(t){const{viewState:n}=t;if(n){const i=this._map;if(n.width!==i.transform.width||n.height!==i.transform.height)return i.resize(),!0}return!1}_updateViewState(t){const n=this._map,i=n.transform;if(!n.isMoving()){const r=k(i,t);if(Object.keys(r).length>0)return this._internalUpdate=!0,n.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(t,n){const i=this._map;let o=!1;for(const r of q)if(r in t&&!m(t[r],n[r])){o=!0;const s=i[`set${r[0].toUpperCase()}${r.slice(1)}`];s==null||s.call(i,t[r])}return o}_updateStyle(t,n){if(t.cursor!==n.cursor&&(this._map.getCanvas().style.cursor=t.cursor||""),t.mapStyle!==n.mapStyle){const{mapStyle:i=z,styleDiffing:o=!0}=t,r={diff:o};"localIdeographFontFamily"in t&&(r.localIdeographFontFamily=t.localIdeographFontFamily),this._map.setStyle(T(i),r)}}_updateStyleComponents({light:t,projection:n,sky:i,terrain:o}){var c,l;const r=this._map,s=this._styleComponents;r.style._loaded&&(t&&!m(t,s.light)&&(s.light=t,r.setLight(t)),n&&!m(n,s.projection)&&n!==((c=s.projection)==null?void 0:c.type)&&(s.projection=typeof n=="string"?{type:n}:n,(l=r.setProjection)==null||l.call(r,s.projection)),i&&!m(i,s.sky)&&(s.sky=i,r.setSky(i)),o!==void 0&&!m(o,s.terrain)&&(!o||r.getSource(o.source))&&(s.terrain=o,r.setTerrain(o)))}_updateHandlers(t,n){const i=this._map;for(const o of B){const r=t[o]??!0,s=n[o]??!0;m(r,s)||(r?i[o].enable(r):i[o].disable())}}_queryRenderedFeatures(t){const n=this._map,{interactiveLayerIds:i=[]}=this.props;try{return n.queryRenderedFeatures(t,{layers:i.filter(n.getLayer.bind(n))})}catch{return[]}}_updateHover(t){var o;const{props:n}=this;if(n.interactiveLayerIds&&(n.onMouseMove||n.onMouseEnter||n.onMouseLeave)){const r=t.type,s=((o=this._hoveredFeatures)==null?void 0:o.length)>0,c=this._queryRenderedFeatures(t.point),l=c.length>0;!l&&s&&(t.type="mouseleave",this._onPointerEvent(t)),this._hoveredFeatures=c,l&&!s&&(t.type="mouseenter",this._onPointerEvent(t)),t.type=r}else this._hoveredFeatures=null}}M.savedMaps=[];const $=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function G(e){if(!e)return null;const t=e.map,n={getMap:()=>t};for(const i of K(t))!(i in n)&&!$.includes(i)&&(n[i]=t[i].bind(t));return n}function K(e){const t=new Set;let n=e;for(;n;){for(const i of Object.getOwnPropertyNames(n))i[0]!=="_"&&typeof e[i]=="function"&&i!=="fire"&&i!=="setEventedParent"&&t.add(i);n=Object.getPrototypeOf(n)}return Array.from(t)}const J=typeof document<"u"?a.useLayoutEffect:a.useEffect;function Y(e,t){const{RTLTextPlugin:n,maxParallelImageRequests:i,workerCount:o,workerUrl:r}=t;if(n&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()==="unavailable"){const{pluginUrl:s,lazy:c=!0}=typeof n=="string"?{pluginUrl:n}:n;e.setRTLTextPlugin(s,l=>{l&&console.error(l)},c)}i!==void 0&&e.setMaxParallelImageRequests(i),o!==void 0&&e.setWorkerCount(o),r!==void 0&&e.setWorkerUrl(r)}const S=a.createContext(null);function Q(e,t){const n=a.useContext(F),[i,o]=a.useState(null),r=a.useRef(),{current:s}=a.useRef({mapLib:null,map:null});a.useEffect(()=>{const u=e.mapLib;let d=!0,f;return Promise.resolve(u||W(()=>import("./maplibre-gl-DOIRzRto.js").then(h=>h.m),__vite__mapDeps([0,1]))).then(h=>{if(!d)return;if(!h)throw new Error("Invalid mapLib");const p="Map"in h?h:h.default;if(!p.Map)throw new Error("Invalid mapLib");Y(p,e),e.reuseMaps&&(f=M.reuse(e,r.current)),f||(f=new M(p.Map,e,r.current)),s.map=G(f),s.mapLib=p,o(f),n==null||n.onMapMount(s.map,e.id)}).catch(h=>{const{onError:p}=e;p?p({type:"error",target:null,originalEvent:null,error:h}):console.error(h)}),()=>{d=!1,f&&(n==null||n.onMapUnmount(e.id),e.reuseMaps?f.recycle():f.destroy())}},[]),J(()=>{i&&i.setProps(e)}),a.useImperativeHandle(t,()=>s.map,[i]);const c=a.useMemo(()=>({position:"relative",width:"100%",height:"100%",...e.style}),[e.style]),l={height:"100%"};return a.createElement("div",{id:e.id,ref:r,style:c},i&&a.createElement(S.Provider,{value:s},a.createElement("div",{"mapboxgl-children":"",style:l},e.children)))}const ge=a.forwardRef(Q),X=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function _(e,t){if(!e||!t)return;const n=e.style;for(const i in t){const o=t[i];Number.isFinite(o)&&!X.test(i)?n[i]=`${o}px`:n[i]=o}}function D(e,t){if(e===t)return null;const n=A(e),i=A(t),o=[];for(const r of i)n.has(r)||o.push(r);for(const r of n)i.has(r)||o.push(r);return o.length===0?null:o}function A(e){return new Set(e?e.trim().split(/\s+/):[])}const ye=a.memo(a.forwardRef((e,t)=>{const{map:n,mapLib:i}=a.useContext(S),o=a.useRef({props:e}),r=a.useMemo(()=>{let x=!1;a.Children.forEach(e.children,v=>{v&&(x=!0)});const H={...e,element:x?document.createElement("div"):void 0},L=new i.Marker(H);return L.setLngLat([e.longitude,e.latitude]),L.getElement().addEventListener("click",v=>{var g,y;(y=(g=o.current.props).onClick)==null||y.call(g,{type:"click",target:L,originalEvent:v})}),L.on("dragstart",v=>{var y,C;const g=v;g.lngLat=r.getLngLat(),(C=(y=o.current.props).onDragStart)==null||C.call(y,g)}),L.on("drag",v=>{var y,C;const g=v;g.lngLat=r.getLngLat(),(C=(y=o.current.props).onDrag)==null||C.call(y,g)}),L.on("dragend",v=>{var y,C;const g=v;g.lngLat=r.getLngLat(),(C=(y=o.current.props).onDragEnd)==null||C.call(y,g)}),L},[]);a.useEffect(()=>(r.addTo(n.getMap()),()=>{r.remove()}),[]);const{longitude:s,latitude:c,offset:l,style:u,draggable:d=!1,popup:f=null,rotation:h=0,rotationAlignment:p="auto",pitchAlignment:b="auto"}=e;a.useEffect(()=>{_(r.getElement(),u)},[u]),a.useImperativeHandle(t,()=>r,[]);const j=o.current.props;(r.getLngLat().lng!==s||r.getLngLat().lat!==c)&&r.setLngLat([s,c]),l&&!Z(r.getOffset(),l)&&r.setOffset(l),r.isDraggable()!==d&&r.setDraggable(d),r.getRotation()!==h&&r.setRotation(h),r.getRotationAlignment()!==p&&r.setRotationAlignment(p),r.getPitchAlignment()!==b&&r.setPitchAlignment(b),r.getPopup()!==f&&r.setPopup(f);const R=D(j.className,e.className);if(R)for(const x of R)r.toggleClassName(x);return o.current.props=e,N.createPortal(e.children,r.getElement())})),pe=a.memo(a.forwardRef((e,t)=>{const{map:n,mapLib:i}=a.useContext(S),o=a.useMemo(()=>document.createElement("div"),[]),r=a.useRef({props:e}),s=a.useMemo(()=>{const c={...e},l=new i.Popup(c);return l.setLngLat([e.longitude,e.latitude]),l.once("open",u=>{var d,f;(f=(d=r.current.props).onOpen)==null||f.call(d,u)}),l},[]);if(a.useEffect(()=>{const c=l=>{var u,d;(d=(u=r.current.props).onClose)==null||d.call(u,l)};return s.on("close",c),s.setDOMContent(o).addTo(n.getMap()),()=>{s.off("close",c),s.isOpen()&&s.remove()}},[]),a.useEffect(()=>{_(s.getElement(),e.style)},[e.style]),a.useImperativeHandle(t,()=>s,[]),s.isOpen()){const c=r.current.props;(s.getLngLat().lng!==e.longitude||s.getLngLat().lat!==e.latitude)&&s.setLngLat([e.longitude,e.latitude]),e.offset&&!m(c.offset,e.offset)&&s.setOffset(e.offset),(c.anchor!==e.anchor||c.maxWidth!==e.maxWidth)&&(s.options.anchor=e.anchor,s.setMaxWidth(e.maxWidth));const l=D(c.className,e.className);if(l)for(const u of l)s.toggleClassName(u);r.current.props=e}return N.createPortal(e.children,o)}));function E(e,t,n,i){const o=a.useContext(S),r=a.useMemo(()=>e(o),[]);return a.useEffect(()=>{const s=t,c=null,l=typeof t=="function"?t:null,{map:u}=o;return u.hasControl(r)||(u.addControl(r,s==null?void 0:s.position),c&&c(o)),()=>{l&&l(o),u.hasControl(r)&&u.removeControl(r)}},[]),r}function ee(e){const t=E(({mapLib:n})=>new n.AttributionControl(e),{position:e.position});return a.useEffect(()=>{_(t._container,e.style)},[e.style]),null}a.memo(ee);function te(e){const t=E(({mapLib:n})=>new n.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return a.useEffect(()=>{_(t._controlContainer,e.style)},[e.style]),null}a.memo(te);function ne(e,t){const n=a.useRef({props:e}),i=E(({mapLib:o})=>{const r=new o.GeolocateControl(e),s=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||s()},r.on("geolocate",c=>{var l,u;(u=(l=n.current.props).onGeolocate)==null||u.call(l,c)}),r.on("error",c=>{var l,u;(u=(l=n.current.props).onError)==null||u.call(l,c)}),r.on("outofmaxbounds",c=>{var l,u;(u=(l=n.current.props).onOutOfMaxBounds)==null||u.call(l,c)}),r.on("trackuserlocationstart",c=>{var l,u;(u=(l=n.current.props).onTrackUserLocationStart)==null||u.call(l,c)}),r.on("trackuserlocationend",c=>{var l,u;(u=(l=n.current.props).onTrackUserLocationEnd)==null||u.call(l,c)}),r},{position:e.position});return n.current.props=e,a.useImperativeHandle(t,()=>i,[]),a.useEffect(()=>{_(i._container,e.style)},[e.style]),null}a.memo(a.forwardRef(ne));function oe(e){const t=E(({mapLib:n})=>new n.NavigationControl(e),{position:e.position});return a.useEffect(()=>{_(t._container,e.style)},[e.style]),null}a.memo(oe);function re(e){const t=E(({mapLib:r})=>new r.ScaleControl(e),{position:e.position}),n=a.useRef(e),i=n.current;n.current=e;const{style:o}=e;return e.maxWidth!==void 0&&e.maxWidth!==i.maxWidth&&(t.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==i.unit&&t.setUnit(e.unit),a.useEffect(()=>{_(t._container,o)},[o]),null}const ve=a.memo(re);function ie(e){const t=E(({mapLib:n})=>new n.TerrainControl(e),{position:e.position});return a.useEffect(()=>{_(t._container,e.style)},[e.style]),null}a.memo(ie);function se(e){const t=E(({mapLib:n})=>new n.LogoControl(e),{position:e.position});return a.useEffect(()=>{_(t._container,e.style)},[e.style]),null}a.memo(se);function w(e,t){if(!e)throw new Error(t)}let ae=0;function ce(e,t,n){if(e.style&&e.style._loaded){const i={...n};return delete i.id,delete i.children,e.addSource(t,i),e.getSource(t)}return null}function le(e,t,n){var s,c,l;w(t.id===n.id,"source id changed"),w(t.type===n.type,"source type changed");let i="",o=0;for(const u in t)u!=="children"&&u!=="id"&&!m(n[u],t[u])&&(i=u,o++);if(!o)return;const r=t.type;if(r==="geojson")e.setData(t.data);else if(r==="image")e.updateImage({url:t.url,coordinates:t.coordinates});else switch(i){case"coordinates":(s=e.setCoordinates)==null||s.call(e,t.coordinates);break;case"url":(c=e.setUrl)==null||c.call(e,t.url);break;case"tiles":(l=e.setTiles)==null||l.call(e,t.tiles);break;default:console.warn(`Unable to update prop: ${i}`)}}function _e(e){const t=a.useContext(S).map.getMap(),n=a.useRef(e),[,i]=a.useState(0),o=a.useMemo(()=>e.id||`jsx-source-${ae++}`,[]);a.useEffect(()=>{if(t){const s=()=>setTimeout(()=>i(c=>c+1),0);return t.on("styledata",s),s(),()=>{var c;if(t.off("styledata",s),t.style&&t.style._loaded&&t.getSource(o)){const l=(c=t.getStyle())==null?void 0:c.layers;if(l)for(const u of l)u.source===o&&t.removeLayer(u.id);t.removeSource(o)}}}},[t]);let r=t&&t.style&&t.getSource(o);return r?le(r,e,n.current):r=ce(t,o,e),n.current=e,r&&a.Children.map(e.children,s=>s&&a.cloneElement(s,{source:o}))||null}function ue(e,t,n,i){if(w(n.id===i.id,"layer id changed"),w(n.type===i.type,"layer type changed"),n.type==="custom"||i.type==="custom")return;const{layout:o={},paint:r={},filter:s,minzoom:c,maxzoom:l,beforeId:u}=n;if(u!==i.beforeId&&e.moveLayer(t,u),o!==i.layout){const d=i.layout||{};for(const f in o)m(o[f],d[f])||e.setLayoutProperty(t,f,o[f]);for(const f in d)o.hasOwnProperty(f)||e.setLayoutProperty(t,f,void 0)}if(r!==i.paint){const d=i.paint||{};for(const f in r)m(r[f],d[f])||e.setPaintProperty(t,f,r[f]);for(const f in d)r.hasOwnProperty(f)||e.setPaintProperty(t,f,void 0)}m(s,i.filter)||e.setFilter(t,s),(c!==i.minzoom||l!==i.maxzoom)&&e.setLayerZoomRange(t,c,l)}function fe(e,t,n){if(e.style&&e.style._loaded&&(!("source"in n)||e.getSource(n.source))){const i={...n,id:t};delete i.beforeId,e.addLayer(i,n.beforeId)}}let de=0;function Ce(e){const t=a.useContext(S).map.getMap(),n=a.useRef(e),[,i]=a.useState(0),o=a.useMemo(()=>e.id||`jsx-layer-${de++}`,[]);if(a.useEffect(()=>{if(t){const s=()=>i(c=>c+1);return t.on("styledata",s),s(),()=>{t.off("styledata",s),t.style&&t.style._loaded&&t.getLayer(o)&&t.removeLayer(o)}}},[t]),t&&t.style&&t.getLayer(o))try{ue(t,o,e,n.current)}catch(s){console.warn(s)}else fe(t,o,e);return n.current=e,null}export{Ce as L,ge as M,pe as P,_e as S,ye as a,ve as b,he as u}; diff --git a/frontend/dist/assets/maplibre-gl-CfJOR1BZ.js b/frontend/dist/assets/maplibre-gl-DOIRzRto.js similarity index 99% rename from frontend/dist/assets/maplibre-gl-CfJOR1BZ.js rename to frontend/dist/assets/maplibre-gl-DOIRzRto.js index 93175f48..154e09ae 100644 --- a/frontend/dist/assets/maplibre-gl-CfJOR1BZ.js +++ b/frontend/dist/assets/maplibre-gl-DOIRzRto.js @@ -1,4 +1,4 @@ -var zg=Object.defineProperty;var kg=(br,wr,Ui)=>wr in br?zg(br,wr,{enumerable:!0,configurable:!0,writable:!0,value:Ui}):br[wr]=Ui;var Ge=(br,wr,Ui)=>kg(br,typeof wr!="symbol"?wr+"":wr,Ui);import{hj as Rg}from"./index-C2xvS0Jd.js";function Lg(br,wr){for(var Ui=0;UiKi[en]})}}}return Object.freeze(Object.defineProperty(br,Symbol.toStringTag,{value:"Module"}))}var wu={exports:{}};/** +var zg=Object.defineProperty;var kg=(br,wr,Ui)=>wr in br?zg(br,wr,{enumerable:!0,configurable:!0,writable:!0,value:Ui}):br[wr]=Ui;var Ge=(br,wr,Ui)=>kg(br,typeof wr!="symbol"?wr+"":wr,Ui);import{hj as Rg}from"./index-D33fcA3L.js";function Lg(br,wr){for(var Ui=0;UiKi[en]})}}}return Object.freeze(Object.defineProperty(br,Symbol.toStringTag,{value:"Module"}))}var wu={exports:{}};/** * MapLibre GL JS * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.15.0/LICENSE.txt */var Fg=wu.exports,sf;function Bg(){return sf||(sf=1,(function(br,wr){(function(Ui,Ki){br.exports=Ki()})(Fg,(function(){var Ui={},Ki={};function en(z,h,Ee){if(Ki[z]=Ee,z==="index"){var Fr="var sharedModule = {}; ("+Ki.shared+")(sharedModule); ("+Ki.worker+")(sharedModule);",Ri={};return Ki.shared(Ri),Ki.index(Ui,Ri),typeof window<"u"&&Ui.setWorkerUrl(window.URL.createObjectURL(new Blob([Fr],{type:"text/javascript"}))),Ui}}en("shared",["exports"],(function(z){function h(r,e,i,s){return new(i||(i=Promise))((function(o,c){function u(y){try{g(s.next(y))}catch(v){c(v)}}function f(y){try{g(s.throw(y))}catch(v){c(v)}}function g(y){var v;y.done?o(y.value):(v=y.value,v instanceof i?v:new i((function(w){w(v)}))).then(u,f)}g((s=s.apply(r,e||[])).next())}))}function Ee(r,e){this.x=r,this.y=e}function Fr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ri,zn;typeof SuppressedError=="function"&&SuppressedError,Ee.prototype={clone(){return new Ee(this.x,this.y)},add(r){return this.clone()._add(r)},sub(r){return this.clone()._sub(r)},multByPoint(r){return this.clone()._multByPoint(r)},divByPoint(r){return this.clone()._divByPoint(r)},mult(r){return this.clone()._mult(r)},div(r){return this.clone()._div(r)},rotate(r){return this.clone()._rotate(r)},rotateAround(r,e){return this.clone()._rotateAround(r,e)},matMult(r){return this.clone()._matMult(r)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(r){return this.x===r.x&&this.y===r.y},dist(r){return Math.sqrt(this.distSqr(r))},distSqr(r){const e=r.x-this.x,i=r.y-this.y;return e*e+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(r){return Math.atan2(this.y-r.y,this.x-r.x)},angleWith(r){return this.angleWithSep(r.x,r.y)},angleWithSep(r,e){return Math.atan2(this.x*e-this.y*r,this.x*r+this.y*e)},_matMult(r){const e=r[2]*this.x+r[3]*this.y;return this.x=r[0]*this.x+r[1]*this.y,this.y=e,this},_add(r){return this.x+=r.x,this.y+=r.y,this},_sub(r){return this.x-=r.x,this.y-=r.y,this},_mult(r){return this.x*=r,this.y*=r,this},_div(r){return this.x/=r,this.y/=r,this},_multByPoint(r){return this.x*=r.x,this.y*=r.y,this},_divByPoint(r){return this.x/=r.x,this.y/=r.y,this},_unit(){return this._div(this.mag()),this},_perp(){const r=this.y;return this.y=this.x,this.x=-r,this},_rotate(r){const e=Math.cos(r),i=Math.sin(r),s=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=s,this},_rotateAround(r,e){const i=Math.cos(r),s=Math.sin(r),o=e.y+s*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-s*(this.y-e.y),this.y=o,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Ee},Ee.convert=function(r){if(r instanceof Ee)return r;if(Array.isArray(r))return new Ee(+r[0],+r[1]);if(r.x!==void 0&&r.y!==void 0)return new Ee(+r.x,+r.y);throw new Error("Expected [x, y] or {x, y} point format")};var vs=(function(){if(zn)return Ri;function r(e,i,s,o){this.cx=3*e,this.bx=3*(s-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(o-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=i,this.p2x=s,this.p2y=o}return zn=1,Ri=r,r.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,i){if(i===void 0&&(i=1e-6),e<0)return 0;if(e>1)return 1;for(var s=e,o=0;o<8;o++){var c=this.sampleCurveX(s)-e;if(Math.abs(c)c?f=s:g=s,s=.5*(g-f)+f;return s},solve:function(e,i){return this.sampleCurveY(this.solveCurveX(e,i))}},Ri})(),oi=Fr(vs);let Tr,tt;function pe(){return Tr==null&&(Tr=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Tr}function kn(){if(tt==null&&(tt=!1,pe())){const e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let s=0;s<25;s++){const o=4*s;e.fillStyle=`rgb(${o},${o+1},${o+2})`,e.fillRect(s%5,Math.floor(s/5),1,1)}const i=e.getImageData(0,0,5,5).data;for(let s=0;s<100;s++)if(s%4!=3&&i[s]!==s){tt=!0;break}}}return tt||!1}var Ct=1e-6,Tt=typeof Float32Array<"u"?Float32Array:Array;function Rn(){var r=new Tt(9);return Tt!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[5]=0,r[6]=0,r[7]=0),r[0]=1,r[4]=1,r[8]=1,r}function Ln(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function bs(){var r=new Tt(3);return Tt!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function Mi(r){var e=r[0],i=r[1],s=r[2];return Math.sqrt(e*e+i*i+s*s)}function Fn(r,e,i){var s=new Tt(3);return s[0]=r,s[1]=e,s[2]=i,s}function Br(r,e,i){return r[0]=e[0]+i[0],r[1]=e[1]+i[1],r[2]=e[2]+i[2],r}function Sr(r,e,i){return r[0]=e[0]*i,r[1]=e[1]*i,r[2]=e[2]*i,r}function tn(r,e,i){var s=e[0],o=e[1],c=e[2],u=i[0],f=i[1],g=i[2];return r[0]=o*g-c*f,r[1]=c*u-s*g,r[2]=s*f-o*u,r}var pr,fr=Mi;function ws(r,e,i){var s=e[0],o=e[1],c=e[2],u=e[3];return r[0]=i[0]*s+i[4]*o+i[8]*c+i[12]*u,r[1]=i[1]*s+i[5]*o+i[9]*c+i[13]*u,r[2]=i[2]*s+i[6]*o+i[10]*c+i[14]*u,r[3]=i[3]*s+i[7]*o+i[11]*c+i[15]*u,r}function rn(){var r=new Tt(4);return Tt!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r[3]=1,r}function wa(r,e,i,s){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",c=Math.PI/360;e*=c,s*=c,i*=c;var u=Math.sin(e),f=Math.cos(e),g=Math.sin(i),y=Math.cos(i),v=Math.sin(s),w=Math.cos(s);switch(o){case"xyz":r[0]=u*y*w+f*g*v,r[1]=f*g*w-u*y*v,r[2]=f*y*v+u*g*w,r[3]=f*y*w-u*g*v;break;case"xzy":r[0]=u*y*w-f*g*v,r[1]=f*g*w-u*y*v,r[2]=f*y*v+u*g*w,r[3]=f*y*w+u*g*v;break;case"yxz":r[0]=u*y*w+f*g*v,r[1]=f*g*w-u*y*v,r[2]=f*y*v-u*g*w,r[3]=f*y*w+u*g*v;break;case"yzx":r[0]=u*y*w+f*g*v,r[1]=f*g*w+u*y*v,r[2]=f*y*v-u*g*w,r[3]=f*y*w-u*g*v;break;case"zxy":r[0]=u*y*w-f*g*v,r[1]=f*g*w+u*y*v,r[2]=f*y*v+u*g*w,r[3]=f*y*w-u*g*v;break;case"zyx":r[0]=u*y*w-f*g*v,r[1]=f*g*w+u*y*v,r[2]=f*y*v-u*g*w,r[3]=f*y*w+u*g*v;break;default:throw new Error("Unknown angle order "+o)}return r}function Li(){var r=new Tt(2);return Tt!=Float32Array&&(r[0]=0,r[1]=0),r}function nn(r,e){var i=new Tt(2);return i[0]=r,i[1]=e,i}bs(),pr=new Tt(4),Tt!=Float32Array&&(pr[0]=0,pr[1]=0,pr[2]=0,pr[3]=0),bs(),Fn(1,0,0),Fn(0,1,0),rn(),rn(),Rn(),Li();const st=8192;function Bn(r,e,i){return e*(st/(r.tileSize*Math.pow(2,i-r.tileID.overscaledZ)))}function Pr(r,e){return(r%e+e)%e}function On(r,e,i){return r*(1-i)+e*i}function Ts(r){if(r<=0)return 0;if(r>=1)return 1;const e=r*r,i=e*r;return 4*(r<.5?i:3*(r-e)+i-.75)}function sn(r,e,i,s){const o=new oi(r,e,i,s);return c=>o.solve(c)}const di=sn(.25,.1,.25,1);function Ji(r,e,i){return Math.min(i,Math.max(e,r))}function Ir(r,e,i){const s=i-e,o=((r-e)%s+s)%s+e;return o===e?i:o}function yi(r,...e){for(const i of e)for(const s in i)r[s]=i[s];return r}let an=1;function Qi(r,e,i){const s={};for(const o in r)s[o]=e.call(this,r[o],o,r);return s}function Ss(r,e,i){const s={};for(const o in r)e.call(this,r[o],o,r)&&(s[o]=r[o]);return s}function er(r){return Array.isArray(r)?r.map(er):typeof r=="object"&&r?Qi(r,er):r}const Ps={};function Qt(r){Ps[r]||(typeof console<"u"&&console.warn(r),Ps[r]=!0)}function Gi(r,e,i){return(i.y-r.y)*(e.x-r.x)>(e.y-r.y)*(i.x-r.x)}function mr(r){return typeof WorkerGlobalScope<"u"&&r!==void 0&&r instanceof WorkerGlobalScope}let kt=null;function Or(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap}const on="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Vn(r,e,i,s,o){return h(this,void 0,void 0,(function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const c=new VideoFrame(r,{timestamp:0});try{const u=c==null?void 0:c.format;if(!u||!u.startsWith("BGR")&&!u.startsWith("RGB"))throw new Error(`Unrecognized format ${u}`);const f=u.startsWith("BGR"),g=new Uint8ClampedArray(s*o*4);if(yield c.copyTo(g,(function(y,v,w,S,P){const E=4*Math.max(-v,0),C=(Math.max(0,w)-w)*S*4+E,D=4*S,F=Math.max(0,v),q=Math.max(0,w);return{rect:{x:F,y:q,width:Math.min(y.width,v+S)-F,height:Math.min(y.height,w+P)-q},layout:[{offset:C,stride:D}]}})(r,e,i,s,o)),f)for(let y=0;y{r.removeEventListener(e,i,s)}}}function Nn(r){return r*Math.PI/180}function Ei(r){return r/Math.PI*180}const re={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},R={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},k="AbortError";class O extends Error{constructor(e=k){super(e instanceof Error?e.message:e),this.name=k,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function K(r){return r.name===k}const Q={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function se(r){return Q.REGISTERED_PROTOCOLS[r.substring(0,r.indexOf("://"))]}const ie="global-dispatcher";class ee extends Error{constructor(e,i,s,o){super(`AJAXError: ${i} (${e}): ${s}`),this.status=e,this.statusText=i,this.url=s,this.body=o}}const he=()=>mr(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,be=function(r,e){if(/:\/\//.test(r.url)&&!/^https?:|^file:/.test(r.url)){const s=se(r.url);if(s)return s(r,e);if(mr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,targetMapId:ie},e)}if(!(/^file:/.test(i=r.url)||/^file:/.test(he())&&!/^\w+:/.test(i))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return(function(s,o){return h(this,void 0,void 0,(function*(){const c=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:he(),signal:o.signal});let u,f;s.type!=="json"||c.headers.has("Accept")||c.headers.set("Accept","application/json");try{u=yield fetch(c)}catch(y){throw K(y)?y:new ee(0,y.message,s.url,new Blob)}if(!u.ok){const y=yield u.blob();throw new ee(u.status,u.statusText,s.url,y)}f=s.type==="arrayBuffer"||s.type==="image"?u.arrayBuffer():s.type==="json"?u.json():u.text();const g=yield f;return o.signal.throwIfAborted(),{data:g,cacheControl:u.headers.get("Cache-Control"),expires:u.headers.get("Expires")}}))})(r,e);if(mr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,mustQueue:!0,targetMapId:ie},e)}var i;return(function(s,o){return new Promise(((c,u)=>{var f;const g=new XMLHttpRequest;g.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(g.responseType="arraybuffer");for(const y in s.headers)g.setRequestHeader(y,s.headers[y]);s.type==="json"&&(g.responseType="text",!((f=s.headers)===null||f===void 0)&&f.Accept||g.setRequestHeader("Accept","application/json")),g.withCredentials=s.credentials==="include",g.onerror=()=>{u(new Error(g.statusText))},g.onload=()=>{if(!o.signal.aborted)if((g.status>=200&&g.status<300||g.status===0)&&g.response!==null){let y=g.response;if(s.type==="json")try{y=JSON.parse(g.response)}catch(v){return void u(v)}c({data:y,cacheControl:g.getResponseHeader("Cache-Control"),expires:g.getResponseHeader("Expires")})}else{const y=new Blob([g.response],{type:g.getResponseHeader("Content-Type")});u(new ee(g.status,g.statusText,s.url,y))}},o.signal.addEventListener("abort",(()=>{g.abort(),u(new O(o.signal.reason))})),g.send(s.body)}))})(r,e)};function _e(r){if(!r||r.indexOf("://")<=0||r.indexOf("data:image/")===0||r.indexOf("blob:")===0)return!0;const e=new URL(r),i=window.location;return e.protocol===i.protocol&&e.host===i.host}function De(r,e,i){i[r]&&i[r].indexOf(e)!==-1||(i[r]=i[r]||[],i[r].push(e))}function Le(r,e,i){if(i&&i[r]){const s=i[r].indexOf(e);s!==-1&&i[r].splice(s,1)}}class je{constructor(e,i={}){yi(this,i),this.type=e}}class ct extends je{constructor(e,i={}){super("error",yi({error:e},i))}}class it{on(e,i){return this._listeners=this._listeners||{},De(e,i,this._listeners),{unsubscribe:()=>{this.off(e,i)}}}off(e,i){return Le(e,i,this._listeners),Le(e,i,this._oneTimeListeners),this}once(e,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},De(e,i,this._oneTimeListeners),this):new Promise((s=>this.once(e,s)))}fire(e,i){typeof e=="string"&&(e=new je(e,i||{}));const s=e.type;if(this.listens(s)){e.target=this;const o=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(const f of o)f.call(this,e);const c=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const f of c)Le(s,f,this._oneTimeListeners),f.call(this,e);const u=this._eventedParent;u&&(yi(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),u.fire(e))}else e instanceof ct&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,i){return this._eventedParent=e,this._eventedParentData=i,this}}var oe={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const ht=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function li(r,e){const i={};for(const s in r)s!=="ref"&&(i[s]=r[s]);return ht.forEach((s=>{s in e&&(i[s]=e[s])})),i}function Ne(r,e){if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(let i=0;i`:r.itemType.kind==="value"?"array":`array<${e}>`}return r.kind}const Ia=[qi,Ce,$e,We,Fi,Sa,Cs,Mr,bi(qe),Pa,As,Un,Gn,Ds];function qn(r,e){if(e.kind==="error")return null;if(r.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!qn(r.itemType,e.itemType))&&(typeof r.N!="number"||r.N===e.N))return null}else{if(r.kind===e.kind)return null;if(r.kind==="value"){for(const i of Ia)if(!qn(i,e))return null}}return`Expected ${lt(r)} but found ${lt(e)} instead.`}function zs(r,e){return e.some((i=>i.kind===r.kind))}function ln(r,e){return e.some((i=>i==="null"?r===null:i==="array"?Array.isArray(r):i==="object"?r&&!Array.isArray(r)&&typeof r=="object":i===typeof r))}function ir(r,e){return r.kind==="array"&&e.kind==="array"?r.itemType.kind===e.itemType.kind&&typeof r.N=="number":r.kind===e.kind}const Wl=.96422,cn=.82521,Ma=4/29,Lt=6/29,Hl=3*Lt*Lt,Xl=Lt*Lt*Lt,ks=Math.PI/180,Yl=180/Math.PI;function Kl(r){return(r%=360)<0&&(r+=360),r}function Jl([r,e,i,s]){let o,c;const u=zo((.2225045*(r=Ea(r))+.7168786*(e=Ea(e))+.0606169*(i=Ea(i)))/1);r===e&&e===i?o=c=u:(o=zo((.4360747*r+.3850649*e+.1430804*i)/Wl),c=zo((.0139322*r+.0971045*e+.7141733*i)/cn));const f=116*u-16;return[f<0?0:f,500*(o-u),200*(u-c),s]}function Ea(r){return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function zo(r){return r>Xl?Math.pow(r,1/3):r/Hl+Ma}function ko([r,e,i,s]){let o=(r+16)/116,c=isNaN(e)?o:o+e/500,u=isNaN(i)?o:o-i/200;return o=1*Lo(o),c=Wl*Lo(c),u=cn*Lo(u),[Ro(3.1338561*c-1.6168667*o-.4906146*u),Ro(-.9787684*c+1.9161415*o+.033454*u),Ro(.0719453*c-.2289914*o+1.4052427*u),s]}function Ro(r){return(r=r<=.00304?12.92*r:1.055*Math.pow(r,1/2.4)-.055)<0?0:r>1?1:r}function Lo(r){return r>Lt?r*r*r:Hl*(r-Ma)}const Tu=Object.hasOwn||function(r,e){return Object.prototype.hasOwnProperty.call(r,e)};function Rs(r,e){return Tu(r,e)?r[e]:void 0}function Ca(r){return parseInt(r.padEnd(2,r),16)/255}function Ql(r,e){return Zn(e?r/100:r,0,1)}function Zn(r,e,i){return Math.min(Math.max(e,r),i)}function Fo(r){return!r.some(Number.isNaN)}const Ls={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function jr(r,e,i){return r+i*(e-r)}function $n(r,e,i){return r.map(((s,o)=>jr(s,e[o],i)))}class He{constructor(e,i,s,o=1,c=!0){this.r=e,this.g=i,this.b=s,this.a=o,c||(this.r*=o,this.g*=o,this.b*=o,o||this.overwriteGetter("rgb",[e,i,s,o]))}static parse(e){if(e instanceof He)return e;if(typeof e!="string")return;const i=(function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];const o=Rs(Ls,s);if(o){const[u,f,g]=o;return[u/255,f/255,g/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){const u=s.length<6?1:2;let f=1;return[Ca(s.slice(f,f+=u)),Ca(s.slice(f,f+=u)),Ca(s.slice(f,f+=u)),Ca(s.slice(f,f+u)||"ff")]}if(s.startsWith("rgb")){const u=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(u){const[f,g,y,v,w,S,P,E,C,D,F,q]=u,B=[v||" ",P||" ",D].join("");if(B===" "||B===" /"||B===",,"||B===",,,"){const V=[y,S,C].join(""),$=V==="%%%"?100:V===""?255:0;if($){const X=[Zn(+g/$,0,1),Zn(+w/$,0,1),Zn(+E/$,0,1),F?Ql(+F,q):1];if(Fo(X))return X}}return}}const c=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(c){const[u,f,g,y,v,w,S,P,E]=c,C=[g||" ",v||" ",S].join("");if(C===" "||C===" /"||C===",,"||C===",,,"){const D=[+f,Zn(+y,0,100),Zn(+w,0,100),P?Ql(+P,E):1];if(Fo(D))return(function([F,q,B,V]){function $(X){const ne=(X+F/30)%12,ge=q*Math.min(B,1-B);return B-ge*Math.max(-1,Math.min(ne-3,9-ne,1))}return F=Kl(F),q/=100,B/=100,[$(0),$(8),$(4),V]})(D)}}})(e);return i?new He(...i,!1):void 0}get rgb(){const{r:e,g:i,b:s,a:o}=this,c=o||1/0;return this.overwriteGetter("rgb",[e/c,i/c,s/c,o])}get hcl(){return this.overwriteGetter("hcl",(function(e){const[i,s,o,c]=Jl(e),u=Math.sqrt(s*s+o*o);return[Math.round(1e4*u)?Kl(Math.atan2(o,s)*Yl):NaN,u,i,c]})(this.rgb))}get lab(){return this.overwriteGetter("lab",Jl(this.rgb))}overwriteGetter(e,i){return Object.defineProperty(this,e,{value:i}),i}toString(){const[e,i,s,o]=this.rgb;return`rgba(${[e,i,s].map((c=>Math.round(255*c))).join(",")},${o})`}static interpolate(e,i,s,o="rgb"){switch(o){case"rgb":{const[c,u,f,g]=$n(e.rgb,i.rgb,s);return new He(c,u,f,g,!1)}case"hcl":{const[c,u,f,g]=e.hcl,[y,v,w,S]=i.hcl;let P,E;if(isNaN(c)||isNaN(y))isNaN(c)?isNaN(y)?P=NaN:(P=y,f!==1&&f!==0||(E=v)):(P=c,w!==1&&w!==0||(E=u));else{let B=y-c;y>c&&B>180?B-=360:y180&&(B+=360),P=c+s*B}const[C,D,F,q]=(function([B,V,$,X]){return B=isNaN(B)?0:B*ks,ko([$,Math.cos(B)*V,Math.sin(B)*V,X])})([P,E??jr(u,v,s),jr(f,w,s),jr(g,S,s)]);return new He(C,D,F,q,!1)}case"lab":{const[c,u,f,g]=ko($n(e.lab,i.lab,s));return new He(c,u,f,g,!1)}}}}He.black=new He(0,0,0,1),He.white=new He(1,1,1,1),He.transparent=new He(0,0,0,0),He.red=new He(1,0,0,1);class Bo{constructor(e,i,s){this.sensitivity=e?i?"variant":"case":i?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,i){return this.collator.compare(e,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Su=["bottom","center","top"];class Oo{constructor(e,i,s,o,c,u){this.text=e,this.image=i,this.scale=s,this.fontStack=o,this.textColor=c,this.verticalAlign=u}}class Ci{constructor(e){this.sections=e}static fromString(e){return new Ci([new Oo(e,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some((e=>e.text.length!==0||e.image&&e.image.name.length!==0))}static factory(e){return e instanceof Ci?e:Ci.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map((e=>e.text)).join("")}}class pi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof pi)return e;if(typeof e=="number")return new pi([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const i of e)if(typeof i!="number")return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new pi(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s){return new pi($n(e.values,i.values,s))}}class At{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof At)return e;if(typeof e=="number")return new At([e]);if(Array.isArray(e)){for(const i of e)if(typeof i!="number")return;return new At(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s){return new At($n(e.values,i.values,s))}}class Ve{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Ve)return e;if(typeof e=="string"){const s=He.parse(e);return s?new Ve([s]):void 0}if(!Array.isArray(e))return;const i=[];for(const s of e){if(typeof s!="string")return;const o=He.parse(s);if(!o)return;i.push(o)}return new Ve(i)}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s,o="rgb"){const c=[];if(e.values.length!=i.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let u=0;u=0&&r<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof i=="number"&&i>=0&&i<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[r,e,i,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[r,e,i,s]:[r,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ur(r){if(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"||r instanceof Ti||r instanceof He||r instanceof Bo||r instanceof Ci||r instanceof pi||r instanceof At||r instanceof Ve||r instanceof wi||r instanceof Bi)return!0;if(Array.isArray(r)){for(const e of r)if(!Ur(e))return!1;return!0}if(typeof r=="object"){for(const e in r)if(!Ur(r[e]))return!1;return!0}return!1}function jt(r){if(r===null)return qi;if(typeof r=="string")return $e;if(typeof r=="boolean")return We;if(typeof r=="number")return Ce;if(r instanceof He)return Fi;if(r instanceof Ti)return Sa;if(r instanceof Bo)return Es;if(r instanceof Ci)return Cs;if(r instanceof pi)return Pa;if(r instanceof At)return As;if(r instanceof Ve)return Un;if(r instanceof wi)return Ds;if(r instanceof Bi)return Gn;if(Array.isArray(r)){const e=r.length;let i;for(const s of r){const o=jt(s);if(i){if(i===o)continue;i=qe;break}i=o}return bi(i||qe,e)}return Mr}function un(r){const e=typeof r;return r===null?"":e==="string"||e==="number"||e==="boolean"?String(r):r instanceof He||r instanceof Ti||r instanceof Ci||r instanceof pi||r instanceof At||r instanceof Ve||r instanceof wi||r instanceof Bi?r.toString():JSON.stringify(r)}class gr{constructor(e,i){this.type=e,this.value=i}static parse(e,i){if(e.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Ur(e[1]))return i.error("invalid value");const s=e[1];let o=jt(s);const c=i.expectedType;return o.kind!=="array"||o.N!==0||!c||c.kind!=="array"||typeof c.N=="number"&&c.N!==0||(o=c),new gr(o,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Aa={string:$e,number:Ce,boolean:We,object:Mr};class Ai{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let s,o=1;const c=e[0];if(c==="array"){let f,g;if(e.length>2){const y=e[1];if(typeof y!="string"||!(y in Aa)||y==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);f=Aa[y],o++}else f=qe;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);g=e[2],o++}s=bi(f,g)}else{if(!Aa[c])throw new Error(`Types doesn't contain name = ${c}`);s=Aa[c]}const u=[];for(;oe.outputDefined()))}}const hn={"to-boolean":We,"to-color":Fi,"to-number":Ce,"to-string":$e};class Er{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const s=e[0];if(!hn[s])throw new Error(`Can't parse ${s} as it is not part of the known types`);if((s==="to-boolean"||s==="to-string")&&e.length!==2)return i.error("Expected one argument.");const o=hn[s],c=[];for(let u=1;u4?`Invalid rgba value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:Wn(i[0],i[1],i[2],i[3]),!s))return new He(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new pt(s||`Could not parse color from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"padding":{let i;for(const s of this.args){i=s.evaluate(e);const o=pi.parse(i);if(o)return o}throw new pt(`Could not parse padding from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"numberArray":{let i;for(const s of this.args){i=s.evaluate(e);const o=At.parse(i);if(o)return o}throw new pt(`Could not parse numberArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"colorArray":{let i;for(const s of this.args){i=s.evaluate(e);const o=Ve.parse(i);if(o)return o}throw new pt(`Could not parse colorArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"variableAnchorOffsetCollection":{let i;for(const s of this.args){i=s.evaluate(e);const o=wi.parse(i);if(o)return o}throw new pt(`Could not parse variableAnchorOffsetCollection from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"number":{let i=null;for(const s of this.args){if(i=s.evaluate(e),i===null)return 0;const o=Number(i);if(!isNaN(o))return o}throw new pt(`Could not convert ${JSON.stringify(i)} to number.`)}case"formatted":return Ci.fromString(un(this.args[0].evaluate(e)));case"resolvedImage":return Bi.fromString(un(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return un(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const ec=["Unknown","Point","LineString","Polygon"];class Vo{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?ec[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let i=this._parseColorCache.get(e);return i||(i=He.parse(e),this._parseColorCache.set(e,i)),i}}class dn{constructor(e,i,s=[],o,c=new Ta,u=[]){this.registry=e,this.path=s,this.key=s.map((f=>`[${f}]`)).join(""),this.scope=c,this.errors=u,this.expectedType=o,this._isConstant=i}parse(e,i,s,o,c={}){return i?this.concat(i,s,o)._parse(e,c):this._parse(e,c)}_parse(e,i){function s(o,c,u){return u==="assert"?new Ai(c,[o]):u==="coerce"?new Er(c,[o]):o}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const o=e[0];if(typeof o!="string")return this.error(`Expression name must be a string, but found ${typeof o} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const c=this.registry[o];if(c){let u=c.parse(e,this);if(!u)return null;if(this.expectedType){const f=this.expectedType,g=u.type;if(f.kind!=="string"&&f.kind!=="number"&&f.kind!=="boolean"&&f.kind!=="object"&&f.kind!=="array"||g.kind!=="value"){if(f.kind==="projectionDefinition"&&["string","array"].includes(g.kind)||["color","formatted","resolvedImage"].includes(f.kind)&&["value","string"].includes(g.kind)||["padding","numberArray"].includes(f.kind)&&["value","number","array"].includes(g.kind)||f.kind==="colorArray"&&["value","string","array"].includes(g.kind)||f.kind==="variableAnchorOffsetCollection"&&["value","array"].includes(g.kind))u=s(u,f,i.typeAnnotation||"coerce");else if(this.checkSubtype(f,g))return null}else u=s(u,f,i.typeAnnotation||"assert")}if(!(u instanceof gr)&&u.type.kind!=="resolvedImage"&&this._isConstant(u)){const f=new Vo;try{u=new gr(u.type,u.evaluate(f))}catch(g){return this.error(g.message),null}}return u}return this.error(`Unknown expression "${o}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,i,s){const o=typeof e=="number"?this.path.concat(e):this.path,c=s?this.scope.concat(s):this.scope;return new dn(this.registry,this._isConstant,o,i||null,c,this.errors)}error(e,...i){const s=`${this.key}${i.map((o=>`[${o}]`)).join("")}`;this.errors.push(new vi(s,e))}checkSubtype(e,i){const s=qn(e,i);return s&&this.error(s),s}}class ft{constructor(e,i){this.type=i.type,this.bindings=[].concat(e),this.result=i}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const i of this.bindings)e(i[1]);e(this.result)}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const s=[];for(let c=1;c=s.length)throw new pt(`Array index out of bounds: ${i} > ${s.length-1}.`);if(i!==Math.floor(i))throw new pt(`Array index must be an integer, but found ${i} instead.`);return s[i]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class Ze{constructor(e,i){this.type=We,this.needle=e,this.haystack=i}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const s=i.parse(e[1],1,qe),o=i.parse(e[2],2,qe);return s&&o?zs(s.type,[We,$e,Ce,qi,qe])?new Ze(s,o):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${lt(s.type)} instead`):null}evaluate(e){const i=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!s)return!1;if(!ln(i,["boolean","string","number","null"]))throw new pt(`Expected first argument to be of type boolean, string, number or null, but found ${lt(jt(i))} instead.`);if(!ln(s,["string","array"]))throw new pt(`Expected second argument to be of type array or string, but found ${lt(jt(s))} instead.`);return s.indexOf(i)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class Xn{constructor(e,i,s){this.type=Ce,this.needle=e,this.haystack=i,this.fromIndex=s}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const s=i.parse(e[1],1,qe),o=i.parse(e[2],2,qe);if(!s||!o)return null;if(!zs(s.type,[We,$e,Ce,qi,qe]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${lt(s.type)} instead`);if(e.length===4){const c=i.parse(e[3],3,Ce);return c?new Xn(s,o,c):null}return new Xn(s,o)}evaluate(e){const i=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!ln(i,["boolean","string","number","null"]))throw new pt(`Expected first argument to be of type boolean, string, number or null, but found ${lt(jt(i))} instead.`);let o;if(this.fromIndex&&(o=this.fromIndex.evaluate(e)),ln(s,["string"])){const c=s.indexOf(i,o);return c===-1?-1:[...s.slice(0,c)].length}if(ln(s,["array"]))return s.indexOf(i,o);throw new pt(`Expected second argument to be of type array or string, but found ${lt(jt(s))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class Qe{constructor(e,i,s,o,c,u){this.inputType=e,this.type=i,this.input=s,this.cases=o,this.outputs=c,this.otherwise=u}static parse(e,i){if(e.length<5)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return i.error("Expected an even number of arguments.");let s,o;i.expectedType&&i.expectedType.kind!=="value"&&(o=i.expectedType);const c={},u=[];for(let y=2;yNumber.MAX_SAFE_INTEGER)return S.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof E=="number"&&Math.floor(E)!==E)return S.error("Numeric branch labels must be integer values.");if(s){if(S.checkSubtype(s,jt(E)))return null}else s=jt(E);if(c[String(E)]!==void 0)return S.error("Branch labels must be unique.");c[String(E)]=u.length}const P=i.parse(w,y,o);if(!P)return null;o=o||P.type,u.push(P)}const f=i.parse(e[1],1,qe);if(!f)return null;const g=i.parse(e[e.length-1],e.length-1,o);return g?f.type.kind!=="value"&&i.concat(1).checkSubtype(s,f.type)?null:new Qe(s,o,f,c,u,g):null}evaluate(e){const i=this.input.evaluate(e);return(jt(i)===this.inputType&&this.outputs[this.cases[i]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class Fs{constructor(e,i,s){this.type=e,this.branches=i,this.otherwise=s}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return i.error("Expected an odd number of arguments.");let s;i.expectedType&&i.expectedType.kind!=="value"&&(s=i.expectedType);const o=[];for(let u=1;ui.outputDefined()))&&this.otherwise.outputDefined()}}class Zi{constructor(e,i,s,o){this.type=e,this.input=i,this.beginIndex=s,this.endIndex=o}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const s=i.parse(e[1],1,qe),o=i.parse(e[2],2,Ce);if(!s||!o)return null;if(!zs(s.type,[bi(qe),$e,qe]))return i.error(`Expected first argument to be of type array or string, but found ${lt(s.type)} instead`);if(e.length===4){const c=i.parse(e[3],3,Ce);return c?new Zi(s.type,s,o,c):null}return new Zi(s.type,s,o)}evaluate(e){const i=this.input.evaluate(e),s=this.beginIndex.evaluate(e);let o;if(this.endIndex&&(o=this.endIndex.evaluate(e)),ln(i,["string"]))return[...i].slice(s,o).join("");if(ln(i,["array"]))return i.slice(s,o);throw new pt(`Expected first argument to be of type array or string, but found ${lt(jt(i))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Yn(r,e){const i=r.length-1;let s,o,c=0,u=i,f=0;for(;c<=u;)if(f=Math.floor((c+u)/2),s=r[f],o=r[f+1],s<=e){if(f===i||ee))throw new pt("Input is not a number.");u=f-1}return 0}class Gr{constructor(e,i,s){this.type=e,this.input=i,this.labels=[],this.outputs=[];for(const[o,c]of s)this.labels.push(o),this.outputs.push(c)}static parse(e,i){if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");const s=i.parse(e[1],1,Ce);if(!s)return null;const o=[];let c=null;i.expectedType&&i.expectedType.kind!=="value"&&(c=i.expectedType);for(let u=1;u=f)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',y);const w=i.parse(g,v,c);if(!w)return null;c=c||w.type,o.push([f,w])}return new Gr(c,s,o)}evaluate(e){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(e);const o=this.input.evaluate(e);if(o<=i[0])return s[0].evaluate(e);const c=i.length;return o>=i[c-1]?s[c-1].evaluate(e):s[Yn(i,o)].evaluate(e)}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function tc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Bs,jo,Pu=(function(){if(jo)return Bs;function r(e,i,s,o){this.cx=3*e,this.bx=3*(s-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(o-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=i,this.p2x=s,this.p2y=o}return jo=1,Bs=r,r.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,i){if(i===void 0&&(i=1e-6),e<0)return 0;if(e>1)return 1;for(var s=e,o=0;o<8;o++){var c=this.sampleCurveX(s)-e;if(Math.abs(c)c?f=s:g=s,s=.5*(g-f)+f;return s},solve:function(e,i){return this.sampleCurveY(this.solveCurveX(e,i))}},Bs})(),ic=tc(Pu);class Si{constructor(e,i,s,o,c){this.type=e,this.operator=i,this.interpolation=s,this.input=o,this.labels=[],this.outputs=[];for(const[u,f]of c)this.labels.push(u),this.outputs.push(f)}static interpolationFactor(e,i,s,o){let c=0;if(e.name==="exponential")c=_r(i,e.base,s,o);else if(e.name==="linear")c=_r(i,1,s,o);else if(e.name==="cubic-bezier"){const u=e.controlPoints;c=new ic(u[0],u[1],u[2],u[3]).solve(_r(i,1,s,o))}return c}static parse(e,i){let[s,o,c,...u]=e;if(!Array.isArray(o)||o.length===0)return i.error("Expected an interpolation type expression.",1);if(o[0]==="linear")o={name:"linear"};else if(o[0]==="exponential"){const y=o[1];if(typeof y!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);o={name:"exponential",base:y}}else{if(o[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(o[0])}`,1,0);{const y=o.slice(1);if(y.length!==4||y.some((v=>typeof v!="number"||v<0||v>1)))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);o={name:"cubic-bezier",controlPoints:y}}}if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(c=i.parse(c,2,Ce),!c)return null;const f=[];let g=null;s!=="interpolate-hcl"&&s!=="interpolate-lab"||i.expectedType==Un?i.expectedType&&i.expectedType.kind!=="value"&&(g=i.expectedType):g=Fi;for(let y=0;y=v)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',S);const E=i.parse(w,P,g);if(!E)return null;g=g||E.type,f.push([v,E])}return ir(g,Ce)||ir(g,Sa)||ir(g,Fi)||ir(g,Pa)||ir(g,As)||ir(g,Un)||ir(g,Ds)||ir(g,bi(Ce))?new Si(g,s,o,c,f):i.error(`Type ${lt(g)} is not interpolatable.`)}evaluate(e){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(e);const o=this.input.evaluate(e);if(o<=i[0])return s[0].evaluate(e);const c=i.length;if(o>=i[c-1])return s[c-1].evaluate(e);const u=Yn(i,o),f=Si.interpolationFactor(this.interpolation,o,i[u],i[u+1]),g=s[u].evaluate(e),y=s[u+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return jr(g,y,f);case"color":return He.interpolate(g,y,f);case"padding":return pi.interpolate(g,y,f);case"colorArray":return Ve.interpolate(g,y,f);case"numberArray":return At.interpolate(g,y,f);case"variableAnchorOffsetCollection":return wi.interpolate(g,y,f);case"array":return $n(g,y,f);case"projectionDefinition":return Ti.interpolate(g,y,f)}case"interpolate-hcl":switch(this.type.kind){case"color":return He.interpolate(g,y,f,"hcl");case"colorArray":return Ve.interpolate(g,y,f,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return He.interpolate(g,y,f,"lab");case"colorArray":return Ve.interpolate(g,y,f,"lab")}}}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function _r(r,e,i,s){const o=s-i,c=r-i;return o===0?0:e===1?c/o:(Math.pow(e,c)-1)/(Math.pow(e,o)-1)}const St={color:He.interpolate,number:jr,padding:pi.interpolate,numberArray:At.interpolate,colorArray:Ve.interpolate,variableAnchorOffsetCollection:wi.interpolate,array:$n};class pn{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let s=null;const o=i.expectedType;o&&o.kind!=="value"&&(s=o);const c=[];for(const f of e.slice(1)){const g=i.parse(f,1+c.length,s,void 0,{typeAnnotation:"omit"});if(!g)return null;s=s||g.type,c.push(g)}if(!s)throw new Error("No output type");const u=o&&c.some((f=>qn(o,f.type)));return new pn(u?qe:s,c)}evaluate(e){let i,s=null,o=0;for(const c of this.args)if(o++,s=c.evaluate(e),s&&s instanceof Bi&&!s.available&&(i||(i=s.name),s=null,o===this.args.length&&(s=i)),s!==null)break;return s}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function No(r,e){return r==="=="||r==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Os(r,e,i,s){return s.compare(e,i)===0}function Ft(r,e,i){const s=r!=="=="&&r!=="!=";return class af{constructor(c,u,f){this.type=We,this.lhs=c,this.rhs=u,this.collator=f,this.hasUntypedArgument=c.type.kind==="value"||u.type.kind==="value"}static parse(c,u){if(c.length!==3&&c.length!==4)return u.error("Expected two or three arguments.");const f=c[0];let g=u.parse(c[1],1,qe);if(!g)return null;if(!No(f,g.type))return u.concat(1).error(`"${f}" comparisons are not supported for type '${lt(g.type)}'.`);let y=u.parse(c[2],2,qe);if(!y)return null;if(!No(f,y.type))return u.concat(2).error(`"${f}" comparisons are not supported for type '${lt(y.type)}'.`);if(g.type.kind!==y.type.kind&&g.type.kind!=="value"&&y.type.kind!=="value")return u.error(`Cannot compare types '${lt(g.type)}' and '${lt(y.type)}'.`);s&&(g.type.kind==="value"&&y.type.kind!=="value"?g=new Ai(y.type,[g]):g.type.kind!=="value"&&y.type.kind==="value"&&(y=new Ai(g.type,[y])));let v=null;if(c.length===4){if(g.type.kind!=="string"&&y.type.kind!=="string"&&g.type.kind!=="value"&&y.type.kind!=="value")return u.error("Cannot use collator to compare non-string types.");if(v=u.parse(c[3],3,Es),!v)return null}return new af(g,y,v)}evaluate(c){const u=this.lhs.evaluate(c),f=this.rhs.evaluate(c);if(s&&this.hasUntypedArgument){const g=jt(u),y=jt(f);if(g.kind!==y.kind||g.kind!=="string"&&g.kind!=="number")throw new pt(`Expected arguments for "${r}" to be (string, string) or (number, number), but found (${g.kind}, ${y.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){const g=jt(u),y=jt(f);if(g.kind!=="string"||y.kind!=="string")return e(c,u,f)}return this.collator?i(c,u,f,this.collator.evaluate(c)):e(c,u,f)}eachChild(c){c(this.lhs),c(this.rhs),this.collator&&c(this.collator)}outputDefined(){return!0}}}const rc=Ft("==",(function(r,e,i){return e===i}),Os),Uo=Ft("!=",(function(r,e,i){return e!==i}),(function(r,e,i,s){return!Os(0,e,i,s)})),nc=Ft("<",(function(r,e,i){return e",(function(r,e,i){return e>i}),(function(r,e,i,s){return s.compare(e,i)>0})),Kn=Ft("<=",(function(r,e,i){return e<=i}),(function(r,e,i,s){return s.compare(e,i)<=0})),Da=Ft(">=",(function(r,e,i){return e>=i}),(function(r,e,i,s){return s.compare(e,i)>=0}));class Jn{constructor(e,i,s){this.type=Es,this.locale=s,this.caseSensitive=e,this.diacriticSensitive=i}static parse(e,i){if(e.length!==2)return i.error("Expected one argument.");const s=e[1];if(typeof s!="object"||Array.isArray(s))return i.error("Collator options argument must be an object.");const o=i.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,We);if(!o)return null;const c=i.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,We);if(!c)return null;let u=null;return s.locale&&(u=i.parse(s.locale,1,$e),!u)?null:new Jn(o,c,u)}evaluate(e){return new Bo(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class Go{constructor(e,i,s,o,c){this.type=$e,this.number=e,this.locale=i,this.currency=s,this.minFractionDigits=o,this.maxFractionDigits=c}static parse(e,i){if(e.length!==3)return i.error("Expected two arguments.");const s=i.parse(e[1],1,Ce);if(!s)return null;const o=e[2];if(typeof o!="object"||Array.isArray(o))return i.error("NumberFormat options argument must be an object.");let c=null;if(o.locale&&(c=i.parse(o.locale,1,$e),!c))return null;let u=null;if(o.currency&&(u=i.parse(o.currency,1,$e),!u))return null;let f=null;if(o["min-fraction-digits"]&&(f=i.parse(o["min-fraction-digits"],1,Ce),!f))return null;let g=null;return o["max-fraction-digits"]&&(g=i.parse(o["max-fraction-digits"],1,Ce),!g)?null:new Go(s,c,u,f,g)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Vs{constructor(e){this.type=Cs,this.sections=e}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const s=e[1];if(!Array.isArray(s)&&typeof s=="object")return i.error("First argument must be an image or text section.");const o=[];let c=!1;for(let u=1;u<=e.length-1;++u){const f=e[u];if(c&&typeof f=="object"&&!Array.isArray(f)){c=!1;let g=null;if(f["font-scale"]&&(g=i.parse(f["font-scale"],1,Ce),!g))return null;let y=null;if(f["text-font"]&&(y=i.parse(f["text-font"],1,bi($e)),!y))return null;let v=null;if(f["text-color"]&&(v=i.parse(f["text-color"],1,Fi),!v))return null;let w=null;if(f["vertical-align"]){if(typeof f["vertical-align"]=="string"&&!Su.includes(f["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${f["vertical-align"]}' instead.`);if(w=i.parse(f["vertical-align"],1,$e),!w)return null}const S=o[o.length-1];S.scale=g,S.font=y,S.textColor=v,S.verticalAlign=w}else{const g=i.parse(e[u],1,qe);if(!g)return null;const y=g.type.kind;if(y!=="string"&&y!=="value"&&y!=="null"&&y!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");c=!0,o.push({content:g,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Vs(o)}evaluate(e){return new Ci(this.sections.map((i=>{const s=i.content.evaluate(e);return jt(s)===Gn?new Oo("",s,null,null,null,i.verticalAlign?i.verticalAlign.evaluate(e):null):new Oo(un(s),null,i.scale?i.scale.evaluate(e):null,i.font?i.font.evaluate(e).join(","):null,i.textColor?i.textColor.evaluate(e):null,i.verticalAlign?i.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const i of this.sections)e(i.content),i.scale&&e(i.scale),i.font&&e(i.font),i.textColor&&e(i.textColor),i.verticalAlign&&e(i.verticalAlign)}outputDefined(){return!1}}class Qn{constructor(e){this.type=Gn,this.input=e}static parse(e,i){if(e.length!==2)return i.error("Expected two arguments.");const s=i.parse(e[1],1,$e);return s?new Qn(s):i.error("No image name provided.")}evaluate(e){const i=this.input.evaluate(e),s=Bi.fromString(i);return s&&e.availableImages&&(s.available=e.availableImages.indexOf(i)>-1),s}eachChild(e){e(this.input)}outputDefined(){return!1}}class es{constructor(e){this.type=Ce,this.input=e}static parse(e,i){if(e.length!==2)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);const s=i.parse(e[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?i.error(`Expected argument of type string or array, but found ${lt(s.type)} instead.`):new es(s):null}evaluate(e){const i=this.input.evaluate(e);if(typeof i=="string")return[...i].length;if(Array.isArray(i))return i.length;throw new pt(`Expected value to be of type string or array, but found ${lt(jt(i))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Ht=8192;function sc(r,e){const i=(180+r[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r[1]*Math.PI/360)))/360,o=Math.pow(2,e.z);return[Math.round(i*o*Ht),Math.round(s*o*Ht)]}function ts(r,e){const i=Math.pow(2,e.z);return[(o=(r[0]/Ht+e.x)/i,360*o-180),(s=(r[1]/Ht+e.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,o}function js(r,e){r[0]=Math.min(r[0],e[0]),r[1]=Math.min(r[1],e[1]),r[2]=Math.max(r[2],e[0]),r[3]=Math.max(r[3],e[1])}function fn(r,e){return!(r[0]<=e[0]||r[2]>=e[2]||r[1]<=e[1]||r[3]>=e[3])}function Mu(r,e,i){const s=r[0]-e[0],o=r[1]-e[1],c=r[0]-i[0],u=r[1]-i[1];return s*u-c*o==0&&s*c<=0&&o*u<=0}function za(r,e,i,s){return(o=[s[0]-i[0],s[1]-i[1]])[0]*(c=[e[0]-r[0],e[1]-r[1]])[1]-o[1]*c[0]!=0&&!(!qo(r,e,i,s)||!qo(i,s,r,e));var o,c}function Eu(r,e,i){for(const s of i)for(let o=0;o(o=r)[1]!=(u=f[g+1])[1]>o[1]&&o[0]<(u[0]-c[0])*(o[1]-c[1])/(u[1]-c[1])+c[0]&&(s=!s)}var o,c,u;return s}function ka(r,e){for(const i of e)if(is(r,i))return!0;return!1}function ac(r,e){for(const i of r)if(!is(i,e))return!1;for(let i=0;i0&&f<0||u<0&&f>0}function Zo(r,e,i){const s=[];for(let o=0;oi[2]){const o=.5*s;let c=r[0]-i[0]>o?-s:i[0]-r[0]>o?s:0;c===0&&(c=r[0]-i[2]>o?-s:i[2]-r[0]>o?s:0),r[0]+=c}js(e,r)}function cc(r,e,i,s){const o=Math.pow(2,s.z)*Ht,c=[s.x*Ht,s.y*Ht],u=[];for(const f of r)for(const g of f){const y=[g.x+c[0],g.y+c[1]];lc(y,e,i,o),u.push(y)}return u}function uc(r,e,i,s){const o=Math.pow(2,s.z)*Ht,c=[s.x*Ht,s.y*Ht],u=[];for(const g of r){const y=[];for(const v of g){const w=[v.x+c[0],v.y+c[1]];js(e,w),y.push(w)}u.push(y)}if(e[2]-e[0]<=o/2){(f=e)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const g of u)for(const y of g)lc(y,e,i,o)}var f;return u}class mn{constructor(e,i){this.type=We,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Ur(e[1])){const s=e[1];if(s.type==="FeatureCollection"){const o=[];for(const c of s.features){const{type:u,coordinates:f}=c.geometry;u==="Polygon"&&o.push(f),u==="MultiPolygon"&&o.push(...f)}if(o.length)return new mn(s,{type:"MultiPolygon",coordinates:o})}else if(s.type==="Feature"){const o=s.geometry.type;if(o==="Polygon"||o==="MultiPolygon")return new mn(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new mn(s,s)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(i,s){const o=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],u=i.canonicalID();if(s.type==="Polygon"){const f=Zo(s.coordinates,c,u),g=cc(i.geometry(),o,c,u);if(!fn(o,c))return!1;for(const y of g)if(!is(y,f))return!1}if(s.type==="MultiPolygon"){const f=$o(s.coordinates,c,u),g=cc(i.geometry(),o,c,u);if(!fn(o,c))return!1;for(const y of g)if(!ka(y,f))return!1}return!0})(e,this.geometries);if(e.geometryType()==="LineString")return(function(i,s){const o=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],u=i.canonicalID();if(s.type==="Polygon"){const f=Zo(s.coordinates,c,u),g=uc(i.geometry(),o,c,u);if(!fn(o,c))return!1;for(const y of g)if(!ac(y,f))return!1}if(s.type==="MultiPolygon"){const f=$o(s.coordinates,c,u),g=uc(i.geometry(),o,c,u);if(!fn(o,c))return!1;for(const y of g)if(!oc(y,f))return!1}return!0})(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let hc=class{constructor(r=[],e=(i,s)=>is?1:0){if(this.data=r,this.length=this.data.length,this.compare=e,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(r){this.data.push(r),this._up(this.length++)}pop(){if(this.length===0)return;const r=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),r}peek(){return this.data[0]}_up(r){const{data:e,compare:i}=this,s=e[r];for(;r>0;){const o=r-1>>1,c=e[o];if(i(s,c)>=0)break;e[r]=c,r=o}e[r]=s}_down(r){const{data:e,compare:i}=this,s=this.length>>1,o=e[r];for(;r=0)break;e[r]=e[c],r=c}e[r]=o}};function Wo(r,e,i=0,s=r.length-1,o=dc){for(;s>i;){if(s-i>600){const g=s-i+1,y=e-i+1,v=Math.log(g),w=.5*Math.exp(2*v/3),S=.5*Math.sqrt(v*w*(g-w)/g)*(y-g/2<0?-1:1);Wo(r,e,Math.max(i,Math.floor(e-y*w/g+S)),Math.min(s,Math.floor(e+(g-y)*w/g+S)),o)}const c=r[e];let u=i,f=s;for(rs(r,i,e),o(r[s],c)>0&&rs(r,i,s);u0;)f--}o(r[i],c)===0?rs(r,i,f):(f++,rs(r,f,s)),f<=e&&(i=f+1),e<=f&&(s=f-1)}}function rs(r,e,i){const s=r[e];r[e]=r[i],r[i]=s}function dc(r,e){return re?1:0}function Ra(r,e){if(r.length<=1)return[r];const i=[];let s,o;for(const c of r){const u=Au(c);u!==0&&(c.area=Math.abs(u),o===void 0&&(o=u<0),o===u<0?(s&&i.push(s),s=[c]):s.push(c))}if(s&&i.push(s),e>1)for(let c=0;c1?(y=e[g+1][0],v=e[g+1][1]):P>0&&(y+=w/this.kx*P,v+=S/this.ky*P)),w=this.wrap(i[0]-y)*this.kx,S=(i[1]-v)*this.ky;const E=w*w+S*S;E180;)e-=360;return e}}function mc(r,e){return e[0]-r[0]}function La(r){return r[1]-r[0]+1}function rr(r,e){return r[1]>=r[0]&&r[1]r[1])return[null,null];const i=La(r);if(e){if(i===2)return[r,null];const o=Math.floor(i/2);return[[r[0],r[0]+o],[r[0]+o,r[1]]]}if(i===1)return[r,null];const s=Math.floor(i/2)-1;return[[r[0],r[0]+s],[r[0]+s+1,r[1]]]}function Xo(r,e){if(!rr(e,r.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let s=e[0];s<=e[1];++s)js(i,r[s]);return i}function Yo(r){const e=[1/0,1/0,-1/0,-1/0];for(const i of r)for(const s of i)js(e,s);return e}function Ko(r){return r[0]!==-1/0&&r[1]!==-1/0&&r[2]!==1/0&&r[3]!==1/0}function Ba(r,e,i){if(!Ko(r)||!Ko(e))return NaN;let s=0,o=0;return r[2]e[2]&&(s=r[0]-e[2]),r[1]>e[3]&&(o=r[1]-e[3]),r[3]=s)return s;if(fn(o,c)){if(_c(r,e))return 0}else if(_c(e,r))return 0;let u=1/0;for(const f of r)for(let g=0,y=f.length,v=y-1;g0;){const g=u.pop();if(g[0]>=c)continue;const y=g[1],v=e?50:100;if(La(y)<=v){if(!rr(y,r.length))return NaN;if(e){const w=ku(r,y,i,s);if(isNaN(w)||w===0)return w;c=Math.min(c,w)}else for(let w=y[0];w<=y[1];++w){const S=zu(r[w],i,s);if(c=Math.min(c,S),c===0)return 0}}else{const w=Fa(y,e);rt(u,c,s,r,f,w[0]),rt(u,c,s,r,f,w[1])}}return c}function ja(r,e,i,s,o,c=1/0){let u=Math.min(c,o.distance(r[0],i[0]));if(u===0)return u;const f=new hc([[0,[0,r.length-1],[0,i.length-1]]],mc);for(;f.length>0;){const g=f.pop();if(g[0]>=u)continue;const y=g[1],v=g[2],w=e?50:100,S=s?50:100;if(La(y)<=w&&La(v)<=S){if(!rr(y,r.length)&&rr(v,i.length))return NaN;let P;if(e&&s)P=Du(r,y,i,v,o),u=Math.min(u,P);else if(e&&!s){const E=r.slice(y[0],y[1]+1);for(let C=v[0];C<=v[1];++C)if(P=gn(i[C],E,o),u=Math.min(u,P),u===0)return u}else if(!e&&s){const E=i.slice(v[0],v[1]+1);for(let C=y[0];C<=y[1];++C)if(P=gn(r[C],E,o),u=Math.min(u,P),u===0)return u}else P=gc(r,y,i,v,o),u=Math.min(u,P)}else{const P=Fa(y,e),E=Fa(v,s);Oa(f,u,o,r,i,P[0],E[0]),Oa(f,u,o,r,i,P[0],E[1]),Oa(f,u,o,r,i,P[1],E[0]),Oa(f,u,o,r,i,P[1],E[1])}}return u}function Qo(r){return r.type==="MultiPolygon"?r.coordinates.map((e=>({type:"Polygon",coordinates:e}))):r.type==="MultiLineString"?r.coordinates.map((e=>({type:"LineString",coordinates:e}))):r.type==="MultiPoint"?r.coordinates.map((e=>({type:"Point",coordinates:e}))):[r]}class _n{constructor(e,i){this.type=Ce,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Ur(e[1])){const s=e[1];if(s.type==="FeatureCollection")return new _n(s,s.features.map((o=>Qo(o.geometry))).flat());if(s.type==="Feature")return new _n(s,Qo(s.geometry));if("type"in s&&"coordinates"in s)return new _n(s,Qo(s))}return i.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(i,s){const o=i.geometry(),c=o.flat().map((g=>ts([g.x,g.y],i.canonical)));if(o.length===0)return NaN;const u=new Ho(c[0][1]);let f=1/0;for(const g of s){switch(g.type){case"Point":f=Math.min(f,ja(c,!1,[g.coordinates],!1,u,f));break;case"LineString":f=Math.min(f,ja(c,!1,g.coordinates,!0,u,f));break;case"Polygon":f=Math.min(f,Va(c,!1,g.coordinates,u,f))}if(f===0)return f}return f})(e,this.geometries);if(e.geometryType()==="LineString")return(function(i,s){const o=i.geometry(),c=o.flat().map((g=>ts([g.x,g.y],i.canonical)));if(o.length===0)return NaN;const u=new Ho(c[0][1]);let f=1/0;for(const g of s){switch(g.type){case"Point":f=Math.min(f,ja(c,!0,[g.coordinates],!1,u,f));break;case"LineString":f=Math.min(f,ja(c,!0,g.coordinates,!0,u,f));break;case"Polygon":f=Math.min(f,Va(c,!0,g.coordinates,u,f))}if(f===0)return f}return f})(e,this.geometries);if(e.geometryType()==="Polygon")return(function(i,s){const o=i.geometry();if(o.length===0||o[0].length===0)return NaN;const c=Ra(o,0).map((g=>g.map((y=>y.map((v=>ts([v.x,v.y],i.canonical))))))),u=new Ho(c[0][0][0][1]);let f=1/0;for(const g of s)for(const y of c){switch(g.type){case"Point":f=Math.min(f,Va([g.coordinates],!1,y,u,f));break;case"LineString":f=Math.min(f,Va(g.coordinates,!0,y,u,f));break;case"Polygon":f=Math.min(f,Ru(y,g.coordinates,u,f))}if(f===0)return f}return f})(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Us{constructor(e){this.type=qe,this.key=e}static parse(e,i){if(e.length!==2)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);const s=e[1];return s==null?i.error("Global state property must be defined."):typeof s!="string"?i.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new Us(s)}evaluate(e){var i;const s=(i=e.globals)===null||i===void 0?void 0:i.globalState;return s&&Object.keys(s).length!==0?Rs(s,this.key):null}eachChild(){}outputDefined(){return!1}}const ns={"==":rc,"!=":Uo,">":Iu,"<":nc,">=":Da,"<=":Kn,array:Ai,at:Je,boolean:Ai,case:Fs,coalesce:pn,collator:Jn,format:Vs,image:Qn,in:Ze,"index-of":Xn,interpolate:Si,"interpolate-hcl":Si,"interpolate-lab":Si,length:es,let:ft,literal:gr,match:Qe,number:Ai,"number-format":Go,object:Ai,slice:Zi,step:Gr,string:Ai,"to-boolean":Er,"to-color":Er,"to-number":Er,"to-string":Er,var:Hn,within:mn,distance:_n,"global-state":Us};class $i{constructor(e,i,s,o){this.name=e,this.type=i,this._evaluate=s,this.args=o}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,i){const s=e[0],o=$i.definitions[s];if(!o)return i.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);const c=Array.isArray(o)?o[0]:o.type,u=Array.isArray(o)?[[o[1],o[2]]]:o.overloads,f=u.filter((([y])=>!Array.isArray(y)||y.length===e.length-1));let g=null;for(const[y,v]of f){g=new dn(i.registry,Na,i.path,null,i.scope);const w=[];let S=!1;for(let P=1;P{return S=w,Array.isArray(S)?`(${S.map(lt).join(", ")})`:`(${lt(S.type)}...)`;var S})).join(" | "),v=[];for(let w=1;w{i=e?i&&Na(s):i&&s instanceof gr})),!!i&&Ua(r)&&Ga(r,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Ua(r){if(r instanceof $i&&(r.name==="get"&&r.args.length===1||r.name==="feature-state"||r.name==="has"&&r.args.length===1||r.name==="properties"||r.name==="geometry-type"||r.name==="id"||/^filter-/.test(r.name))||r instanceof mn||r instanceof _n)return!1;let e=!0;return r.eachChild((i=>{e&&!Ua(i)&&(e=!1)})),e}function Gs(r){if(r instanceof $i&&r.name==="feature-state")return!1;let e=!0;return r.eachChild((i=>{e&&!Gs(i)&&(e=!1)})),e}function Ga(r,e){if(r instanceof $i&&e.indexOf(r.name)>=0)return!1;let i=!0;return r.eachChild((s=>{i&&!Ga(s,e)&&(i=!1)})),i}function vc(r){return{result:"success",value:r}}function ss(r){return{result:"error",value:r}}function as(r){return r["property-type"]==="data-driven"||r["property-type"]==="cross-faded-data-driven"}function bc(r){return!!r.expression&&r.expression.parameters.indexOf("zoom")>-1}function tl(r){return!!r.expression&&r.expression.interpolated}function Xe(r){return r instanceof Number?"number":r instanceof String?"string":r instanceof Boolean?"boolean":Array.isArray(r)?"array":r===null?"null":typeof r}function qa(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)&&jt(r)===Mr}function Lu(r){return r}function wc(r,e){const i=r.stops&&typeof r.stops[0][0]=="object",s=i||!(i||r.property!==void 0),o=r.type||(tl(e)?"exponential":"interval"),c=(function(v){switch(v.type){case"color":return He.parse;case"padding":return pi.parse;case"numberArray":return At.parse;case"colorArray":return Ve.parse;default:return null}})(e);if(c&&((r=xi({},r)).stops&&(r.stops=r.stops.map((v=>[v[0],c(v[1])]))),r.default=c(r.default?r.default:e.default)),r.colorSpace&&(u=r.colorSpace)!=="rgb"&&u!=="hcl"&&u!=="lab")throw new Error(`Unknown color space: "${r.colorSpace}"`);var u;const f=(function(v){switch(v){case"exponential":return Tc;case"interval":return Bu;case"categorical":return Fu;case"identity":return Ou;default:throw new Error(`Unknown function type "${v}"`)}})(o);let g,y;if(o==="categorical"){g=Object.create(null);for(const v of r.stops)g[v[0]]=v[1];y=typeof r.stops[0][0]}if(i){const v={},w=[];for(let E=0;EE[0])),evaluate:({zoom:E},C)=>Tc({stops:S,base:r.base},e,E).evaluate(E,C)}}if(s){const v=o==="exponential"?{name:"exponential",base:r.base!==void 0?r.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:Si.interpolationFactor.bind(void 0,v),zoomStops:r.stops.map((w=>w[0])),evaluate:({zoom:w})=>f(r,e,w,g,y)}}return{kind:"source",evaluate(v,w){const S=w&&w.properties?w.properties[r.property]:void 0;return S===void 0?qs(r.default,e.default):f(r,e,S,g,y)}}}function qs(r,e,i){return r!==void 0?r:e!==void 0?e:i!==void 0?i:void 0}function Fu(r,e,i,s,o){return qs(typeof i===o?s[i]:void 0,r.default,e.default)}function Bu(r,e,i){if(Xe(i)!=="number")return qs(r.default,e.default);const s=r.stops.length;if(s===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[s-1][0])return r.stops[s-1][1];const o=Yn(r.stops.map((c=>c[0])),i);return r.stops[o][1]}function Tc(r,e,i){const s=r.base!==void 0?r.base:1;if(Xe(i)!=="number")return qs(r.default,e.default);const o=r.stops.length;if(o===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[o-1][0])return r.stops[o-1][1];const c=Yn(r.stops.map((v=>v[0])),i),u=(function(v,w,S,P){const E=P-S,C=v-S;return E===0?0:w===1?C/E:(Math.pow(w,C)-1)/(Math.pow(w,E)-1)})(i,s,r.stops[c][0],r.stops[c+1][0]),f=r.stops[c][1],g=r.stops[c+1][1],y=St[e.type]||Lu;return typeof f.evaluate=="function"?{evaluate(...v){const w=f.evaluate.apply(void 0,v),S=g.evaluate.apply(void 0,v);if(w!==void 0&&S!==void 0)return y(w,S,u,r.colorSpace)}}:y(f,g,u,r.colorSpace)}function Ou(r,e,i){switch(e.type){case"color":i=He.parse(i);break;case"formatted":i=Ci.fromString(i.toString());break;case"resolvedImage":i=Bi.fromString(i.toString());break;case"padding":i=pi.parse(i);break;case"colorArray":i=Ve.parse(i);break;case"numberArray":i=At.parse(i);break;default:Xe(i)===e.type||e.type==="enum"&&e.values[i]||(i=void 0)}return qs(i,r.default,e.default)}$i.register(ns,{error:[{kind:"error"},[$e],(r,[e])=>{throw new pt(e.evaluate(r))}],typeof:[$e,[qe],(r,[e])=>lt(jt(e.evaluate(r)))],"to-rgba":[bi(Ce,4),[Fi],(r,[e])=>{const[i,s,o,c]=e.evaluate(r).rgb;return[255*i,255*s,255*o,c]}],rgb:[Fi,[Ce,Ce,Ce],yc],rgba:[Fi,[Ce,Ce,Ce,Ce],yc],has:{type:We,overloads:[[[$e],(r,[e])=>xc(e.evaluate(r),r.properties())],[[$e,Mr],(r,[e,i])=>xc(e.evaluate(r),i.evaluate(r))]]},get:{type:qe,overloads:[[[$e],(r,[e])=>el(e.evaluate(r),r.properties())],[[$e,Mr],(r,[e,i])=>el(e.evaluate(r),i.evaluate(r))]]},"feature-state":[qe,[$e],(r,[e])=>el(e.evaluate(r),r.featureState||{})],properties:[Mr,[],r=>r.properties()],"geometry-type":[$e,[],r=>r.geometryType()],id:[qe,[],r=>r.id()],zoom:[Ce,[],r=>r.globals.zoom],"heatmap-density":[Ce,[],r=>r.globals.heatmapDensity||0],elevation:[Ce,[],r=>r.globals.elevation||0],"line-progress":[Ce,[],r=>r.globals.lineProgress||0],accumulated:[qe,[],r=>r.globals.accumulated===void 0?null:r.globals.accumulated],"+":[Ce,yn(Ce),(r,e)=>{let i=0;for(const s of e)i+=s.evaluate(r);return i}],"*":[Ce,yn(Ce),(r,e)=>{let i=1;for(const s of e)i*=s.evaluate(r);return i}],"-":{type:Ce,overloads:[[[Ce,Ce],(r,[e,i])=>e.evaluate(r)-i.evaluate(r)],[[Ce],(r,[e])=>-e.evaluate(r)]]},"/":[Ce,[Ce,Ce],(r,[e,i])=>e.evaluate(r)/i.evaluate(r)],"%":[Ce,[Ce,Ce],(r,[e,i])=>e.evaluate(r)%i.evaluate(r)],ln2:[Ce,[],()=>Math.LN2],pi:[Ce,[],()=>Math.PI],e:[Ce,[],()=>Math.E],"^":[Ce,[Ce,Ce],(r,[e,i])=>Math.pow(e.evaluate(r),i.evaluate(r))],sqrt:[Ce,[Ce],(r,[e])=>Math.sqrt(e.evaluate(r))],log10:[Ce,[Ce],(r,[e])=>Math.log(e.evaluate(r))/Math.LN10],ln:[Ce,[Ce],(r,[e])=>Math.log(e.evaluate(r))],log2:[Ce,[Ce],(r,[e])=>Math.log(e.evaluate(r))/Math.LN2],sin:[Ce,[Ce],(r,[e])=>Math.sin(e.evaluate(r))],cos:[Ce,[Ce],(r,[e])=>Math.cos(e.evaluate(r))],tan:[Ce,[Ce],(r,[e])=>Math.tan(e.evaluate(r))],asin:[Ce,[Ce],(r,[e])=>Math.asin(e.evaluate(r))],acos:[Ce,[Ce],(r,[e])=>Math.acos(e.evaluate(r))],atan:[Ce,[Ce],(r,[e])=>Math.atan(e.evaluate(r))],min:[Ce,yn(Ce),(r,e)=>Math.min(...e.map((i=>i.evaluate(r))))],max:[Ce,yn(Ce),(r,e)=>Math.max(...e.map((i=>i.evaluate(r))))],abs:[Ce,[Ce],(r,[e])=>Math.abs(e.evaluate(r))],round:[Ce,[Ce],(r,[e])=>{const i=e.evaluate(r);return i<0?-Math.round(-i):Math.round(i)}],floor:[Ce,[Ce],(r,[e])=>Math.floor(e.evaluate(r))],ceil:[Ce,[Ce],(r,[e])=>Math.ceil(e.evaluate(r))],"filter-==":[We,[$e,qe],(r,[e,i])=>r.properties()[e.value]===i.value],"filter-id-==":[We,[qe],(r,[e])=>r.id()===e.value],"filter-type-==":[We,[$e],(r,[e])=>r.geometryType()===e.value],"filter-<":[We,[$e,qe],(r,[e,i])=>{const s=r.properties()[e.value],o=i.value;return typeof s==typeof o&&s{const i=r.id(),s=e.value;return typeof i==typeof s&&i":[We,[$e,qe],(r,[e,i])=>{const s=r.properties()[e.value],o=i.value;return typeof s==typeof o&&s>o}],"filter-id->":[We,[qe],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i>s}],"filter-<=":[We,[$e,qe],(r,[e,i])=>{const s=r.properties()[e.value],o=i.value;return typeof s==typeof o&&s<=o}],"filter-id-<=":[We,[qe],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i<=s}],"filter->=":[We,[$e,qe],(r,[e,i])=>{const s=r.properties()[e.value],o=i.value;return typeof s==typeof o&&s>=o}],"filter-id->=":[We,[qe],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i>=s}],"filter-has":[We,[qe],(r,[e])=>e.value in r.properties()],"filter-has-id":[We,[],r=>r.id()!==null&&r.id()!==void 0],"filter-type-in":[We,[bi($e)],(r,[e])=>e.value.indexOf(r.geometryType())>=0],"filter-id-in":[We,[bi(qe)],(r,[e])=>e.value.indexOf(r.id())>=0],"filter-in-small":[We,[$e,bi(qe)],(r,[e,i])=>i.value.indexOf(r.properties()[e.value])>=0],"filter-in-large":[We,[$e,bi(qe)],(r,[e,i])=>(function(s,o,c,u){for(;c<=u;){const f=c+u>>1;if(o[f]===s)return!0;o[f]>s?u=f-1:c=f+1}return!1})(r.properties()[e.value],i.value,0,i.value.length-1)],all:{type:We,overloads:[[[We,We],(r,[e,i])=>e.evaluate(r)&&i.evaluate(r)],[yn(We),(r,e)=>{for(const i of e)if(!i.evaluate(r))return!1;return!0}]]},any:{type:We,overloads:[[[We,We],(r,[e,i])=>e.evaluate(r)||i.evaluate(r)],[yn(We),(r,e)=>{for(const i of e)if(i.evaluate(r))return!0;return!1}]]},"!":[We,[We],(r,[e])=>!e.evaluate(r)],"is-supported-script":[We,[$e],(r,[e])=>{const i=r.globals&&r.globals.isSupportedScript;return!i||i(e.evaluate(r))}],upcase:[$e,[$e],(r,[e])=>e.evaluate(r).toUpperCase()],downcase:[$e,[$e],(r,[e])=>e.evaluate(r).toLowerCase()],concat:[$e,yn(qe),(r,e)=>e.map((i=>un(i.evaluate(r)))).join("")],"resolved-locale":[$e,[Es],(r,[e])=>e.evaluate(r).resolvedLocale()]});class il{constructor(e,i,s){this.expression=e,this._warningHistory={},this._evaluator=new Vo,this._defaultValue=i?(function(o){if(o.type==="color"&&qa(o.default))return new He(0,0,0,0);switch(o.type){case"color":return He.parse(o.default)||null;case"padding":return pi.parse(o.default)||null;case"numberArray":return At.parse(o.default)||null;case"colorArray":return Ve.parse(o.default)||null;case"variableAnchorOffsetCollection":return wi.parse(o.default)||null;case"projectionDefinition":return Ti.parse(o.default)||null;default:return o.default===void 0?null:o.default}})(i):null,this._enumValues=i&&i.type==="enum"?i.values:null,this._globalState=s}evaluateWithoutErrorHandling(e,i,s,o,c,u){return this._globalState&&(e=xn(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=i,this._evaluator.featureState=s,this._evaluator.canonical=o,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=u,this.expression.evaluate(this._evaluator)}evaluate(e,i,s,o,c,u){this._globalState&&(e=xn(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=i||null,this._evaluator.featureState=s||null,this._evaluator.canonical=o,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=u||null;try{const f=this.expression.evaluate(this._evaluator);if(f==null||typeof f=="number"&&f!=f)return this._defaultValue;if(this._enumValues&&!(f in this._enumValues))throw new pt(`Expected value to be one of ${Object.keys(this._enumValues).map((g=>JSON.stringify(g))).join(", ")}, but found ${JSON.stringify(f)} instead.`);return f}catch(f){return this._warningHistory[f.message]||(this._warningHistory[f.message]=!0,typeof console<"u"&&console.warn(f.message)),this._defaultValue}}}function os(r){return Array.isArray(r)&&r.length>0&&typeof r[0]=="string"&&r[0]in ns}function Zs(r,e,i){const s=new dn(ns,Na,[],e?(function(c){const u={color:Fi,string:$e,number:Ce,enum:$e,boolean:We,formatted:Cs,padding:Pa,numberArray:As,colorArray:Un,projectionDefinition:Sa,resolvedImage:Gn,variableAnchorOffsetCollection:Ds};return c.type==="array"?bi(u[c.value]||qe,c.length):u[c.type]})(e):void 0),o=s.parse(r,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return o?vc(new il(o,e,i)):ss(s.errors)}class Za{constructor(e,i,s){this.kind=e,this._styleExpression=i,this.isStateDependent=e!=="constant"&&!Gs(i.expression),this.globalStateRefs=qr(i.expression),this._globalState=s}evaluateWithoutErrorHandling(e,i,s,o,c,u){return this._globalState&&(e=xn(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,i,s,o,c,u)}evaluate(e,i,s,o,c,u){return this._globalState&&(e=xn(e,this._globalState)),this._styleExpression.evaluate(e,i,s,o,c,u)}}class rl{constructor(e,i,s,o,c){this.kind=e,this.zoomStops=s,this._styleExpression=i,this.isStateDependent=e!=="camera"&&!Gs(i.expression),this.globalStateRefs=qr(i.expression),this.interpolationType=o,this._globalState=c}evaluateWithoutErrorHandling(e,i,s,o,c,u){return this._globalState&&(e=xn(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,i,s,o,c,u)}evaluate(e,i,s,o,c,u){return this._globalState&&(e=xn(e,this._globalState)),this._styleExpression.evaluate(e,i,s,o,c,u)}interpolationFactor(e,i,s){return this.interpolationType?Si.interpolationFactor(this.interpolationType,e,i,s):0}}function nl(r,e,i){const s=Zs(r,e,i);if(s.result==="error")return s;const o=s.value.expression,c=Ua(o);if(!c&&!as(e))return ss([new vi("","data expressions not supported")]);const u=Ga(o,["zoom"]);if(!u&&!bc(e))return ss([new vi("","zoom expressions not supported")]);const f=Wa(o);return f||u?f instanceof vi?ss([f]):f instanceof Si&&!tl(e)?ss([new vi("",'"interpolate" expressions cannot be used with this property')]):vc(f?new rl(c?"camera":"composite",s.value,f.labels,f instanceof Si?f.interpolation:void 0,i):new Za(c?"constant":"source",s.value,i)):ss([new vi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class $a{constructor(e,i){this._parameters=e,this._specification=i,xi(this,wc(this._parameters,this._specification))}static deserialize(e){return new $a(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Wa(r){let e=null;if(r instanceof ft)e=Wa(r.result);else if(r instanceof pn){for(const i of r.args)if(e=Wa(i),e)break}else(r instanceof Gr||r instanceof Si)&&r.input instanceof $i&&r.input.name==="zoom"&&(e=r);return e instanceof vi||r.eachChild((i=>{const s=Wa(i);s instanceof vi?e=s:!e&&s?e=new vi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&s&&e!==s&&(e=new vi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function qr(r,e=new Set){return r instanceof Us&&e.add(r.key),r.eachChild((i=>{qr(i,e)})),e}function xn(r,e){const{zoom:i,heatmapDensity:s,elevation:o,lineProgress:c,isSupportedScript:u,accumulated:f}=r??{};return{zoom:i,heatmapDensity:s,elevation:o,lineProgress:c,isSupportedScript:u,accumulated:f,globalState:e}}function sl(r){if(r===!0||r===!1)return!0;if(!Array.isArray(r)||r.length===0)return!1;switch(r[0]){case"has":return r.length>=2&&r[1]!=="$id"&&r[1]!=="$type";case"in":return r.length>=3&&(typeof r[1]!="string"||Array.isArray(r[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return r.length!==3||Array.isArray(r[1])||Array.isArray(r[2]);case"any":case"all":for(const e of r.slice(1))if(!sl(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const Vu={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function $s(r,e){if(r==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};sl(r)||(r=Ws(r));const i=Zs(r,Vu,e);if(i.result==="error")throw new Error(i.value.map((s=>`${s.key}: ${s.message}`)).join(", "));return{filter:(s,o,c)=>i.value.evaluate(s,o,{},c),needGeometry:Sc(r),getGlobalStateRefs:()=>qr(i.value.expression)}}function ju(r,e){return re?1:0}function Sc(r){if(!Array.isArray(r))return!1;if(r[0]==="within"||r[0]==="distance")return!0;for(let e=1;e"||e==="<="||e===">="?Ha(r[1],r[2],e):e==="any"?(i=r.slice(1),["any"].concat(i.map(Ws))):e==="all"?["all"].concat(r.slice(1).map(Ws)):e==="none"?["all"].concat(r.slice(1).map(Ws).map(Hs)):e==="in"?Pc(r[1],r.slice(2)):e==="!in"?Hs(Pc(r[1],r.slice(2))):e==="has"?Ic(r[1]):e!=="!has"||Hs(Ic(r[1]));var i}function Ha(r,e,i){switch(r){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,r,e]}}function Pc(r,e){if(e.length===0)return!1;switch(r){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((i=>typeof i!=typeof e[0]))?["filter-in-large",r,["literal",e.sort(ju)]]:["filter-in-small",r,["literal",e]]}}function Ic(r){switch(r){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",r]}}function Hs(r){return["!",r]}function Xa(r){const e=typeof r;if(e==="number"||e==="boolean"||e==="string"||r==null)return JSON.stringify(r);if(Array.isArray(r)){let o="[";for(const c of r)o+=`${Xa(c)},`;return`${o}]`}const i=Object.keys(r).sort();let s="{";for(let o=0;os.maximum?[new we(e,i,`${i} is greater than the maximum value ${s.maximum}`)]:[]}function Ka(r){const e=r.valueSpec,i=Nt(r.value.type);let s,o,c,u={};const f=i!=="categorical"&&r.value.property===void 0,g=!f,y=Xe(r.value.stops)==="array"&&Xe(r.value.stops[0])==="array"&&Xe(r.value.stops[0][0])==="object",v=Oi({key:r.key,value:r.value,valueSpec:r.styleSpec.function,validateSpec:r.validateSpec,style:r.style,styleSpec:r.styleSpec,objectElementValidators:{stops:function(P){if(i==="identity")return[new we(P.key,P.value,'identity function may not have a "stops" property')];let E=[];const C=P.value;return E=E.concat(Ya({key:P.key,value:C,valueSpec:P.valueSpec,validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec,arrayElementValidator:w})),Xe(C)==="array"&&C.length===0&&E.push(new we(P.key,C,"array must have at least one stop")),E},default:function(P){return P.validateSpec({key:P.key,value:P.value,valueSpec:e,validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec})}}});return i==="identity"&&f&&v.push(new we(r.key,r.value,'missing required property "property"')),i==="identity"||r.value.stops||v.push(new we(r.key,r.value,'missing required property "stops"')),i==="exponential"&&r.valueSpec.expression&&!tl(r.valueSpec)&&v.push(new we(r.key,r.value,"exponential functions not supported")),r.styleSpec.$version>=8&&(g&&!as(r.valueSpec)?v.push(new we(r.key,r.value,"property functions not supported")):f&&!bc(r.valueSpec)&&v.push(new we(r.key,r.value,"zoom functions not supported"))),i!=="categorical"&&!y||r.value.property!==void 0||v.push(new we(r.key,r.value,'"property" property is required')),v;function w(P){let E=[];const C=P.value,D=P.key;if(Xe(C)!=="array")return[new we(D,C,`array expected, ${Xe(C)} found`)];if(C.length!==2)return[new we(D,C,`array length 2 expected, length ${C.length} found`)];if(y){if(Xe(C[0])!=="object")return[new we(D,C,`object expected, ${Xe(C[0])} found`)];if(C[0].zoom===void 0)return[new we(D,C,"object stop key must have zoom")];if(C[0].value===void 0)return[new we(D,C,"object stop key must have value")];if(c&&c>Nt(C[0].zoom))return[new we(D,C[0].zoom,"stop zoom values must appear in ascending order")];Nt(C[0].zoom)!==c&&(c=Nt(C[0].zoom),o=void 0,u={}),E=E.concat(Oi({key:`${D}[0]`,value:C[0],valueSpec:{zoom:{}},validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec,objectElementValidators:{zoom:Xs,value:S}}))}else E=E.concat(S({key:`${D}[0]`,value:C[0],validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec},C));return os(vn(C[1]))?E.concat([new we(`${D}[1]`,C[1],"expressions are not allowed in function stops.")]):E.concat(P.validateSpec({key:`${D}[1]`,value:C[1],valueSpec:e,validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec}))}function S(P,E){const C=Xe(P.value),D=Nt(P.value),F=P.value!==null?P.value:E;if(s){if(C!==s)return[new we(P.key,F,`${C} stop domain type must match previous stop domain type ${s}`)]}else s=C;if(C!=="number"&&C!=="string"&&C!=="boolean")return[new we(P.key,F,"stop domain value must be a number, string, or boolean")];if(C!=="number"&&i!=="categorical"){let q=`number expected, ${C} found`;return as(e)&&i===void 0&&(q+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new we(P.key,F,q)]}return i!=="categorical"||C!=="number"||isFinite(D)&&Math.floor(D)===D?i!=="categorical"&&C==="number"&&o!==void 0&&Dnew we(`${r.key}${s.key}`,r.value,s.message)));const i=e.value.expression||e.value._styleExpression.expression;if(r.expressionContext==="property"&&r.propertyKey==="text-font"&&!i.outputDefined())return[new we(r.key,r.value,`Invalid data expression for "${r.propertyKey}". Output values must be contained as literals within the expression.`)];if(r.expressionContext==="property"&&r.propertyType==="layout"&&!Gs(i))return[new we(r.key,r.value,'"feature-state" data expressions are not supported with layout properties.')];if(r.expressionContext==="filter"&&!Gs(i))return[new we(r.key,r.value,'"feature-state" data expressions are not supported with filters.')];if(r.expressionContext&&r.expressionContext.indexOf("cluster")===0){if(!Ga(i,["zoom","feature-state"]))return[new we(r.key,r.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(r.expressionContext==="cluster-initial"&&!Ua(i))return[new we(r.key,r.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ys(r){const e=r.key,i=r.value,s=Xe(i);return s!=="string"?[new we(e,i,`color expected, ${s} found`)]:He.parse(String(i))?[]:[new we(e,i,`color expected, "${i}" found`)]}function bn(r){const e=r.key,i=r.value,s=r.valueSpec,o=[];return Array.isArray(s.values)?s.values.indexOf(Nt(i))===-1&&o.push(new we(e,i,`expected one of [${s.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(s.values).indexOf(Nt(i))===-1&&o.push(new we(e,i,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(i)} found`)),o}function ls(r){return sl(vn(r.value))?Zr(xi({},r,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Cc(r)}function Cc(r){const e=r.value,i=r.key;if(Xe(e)!=="array")return[new we(i,e,`array expected, ${Xe(e)} found`)];const s=r.styleSpec;let o,c=[];if(e.length<1)return[new we(i,e,"filter array must have at least 1 element")];switch(c=c.concat(bn({key:`${i}[0]`,value:e[0],valueSpec:s.filter_operator,style:r.style,styleSpec:r.styleSpec})),Nt(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&Nt(e[1])==="$type"&&c.push(new we(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&c.push(new we(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(o=Xe(e[1]),o!=="string"&&c.push(new we(`${i}[1]`,e[1],`string expected, ${o} found`)));for(let u=2;u0)n=e._traceSnrPath;else if(e.raw_packet){const r=s(e.raw_packet,a);r&&r.length>0&&(n=r)}return c(t,n)}catch{return null}}function N(e){if((e.payload_type??e.type)!==o.ADVERT||!e.payload)return null;try{const t=d(e.payload),n=y(t);if(!n)return null;const r=n.publicKey.slice(0,2).toUpperCase(),l={...n,prefix:r};let i=null;return n.latitude&&n.longitude&&(i={latitude:n.latitude,longitude:n.longitude,name:n.name||`Node ${r||"??"}`,prefix:r,publicKey:n.publicKey}),{data:l,sourceNode:i}}catch{return null}}function u(e){if(!e)return null;const a=e.trim(),t=/(-?\d+\.?\d*)\s*[,\s]\s*(-?\d+\.?\d*)/,n=a.match(t);if(!n)return null;const r=parseFloat(n[1]),l=parseFloat(n[2]);return isNaN(r)||isNaN(l)||r<-90||r>90||l<-180||l>180||r===0&&l===0?null:{lat:r,lon:l}}function T(e){var t,n;if(!e.decrypted||!((t=e.channelName)!=null&&t.toLowerCase().includes("wardrive")))return null;const a=u(e.text);return a?{latitude:a.lat,longitude:a.lon,name:e.senderName||"Wardrive Ping",prefix:((n=e.senderName)==null?void 0:n.slice(0,2).toUpperCase())||"WD",nodeType:"wardrive"}:null}function C(e,a){const t=e.payload_type??e.type;if(t===o.TRACE){const n=h(e);if(n)return{kind:"trace",data:n,snrValues:n.snrValues}}if(t===o.ADVERT){const n=N(e);if(n)return{kind:"advert",data:n.data,sourceNode:n.sourceNode}}if(t===o.GRP_TXT&&a){const n=u(a.text),r=T(a);return{kind:"grp_txt",decoded:a,wardriveCoords:n,wardriveSourceNode:r}}if(t===o.CONTROL){const n=_(e);if(n)return{kind:"control",data:n}}if(t===o.ANON_REQ){const n=R(e);if(n)return{kind:"anon_req",data:n}}return{kind:"generic"}}function _(e){if((e.payload_type??e.type)!==o.CONTROL||!e.payload)return null;try{const t=d(e.payload);return f(t)}catch{return null}}function R(e){if((e.payload_type??e.type)!==o.ANON_REQ||!e.payload)return null;try{const t=d(e.payload),n=p(t);if(!n)return null;const r=n.senderPublicKey.slice(0,2).toUpperCase();return{...n,prefix:r}}catch{return null}}export{h as a,C as d,u as p}; +import{ax as o,c9 as d,fj as s,fi as c,hg as y,hh as f,hi as p}from"./index-D33fcA3L.js";function h(e){const a=e.payload_type??e.type;if(a!==o.TRACE||!e.payload)return null;try{const t=d(e.payload);let n=[];if(e._traceSnrPath!=null&&e._traceSnrPath.length>0)n=e._traceSnrPath;else if(e.raw_packet){const r=s(e.raw_packet,a);r&&r.length>0&&(n=r)}return c(t,n)}catch{return null}}function N(e){if((e.payload_type??e.type)!==o.ADVERT||!e.payload)return null;try{const t=d(e.payload),n=y(t);if(!n)return null;const r=n.publicKey.slice(0,2).toUpperCase(),l={...n,prefix:r};let i=null;return n.latitude&&n.longitude&&(i={latitude:n.latitude,longitude:n.longitude,name:n.name||`Node ${r||"??"}`,prefix:r,publicKey:n.publicKey}),{data:l,sourceNode:i}}catch{return null}}function u(e){if(!e)return null;const a=e.trim(),t=/(-?\d+\.?\d*)\s*[,\s]\s*(-?\d+\.?\d*)/,n=a.match(t);if(!n)return null;const r=parseFloat(n[1]),l=parseFloat(n[2]);return isNaN(r)||isNaN(l)||r<-90||r>90||l<-180||l>180||r===0&&l===0?null:{lat:r,lon:l}}function T(e){var t,n;if(!e.decrypted||!((t=e.channelName)!=null&&t.toLowerCase().includes("wardrive")))return null;const a=u(e.text);return a?{latitude:a.lat,longitude:a.lon,name:e.senderName||"Wardrive Ping",prefix:((n=e.senderName)==null?void 0:n.slice(0,2).toUpperCase())||"WD",nodeType:"wardrive"}:null}function C(e,a){const t=e.payload_type??e.type;if(t===o.TRACE){const n=h(e);if(n)return{kind:"trace",data:n,snrValues:n.snrValues}}if(t===o.ADVERT){const n=N(e);if(n)return{kind:"advert",data:n.data,sourceNode:n.sourceNode}}if(t===o.GRP_TXT&&a){const n=u(a.text),r=T(a);return{kind:"grp_txt",decoded:a,wardriveCoords:n,wardriveSourceNode:r}}if(t===o.CONTROL){const n=_(e);if(n)return{kind:"control",data:n}}if(t===o.ANON_REQ){const n=R(e);if(n)return{kind:"anon_req",data:n}}return{kind:"generic"}}function _(e){if((e.payload_type??e.type)!==o.CONTROL||!e.payload)return null;try{const t=d(e.payload);return f(t)}catch{return null}}function R(e){if((e.payload_type??e.type)!==o.ANON_REQ||!e.payload)return null;try{const t=d(e.payload),n=p(t);if(!n)return null;const r=n.senderPublicKey.slice(0,2).toUpperCase();return{...n,prefix:r}}catch{return null}}export{h as a,C as d,u as p}; diff --git a/frontend/dist/assets/pencil-55Hza1I4.js b/frontend/dist/assets/pencil-Cg0kSr82.js similarity index 95% rename from frontend/dist/assets/pencil-55Hza1I4.js rename to frontend/dist/assets/pencil-Cg0kSr82.js index 7e2bd11e..fc19023d 100644 --- a/frontend/dist/assets/pencil-55Hza1I4.js +++ b/frontend/dist/assets/pencil-Cg0kSr82.js @@ -1,4 +1,4 @@ -import{e as a}from"./index-C2xvS0Jd.js";/** +import{e as a}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/plus-CH14Vv92.js b/frontend/dist/assets/plus-C0dCjBh9.js similarity index 87% rename from frontend/dist/assets/plus-CH14Vv92.js rename to frontend/dist/assets/plus-C0dCjBh9.js index fbceb360..507795c4 100644 --- a/frontend/dist/assets/plus-CH14Vv92.js +++ b/frontend/dist/assets/plus-C0dCjBh9.js @@ -1,4 +1,4 @@ -import{e}from"./index-C2xvS0Jd.js";/** +import{e}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/primitives-Ctn6pdEU.js b/frontend/dist/assets/primitives-C8YoaXqf.js similarity index 93% rename from frontend/dist/assets/primitives-Ctn6pdEU.js rename to frontend/dist/assets/primitives-C8YoaXqf.js index 89b9cce0..c67151b1 100644 --- a/frontend/dist/assets/primitives-Ctn6pdEU.js +++ b/frontend/dist/assets/primitives-C8YoaXqf.js @@ -1 +1 @@ -import{bR as P,ed as v,bV as $,bU as w,c8 as z,fi as B,fj as M,j as r,r as h,f2 as O,f3 as V,f4 as D}from"./index-C2xvS0Jd.js";function _(t){const e=t&3,s=t>>2&15,n=t>>6&3;return[{bits:"0-1",field:"Route Type",value:$(e),binary:(e&3).toString(2).padStart(2,"0")},{bits:"2-5",field:"Payload Type",value:w(s),binary:(s&15).toString(2).padStart(4,"0")},{bits:"6-7",field:"Version",value:n.toString(),binary:(n&3).toString(2).padStart(2,"0")}]}function U(t){if(!t||t.length<4)return null;const e=P.fromHex(t);if(!e.success||!e.packet)return null;const s=e.packet,n=_(s.header),o=t.slice(0,2);let a=2,i="";s.hasTransportCodes()&&(i=t.slice(2,10),a=10);const l=t.slice(a,a+2),d=a+2,x=d+s.pathLen*2,f=t.slice(d,x),p=t.slice(x),m=v(s),c=Math.floor(a/2),u=Math.floor(d/2);return{packet:s,headerHex:o,headerFields:n,transportCodesHex:i,pathLengthHex:l,pathDataHex:f,payloadHex:p,pathLenByteOffset:c,pathByteOffset:u,payloadStartByte:Math.floor(x/2),decoded:m}}function F(t){if(!t||t.length<8)return null;const e=parseInt(t.slice(0,2),16),s=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16),o=parseInt(t.slice(6,8),16);return isNaN(e)||isNaN(s)||isNaN(n)||isNaN(o)?null:((e|s<<8|n<<16|o<<24)>>>0).toString(16).toUpperCase().padStart(8,"0")}function R(t){return t>=10?"excellent":t>=5?"good":t>=0?"fair":t>=-5?"poor":"critical"}function L(t){if(t._traceSnrPath!=null&&t._traceSnrPath.length>0)return t._traceSnrPath;if(t.raw_packet){const e=t.payload_type??t.type,s=M(t.raw_packet,e);if(s&&s.length>0)return s}return[]}function E(t){if(!t.payload)return null;try{const e=z(t.payload),s=L(t),n=B(e,s);return n?{packet:t,decoded:n,timestamp:t.timestamp??0,hopCount:n.snrValues.length,rssi:t.rssi,snr:t.snr}:null}catch{return null}}function I(t){const e=new Map;for(const s of t){const n=E(s);if(!n)continue;const o=n.decoded.traceTag,a=e.get(o)||[];a.push(n),e.set(o,a)}for(const[s,n]of e)n.sort((o,a)=>o.timestamp-a.timestamp),e.set(s,n);return e}function Q(t,e){if(e.length===0)return{traceTag:t,traceTagValue:0,targetPath:[],targetHopCount:0,observations:[],observationCount:0,firstSeen:0,lastSeen:0,duration:0,isComplete:!1,maxHopsObserved:0,progressPercent:0,bestObservation:null,hopStats:[],linkQuality:null};const s=[...e].sort((c,u)=>c.timestamp-u.timestamp),n=s.reduce((c,u)=>u.hopCount>c.hopCount?u:c,s[0]),o=s[0].timestamp,a=s[s.length-1].timestamp,i=n.decoded.pathHashes,l=i.length,d=n.hopCount,x=n.decoded.isComplete,f=[],p=n.decoded.snrValues;for(let c=0;c0){const c=Math.min(...p),u=Math.max(...p),j=p.reduce((C,T)=>C+T,0)/p.length,S=p.indexOf(c),k=p.indexOf(u);m={minSnr:c,maxSnr:u,avgSnr:j,weakestLinkPosition:S,strongestLinkPosition:k}}return{traceTag:t,traceTagValue:n.decoded.traceTagValue,targetPath:i,targetHopCount:l,observations:s,observationCount:s.length,firstSeen:o,lastSeen:a,duration:a-o,isComplete:x,maxHopsObserved:d,progressPercent:l>0?Math.round(d/l*100):0,bestObservation:n,hopStats:f,linkQuality:m,srcHash:n.packet.src_hash,dstHash:n.packet.dst_hash}}const g={zinc:{stem:"bg-zinc-500/40",dot:"bg-zinc-400",row:"bg-zinc-500/8",text:"text-fg-muted/60",chip:"bg-zinc-500/20 text-fg-muted"},green:{stem:"bg-sys-green/50",dot:"bg-sys-green",row:"bg-sys-green/8",text:"text-sys-green",chip:"bg-sys-green/15 text-sys-green"},amber:{stem:"bg-sys-amber/50",dot:"bg-sys-amber",row:"bg-sys-amber/8",text:"text-sys-amber",chip:"bg-sys-amber/15 text-sys-amber"},red:{stem:"bg-sys-red/50",dot:"bg-sys-red",row:"bg-sys-red/8",text:"text-sys-red",chip:"bg-sys-red/15 text-sys-red"},blue:{stem:"bg-sys-blue/50",dot:"bg-sys-blue",row:"bg-sys-blue/8",text:"text-sys-blue",chip:"bg-sys-blue/15 text-sys-blue"},purple:{stem:"bg-sys-purple/50",dot:"bg-sys-purple",row:"bg-sys-purple/8",text:"text-sys-purple",chip:"bg-sys-purple/15 text-sys-purple"},teal:{stem:"bg-sys-teal/50",dot:"bg-sys-teal",row:"bg-sys-teal/8",text:"text-sys-teal",chip:"bg-sys-teal/15 text-sys-teal"},cyan:{stem:"bg-sys-cyan/50",dot:"bg-sys-cyan",row:"bg-sys-cyan/8",text:"text-sys-cyan",chip:"bg-sys-cyan/15 text-sys-cyan"},sky:{stem:"bg-sys-sky/50",dot:"bg-sys-sky",row:"bg-sys-sky/8",text:"text-sys-sky",chip:"bg-sys-sky/15 text-sys-sky"},pink:{stem:"bg-sys-pink/50",dot:"bg-sys-pink",row:"bg-sys-pink/8",text:"text-sys-pink",chip:"bg-sys-pink/15 text-sys-pink"},orange:{stem:"bg-sys-orange/50",dot:"bg-sys-orange",row:"bg-sys-orange/8",text:"text-sys-orange",chip:"bg-sys-orange/15 text-sys-orange"}};Object.fromEntries(Object.entries(g).map(([t,e])=>[t,e.text]));const b=h.createContext("");function A({prefix:t,children:e}){return r.jsx(b.Provider,{value:t,children:e})}function N(){return h.useContext(b)}function K({children:t,color:e="zinc"}){var s;return r.jsx("span",{className:`inline-flex items-center px-1.5 py-px rounded-full text-[9px] font-mono font-medium leading-tight ${((s=g[e])==null?void 0:s.chip)??g.zinc.chip}`,children:t})}function W({fn:t,value:e,color:s="zinc"}){var a;const n=N(),o=n?`${n}(${t})`:t;return r.jsxs("span",{title:o,className:"inline-flex items-baseline gap-0 font-mono",children:[r.jsx("span",{className:"text-fg-muted/40",children:t}),r.jsx("span",{className:"text-fg-muted/20",children:"("}),e?r.jsx("span",{className:((a=g[s])==null?void 0:a.text)??g.zinc.text,children:e}):r.jsx("span",{className:"text-fg-muted/20",children:"·"}),r.jsx("span",{className:"text-fg-muted/20",children:")"})]})}function q({label:t,children:e,mono:s=!0,padY:n=!1}){const o=N(),a=t.trim(),i=o?`${o}(${a})`:a;return r.jsxs("div",{className:`flex items-center gap-2 ${n?"py-1":"py-0.5"}`,children:[r.jsx("dt",{className:"text-fg-muted shrink-0 w-28 text-right",children:t}),r.jsx("dd",{title:i,className:s?"text-fg-primary break-all":"text-fg-primary",children:e})]})}function G({value:t,className:e}){const s=typeof t=="number"?`0x${t.toString(16).toUpperCase().padStart(2,"0")}`:t.startsWith("0x")?t:`0x${t}`;return r.jsx("span",{className:e??"text-sys-blue",children:s})}function Y({value:t}){const e=typeof t=="number"?t.toString(16).toUpperCase().padStart(2,"0"):t.replace(/^0x/i,"").toUpperCase();return r.jsxs("span",{className:"px-1 py-px rounded bg-zinc-500/15 text-fg-secondary font-mono text-[11px]",children:["0x",e]})}function J({value:t}){return r.jsx("span",{className:"px-1 py-px rounded bg-zinc-500/10 text-fg-muted font-mono text-[10px]",children:t.toString(2).padStart(8,"0")})}function X({raw:t,children:e}){return r.jsxs("span",{className:"inline-flex items-center gap-1.5 flex-wrap",children:[r.jsx("span",{className:"font-mono text-fg-muted",children:t}),r.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),e]})}const y={blue:"text-sys-blue",amber:"text-sys-amber",green:"text-sys-green",teal:"text-sys-teal",purple:"text-sys-purple"};function Z({hops:t,hexPrefix:e,color:s="amber"}){if(t.length===0)return r.jsx("span",{className:"text-fg-muted italic",children:"∅ zero-hop"});const n=y[s]??y.amber;return r.jsxs("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[e&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"font-mono text-fg-muted text-[10px]",children:e}),r.jsx("span",{className:"text-fg-muted/40 text-[10px] mx-0.5",children:"→"})]}),t.map((o,a)=>r.jsxs("span",{className:"inline-flex items-center",children:[a>0&&r.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),r.jsx("span",{className:`inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] ${n}`,children:o.toUpperCase()})]},a))]})}function tt({title:t}){return r.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:t&&r.jsx("p",{className:"text-sys-amber font-semibold mb-0.5",children:t})})}function et(t){if(!t||t<=0)return"never";const e=Math.floor(Date.now()/1e3)-t;return e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)}m ago`:e<86400?`${Math.floor(e/3600)}h ago`:`${Math.floor(e/86400)}d ago`}function st(t){return t>0?"green":"zinc"}function nt({children:t,c:e}){return r.jsx("span",{className:e??"text-fg-muted",children:t})}function rt({tokens:t,label:e="emits"}){const s=t.filter(a=>a.value!=null&&a.value!=="");if(s.length===0)return null;const n=[];let o;for(let a=0;a{var x;if(a.type==="label")return r.jsx("span",{className:"text-[8px] text-fg-muted/40 uppercase tracking-wider font-mono",children:a.group},`g-${i}`);const l=a.token,d=l.raw?`${l.fn}(${l.raw} → ${l.value})`:`${l.fn}(${l.value})`;return r.jsx("span",{title:d,className:`inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono cursor-default ${((x=g[l.color??"zinc"])==null?void 0:x.text)??g.zinc.text}`,children:l.value},a.idx)})})})]})})}export{g as A,J as B,K as C,Y as H,q as K,Z as P,X as R,A as S,W as T,rt as a,Q as b,tt as c,G as d,F as e,nt as f,I as g,et as h,U as p,st as s}; +import{bS as P,ed as v,bW as $,bV as w,c9 as z,fi as B,fj as M,j as r,r as h,f2 as O,f3 as V,f4 as D}from"./index-D33fcA3L.js";function _(t){const e=t&3,s=t>>2&15,n=t>>6&3;return[{bits:"0-1",field:"Route Type",value:$(e),binary:(e&3).toString(2).padStart(2,"0")},{bits:"2-5",field:"Payload Type",value:w(s),binary:(s&15).toString(2).padStart(4,"0")},{bits:"6-7",field:"Version",value:n.toString(),binary:(n&3).toString(2).padStart(2,"0")}]}function U(t){if(!t||t.length<4)return null;const e=P.fromHex(t);if(!e.success||!e.packet)return null;const s=e.packet,n=_(s.header),o=t.slice(0,2);let a=2,i="";s.hasTransportCodes()&&(i=t.slice(2,10),a=10);const l=t.slice(a,a+2),d=a+2,x=d+s.pathLen*2,f=t.slice(d,x),p=t.slice(x),m=v(s),c=Math.floor(a/2),u=Math.floor(d/2);return{packet:s,headerHex:o,headerFields:n,transportCodesHex:i,pathLengthHex:l,pathDataHex:f,payloadHex:p,pathLenByteOffset:c,pathByteOffset:u,payloadStartByte:Math.floor(x/2),decoded:m}}function F(t){if(!t||t.length<8)return null;const e=parseInt(t.slice(0,2),16),s=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16),o=parseInt(t.slice(6,8),16);return isNaN(e)||isNaN(s)||isNaN(n)||isNaN(o)?null:((e|s<<8|n<<16|o<<24)>>>0).toString(16).toUpperCase().padStart(8,"0")}function L(t){return t>=10?"excellent":t>=5?"good":t>=0?"fair":t>=-5?"poor":"critical"}function R(t){if(t._traceSnrPath!=null&&t._traceSnrPath.length>0)return t._traceSnrPath;if(t.raw_packet){const e=t.payload_type??t.type,s=M(t.raw_packet,e);if(s&&s.length>0)return s}return[]}function E(t){if(!t.payload)return null;try{const e=z(t.payload),s=R(t),n=B(e,s);return n?{packet:t,decoded:n,timestamp:t.timestamp??0,hopCount:n.snrValues.length,rssi:t.rssi,snr:t.snr}:null}catch{return null}}function I(t){const e=new Map;for(const s of t){const n=E(s);if(!n)continue;const o=n.decoded.traceTag,a=e.get(o)||[];a.push(n),e.set(o,a)}for(const[s,n]of e)n.sort((o,a)=>o.timestamp-a.timestamp),e.set(s,n);return e}function Q(t,e){if(e.length===0)return{traceTag:t,traceTagValue:0,targetPath:[],targetHopCount:0,observations:[],observationCount:0,firstSeen:0,lastSeen:0,duration:0,isComplete:!1,maxHopsObserved:0,progressPercent:0,bestObservation:null,hopStats:[],linkQuality:null};const s=[...e].sort((c,u)=>c.timestamp-u.timestamp),n=s.reduce((c,u)=>u.hopCount>c.hopCount?u:c,s[0]),o=s[0].timestamp,a=s[s.length-1].timestamp,i=n.decoded.pathHashes,l=i.length,d=n.hopCount,x=n.decoded.isComplete,f=[],p=n.decoded.snrValues;for(let c=0;c0){const c=Math.min(...p),u=Math.max(...p),j=p.reduce((C,T)=>C+T,0)/p.length,S=p.indexOf(c),k=p.indexOf(u);m={minSnr:c,maxSnr:u,avgSnr:j,weakestLinkPosition:S,strongestLinkPosition:k}}return{traceTag:t,traceTagValue:n.decoded.traceTagValue,targetPath:i,targetHopCount:l,observations:s,observationCount:s.length,firstSeen:o,lastSeen:a,duration:a-o,isComplete:x,maxHopsObserved:d,progressPercent:l>0?Math.round(d/l*100):0,bestObservation:n,hopStats:f,linkQuality:m,srcHash:n.packet.src_hash,dstHash:n.packet.dst_hash}}const g={zinc:{stem:"bg-zinc-500/40",dot:"bg-zinc-400",row:"bg-zinc-500/8",text:"text-fg-muted/60",chip:"bg-zinc-500/20 text-fg-muted"},green:{stem:"bg-sys-green/50",dot:"bg-sys-green",row:"bg-sys-green/8",text:"text-sys-green",chip:"bg-sys-green/15 text-sys-green"},amber:{stem:"bg-sys-amber/50",dot:"bg-sys-amber",row:"bg-sys-amber/8",text:"text-sys-amber",chip:"bg-sys-amber/15 text-sys-amber"},red:{stem:"bg-sys-red/50",dot:"bg-sys-red",row:"bg-sys-red/8",text:"text-sys-red",chip:"bg-sys-red/15 text-sys-red"},blue:{stem:"bg-sys-blue/50",dot:"bg-sys-blue",row:"bg-sys-blue/8",text:"text-sys-blue",chip:"bg-sys-blue/15 text-sys-blue"},purple:{stem:"bg-sys-purple/50",dot:"bg-sys-purple",row:"bg-sys-purple/8",text:"text-sys-purple",chip:"bg-sys-purple/15 text-sys-purple"},teal:{stem:"bg-sys-teal/50",dot:"bg-sys-teal",row:"bg-sys-teal/8",text:"text-sys-teal",chip:"bg-sys-teal/15 text-sys-teal"},cyan:{stem:"bg-sys-cyan/50",dot:"bg-sys-cyan",row:"bg-sys-cyan/8",text:"text-sys-cyan",chip:"bg-sys-cyan/15 text-sys-cyan"},sky:{stem:"bg-sys-sky/50",dot:"bg-sys-sky",row:"bg-sys-sky/8",text:"text-sys-sky",chip:"bg-sys-sky/15 text-sys-sky"},pink:{stem:"bg-sys-pink/50",dot:"bg-sys-pink",row:"bg-sys-pink/8",text:"text-sys-pink",chip:"bg-sys-pink/15 text-sys-pink"},orange:{stem:"bg-sys-orange/50",dot:"bg-sys-orange",row:"bg-sys-orange/8",text:"text-sys-orange",chip:"bg-sys-orange/15 text-sys-orange"}};Object.fromEntries(Object.entries(g).map(([t,e])=>[t,e.text]));const b=h.createContext("");function W({prefix:t,children:e}){return r.jsx(b.Provider,{value:t,children:e})}function N(){return h.useContext(b)}function A({children:t,color:e="zinc"}){var s;return r.jsx("span",{className:`inline-flex items-center px-1.5 py-px rounded-full text-[9px] font-mono font-medium leading-tight ${((s=g[e])==null?void 0:s.chip)??g.zinc.chip}`,children:t})}function K({fn:t,value:e,color:s="zinc"}){var a;const n=N(),o=n?`${n}(${t})`:t;return r.jsxs("span",{title:o,className:"inline-flex items-baseline gap-0 font-mono",children:[r.jsx("span",{className:"text-fg-muted/40",children:t}),r.jsx("span",{className:"text-fg-muted/20",children:"("}),e?r.jsx("span",{className:((a=g[s])==null?void 0:a.text)??g.zinc.text,children:e}):r.jsx("span",{className:"text-fg-muted/20",children:"·"}),r.jsx("span",{className:"text-fg-muted/20",children:")"})]})}function q({label:t,children:e,mono:s=!0,padY:n=!1}){const o=N(),a=t.trim(),i=o?`${o}(${a})`:a;return r.jsxs("div",{className:`flex items-center gap-2 ${n?"py-1":"py-0.5"}`,children:[r.jsx("dt",{className:"text-fg-muted shrink-0 w-28 text-right",children:t}),r.jsx("dd",{title:i,className:s?"text-fg-primary break-all":"text-fg-primary",children:e})]})}function G({value:t,className:e}){const s=typeof t=="number"?`0x${t.toString(16).toUpperCase().padStart(2,"0")}`:t.startsWith("0x")?t:`0x${t}`;return r.jsx("span",{className:e??"text-sys-blue",children:s})}function Y({value:t}){const e=typeof t=="number"?t.toString(16).toUpperCase().padStart(2,"0"):t.replace(/^0x/i,"").toUpperCase();return r.jsxs("span",{className:"px-1 py-px rounded bg-zinc-500/15 text-fg-secondary font-mono text-[11px]",children:["0x",e]})}function J({value:t}){return r.jsx("span",{className:"px-1 py-px rounded bg-zinc-500/10 text-fg-muted font-mono text-[10px]",children:t.toString(2).padStart(8,"0")})}function X({raw:t,children:e}){return r.jsxs("span",{className:"inline-flex items-center gap-1.5 flex-wrap",children:[r.jsx("span",{className:"font-mono text-fg-muted",children:t}),r.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),e]})}const y={blue:"text-sys-blue",amber:"text-sys-amber",green:"text-sys-green",teal:"text-sys-teal",purple:"text-sys-purple"};function Z({hops:t,hexPrefix:e,color:s="amber"}){if(t.length===0)return r.jsx("span",{className:"text-fg-muted italic",children:"∅ zero-hop"});const n=y[s]??y.amber;return r.jsxs("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[e&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"font-mono text-fg-muted text-[10px]",children:e}),r.jsx("span",{className:"text-fg-muted/40 text-[10px] mx-0.5",children:"→"})]}),t.map((o,a)=>r.jsxs("span",{className:"inline-flex items-center",children:[a>0&&r.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),r.jsx("span",{className:`inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] ${n}`,children:o.toUpperCase()})]},a))]})}function tt({title:t}){return r.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:t&&r.jsx("p",{className:"text-sys-amber font-semibold mb-0.5",children:t})})}function et(t){if(!t||t<=0)return"never";const e=Math.floor(Date.now()/1e3)-t;return e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)}m ago`:e<86400?`${Math.floor(e/3600)}h ago`:`${Math.floor(e/86400)}d ago`}function st(t){return t>0?"green":"zinc"}function nt({children:t,c:e}){return r.jsx("span",{className:e??"text-fg-muted",children:t})}function rt({tokens:t,label:e="emits"}){const s=t.filter(a=>a.value!=null&&a.value!=="");if(s.length===0)return null;const n=[];let o;for(let a=0;a{var x;if(a.type==="label")return r.jsx("span",{className:"text-[8px] text-fg-muted/40 uppercase tracking-wider font-mono",children:a.group},`g-${i}`);const l=a.token,d=l.raw?`${l.fn}(${l.raw} → ${l.value})`:`${l.fn}(${l.value})`;return r.jsx("span",{title:d,className:`inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono cursor-default ${((x=g[l.color??"zinc"])==null?void 0:x.text)??g.zinc.text}`,children:l.value},a.idx)})})})]})})}export{g as A,J as B,A as C,Y as H,q as K,Z as P,X as R,W as S,K as T,rt as a,Q as b,tt as c,G as d,F as e,nt as f,I as g,et as h,U as p,st as s}; diff --git a/frontend/dist/assets/repeat-CprMAEnr.js b/frontend/dist/assets/repeat-DUo9RRDi.js similarity index 91% rename from frontend/dist/assets/repeat-CprMAEnr.js rename to frontend/dist/assets/repeat-DUo9RRDi.js index 3c09eba1..fb199cd3 100644 --- a/frontend/dist/assets/repeat-CprMAEnr.js +++ b/frontend/dist/assets/repeat-DUo9RRDi.js @@ -1,4 +1,4 @@ -import{e}from"./index-C2xvS0Jd.js";/** +import{e}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/rotate-ccw-Sqgw9a-1.js b/frontend/dist/assets/rotate-ccw-B3SnN1wY.js similarity index 89% rename from frontend/dist/assets/rotate-ccw-Sqgw9a-1.js rename to frontend/dist/assets/rotate-ccw-B3SnN1wY.js index 84f0864f..b6bd325f 100644 --- a/frontend/dist/assets/rotate-ccw-Sqgw9a-1.js +++ b/frontend/dist/assets/rotate-ccw-B3SnN1wY.js @@ -1,4 +1,4 @@ -import{e}from"./index-C2xvS0Jd.js";/** +import{e}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/route-Awj5QSAO.js b/frontend/dist/assets/route-5o9tQENO.js similarity index 94% rename from frontend/dist/assets/route-Awj5QSAO.js rename to frontend/dist/assets/route-5o9tQENO.js index bc83ecd8..5b128b7e 100644 --- a/frontend/dist/assets/route-Awj5QSAO.js +++ b/frontend/dist/assets/route-5o9tQENO.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-C2xvS0Jd.js";/** +import{e as c}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/search-DPGHPI2q.js b/frontend/dist/assets/search-DN8guzpX.js similarity index 87% rename from frontend/dist/assets/search-DPGHPI2q.js rename to frontend/dist/assets/search-DN8guzpX.js index 7c2392ed..4540c72f 100644 --- a/frontend/dist/assets/search-DPGHPI2q.js +++ b/frontend/dist/assets/search-DN8guzpX.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-C2xvS0Jd.js";/** +import{e as c}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/settings-2-OYYe3udS.js b/frontend/dist/assets/settings-2-C5Lvk9-M.js similarity index 89% rename from frontend/dist/assets/settings-2-OYYe3udS.js rename to frontend/dist/assets/settings-2-C5Lvk9-M.js index 7486b631..dfc6023c 100644 --- a/frontend/dist/assets/settings-2-OYYe3udS.js +++ b/frontend/dist/assets/settings-2-C5Lvk9-M.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-C2xvS0Jd.js";/** +import{e as c}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/share-2-DLfTr0kI.js b/frontend/dist/assets/share-2-BAsDxZE2.js similarity index 91% rename from frontend/dist/assets/share-2-DLfTr0kI.js rename to frontend/dist/assets/share-2-BAsDxZE2.js index 90a61e37..97c420f1 100644 --- a/frontend/dist/assets/share-2-DLfTr0kI.js +++ b/frontend/dist/assets/share-2-BAsDxZE2.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-C2xvS0Jd.js";/** +import{e as c}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/shield-DvZvtyKV.js b/frontend/dist/assets/shield-Ceq641wy.js similarity index 91% rename from frontend/dist/assets/shield-DvZvtyKV.js rename to frontend/dist/assets/shield-Ceq641wy.js index bbbaf918..8cbc3c8d 100644 --- a/frontend/dist/assets/shield-DvZvtyKV.js +++ b/frontend/dist/assets/shield-Ceq641wy.js @@ -1,4 +1,4 @@ -import{e}from"./index-C2xvS0Jd.js";/** +import{e}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/shield-check-BB1TbeiZ.js b/frontend/dist/assets/shield-check-DOoXovft.js similarity index 92% rename from frontend/dist/assets/shield-check-BB1TbeiZ.js rename to frontend/dist/assets/shield-check-DOoXovft.js index 8919e91c..d241a623 100644 --- a/frontend/dist/assets/shield-check-BB1TbeiZ.js +++ b/frontend/dist/assets/shield-check-DOoXovft.js @@ -1,4 +1,4 @@ -import{e}from"./index-C2xvS0Jd.js";/** +import{e}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/system-Cf6Lcq9I.js b/frontend/dist/assets/system-4FyMIaL1.js similarity index 91% rename from frontend/dist/assets/system-Cf6Lcq9I.js rename to frontend/dist/assets/system-4FyMIaL1.js index 9ed5a451..70841aa3 100644 --- a/frontend/dist/assets/system-Cf6Lcq9I.js +++ b/frontend/dist/assets/system-4FyMIaL1.js @@ -1 +1 @@ -import{ew as n}from"./index-C2xvS0Jd.js";async function r(){return n("/api/transport_keys")}async function s(o){return n("/api/transport_keys",{method:"POST",body:JSON.stringify(o)})}async function a(o,t){return n(`/api/transport_key/${o}`,{method:"PUT",body:JSON.stringify(t)})}async function c(o){return n(`/api/transport_key/${o}`,{method:"DELETE"})}async function i(){return n("/api/unscoped_flood_policy")}async function y(o){return n("/api/unscoped_flood_policy",{method:"POST",body:JSON.stringify({unscoped_flood_allow:o})})}async function p(o){return n("/api/restart_service",{method:"POST",body:"{}",signal:o})}async function d(){return n("/api/check_pymc_console")}export{i as a,s as b,d as c,c as d,r as g,p as r,y as s,a as u}; +import{ew as n}from"./index-D33fcA3L.js";async function r(){return n("/api/transport_keys")}async function s(o){return n("/api/transport_keys",{method:"POST",body:JSON.stringify(o)})}async function a(o,t){return n(`/api/transport_key/${o}`,{method:"PUT",body:JSON.stringify(t)})}async function c(o){return n(`/api/transport_key/${o}`,{method:"DELETE"})}async function i(){return n("/api/unscoped_flood_policy")}async function y(o){return n("/api/unscoped_flood_policy",{method:"POST",body:JSON.stringify({unscoped_flood_allow:o})})}async function p(o){return n("/api/restart_service",{method:"POST",body:"{}",signal:o})}async function d(){return n("/api/check_pymc_console")}export{i as a,s as b,d as c,c as d,r as g,p as r,y as s,a as u}; diff --git a/frontend/dist/assets/target-BpFOYbOg.js b/frontend/dist/assets/target-B3CHoIpd.js similarity index 94% rename from frontend/dist/assets/target-BpFOYbOg.js rename to frontend/dist/assets/target-B3CHoIpd.js index c55aab7f..616dc60b 100644 --- a/frontend/dist/assets/target-BpFOYbOg.js +++ b/frontend/dist/assets/target-B3CHoIpd.js @@ -1,4 +1,4 @@ -import{e as c}from"./index-C2xvS0Jd.js";/** +import{e as c}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/thermometer-CG3c-cKn.js b/frontend/dist/assets/thermometer-A8kLkazp.js similarity index 88% rename from frontend/dist/assets/thermometer-CG3c-cKn.js rename to frontend/dist/assets/thermometer-A8kLkazp.js index d5129b9d..0e389826 100644 --- a/frontend/dist/assets/thermometer-CG3c-cKn.js +++ b/frontend/dist/assets/thermometer-A8kLkazp.js @@ -1,4 +1,4 @@ -import{e}from"./index-C2xvS0Jd.js";/** +import{e}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/trash-2-Def3YmfN.js b/frontend/dist/assets/trash-2-CUY4NG5t.js similarity index 91% rename from frontend/dist/assets/trash-2-Def3YmfN.js rename to frontend/dist/assets/trash-2-CUY4NG5t.js index 8c9fa9ca..e3d4e442 100644 --- a/frontend/dist/assets/trash-2-Def3YmfN.js +++ b/frontend/dist/assets/trash-2-CUY4NG5t.js @@ -1,4 +1,4 @@ -import{e as a}from"./index-C2xvS0Jd.js";/** +import{e as a}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/use-text-value-CU5Ho7TY.js b/frontend/dist/assets/use-text-value-iYUkduzo.js similarity index 93% rename from frontend/dist/assets/use-text-value-CU5Ho7TY.js rename to frontend/dist/assets/use-text-value-iYUkduzo.js index 89b19a09..70e9fa6f 100644 --- a/frontend/dist/assets/use-text-value-CU5Ho7TY.js +++ b/frontend/dist/assets/use-text-value-iYUkduzo.js @@ -1 +1 @@ -import{bi as c,r as o,aT as s}from"./index-C2xvS0Jd.js";let a=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function f(r){var u,n;let e=(u=r.innerText)!=null?u:"",l=r.cloneNode(!0);if(!c(l))return e;let t=!1;for(let F of l.querySelectorAll('[hidden],[aria-hidden],[role="img"]'))F.remove(),t=!0;let i=t?(n=l.innerText)!=null?n:"":e;return a.test(i)&&(i=i.replace(a,"")),i}function m(r){let u=r.getAttribute("aria-label");if(typeof u=="string")return u.trim();let n=r.getAttribute("aria-labelledby");if(n){let e=n.split(" ").map(l=>{let t=document.getElementById(l);if(t){let i=t.getAttribute("aria-label");return typeof i=="string"?i.trim():f(t).trim()}return null}).filter(Boolean);if(e.length>0)return e.join(", ")}return f(r).trim()}function g(r){let u=o.useRef(""),n=o.useRef("");return s(()=>{let e=r.current;if(!e)return"";let l=e.innerText;if(u.current===l)return n.current;let t=m(e).trim().toLowerCase();return u.current=l,n.current=t,t})}export{g as s}; +import{bj as c,r as o,aU as s}from"./index-D33fcA3L.js";let a=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function f(r){var u,n;let e=(u=r.innerText)!=null?u:"",l=r.cloneNode(!0);if(!c(l))return e;let t=!1;for(let F of l.querySelectorAll('[hidden],[aria-hidden],[role="img"]'))F.remove(),t=!0;let i=t?(n=l.innerText)!=null?n:"":e;return a.test(i)&&(i=i.replace(a,"")),i}function m(r){let u=r.getAttribute("aria-label");if(typeof u=="string")return u.trim();let n=r.getAttribute("aria-labelledby");if(n){let e=n.split(" ").map(l=>{let t=document.getElementById(l);if(t){let i=t.getAttribute("aria-label");return typeof i=="string"?i.trim():f(t).trim()}return null}).filter(Boolean);if(e.length>0)return e.join(", ")}return f(r).trim()}function g(r){let u=o.useRef(""),n=o.useRef("");return s(()=>{let e=r.current;if(!e)return"";let l=e.innerText;if(u.current===l)return n.current;let t=m(e).trim().toLowerCase();return u.current=l,n.current=t,t})}export{g as s}; diff --git a/frontend/dist/assets/use-tree-walker-BpJfMrbM.js b/frontend/dist/assets/use-tree-walker-DjLWwhV9.js similarity index 84% rename from frontend/dist/assets/use-tree-walker-BpJfMrbM.js rename to frontend/dist/assets/use-tree-walker-DjLWwhV9.js index 2a1b74ac..1b1f1f86 100644 --- a/frontend/dist/assets/use-tree-walker-BpJfMrbM.js +++ b/frontend/dist/assets/use-tree-walker-DjLWwhV9.js @@ -1 +1 @@ -import{r as a,bs as d,d0 as E}from"./index-C2xvS0Jd.js";function x(o,{container:e,accept:r,walk:t}){let n=a.useRef(r),c=a.useRef(t);a.useEffect(()=>{n.current=r,c.current=t},[r,t]),d(()=>{if(!e||!o)return;let u=E(e);if(!u)return;let f=n.current,l=c.current,i=Object.assign(p=>f(p),{acceptNode:f}),s=u.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,i,!1);for(;s.nextNode();)l(s.currentNode)},[e,o,n,c])}export{x as F}; +import{r as a,bt as d,d1 as E}from"./index-D33fcA3L.js";function x(o,{container:e,accept:r,walk:t}){let n=a.useRef(r),c=a.useRef(t);a.useEffect(()=>{n.current=r,c.current=t},[r,t]),d(()=>{if(!e||!o)return;let u=E(e);if(!u)return;let f=n.current,l=c.current,i=Object.assign(p=>f(p),{acceptNode:f}),s=u.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,i,!1);for(;s.nextNode();)l(s.currentNode)},[e,o,n,c])}export{x as F}; diff --git a/frontend/dist/assets/useMapViewStore-DnPjO7Qt.js b/frontend/dist/assets/useMapViewStore-Ey8vE9rr.js similarity index 85% rename from frontend/dist/assets/useMapViewStore-DnPjO7Qt.js rename to frontend/dist/assets/useMapViewStore-Ey8vE9rr.js index 0476c173..95fedbe1 100644 --- a/frontend/dist/assets/useMapViewStore-DnPjO7Qt.js +++ b/frontend/dist/assets/useMapViewStore-Ey8vE9rr.js @@ -1,6 +1,6 @@ -import{e as L,r as y,j as T,cZ as E,t as D}from"./index-C2xvS0Jd.js";import{A as H}from"./index-QCPybZMd.js";/** +import{e as L,r as y,j as I,c_ as E,t as D}from"./index-D33fcA3L.js";import{A as H}from"./index-5slIee7x.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 M=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],x=L("house",M),N=400;function P({value:a,format:o,prefix:t,className:n,style:s}){const[e,u]=y.useState("waiting");if(y.useEffect(()=>{const l=setTimeout(()=>u("mounted"),N);return()=>clearTimeout(l)},[]),y.useEffect(()=>{if(e==="mounted"){const l=requestAnimationFrame(()=>u("animating"));return()=>cancelAnimationFrame(l)}},[e]),e==="waiting"){const l=0 .toLocaleString(void 0,o);return T.jsxs("span",{className:n,style:s,children:[t,l]})}return T.jsx(H,{className:n,style:s,format:o,prefix:t,transition:E.numberReveal,children:e==="animating"?a:0})}function O(a,o){let t;try{t=a()}catch{return}return{getItem:s=>{var e;const u=m=>m===null?null:JSON.parse(m,void 0),l=(e=t.getItem(s))!=null?e:null;return l instanceof Promise?l.then(u):u(l)},setItem:(s,e)=>t.setItem(s,JSON.stringify(e,void 0)),removeItem:s=>t.removeItem(s)}}const A=a=>o=>{try{const t=a(o);return t instanceof Promise?t:{then(n){return A(n)(t)},catch(n){return this}}}catch(t){return{then(n){return this},catch(n){return A(n)(t)}}}},R=(a,o)=>(t,n,s)=>{let e={storage:O(()=>localStorage),partialize:r=>r,version:0,merge:(r,h)=>({...h,...r}),...o},u=!1;const l=new Set,m=new Set;let d=e.storage;if(!d)return a((...r)=>{console.warn(`[zustand persist middleware] Unable to update item '${e.name}', the given storage is currently unavailable.`),t(...r)},n,s);const p=()=>{const r=e.partialize({...n()});return d.setItem(e.name,{state:r,version:e.version})},F=s.setState;s.setState=(r,h)=>(F(r,h),p());const v=a((...r)=>(t(...r),p()),n,s);s.getInitialState=()=>v;let g;const I=()=>{var r,h;if(!d)return;u=!1,l.forEach(i=>{var c;return i((c=n())!=null?c:v)});const f=((h=e.onRehydrateStorage)==null?void 0:h.call(e,(r=n())!=null?r:v))||void 0;return A(d.getItem.bind(d))(e.name).then(i=>{if(i)if(typeof i.version=="number"&&i.version!==e.version){if(e.migrate){const c=e.migrate(i.state,i.version);return c instanceof Promise?c.then(S=>[!0,S]):[!0,c]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,i.state];return[!1,void 0]}).then(i=>{var c;const[S,b]=i;if(g=e.merge(b,(c=n())!=null?c:v),t(g,!0),S)return p()}).then(()=>{f==null||f(g,void 0),g=n(),u=!0,m.forEach(i=>i(g))}).catch(i=>{f==null||f(void 0,i)})};return s.persist={setOptions:r=>{e={...e,...r},r.storage&&(d=r.storage)},clearStorage:()=>{d==null||d.removeItem(e.name)},getOptions:()=>e,rehydrate:()=>I(),hasHydrated:()=>u,onHydrate:r=>(l.add(r),()=>{l.delete(r)}),onFinishHydration:r=>(m.add(r),()=>{m.delete(r)})},e.skipHydration||I(),g||v},z=R,w=["repeater","companion","room_server","hubs","direct"],_={showTopology:!1,showNeighborLines:!0,show3DTerrain:!1,showMinCut:!1,showLinkQuality:!1,nodeFilters:[...w]},C=D()(z(a=>({viewState:null,setViewState:o=>a({viewState:o,lastSavedAt:Date.now()}),toggles:_,setToggle:(o,t)=>a(n=>({toggles:{...n.toggles,[o]:t},lastSavedAt:Date.now()})),setToggles:o=>a(t=>({toggles:{...t.toggles,...o},lastSavedAt:Date.now()})),hasAnalyzed:!1,setHasAnalyzed:o=>a({hasAnalyzed:o,lastSavedAt:Date.now()}),modalMapOpen:!1,setModalMapOpen:o=>a({modalMapOpen:o}),lastSavedAt:null,reset:()=>a({viewState:null,toggles:_,hasAnalyzed:!1,lastSavedAt:null})}),{name:"pymc-map-view",version:2,migrate:(a,o)=>{const t=a,n=t.toggles??{};if(o===0){const s=n.nodeFilter;let e=[...w];return s==="hubs"?e=["hubs"]:s==="direct"&&(e=["direct"]),{...t,toggles:{...n,nodeFilters:e,nodeFilter:void 0}}}if(o===1){const s=n.nodeFilters,e=s&&s.length>0?s:[...w];return{...t,toggles:{...n,nodeFilters:e}}}return a},partialize:a=>({viewState:a.viewState,toggles:a.toggles,hasAnalyzed:a.hasAnalyzed,lastSavedAt:a.lastSavedAt})}));export{w as A,P as D,x as H,O as c,z as p,C as u}; + */const M=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],x=L("house",M),N=400;function P({value:a,format:o,prefix:t,className:n,style:s}){const[e,u]=y.useState("waiting");if(y.useEffect(()=>{const l=setTimeout(()=>u("mounted"),N);return()=>clearTimeout(l)},[]),y.useEffect(()=>{if(e==="mounted"){const l=requestAnimationFrame(()=>u("animating"));return()=>cancelAnimationFrame(l)}},[e]),e==="waiting"){const l=0 .toLocaleString(void 0,o);return I.jsxs("span",{className:n,style:s,children:[t,l]})}return I.jsx(H,{className:n,style:s,format:o,prefix:t,transition:E.numberReveal,children:e==="animating"?a:0})}function O(a,o){let t;try{t=a()}catch{return}return{getItem:s=>{var e;const u=m=>m===null?null:JSON.parse(m,void 0),l=(e=t.getItem(s))!=null?e:null;return l instanceof Promise?l.then(u):u(l)},setItem:(s,e)=>t.setItem(s,JSON.stringify(e,void 0)),removeItem:s=>t.removeItem(s)}}const A=a=>o=>{try{const t=a(o);return t instanceof Promise?t:{then(n){return A(n)(t)},catch(n){return this}}}catch(t){return{then(n){return this},catch(n){return A(n)(t)}}}},R=(a,o)=>(t,n,s)=>{let e={storage:O(()=>localStorage),partialize:r=>r,version:0,merge:(r,h)=>({...h,...r}),...o},u=!1;const l=new Set,m=new Set;let d=e.storage;if(!d)return a((...r)=>{console.warn(`[zustand persist middleware] Unable to update item '${e.name}', the given storage is currently unavailable.`),t(...r)},n,s);const p=()=>{const r=e.partialize({...n()});return d.setItem(e.name,{state:r,version:e.version})},F=s.setState;s.setState=(r,h)=>(F(r,h),p());const v=a((...r)=>(t(...r),p()),n,s);s.getInitialState=()=>v;let g;const _=()=>{var r,h;if(!d)return;u=!1,l.forEach(i=>{var c;return i((c=n())!=null?c:v)});const f=((h=e.onRehydrateStorage)==null?void 0:h.call(e,(r=n())!=null?r:v))||void 0;return A(d.getItem.bind(d))(e.name).then(i=>{if(i)if(typeof i.version=="number"&&i.version!==e.version){if(e.migrate){const c=e.migrate(i.state,i.version);return c instanceof Promise?c.then(S=>[!0,S]):[!0,c]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,i.state];return[!1,void 0]}).then(i=>{var c;const[S,b]=i;if(g=e.merge(b,(c=n())!=null?c:v),t(g,!0),S)return p()}).then(()=>{f==null||f(g,void 0),g=n(),u=!0,m.forEach(i=>i(g))}).catch(i=>{f==null||f(void 0,i)})};return s.persist={setOptions:r=>{e={...e,...r},r.storage&&(d=r.storage)},clearStorage:()=>{d==null||d.removeItem(e.name)},getOptions:()=>e,rehydrate:()=>_(),hasHydrated:()=>u,onHydrate:r=>(l.add(r),()=>{l.delete(r)}),onFinishHydration:r=>(m.add(r),()=>{m.delete(r)})},e.skipHydration||_(),g||v},z=R,w=["repeater","companion","room_server","hubs","direct"],T={showTopology:!1,showNeighborLines:!0,show3DTerrain:!1,showMinCut:!1,showLinkQuality:!1,nodeFilters:[...w]},C=D()(z(a=>({viewState:null,setViewState:o=>a({viewState:o,lastSavedAt:Date.now()}),toggles:T,setToggle:(o,t)=>a(n=>({toggles:{...n.toggles,[o]:t},lastSavedAt:Date.now()})),setToggles:o=>a(t=>({toggles:{...t.toggles,...o},lastSavedAt:Date.now()})),hasAnalyzed:!1,setHasAnalyzed:o=>a({hasAnalyzed:o,lastSavedAt:Date.now()}),modalMapOpen:!1,setModalMapOpen:o=>a({modalMapOpen:o}),lastSavedAt:null,reset:()=>a({viewState:null,toggles:T,hasAnalyzed:!1,lastSavedAt:null})}),{name:"pymc-map-view",version:2,migrate:(a,o)=>{const t=a,n=t.toggles??{};if(o===0){const s=n.nodeFilter;let e=[...w];return s==="hubs"?e=["hubs"]:s==="direct"&&(e=["direct"]),{...t,toggles:{...n,nodeFilters:e,nodeFilter:void 0}}}if(o===1){const s=n.nodeFilters,e=s&&s.length>0?s:[...w];return{...t,toggles:{...n,nodeFilters:e}}}return a},partialize:a=>({viewState:a.viewState,toggles:a.toggles,hasAnalyzed:a.hasAnalyzed,lastSavedAt:a.lastSavedAt})}));export{w as A,P as D,x as H,O as c,z as p,C as u}; diff --git a/frontend/dist/assets/usePipelineStore-Do-g28wv.js b/frontend/dist/assets/usePipelineStore-DDHEHTlZ.js similarity index 97% rename from frontend/dist/assets/usePipelineStore-Do-g28wv.js rename to frontend/dist/assets/usePipelineStore-DDHEHTlZ.js index a9e56f6e..cd95d5da 100644 --- a/frontend/dist/assets/usePipelineStore-Do-g28wv.js +++ b/frontend/dist/assets/usePipelineStore-DDHEHTlZ.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C2xvS0Jd.js","assets/index-7uzBcJ1E.css"])))=>i.map(i=>d[i]); -import{cn as ne,co as re,t as ce,at as te,r as ie,_ as U,hk as de,ao as K,fg as W,hl as le}from"./index-C2xvS0Jd.js";import{c as he,m as j,i as E}from"./node-types-BD70swWz.js";function oe(e){if(!e||e.length<6)return null;const l=re(e);if(!l||l.offset>=e.length)return null;const n=e.slice(l.offset);return n.length>=38?n.slice(0,38):n}function q(e,l="name-only"){const n=e.decoded;if(!n||!n.decrypted)return null;if(n.macCorrupted)switch(l){case"strict":return null;case"name-only":return{senderName:n.senderName||null,channelName:n.channelName||null,channelHash:n.channelHash||null,text:null,corrupted:!0,decrypted:!0}}return{senderName:n.senderName||null,channelName:n.channelName||null,channelHash:n.channelHash||null,text:n.text||null,corrupted:!!n.macCorrupted,decrypted:!0}}function J(e,l){var u;const n=new Map,r=new Map;for(const o of e){const _=o.payload_type??o.type;if(_!==ne.GRP_TXT)continue;const g=l.get(o.packet_hash);if(!((u=g==null?void 0:g.decoded)!=null&&u.decrypted)||g.decoded.macCorrupted)continue;const i=o._payloadHexPrefix??oe(o.raw_packet);i&&!n.has(i)&&n.set(i,g);const y=o.payload_length??o.length??0,s=Math.floor((o.timestamp??0)/60),m=`${_}:${y}:${s}`;r.has(m)||r.set(m,g)}return{byPayload:n,byApprox:r}}function pe(e,l,n,r="name-only"){const u=e.payload_type??e.type;if(u!==ne.GRP_TXT)return null;const o=l.get(e.packet_hash);if(o)return q(o,r);const _=e._payloadHexPrefix??oe(e.raw_packet),g=(_?n.byPayload.get(_):null)??n.byApprox.get(`${u}:${e.payload_length??e.length??0}:${Math.floor((e.timestamp??0)/60)}`);return g?q(g,r):null}function ue(e){return e.name||e.node_name||null}function M(e,l,n,r,u,o,_){return{hash:e,type:l,name:n,isRepeater:l==="repeater",isCompanion:l==="companion",confident:r,advertObservations:u,topologyNeighborCount:o,topologyAffinity:_}}const se=Object.freeze(M(null,"unknown",null,!1,0,0,0)),fe=5,ye={disambiguationEnabled:!0,recencyDecayHours:12,zeroHopDecayHours:72,confidenceThreshold:.6,macCorruptedPolicy:"name-only"};function me(e){const l=new Map,n=new Map,r=new Map,u=new Map,o=new Map,_=new Map,g=new Map;for(const[s,m]of Object.entries(e)){const d=he(m).type;l.set(s,d);const f=(s.startsWith("0x")?s.slice(2):s).toLowerCase();n.set(f,s);const T=K(s),H=ue(m);let b=r.get(T);b||(b=[],r.set(T,b)),b.push({hash:s,name:H,type:d});const N=u.get(T)||{repeaters:0,others:0};if(d==="repeater"?N.repeaters++:N.others++,u.set(T,N),H){_.set(s,H);const P=H.toLowerCase(),D=g.get(P)??0,A=m.last_seen??0;(!o.has(P)||A>D)&&(o.set(P,s),g.set(P,A))}}const i=new Set,y=new Set;for(const[s,m]of u)m.repeaters>0&&m.others>0&&i.add(s),(m.repeaters>=2||m.others>=2)&&y.add(s);return{hashToType:l,pubKeyMap:n,prefixIndex:r,crossClassPrefixes:i,sameClassAmbiguous:y,nameToHash:o,hashToName:_}}function Z(e,l,n,r){const u=new Map(l),o=new Map,_=new Map,g=new Map,i=new Map,y=new Map;for(const s of e){const m=s.timestamp??0;if(s._advertSender){const d=n.get(s._advertSender)??s._advertSender,f=y.get(d);(!f||m>f.lastSeen)&&y.set(d,{lastSeen:m,name:s._advertName??(f==null?void 0:f.name)??null,nodeType:s._advertNodeType!=null?j(s._advertNodeType):(f==null?void 0:f.nodeType)??E(s.type??s.payload_type),latitude:s._advertLatitude??(f==null?void 0:f.latitude),longitude:s._advertLongitude??(f==null?void 0:f.longitude)})}else if(s.src_hash&&s.src_hash.length>8){const d=s.src_hash,f=y.get(d);f?m>f.lastSeen&&(f.lastSeen=m):y.set(d,{lastSeen:m,name:null,nodeType:E(s.type??s.payload_type)})}if(s._advertNodeType==null&&!s._advertName)continue;const v=s._advertSender;if(s._advertNodeType!=null){let d;if(v&&(d=n.get(v)),!d&&s.src_hash&&u.has(s.src_hash)&&(d=s.src_hash),d){const f=u.get(d);if(!f||f==="unknown"){const T=j(s._advertNodeType);T!=="unknown"&&u.set(d,T)}}}if(s._advertName&&v){const d=n.get(v)??v,f=s.timestamp??0,T=s._advertName.toLowerCase();if(!r.has(T)){const b=g.get(T)??0;(!o.has(T)||f>b)&&(o.set(T,d),g.set(T,f))}const H=i.get(d)??0;(!_.has(d)||f>H)&&(_.set(d,s._advertName),i.set(d,f))}}for(const[s,m]of y){const v=u.get(s);v&&v!=="unknown"&&m.nodeType==="unknown"&&(m.nodeType=v)}return{extendedHashToType:u,advertNameToHash:o,advertHashToName:_,discoveredNodes:y}}function k(e,l,n,r,u){var y;const o=new Map,_=new Map;if(l.size===0)return{decryptedNameToHash:o,decryptedHashToName:_};const{prefixIndex:g,nameToHash:i}=n;for(const s of e){if((s.type??s.payload_type)!==fe)continue;const v=l.get(s.packet_hash);if(!((y=v==null?void 0:v.decoded)!=null&&y.decrypted)||v.decoded.macCorrupted)continue;const d=v.decoded.senderName;if(!d)continue;const f=s.src_hash;if(!f)continue;const T=K(f);let H=u.get(T);if(!H){const N=g.get(T);(N==null?void 0:N.length)===1&&(H=N[0].hash)}if(!H&&f.length>4&&(H=f),!H)continue;const b=d.toLowerCase();!i.has(b)&&!r.has(b)&&o.set(b,H),_.has(H)||_.set(H,d)}return{decryptedNameToHash:o,decryptedHashToName:_}}function ge(e,l,n,r,u,o,_,g,i,y,s){var $,z,F,G,R,w,S;const m=e.src_hash,v=g==null?void 0:g.get(e.packet_hash),d=(($=v==null?void 0:v.decoded)==null?void 0:$.senderName)??null,{nameToHash:f}=l;if(!m){const a=e.type??e.payload_type,t=E(a),h=e._advertName??null;if(d){const p=d.toLowerCase(),x=f.get(p)??r.get(p)??i.get(p);if(x){const C=n.get(x)??t;return M(x,C,d,!0)}return M(null,t!=="unknown"?t:"companion",d,!1)}if(e._advertSender){const{pubKeyMap:p,hashToName:x}=l,C=p.get(e._advertSender);if(C){const V=n.get(C)??t,ae=x.get(C)??u.get(C)??y.get(C)??null;return M(C,V,ae,!0)}const I=u.get(e._advertSender);if(I){const V=n.get(e._advertSender)??t;return M(e._advertSender,V,I,!0)}const Q=y.get(e._advertSender);if(Q){const V=n.get(e._advertSender)??t;return M(e._advertSender,V,Q,!0)}}if(t!=="unknown")return M(null,t,h,!1);if(e._advertNodeType!=null){const p=j(e._advertNodeType);if(p!=="unknown")return M(null,p,h,!1)}return h?M(null,"unknown",h,!1):se}const T=e.type??e.payload_type??-1,H=e._advertSender?`${m}\0${e._advertSender}`:`${m}\0${T}\0${d??""}`,b=s.get(H);if(b)return b;const N=K(m),{pubKeyMap:P,prefixIndex:D,crossClassPrefixes:A,sameClassAmbiguous:X}=l;let c;if(e._advertSender){const a=P.get(e._advertSender);if(a){const t=n.get(a)??"unknown",h=(z=D.get(N))==null?void 0:z.find(p=>p.hash===a);c=M(a,t,(h==null?void 0:h.name)??null,!0)}else if(e._advertNodeType!=null){const t=j(e._advertNodeType);t!=="unknown"&&(c=M(e._advertSender,t,e._advertName??null,!0))}else{const t=u.get(e._advertSender);if(t){const h=n.get(e._advertSender)??E(e.type??e.payload_type);c=M(e._advertSender,h,t,!0)}}}if(!c&&d){const a=D.get(N),t=a==null?void 0:a.find(h=>{var p;return((p=h.name)==null?void 0:p.toLowerCase())===d.toLowerCase()});if(t){const h=n.get(t.hash)??t.type;c=M(t.hash,h,t.name,!0)}else{const h=d.toLowerCase(),p=f.get(h)??r.get(h)??i.get(h);if(p){const x=n.get(p)??"unknown",C=(F=D.get(K(p)))==null?void 0:F.find(I=>I.hash===p);c=M(p,x,(C==null?void 0:C.name)??d,!0)}}}if(!c&&A.has(N)){const a=E(e.type??e.payload_type);if(a!=="unknown"){const t=(G=D.get(N))==null?void 0:G.find(h=>h.type===a);t&&(c=M(t.hash,a,t.name,!0))}if(!c&&e._advertNodeType!=null){const t=j(e._advertNodeType);if(t!=="unknown"){const h=(R=D.get(N))==null?void 0:R.find(p=>p.type===t);h&&(c=M(h.hash,t,h.name,!0))}}if(!c){const t=D.get(N),h=o.get(N),p=h?t==null?void 0:t.find(I=>I.hash===h):t==null?void 0:t[0],x=p?n.get(p.hash)??p.type:"unknown",C=!!h&&!!p&&p.hash===h;c=M((p==null?void 0:p.hash)??null,x,(p==null?void 0:p.name)??null,C)}}if(!c){const a=o.get(N);if(a){const t=n.get(a)??"unknown",h=(w=D.get(N))==null?void 0:w.find(p=>p.hash===a);c=M(a,t,(h==null?void 0:h.name)??null,!0)}}if(!c&&X.has(N)){const a=(S=D.get(N))==null?void 0:S[0];c=M((a==null?void 0:a.hash)??null,(a==null?void 0:a.type)??"unknown",(a==null?void 0:a.name)??null,!1)}if(!c){const a=D.get(N);if((a==null?void 0:a.length)===1){const t=a[0];c=M(t.hash,t.type,t.name,!0)}else c=M(null,E(T),null,!1)}const O=E(T);if(O!=="unknown"&&O!==c.type&&(c=M(c.hash,O,c.name,c.confident)),c.type==="unknown"&&e._advertNodeType!=null){const a=j(e._advertNodeType);a!=="unknown"&&(c=M(c.hash,a,c.name,c.confident))}if(c.hash){const a=_.get(N);if(a){const t=a.find(h=>h.hash===c.hash);if(t){let h=0;const p=e.original_path??e.forwarded_path;if(p&&Array.isArray(p)&&p.length>0&&t.totalForwarderObservations>0){const x=new Set;for(const C of p){const I=String(C).toUpperCase().slice(0,2);I.length>=2&&I!==N&&x.add(I)}if(x.size>0){let C=0;for(const I of x)t.forwarderPrefixes.has(I)&&C++;h=C/x.size}}c=M(c.hash,c.type,c.name,c.confident,t.advertCount,t.forwarderPrefixes.size,h)}}}if(c.name===null&&c.hash){const a=l.hashToName.get(c.hash)??u.get(c.hash)??y.get(c.hash)??null;a&&(c=M(c.hash,c.type,a,c.confident,c.advertObservations,c.topologyNeighborCount,c.topologyAffinity))}return s.set(H,c),c}const _e={hashToType:new Map,pubKeyMap:new Map,prefixIndex:new Map,crossClassPrefixes:new Set,sameClassAmbiguous:new Set,nameToHash:new Map,hashToName:new Map},ve={byPayload:new Map,byApprox:new Map},L=ce((e,l)=>({config:ye,neighborContext:_e,extendedHashToType:new Map,advertNameToHash:new Map,advertHashToName:new Map,resolverMap:new Map,topologyProfiles:new Map,decryptedNameToHash:new Map,decryptedHashToName:new Map,srcHashResolverMap:new Map,discoveredNodes:new Map,contentInheritanceIndex:ve,_cache:new Map,_neighborFingerprint:"",_resolverFingerprint:"",_advertScanFingerprint:"",_decodedNameFingerprint:"",_inheritanceFingerprint:"",_decodedContentVersion:0,_lastProcessedQuantizedLen:0,resolveSource:n=>{const r=l();return r.config.disambiguationEnabled?ge(n,r.neighborContext,r.extendedHashToType,r.advertNameToHash,r.advertHashToName,r.resolverMap,r.topologyProfiles,Y,r.decryptedNameToHash,r.decryptedHashToName,r._cache):se},getDecodedContent:n=>{const r=l(),u=te.getState().messages;return pe(n,u,r.contentInheritanceIndex,r.config.macCorruptedPolicy)},setConfig:n=>{const r={...l().config,...n};e({config:r,_cache:new Map}),B==null||B()},recompute:(n,r,u)=>{const o=l(),{config:_}=o,g=`${Object.keys(r).length}`;let i=o.neighborContext;const y=g!==o._neighborFingerprint;y&&(i=me(r));const s=n.length>1e5?500:n.length>1e4?200:50,m=Math.floor(n.length/s)*s,v=o._lastProcessedQuantizedLen??0,d=!y&&v>0&&m>v,f=d?v:0,T=`${g}:${m}`;let H=o.extendedHashToType,b=o.advertNameToHash,N=o.advertHashToName,P=o.discoveredNodes;if(T!==o._advertScanFingerprint||y)if(d&&T!==o._advertScanFingerprint&&!y){const w=n.slice(f),S=Z(w,i.hashToType,i.pubKeyMap,i.nameToHash);H=new Map([...o.extendedHashToType,...S.extendedHashToType]),b=new Map([...o.advertNameToHash,...S.advertNameToHash]),N=new Map([...o.advertHashToName,...S.advertHashToName]),P=new Map([...o.discoveredNodes,...S.discoveredNodes])}else{const w=Z(n,i.hashToType,i.pubKeyMap,i.nameToHash);H=w.extendedHashToType,b=w.advertNameToHash,N=w.advertHashToName,P=w.discoveredNodes}const D=`${Object.keys(r).length}:${m}:${i.crossClassPrefixes.size}:${_.recencyDecayHours}:${_.zeroHopDecayHours}`;let A=o.resolverMap,X=o.topologyProfiles;if(D!==o._resolverFingerprint){const w=de(n,r,{recencyDecayHours:_.recencyDecayHours,zeroHopDecayHours:_.zeroHopDecayHours});A=w.resolver,X=w.topologyProfiles}const c=Math.floor(u.size/20)*20,O=`${m}:${c}:${D}`;let $=o.decryptedNameToHash,z=o.decryptedHashToName;if(O!==o._decodedNameFingerprint)if(d&&!y){const w=n.slice(f),S=k(w,u,i,b,A);$=new Map([...o.decryptedNameToHash,...S.decryptedNameToHash]),z=new Map([...o.decryptedHashToName,...S.decryptedHashToName])}else{const w=k(n,u,i,b,A);$=w.decryptedNameToHash,z=w.decryptedHashToName}{const w=[];for(const[S,a]of P)if(a.name===null){const t=i.hashToName.get(S)??N.get(S)??z.get(S)??null;t&&w.push([S,t])}if(w.length>0){P=new Map(P);for(const[S,a]of w){const t=P.get(S);P.set(S,{...t,name:a})}}}const F=new Map(A);for(const[w,S]of $){const a=K(S),t=i.prefixIndex.get(a);if(!t||t.length<=1)continue;const h=t.find(p=>{var x;return((x=p.name)==null?void 0:x.toLowerCase())===w});h&&F.get(a)!==h.hash&&F.set(a,h.hash)}for(const[w,S]of b){const a=K(S),t=i.prefixIndex.get(a);if(!t||t.length<=1)continue;const h=t.find(p=>{var x;return((x=p.name)==null?void 0:x.toLowerCase())===w});h&&F.get(a)!==h.hash&&F.set(a,h.hash)}const G=`${m}:${c}`;let R=o.contentInheritanceIndex;if(G!==o._inheritanceFingerprint)if(d&&!y){const w=n.slice(f),S=J(w,u),a=new Map([...S.byPayload,...o.contentInheritanceIndex.byPayload]),t=new Map([...S.byApprox,...o.contentInheritanceIndex.byApprox]);R={byPayload:a,byApprox:t}}else R=J(n,u);le(F),W.active&&W.emit("pipeline:disambig:recompute",{packets:n.length,neighbors:Object.keys(r).length,decoded:u.size,incremental:d}),e({neighborContext:i,extendedHashToType:H,advertNameToHash:b,advertHashToName:N,resolverMap:A,topologyProfiles:X,decryptedNameToHash:$,decryptedHashToName:z,srcHashResolverMap:F,discoveredNodes:P,contentInheritanceIndex:R,_cache:new Map,_neighborFingerprint:g,_resolverFingerprint:D,_advertScanFingerprint:T,_decodedNameFingerprint:O,_inheritanceFingerprint:G,_decodedContentVersion:o._decodedContentVersion+1,_lastProcessedQuantizedLen:m})}}));let Y=new Map,B=null;function ee(e,l){var u,o,_,g;if(!(l!=null&&l.public_key))return e;const n=l.public_key.toLowerCase(),r=n.startsWith("0x")?n.slice(2):n;for(const i of Object.keys(e))if((i.startsWith("0x")?i.slice(2):i).toLowerCase()===r)return e;return{...e,[l.public_key]:{name:l.node_name,node_name:l.node_name,contact_type:"Repeater",is_repeater:!0,last_seen:Date.now()/1e3,latitude:(o=(u=l.config)==null?void 0:u.repeater)==null?void 0:o.latitude,longitude:(g=(_=l.config)==null?void 0:_.repeater)==null?void 0:g.longitude,zero_hop:!0}}}if(typeof window<"u"){let e=function(){if(!n)return 150;const i=n.useStore.getState().packets.length;return i>1e5?1e3:i>1e4?500:150},l=function(){g&&clearTimeout(g),g=setTimeout(()=>{var d;if(g=null,!n||!r)return;const i=n.useStore.getState(),y=r.useDecodedMessagesStore.getState(),s=i.packets,m=ee(((d=i.stats)==null?void 0:d.neighbors)??{},i.stats),v=y.stableMessages;L.getState().recompute(s,m,v)},e())},n=null,r=null,u=[],o,_=new Map,g=null;B=l,setTimeout(()=>{U(()=>import("./index-C2xvS0Jd.js").then(i=>i.ho),__vite__mapDeps([0,1])).then(i=>{var m,v;n=i,i.useStore.subscribe(d=>{var H,b;const f=d.packets!==u,T=((H=d.stats)==null?void 0:H.neighbors)!==o;(f||T)&&(u=d.packets,o=(b=d.stats)==null?void 0:b.neighbors,l())});const y=i.useStore.getState();u=y.packets,o=(m=y.stats)==null?void 0:m.neighbors;const s=ee(((v=y.stats)==null?void 0:v.neighbors)??{},y.stats);(u.length>0||Object.keys(s).length>0)&&L.getState().recompute(u,s,new Map)}),U(()=>import("./index-C2xvS0Jd.js").then(i=>i.hm),__vite__mapDeps([0,1])).then(i=>{r=i,Y=i.useDecodedMessagesStore.getState().messages,i.useDecodedMessagesStore.subscribe(y=>{y.messages!==Y&&(Y=y.messages),y.stableMessages!==_&&(_=y.stableMessages,l())})})},0)}const Te=L;function He(){return L(e=>e.resolveSource)}function Se(){return L(e=>e.neighborContext)}function Me(){return L(e=>e.topologyProfiles)}function be(){return L(e=>e.advertNameToHash)}function xe(){const e=L(r=>r.getDecodedContent),l=L(r=>r._decodedContentVersion),n=te(r=>r._successCount);return ie.useCallback(r=>e(r),[e,l,n])}function Ce(){return L(e=>e.config)}function Pe(){return L(e=>e.srcHashResolverMap)}function De(){return L(e=>e.discoveredNodes)}export{ye as DEFAULT_PIPELINE_CONFIG,be as useAdvertNameToHash,De as useDiscoveredNodes,xe as useGetDecodedContent,Se as useNeighborContext,Ce as usePipelineConfig,Te as usePipelineStore,He as useResolveSource,Pe as useSrcHashResolverMap,Me as useTopologyProfiles}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-D33fcA3L.js","assets/index-7uzBcJ1E.css"])))=>i.map(i=>d[i]); +import{co as ne,cp as re,t as ce,at as te,r as ie,_ as U,hk as de,ao as K,fg as W,hl as le}from"./index-D33fcA3L.js";import{c as he,m as j,i as E}from"./node-types-BoqnL0Eg.js";function oe(e){if(!e||e.length<6)return null;const l=re(e);if(!l||l.offset>=e.length)return null;const n=e.slice(l.offset);return n.length>=38?n.slice(0,38):n}function q(e,l="name-only"){const n=e.decoded;if(!n||!n.decrypted)return null;if(n.macCorrupted)switch(l){case"strict":return null;case"name-only":return{senderName:n.senderName||null,channelName:n.channelName||null,channelHash:n.channelHash||null,text:null,corrupted:!0,decrypted:!0}}return{senderName:n.senderName||null,channelName:n.channelName||null,channelHash:n.channelHash||null,text:n.text||null,corrupted:!!n.macCorrupted,decrypted:!0}}function J(e,l){var u;const n=new Map,r=new Map;for(const o of e){const _=o.payload_type??o.type;if(_!==ne.GRP_TXT)continue;const g=l.get(o.packet_hash);if(!((u=g==null?void 0:g.decoded)!=null&&u.decrypted)||g.decoded.macCorrupted)continue;const i=o._payloadHexPrefix??oe(o.raw_packet);i&&!n.has(i)&&n.set(i,g);const y=o.payload_length??o.length??0,s=Math.floor((o.timestamp??0)/60),m=`${_}:${y}:${s}`;r.has(m)||r.set(m,g)}return{byPayload:n,byApprox:r}}function pe(e,l,n,r="name-only"){const u=e.payload_type??e.type;if(u!==ne.GRP_TXT)return null;const o=l.get(e.packet_hash);if(o)return q(o,r);const _=e._payloadHexPrefix??oe(e.raw_packet),g=(_?n.byPayload.get(_):null)??n.byApprox.get(`${u}:${e.payload_length??e.length??0}:${Math.floor((e.timestamp??0)/60)}`);return g?q(g,r):null}function ue(e){return e.name||e.node_name||null}function M(e,l,n,r,u,o,_){return{hash:e,type:l,name:n,isRepeater:l==="repeater",isCompanion:l==="companion",confident:r,advertObservations:u,topologyNeighborCount:o,topologyAffinity:_}}const se=Object.freeze(M(null,"unknown",null,!1,0,0,0)),fe=5,ye={disambiguationEnabled:!0,recencyDecayHours:12,zeroHopDecayHours:72,confidenceThreshold:.6,macCorruptedPolicy:"name-only"};function me(e){const l=new Map,n=new Map,r=new Map,u=new Map,o=new Map,_=new Map,g=new Map;for(const[s,m]of Object.entries(e)){const d=he(m).type;l.set(s,d);const f=(s.startsWith("0x")?s.slice(2):s).toLowerCase();n.set(f,s);const T=K(s),H=ue(m);let b=r.get(T);b||(b=[],r.set(T,b)),b.push({hash:s,name:H,type:d});const N=u.get(T)||{repeaters:0,others:0};if(d==="repeater"?N.repeaters++:N.others++,u.set(T,N),H){_.set(s,H);const P=H.toLowerCase(),D=g.get(P)??0,A=m.last_seen??0;(!o.has(P)||A>D)&&(o.set(P,s),g.set(P,A))}}const i=new Set,y=new Set;for(const[s,m]of u)m.repeaters>0&&m.others>0&&i.add(s),(m.repeaters>=2||m.others>=2)&&y.add(s);return{hashToType:l,pubKeyMap:n,prefixIndex:r,crossClassPrefixes:i,sameClassAmbiguous:y,nameToHash:o,hashToName:_}}function Z(e,l,n,r){const u=new Map(l),o=new Map,_=new Map,g=new Map,i=new Map,y=new Map;for(const s of e){const m=s.timestamp??0;if(s._advertSender){const d=n.get(s._advertSender)??s._advertSender,f=y.get(d);(!f||m>f.lastSeen)&&y.set(d,{lastSeen:m,name:s._advertName??(f==null?void 0:f.name)??null,nodeType:s._advertNodeType!=null?j(s._advertNodeType):(f==null?void 0:f.nodeType)??E(s.type??s.payload_type),latitude:s._advertLatitude??(f==null?void 0:f.latitude),longitude:s._advertLongitude??(f==null?void 0:f.longitude)})}else if(s.src_hash&&s.src_hash.length>8){const d=s.src_hash,f=y.get(d);f?m>f.lastSeen&&(f.lastSeen=m):y.set(d,{lastSeen:m,name:null,nodeType:E(s.type??s.payload_type)})}if(s._advertNodeType==null&&!s._advertName)continue;const v=s._advertSender;if(s._advertNodeType!=null){let d;if(v&&(d=n.get(v)),!d&&s.src_hash&&u.has(s.src_hash)&&(d=s.src_hash),d){const f=u.get(d);if(!f||f==="unknown"){const T=j(s._advertNodeType);T!=="unknown"&&u.set(d,T)}}}if(s._advertName&&v){const d=n.get(v)??v,f=s.timestamp??0,T=s._advertName.toLowerCase();if(!r.has(T)){const b=g.get(T)??0;(!o.has(T)||f>b)&&(o.set(T,d),g.set(T,f))}const H=i.get(d)??0;(!_.has(d)||f>H)&&(_.set(d,s._advertName),i.set(d,f))}}for(const[s,m]of y){const v=u.get(s);v&&v!=="unknown"&&m.nodeType==="unknown"&&(m.nodeType=v)}return{extendedHashToType:u,advertNameToHash:o,advertHashToName:_,discoveredNodes:y}}function k(e,l,n,r,u){var y;const o=new Map,_=new Map;if(l.size===0)return{decryptedNameToHash:o,decryptedHashToName:_};const{prefixIndex:g,nameToHash:i}=n;for(const s of e){if((s.type??s.payload_type)!==fe)continue;const v=l.get(s.packet_hash);if(!((y=v==null?void 0:v.decoded)!=null&&y.decrypted)||v.decoded.macCorrupted)continue;const d=v.decoded.senderName;if(!d)continue;const f=s.src_hash;if(!f)continue;const T=K(f);let H=u.get(T);if(!H){const N=g.get(T);(N==null?void 0:N.length)===1&&(H=N[0].hash)}if(!H&&f.length>4&&(H=f),!H)continue;const b=d.toLowerCase();!i.has(b)&&!r.has(b)&&o.set(b,H),_.has(H)||_.set(H,d)}return{decryptedNameToHash:o,decryptedHashToName:_}}function ge(e,l,n,r,u,o,_,g,i,y,s){var $,z,F,G,R,w,S;const m=e.src_hash,v=g==null?void 0:g.get(e.packet_hash),d=(($=v==null?void 0:v.decoded)==null?void 0:$.senderName)??null,{nameToHash:f}=l;if(!m){const a=e.type??e.payload_type,t=E(a),h=e._advertName??null;if(d){const p=d.toLowerCase(),x=f.get(p)??r.get(p)??i.get(p);if(x){const C=n.get(x)??t;return M(x,C,d,!0)}return M(null,t!=="unknown"?t:"companion",d,!1)}if(e._advertSender){const{pubKeyMap:p,hashToName:x}=l,C=p.get(e._advertSender);if(C){const V=n.get(C)??t,ae=x.get(C)??u.get(C)??y.get(C)??null;return M(C,V,ae,!0)}const I=u.get(e._advertSender);if(I){const V=n.get(e._advertSender)??t;return M(e._advertSender,V,I,!0)}const Q=y.get(e._advertSender);if(Q){const V=n.get(e._advertSender)??t;return M(e._advertSender,V,Q,!0)}}if(t!=="unknown")return M(null,t,h,!1);if(e._advertNodeType!=null){const p=j(e._advertNodeType);if(p!=="unknown")return M(null,p,h,!1)}return h?M(null,"unknown",h,!1):se}const T=e.type??e.payload_type??-1,H=e._advertSender?`${m}\0${e._advertSender}`:`${m}\0${T}\0${d??""}`,b=s.get(H);if(b)return b;const N=K(m),{pubKeyMap:P,prefixIndex:D,crossClassPrefixes:A,sameClassAmbiguous:X}=l;let c;if(e._advertSender){const a=P.get(e._advertSender);if(a){const t=n.get(a)??"unknown",h=(z=D.get(N))==null?void 0:z.find(p=>p.hash===a);c=M(a,t,(h==null?void 0:h.name)??null,!0)}else if(e._advertNodeType!=null){const t=j(e._advertNodeType);t!=="unknown"&&(c=M(e._advertSender,t,e._advertName??null,!0))}else{const t=u.get(e._advertSender);if(t){const h=n.get(e._advertSender)??E(e.type??e.payload_type);c=M(e._advertSender,h,t,!0)}}}if(!c&&d){const a=D.get(N),t=a==null?void 0:a.find(h=>{var p;return((p=h.name)==null?void 0:p.toLowerCase())===d.toLowerCase()});if(t){const h=n.get(t.hash)??t.type;c=M(t.hash,h,t.name,!0)}else{const h=d.toLowerCase(),p=f.get(h)??r.get(h)??i.get(h);if(p){const x=n.get(p)??"unknown",C=(F=D.get(K(p)))==null?void 0:F.find(I=>I.hash===p);c=M(p,x,(C==null?void 0:C.name)??d,!0)}}}if(!c&&A.has(N)){const a=E(e.type??e.payload_type);if(a!=="unknown"){const t=(G=D.get(N))==null?void 0:G.find(h=>h.type===a);t&&(c=M(t.hash,a,t.name,!0))}if(!c&&e._advertNodeType!=null){const t=j(e._advertNodeType);if(t!=="unknown"){const h=(R=D.get(N))==null?void 0:R.find(p=>p.type===t);h&&(c=M(h.hash,t,h.name,!0))}}if(!c){const t=D.get(N),h=o.get(N),p=h?t==null?void 0:t.find(I=>I.hash===h):t==null?void 0:t[0],x=p?n.get(p.hash)??p.type:"unknown",C=!!h&&!!p&&p.hash===h;c=M((p==null?void 0:p.hash)??null,x,(p==null?void 0:p.name)??null,C)}}if(!c){const a=o.get(N);if(a){const t=n.get(a)??"unknown",h=(w=D.get(N))==null?void 0:w.find(p=>p.hash===a);c=M(a,t,(h==null?void 0:h.name)??null,!0)}}if(!c&&X.has(N)){const a=(S=D.get(N))==null?void 0:S[0];c=M((a==null?void 0:a.hash)??null,(a==null?void 0:a.type)??"unknown",(a==null?void 0:a.name)??null,!1)}if(!c){const a=D.get(N);if((a==null?void 0:a.length)===1){const t=a[0];c=M(t.hash,t.type,t.name,!0)}else c=M(null,E(T),null,!1)}const O=E(T);if(O!=="unknown"&&O!==c.type&&(c=M(c.hash,O,c.name,c.confident)),c.type==="unknown"&&e._advertNodeType!=null){const a=j(e._advertNodeType);a!=="unknown"&&(c=M(c.hash,a,c.name,c.confident))}if(c.hash){const a=_.get(N);if(a){const t=a.find(h=>h.hash===c.hash);if(t){let h=0;const p=e.original_path??e.forwarded_path;if(p&&Array.isArray(p)&&p.length>0&&t.totalForwarderObservations>0){const x=new Set;for(const C of p){const I=String(C).toUpperCase().slice(0,2);I.length>=2&&I!==N&&x.add(I)}if(x.size>0){let C=0;for(const I of x)t.forwarderPrefixes.has(I)&&C++;h=C/x.size}}c=M(c.hash,c.type,c.name,c.confident,t.advertCount,t.forwarderPrefixes.size,h)}}}if(c.name===null&&c.hash){const a=l.hashToName.get(c.hash)??u.get(c.hash)??y.get(c.hash)??null;a&&(c=M(c.hash,c.type,a,c.confident,c.advertObservations,c.topologyNeighborCount,c.topologyAffinity))}return s.set(H,c),c}const _e={hashToType:new Map,pubKeyMap:new Map,prefixIndex:new Map,crossClassPrefixes:new Set,sameClassAmbiguous:new Set,nameToHash:new Map,hashToName:new Map},ve={byPayload:new Map,byApprox:new Map},L=ce((e,l)=>({config:ye,neighborContext:_e,extendedHashToType:new Map,advertNameToHash:new Map,advertHashToName:new Map,resolverMap:new Map,topologyProfiles:new Map,decryptedNameToHash:new Map,decryptedHashToName:new Map,srcHashResolverMap:new Map,discoveredNodes:new Map,contentInheritanceIndex:ve,_cache:new Map,_neighborFingerprint:"",_resolverFingerprint:"",_advertScanFingerprint:"",_decodedNameFingerprint:"",_inheritanceFingerprint:"",_decodedContentVersion:0,_lastProcessedQuantizedLen:0,resolveSource:n=>{const r=l();return r.config.disambiguationEnabled?ge(n,r.neighborContext,r.extendedHashToType,r.advertNameToHash,r.advertHashToName,r.resolverMap,r.topologyProfiles,Y,r.decryptedNameToHash,r.decryptedHashToName,r._cache):se},getDecodedContent:n=>{const r=l(),u=te.getState().messages;return pe(n,u,r.contentInheritanceIndex,r.config.macCorruptedPolicy)},setConfig:n=>{const r={...l().config,...n};e({config:r,_cache:new Map}),B==null||B()},recompute:(n,r,u)=>{const o=l(),{config:_}=o,g=`${Object.keys(r).length}`;let i=o.neighborContext;const y=g!==o._neighborFingerprint;y&&(i=me(r));const s=n.length>1e5?500:n.length>1e4?200:50,m=Math.floor(n.length/s)*s,v=o._lastProcessedQuantizedLen??0,d=!y&&v>0&&m>v,f=d?v:0,T=`${g}:${m}`;let H=o.extendedHashToType,b=o.advertNameToHash,N=o.advertHashToName,P=o.discoveredNodes;if(T!==o._advertScanFingerprint||y)if(d&&T!==o._advertScanFingerprint&&!y){const w=n.slice(f),S=Z(w,i.hashToType,i.pubKeyMap,i.nameToHash);H=new Map([...o.extendedHashToType,...S.extendedHashToType]),b=new Map([...o.advertNameToHash,...S.advertNameToHash]),N=new Map([...o.advertHashToName,...S.advertHashToName]),P=new Map([...o.discoveredNodes,...S.discoveredNodes])}else{const w=Z(n,i.hashToType,i.pubKeyMap,i.nameToHash);H=w.extendedHashToType,b=w.advertNameToHash,N=w.advertHashToName,P=w.discoveredNodes}const D=`${Object.keys(r).length}:${m}:${i.crossClassPrefixes.size}:${_.recencyDecayHours}:${_.zeroHopDecayHours}`;let A=o.resolverMap,X=o.topologyProfiles;if(D!==o._resolverFingerprint){const w=de(n,r,{recencyDecayHours:_.recencyDecayHours,zeroHopDecayHours:_.zeroHopDecayHours});A=w.resolver,X=w.topologyProfiles}const c=Math.floor(u.size/20)*20,O=`${m}:${c}:${D}`;let $=o.decryptedNameToHash,z=o.decryptedHashToName;if(O!==o._decodedNameFingerprint)if(d&&!y){const w=n.slice(f),S=k(w,u,i,b,A);$=new Map([...o.decryptedNameToHash,...S.decryptedNameToHash]),z=new Map([...o.decryptedHashToName,...S.decryptedHashToName])}else{const w=k(n,u,i,b,A);$=w.decryptedNameToHash,z=w.decryptedHashToName}{const w=[];for(const[S,a]of P)if(a.name===null){const t=i.hashToName.get(S)??N.get(S)??z.get(S)??null;t&&w.push([S,t])}if(w.length>0){P=new Map(P);for(const[S,a]of w){const t=P.get(S);P.set(S,{...t,name:a})}}}const F=new Map(A);for(const[w,S]of $){const a=K(S),t=i.prefixIndex.get(a);if(!t||t.length<=1)continue;const h=t.find(p=>{var x;return((x=p.name)==null?void 0:x.toLowerCase())===w});h&&F.get(a)!==h.hash&&F.set(a,h.hash)}for(const[w,S]of b){const a=K(S),t=i.prefixIndex.get(a);if(!t||t.length<=1)continue;const h=t.find(p=>{var x;return((x=p.name)==null?void 0:x.toLowerCase())===w});h&&F.get(a)!==h.hash&&F.set(a,h.hash)}const G=`${m}:${c}`;let R=o.contentInheritanceIndex;if(G!==o._inheritanceFingerprint)if(d&&!y){const w=n.slice(f),S=J(w,u),a=new Map([...S.byPayload,...o.contentInheritanceIndex.byPayload]),t=new Map([...S.byApprox,...o.contentInheritanceIndex.byApprox]);R={byPayload:a,byApprox:t}}else R=J(n,u);le(F),W.active&&W.emit("pipeline:disambig:recompute",{packets:n.length,neighbors:Object.keys(r).length,decoded:u.size,incremental:d}),e({neighborContext:i,extendedHashToType:H,advertNameToHash:b,advertHashToName:N,resolverMap:A,topologyProfiles:X,decryptedNameToHash:$,decryptedHashToName:z,srcHashResolverMap:F,discoveredNodes:P,contentInheritanceIndex:R,_cache:new Map,_neighborFingerprint:g,_resolverFingerprint:D,_advertScanFingerprint:T,_decodedNameFingerprint:O,_inheritanceFingerprint:G,_decodedContentVersion:o._decodedContentVersion+1,_lastProcessedQuantizedLen:m})}}));let Y=new Map,B=null;function ee(e,l){var u,o,_,g;if(!(l!=null&&l.public_key))return e;const n=l.public_key.toLowerCase(),r=n.startsWith("0x")?n.slice(2):n;for(const i of Object.keys(e))if((i.startsWith("0x")?i.slice(2):i).toLowerCase()===r)return e;return{...e,[l.public_key]:{name:l.node_name,node_name:l.node_name,contact_type:"Repeater",is_repeater:!0,last_seen:Date.now()/1e3,latitude:(o=(u=l.config)==null?void 0:u.repeater)==null?void 0:o.latitude,longitude:(g=(_=l.config)==null?void 0:_.repeater)==null?void 0:g.longitude,zero_hop:!0}}}if(typeof window<"u"){let e=function(){if(!n)return 150;const i=n.useStore.getState().packets.length;return i>1e5?1e3:i>1e4?500:150},l=function(){g&&clearTimeout(g),g=setTimeout(()=>{var d;if(g=null,!n||!r)return;const i=n.useStore.getState(),y=r.useDecodedMessagesStore.getState(),s=i.packets,m=ee(((d=i.stats)==null?void 0:d.neighbors)??{},i.stats),v=y.stableMessages;L.getState().recompute(s,m,v)},e())},n=null,r=null,u=[],o,_=new Map,g=null;B=l,setTimeout(()=>{U(()=>import("./index-D33fcA3L.js").then(i=>i.ho),__vite__mapDeps([0,1])).then(i=>{var m,v;n=i,i.useStore.subscribe(d=>{var H,b;const f=d.packets!==u,T=((H=d.stats)==null?void 0:H.neighbors)!==o;(f||T)&&(u=d.packets,o=(b=d.stats)==null?void 0:b.neighbors,l())});const y=i.useStore.getState();u=y.packets,o=(m=y.stats)==null?void 0:m.neighbors;const s=ee(((v=y.stats)==null?void 0:v.neighbors)??{},y.stats);(u.length>0||Object.keys(s).length>0)&&L.getState().recompute(u,s,new Map)}),U(()=>import("./index-D33fcA3L.js").then(i=>i.hm),__vite__mapDeps([0,1])).then(i=>{r=i,Y=i.useDecodedMessagesStore.getState().messages,i.useDecodedMessagesStore.subscribe(y=>{y.messages!==Y&&(Y=y.messages),y.stableMessages!==_&&(_=y.stableMessages,l())})})},0)}const Te=L;function He(){return L(e=>e.resolveSource)}function Se(){return L(e=>e.neighborContext)}function Me(){return L(e=>e.topologyProfiles)}function be(){return L(e=>e.advertNameToHash)}function xe(){const e=L(r=>r.getDecodedContent),l=L(r=>r._decodedContentVersion),n=te(r=>r._successCount);return ie.useCallback(r=>e(r),[e,l,n])}function Ce(){return L(e=>e.config)}function Pe(){return L(e=>e.srcHashResolverMap)}function De(){return L(e=>e.discoveredNodes)}export{ye as DEFAULT_PIPELINE_CONFIG,be as useAdvertNameToHash,De as useDiscoveredNodes,xe as useGetDecodedContent,Se as useNeighborContext,Ce as usePipelineConfig,Te as usePipelineStore,He as useResolveSource,Pe as useSrcHashResolverMap,Me as useTopologyProfiles}; diff --git a/frontend/dist/assets/useReplayTick-DbeD1_Sw.js b/frontend/dist/assets/useReplayTick-BbXJoz75.js similarity index 97% rename from frontend/dist/assets/useReplayTick-DbeD1_Sw.js rename to frontend/dist/assets/useReplayTick-BbXJoz75.js index fe8f1c3a..f84fb0b6 100644 --- a/frontend/dist/assets/useReplayTick-DbeD1_Sw.js +++ b/frontend/dist/assets/useReplayTick-BbXJoz75.js @@ -1 +1 @@ -import{t as A,r as S}from"./index-C2xvS0Jd.js";import{p as T}from"./payload-detail-BAEvS7Pl.js";function E(t){const r=[];for(const n of t){if(n.is_outgoing)continue;const o=T(n.text);o&&r.push({lat:o.lat,lon:o.lon,timestampS:n.timestamp,senderName:n.sender_name??"Unknown",pathHops:n.path_hops,pathSnr:n.path_snr,pathRssi:n.path_rssi,msgSnr:n.msg_snr})}return r.sort((n,o)=>n.timestampS-o.timestampS),r}function v(t,r){if(t.length===0)return null;if(r<=t[0].timestampS)return{lo:0,hi:0,t:0};if(r>=t[t.length-1].timestampS){const i=t.length-1;return{lo:i,hi:i,t:0}}let n=0,o=t.length-1;for(;n>1;t[i].timestampS<=r?n=i:o=i}const e=t[o].timestampS-t[n].timestampS,a=e>0?(r-t[n].timestampS)/e:0;return{lo:n,hi:o,t:a}}function x(t,r,n,o,e){const a=e*e,i=a*e;return .5*(2*r+(-t+n)*e+(2*t-5*r+4*n-o)*a+(-t+3*r-3*n+o)*i)}function I(t,r,n,o){const e=Math.PI/180,a=(o-r)*e,i=Math.sin(a)*Math.cos(n*e),u=Math.cos(t*e)*Math.sin(n*e)-Math.sin(t*e)*Math.cos(n*e)*Math.cos(a);return(Math.atan2(i,u)*180/Math.PI+360)%360}function b(t,r){if(t.length===0)return null;const n=v(t,r);if(!n)return null;const{lo:o,hi:e,t:a}=n;if(o===e)return{lat:t[o].lat,lon:t[o].lon,bearing:null};const i=Math.max(0,o-1),u=o,h=e,g=Math.min(t.length-1,e+1),s=t[i],c=t[u],f=t[h],d=t[g];let m,p;i===u&&h===g?(m=c.lat+(f.lat-c.lat)*a,p=c.lon+(f.lon-c.lon)*a):(m=x(s.lat,c.lat,f.lat,d.lat,a),p=x(s.lon,c.lon,f.lon,d.lon,a));const P=I(c.lat,c.lon,f.lat,f.lon);return{lat:m,lon:p,bearing:P}}function $(t,r){const n=[];for(const e of t){if(e.timestampS>r)break;n.push([e.lon,e.lat])}const o=b(t,r);if(o&&n.length>0){const e=n[n.length-1];(Math.abs(e[0]-o.lon)>1e-7||Math.abs(e[1]-o.lat)>1e-7)&&n.push([o.lon,o.lat])}return n}function R(t,r){if(t.length===0)return null;if(t.length===1)return{lat:t[0].lat,lon:t[0].lon,bearing:null};const n=t.length-1,o=Math.max(0,Math.min(n,r)),e=Math.floor(o),a=Math.min(e+1,n),i=o-e;if(e===a)return{lat:t[e].lat,lon:t[e].lon,bearing:null};const u=Math.max(0,e-1),h=Math.min(n,a+1),g=t[u],s=t[e],c=t[a],f=t[h];let d,m;u===e&&a===h?(d=s.lat+(c.lat-s.lat)*i,m=s.lon+(c.lon-s.lon)*i):(d=x(g.lat,s.lat,c.lat,f.lat,i),m=x(g.lon,s.lon,c.lon,f.lon,i));const p=I(s.lat,s.lon,c.lat,c.lon);return{lat:d,lon:m,bearing:p}}function F(t,r){if(t.length===0)return[];const n=[],o=R(t,r);o&&n.push([o.lon,o.lat]);const e=Math.ceil(Math.max(0,r));for(let a=e;a0?`${n}:${String(o).padStart(2,"0")}:${String(e).padStart(2,"0")}`:`${o}:${String(e).padStart(2,"0")}`}const K=[2,5,10,20],M={isActive:!1,ownerKey:null,samples:[],isPlaying:!1,speed:5,currentIdx:0,currentTimeS:0,timeRange:{start:0,end:0}},l=A((t,r)=>({...M,startRewind:(n,o)=>{if(n.length<2){t({...M});return}const e=n.length-1,a={start:n[0].timestampS,end:n[e].timestampS};t({isActive:!0,ownerKey:o,samples:n,isPlaying:!0,speed:5,currentIdx:e,currentTimeS:a.end,timeRange:a})},togglePlay:()=>{var a;const{isPlaying:n,currentIdx:o,samples:e}=r();if(n)t({isPlaying:!1});else if(o<=0){const i=e.length-1;t({isPlaying:!0,currentIdx:i,currentTimeS:((a=e[i])==null?void 0:a.timestampS)??0})}else t({isPlaying:!0})},pause:()=>t({isPlaying:!1}),setSpeed:n=>t({speed:n}),seek:n=>{const{samples:o}=r();if(o.length<2)return;const e=o.length-1,a=Math.max(0,Math.min(e,n*e));t({currentIdx:a,currentTimeS:y(o,a)})},stopRewind:()=>t({...M}),tick:n=>{const{isPlaying:o,speed:e,currentIdx:a,samples:i}=r();if(!o||i.length<2)return;const u=e*(n/1e3),h=a-u;h<=0?t({currentIdx:0,currentTimeS:i[0].timestampS,isPlaying:!1}):t({currentIdx:h,currentTimeS:y(i,h)})}}));function y(t,r){if(t.length===0)return 0;const n=t.length-1,o=Math.max(0,Math.min(n,r)),e=Math.floor(o),a=Math.min(e+1,n);if(e===a)return t[e].timestampS;const i=o-e;return t[e].timestampS+i*(t[a].timestampS-t[e].timestampS)}const L=()=>l(t=>t.isActive),W=()=>l(t=>t.ownerKey),k=()=>l(t=>t.isPlaying),q=()=>l(t=>t.currentIdx),B=()=>l(t=>t.currentTimeS),D=()=>l(t=>t.speed),H=()=>l(t=>t.timeRange),N=()=>l(t=>t.samples);function j(){const{isActive:t,samples:r,currentIdx:n}=l.getState();return!t||r.length===0?null:R(r,n)}function O(){var e;const{isActive:t,samples:r,currentIdx:n}=l.getState();if(!t||r.length===0)return;const o=Math.round(Math.max(0,Math.min(r.length-1,n)));return(e=r[o])==null?void 0:e.pathHops}function U(){const t=k(),r=S.useRef(0),n=S.useRef(0);S.useEffect(()=>{if(!t){n.current=0;return}const o=l.getState().tick,e=a=>{if(n.current>0){const i=Math.min(a-n.current,100);o(i)}n.current=a,r.current=requestAnimationFrame(e)};return r.current=requestAnimationFrame(e),()=>{cancelAnimationFrame(r.current),n.current=0}},[t])}export{K as R,k as a,B as b,D as c,H as d,l as e,C as f,E as g,j as h,O as i,N as j,U as k,W as l,q as m,R as p,F as r,$ as t,L as u}; +import{t as A,r as S}from"./index-D33fcA3L.js";import{p as T}from"./payload-detail-DbnSd5NL.js";function E(t){const r=[];for(const n of t){if(n.is_outgoing)continue;const o=T(n.text);o&&r.push({lat:o.lat,lon:o.lon,timestampS:n.timestamp,senderName:n.sender_name??"Unknown",pathHops:n.path_hops,pathSnr:n.path_snr,pathRssi:n.path_rssi,msgSnr:n.msg_snr})}return r.sort((n,o)=>n.timestampS-o.timestampS),r}function v(t,r){if(t.length===0)return null;if(r<=t[0].timestampS)return{lo:0,hi:0,t:0};if(r>=t[t.length-1].timestampS){const i=t.length-1;return{lo:i,hi:i,t:0}}let n=0,o=t.length-1;for(;n>1;t[i].timestampS<=r?n=i:o=i}const e=t[o].timestampS-t[n].timestampS,a=e>0?(r-t[n].timestampS)/e:0;return{lo:n,hi:o,t:a}}function x(t,r,n,o,e){const a=e*e,i=a*e;return .5*(2*r+(-t+n)*e+(2*t-5*r+4*n-o)*a+(-t+3*r-3*n+o)*i)}function I(t,r,n,o){const e=Math.PI/180,a=(o-r)*e,i=Math.sin(a)*Math.cos(n*e),u=Math.cos(t*e)*Math.sin(n*e)-Math.sin(t*e)*Math.cos(n*e)*Math.cos(a);return(Math.atan2(i,u)*180/Math.PI+360)%360}function b(t,r){if(t.length===0)return null;const n=v(t,r);if(!n)return null;const{lo:o,hi:e,t:a}=n;if(o===e)return{lat:t[o].lat,lon:t[o].lon,bearing:null};const i=Math.max(0,o-1),u=o,h=e,g=Math.min(t.length-1,e+1),s=t[i],c=t[u],f=t[h],d=t[g];let m,p;i===u&&h===g?(m=c.lat+(f.lat-c.lat)*a,p=c.lon+(f.lon-c.lon)*a):(m=x(s.lat,c.lat,f.lat,d.lat,a),p=x(s.lon,c.lon,f.lon,d.lon,a));const P=I(c.lat,c.lon,f.lat,f.lon);return{lat:m,lon:p,bearing:P}}function $(t,r){const n=[];for(const e of t){if(e.timestampS>r)break;n.push([e.lon,e.lat])}const o=b(t,r);if(o&&n.length>0){const e=n[n.length-1];(Math.abs(e[0]-o.lon)>1e-7||Math.abs(e[1]-o.lat)>1e-7)&&n.push([o.lon,o.lat])}return n}function R(t,r){if(t.length===0)return null;if(t.length===1)return{lat:t[0].lat,lon:t[0].lon,bearing:null};const n=t.length-1,o=Math.max(0,Math.min(n,r)),e=Math.floor(o),a=Math.min(e+1,n),i=o-e;if(e===a)return{lat:t[e].lat,lon:t[e].lon,bearing:null};const u=Math.max(0,e-1),h=Math.min(n,a+1),g=t[u],s=t[e],c=t[a],f=t[h];let d,m;u===e&&a===h?(d=s.lat+(c.lat-s.lat)*i,m=s.lon+(c.lon-s.lon)*i):(d=x(g.lat,s.lat,c.lat,f.lat,i),m=x(g.lon,s.lon,c.lon,f.lon,i));const p=I(s.lat,s.lon,c.lat,c.lon);return{lat:d,lon:m,bearing:p}}function F(t,r){if(t.length===0)return[];const n=[],o=R(t,r);o&&n.push([o.lon,o.lat]);const e=Math.ceil(Math.max(0,r));for(let a=e;a0?`${n}:${String(o).padStart(2,"0")}:${String(e).padStart(2,"0")}`:`${o}:${String(e).padStart(2,"0")}`}const K=[2,5,10,20],M={isActive:!1,ownerKey:null,samples:[],isPlaying:!1,speed:5,currentIdx:0,currentTimeS:0,timeRange:{start:0,end:0}},l=A((t,r)=>({...M,startRewind:(n,o)=>{if(n.length<2){t({...M});return}const e=n.length-1,a={start:n[0].timestampS,end:n[e].timestampS};t({isActive:!0,ownerKey:o,samples:n,isPlaying:!0,speed:5,currentIdx:e,currentTimeS:a.end,timeRange:a})},togglePlay:()=>{var a;const{isPlaying:n,currentIdx:o,samples:e}=r();if(n)t({isPlaying:!1});else if(o<=0){const i=e.length-1;t({isPlaying:!0,currentIdx:i,currentTimeS:((a=e[i])==null?void 0:a.timestampS)??0})}else t({isPlaying:!0})},pause:()=>t({isPlaying:!1}),setSpeed:n=>t({speed:n}),seek:n=>{const{samples:o}=r();if(o.length<2)return;const e=o.length-1,a=Math.max(0,Math.min(e,n*e));t({currentIdx:a,currentTimeS:y(o,a)})},stopRewind:()=>t({...M}),tick:n=>{const{isPlaying:o,speed:e,currentIdx:a,samples:i}=r();if(!o||i.length<2)return;const u=e*(n/1e3),h=a-u;h<=0?t({currentIdx:0,currentTimeS:i[0].timestampS,isPlaying:!1}):t({currentIdx:h,currentTimeS:y(i,h)})}}));function y(t,r){if(t.length===0)return 0;const n=t.length-1,o=Math.max(0,Math.min(n,r)),e=Math.floor(o),a=Math.min(e+1,n);if(e===a)return t[e].timestampS;const i=o-e;return t[e].timestampS+i*(t[a].timestampS-t[e].timestampS)}const L=()=>l(t=>t.isActive),W=()=>l(t=>t.ownerKey),k=()=>l(t=>t.isPlaying),q=()=>l(t=>t.currentIdx),B=()=>l(t=>t.currentTimeS),D=()=>l(t=>t.speed),H=()=>l(t=>t.timeRange),N=()=>l(t=>t.samples);function j(){const{isActive:t,samples:r,currentIdx:n}=l.getState();return!t||r.length===0?null:R(r,n)}function O(){var e;const{isActive:t,samples:r,currentIdx:n}=l.getState();if(!t||r.length===0)return;const o=Math.round(Math.max(0,Math.min(r.length-1,n)));return(e=r[o])==null?void 0:e.pathHops}function U(){const t=k(),r=S.useRef(0),n=S.useRef(0);S.useEffect(()=>{if(!t){n.current=0;return}const o=l.getState().tick,e=a=>{if(n.current>0){const i=Math.min(a-n.current,100);o(i)}n.current=a,r.current=requestAnimationFrame(e)};return r.current=requestAnimationFrame(e),()=>{cancelAnimationFrame(r.current),n.current=0}},[t])}export{K as R,k as a,B as b,D as c,H as d,l as e,C as f,E as g,j as h,O as i,N as j,U as k,W as l,q as m,R as p,F as r,$ as t,L as u}; diff --git a/frontend/dist/assets/variants-cyDnzhWy.js b/frontend/dist/assets/variants-ByRhxIcL.js similarity index 95% rename from frontend/dist/assets/variants-cyDnzhWy.js rename to frontend/dist/assets/variants-ByRhxIcL.js index e3961273..b1a5ca3c 100644 --- a/frontend/dist/assets/variants-cyDnzhWy.js +++ b/frontend/dist/assets/variants-ByRhxIcL.js @@ -1,4 +1,4 @@ -import{e as t,en as a,eo as i}from"./index-C2xvS0Jd.js";/** +import{e as t,en as a,eo as i}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/wand-sparkles-D9rSrVnU.js b/frontend/dist/assets/wand-sparkles-CEbXzjVw.js similarity index 93% rename from frontend/dist/assets/wand-sparkles-D9rSrVnU.js rename to frontend/dist/assets/wand-sparkles-CEbXzjVw.js index 68f03bcc..3d5b66c3 100644 --- a/frontend/dist/assets/wand-sparkles-D9rSrVnU.js +++ b/frontend/dist/assets/wand-sparkles-CEbXzjVw.js @@ -1,4 +1,4 @@ -import{e as a}from"./index-C2xvS0Jd.js";/** +import{e as a}from"./index-D33fcA3L.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/webgl-device-QoBMYpnS-Crxmw1Do.js b/frontend/dist/assets/webgl-device-QoBMYpnS-CdQYT9sr.js similarity index 99% rename from frontend/dist/assets/webgl-device-QoBMYpnS-Crxmw1Do.js rename to frontend/dist/assets/webgl-device-QoBMYpnS-CdQYT9sr.js index e2afa5c8..e9d23675 100644 --- a/frontend/dist/assets/webgl-device-QoBMYpnS-Crxmw1Do.js +++ b/frontend/dist/assets/webgl-device-QoBMYpnS-CdQYT9sr.js @@ -1,2 +1,2 @@ -import{N as ie,B as p,c as Ke,u as Ye,s as Je,o as Ze,$ as F,e as B,D as et,K as tt,l as rt,a as st,h as it,T as Se,j as nt,U as _e,J as at,r as ot,d as lt,b as S,f as ct,H as ut,I as ht}from"./MeshGraph-D_cqlL51.js";import"./index-C2xvS0Jd.js";import"./max-BBb5g8bL.js";import"./consumer-registry-DJyYnY6J.js";import"./variants-cyDnzhWy.js";import"./git-branch-BhoB5t-Q.js";import"./clock-DU0z3qMB.js";import"./database-cyku2KnA.js";import"./badge-colors-Dl76Mz8m.js";import"./meshcore-tx-constants-DgpFTAmf.js";import"./target-BpFOYbOg.js";import"./layers-BICmdhXR.js";import"./search-DPGHPI2q.js";import"./settings-2-OYYe3udS.js";import"./rotate-ccw-Sqgw9a-1.js";import"./chevron-right-C9GG0xWI.js";import"./network-D80fXCJJ.js";var dt=Object.defineProperty,ft=(r,e,t)=>e in r?dt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,o=(r,e,t)=>ft(r,typeof e!="symbol"?e+"":e,t);function gt(r){return _e()?at()?"Electron":(ot.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node"}function pt(){let r,e;return{promise:new Promise((t,s)=>{r=t,e=s}),resolve:r,reject:e}}const Pe=class R{constructor(e){o(this,"id"),o(this,"props"),o(this,"canvas"),o(this,"htmlCanvas"),o(this,"offscreenCanvas"),o(this,"type"),o(this,"initialized"),o(this,"isInitialized",!1),o(this,"isVisible",!0),o(this,"cssWidth"),o(this,"cssHeight"),o(this,"devicePixelRatio"),o(this,"devicePixelWidth"),o(this,"devicePixelHeight"),o(this,"drawingBufferWidth"),o(this,"drawingBufferHeight"),o(this,"_initializedResolvers",pt()),o(this,"_resizeObserver"),o(this,"_intersectionObserver"),o(this,"_position"),o(this,"destroyed",!1);var t,s;if(this.props={...R.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,_e()?e.canvas?typeof e.canvas=="string"?this.canvas=bt(e.canvas):this.canvas=e.canvas:this.canvas=vt(e):this.canvas={width:e.width||1,height:e.height||1},R.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):R.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=((t=this.htmlCanvas)==null?void 0:t.clientWidth)||this.canvas.width,this.cssHeight=((s=this.htmlCanvas)==null?void 0:s.clientHeight)||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],R.isHTMLCanvas(this.canvas)){this._intersectionObserver=new IntersectionObserver(i=>this._handleIntersection(i)),this._intersectionObserver.observe(this.canvas),this._resizeObserver=new ResizeObserver(i=>this._handleResize(i));try{this._resizeObserver.observe(this.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.canvas,{box:"content-box"})}setTimeout(()=>this._observeDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}destroy(){this.destroyed=!0}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){const e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){this.canvas.width=e,this.canvas.height=t,this.drawingBufferWidth=e,this.drawingBufferHeight=t}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){const s=this.cssToDeviceRatio(),[i,n]=this.getDrawingBufferSize();return yt(e,s,i,n,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){const[e,t]=this.getDevicePixelSize();return e/t}cssToDeviceRatio(){try{const[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){var t;((t=this.htmlCanvas)==null?void 0:t.id)==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_handleIntersection(e){const t=e.find(i=>i.target===this.canvas);if(!t)return;const s=t.isIntersecting;this.isVisible!==s&&(this.isVisible=s,this.device.props.onVisibilityChange(this))}_handleResize(e){var t,s;const i=e.find(h=>h.target===this.canvas);if(!i)return;this.cssWidth=i.contentBoxSize[0].inlineSize,this.cssHeight=i.contentBoxSize[0].blockSize;const n=this.getDevicePixelSize(),a=((t=i.devicePixelContentBoxSize)==null?void 0:t[0].inlineSize)||i.contentBoxSize[0].inlineSize*devicePixelRatio,l=((s=i.devicePixelContentBoxSize)==null?void 0:s[0].blockSize)||i.contentBoxSize[0].blockSize*devicePixelRatio,[c,u]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(a,c)),this.devicePixelHeight=Math.max(1,Math.min(l,u)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:n})}_updateDrawingBufferSize(){if(this.props.autoResize){if(typeof this.props.useDevicePixels=="number"){const e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._updateDevice()}this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_observeDevicePixelRatio(){const e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange(this,{oldRatio:e}),matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener("change",()=>this._observeDevicePixelRatio(),{once:!0})}_trackPosition(e=100){const t=setInterval(()=>{this.destroyed?clearInterval(t):this.updatePosition()},e)}updatePosition(){var e,t,s;const i=(e=this.htmlCanvas)==null?void 0:e.getBoundingClientRect();if(i){const n=[i.left,i.top];if(this._position??(this._position=n),n[0]!==this._position[0]||n[1]!==this._position[1]){const a=this._position;this._position=n,(s=(t=this.device.props).onPositionChange)==null||s.call(t,this,{oldPosition:a})}}}};o(Pe,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1});let Te=Pe;function mt(r){if(typeof r=="string"){const e=document.getElementById(r);if(!e)throw new Error(`${r} is not an HTML element`);return e}return r||document.body}function bt(r){const e=document.getElementById(r);if(!Te.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function vt(r){const{width:e,height:t}=r,s=document.createElement("canvas");s.id=ht("lumagl-auto-created-canvas"),s.width=e||1,s.height=t||1,s.style.width=Number.isFinite(e)?`${e}px`:"100%",s.style.height=Number.isFinite(t)?`${t}px`:"100%",r!=null&&r.visible||(s.style.visibility="hidden");const i=mt((r==null?void 0:r.container)||null);return i.insertBefore(s,i.firstChild),s}function yt(r,e,t,s,i){const n=r,a=ne(n[0],e,t);let l=ae(n[1],e,s,i),c=ne(n[0]+1,e,t);const u=c===t-1?c:c-1;c=ae(n[1]+1,e,s,i);let h;return i?(c=c===0?c:c+1,h=l,l=c):h=c===s-1?c:c-1,{x:a,y:l,width:Math.max(u-a+1,1),height:Math.max(h-l+1,1)}}function ne(r,e,t){return Math.min(Math.round(r*e),t-1)}function ae(r,e,t,s){return s?Math.max(0,t-1-Math.round(r*e)):Math.min(Math.round(r*e),t-1)}const Ae=class Be extends S{constructor(e,t={}){super(e,t,Be.defaultProps),o(this,"width"),o(this,"height"),this.width=this.props.width,this.height=this.props.height}get[Symbol.toStringTag](){return"Framebuffer"}clone(e){const t=this.colorAttachments.map(i=>i.texture.clone(e)),s=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,colorAttachments:t,depthStencilAttachment:s})}resize(e){let t=!e;if(e){const[s,i]=Array.isArray(e)?e:[e.width,e.height];t=t||i!==this.height||s!==this.width,this.width=s,this.height=i}t&&(p.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((t,s)=>{if(typeof t=="string"){const i=this.createColorTexture(t,s);return this.attachResource(i),i.view}return t instanceof B?t.view:t});const e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){const t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof B?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:B.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:B.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let s=0;se?r.enable(t):r.disable(t),oe=(r,e,t)=>r.hint(t,e),P=(r,e,t)=>r.pixelStorei(t,e),le=(r,e,t)=>{const s=t===36006?36009:36008;return r.bindFramebuffer(s,e)},M=(r,e,t)=>{const s={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[t];r.bindBuffer(s,e)};function H(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}const At={3042:y,32773:(r,e)=>r.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(r,e)=>r.clearColor(...e),3107:(r,e)=>r.colorMask(...e),2884:y,2885:(r,e)=>r.cullFace(e),2929:y,2931:(r,e)=>r.clearDepth(e),2932:(r,e)=>r.depthFunc(e),2928:(r,e)=>r.depthRange(...e),2930:(r,e)=>r.depthMask(e),3024:y,35723:oe,35725:(r,e)=>r.useProgram(e),36007:(r,e)=>r.bindRenderbuffer(36161,e),36389:(r,e)=>{var t;return(t=r.bindTransformFeedback)==null?void 0:t.call(r,36386,e)},34229:(r,e)=>r.bindVertexArray(e),36006:le,36010:le,34964:M,36662:M,36663:M,35053:M,35055:M,2886:(r,e)=>r.frontFace(e),33170:oe,2849:(r,e)=>r.lineWidth(e),32823:y,32824:"polygonOffset",10752:"polygonOffset",35977:y,32926:y,32928:y,32938:"sampleCoverage",32939:"sampleCoverage",3089:y,3088:(r,e)=>r.scissor(...e),2960:y,2961:(r,e)=>r.clearStencil(e),2968:(r,e)=>r.stencilMaskSeparate(1028,e),36005:(r,e)=>r.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(r,e)=>r.viewport(...e),34383:y,10754:y,12288:y,12289:y,12290:y,12291:y,12292:y,12293:y,12294:y,12295:y,3333:P,3317:P,37440:P,37441:P,37443:P,3330:P,3332:P,3331:P,3314:P,32878:P,3316:P,3315:P,32877:P,framebuffer:(r,e)=>{const t=e&&"handle"in e?e.handle:e;return r.bindFramebuffer(36160,t)},blend:(r,e)=>e?r.enable(3042):r.disable(3042),blendColor:(r,e)=>r.blendColor(...e),blendEquation:(r,e)=>{const t=typeof e=="number"?[e,e]:e;r.blendEquationSeparate(...t)},blendFunc:(r,e)=>{const t=(e==null?void 0:e.length)===2?[...e,...e]:e;r.blendFuncSeparate(...t)},clearColor:(r,e)=>r.clearColor(...e),clearDepth:(r,e)=>r.clearDepth(e),clearStencil:(r,e)=>r.clearStencil(e),colorMask:(r,e)=>r.colorMask(...e),cull:(r,e)=>e?r.enable(2884):r.disable(2884),cullFace:(r,e)=>r.cullFace(e),depthTest:(r,e)=>e?r.enable(2929):r.disable(2929),depthFunc:(r,e)=>r.depthFunc(e),depthMask:(r,e)=>r.depthMask(e),depthRange:(r,e)=>r.depthRange(...e),dither:(r,e)=>e?r.enable(3024):r.disable(3024),derivativeHint:(r,e)=>{r.hint(35723,e)},frontFace:(r,e)=>r.frontFace(e),mipmapHint:(r,e)=>r.hint(33170,e),lineWidth:(r,e)=>r.lineWidth(e),polygonOffsetFill:(r,e)=>e?r.enable(32823):r.disable(32823),polygonOffset:(r,e)=>r.polygonOffset(...e),sampleCoverage:(r,e)=>r.sampleCoverage(e[0],e[1]||!1),scissorTest:(r,e)=>e?r.enable(3089):r.disable(3089),scissor:(r,e)=>r.scissor(...e),stencilTest:(r,e)=>e?r.enable(2960):r.disable(2960),stencilMask:(r,e)=>{e=H(e)?e:[e,e];const[t,s]=e;r.stencilMaskSeparate(1028,t),r.stencilMaskSeparate(1029,s)},stencilFunc:(r,e)=>{e=H(e)&&e.length===3?[...e,...e]:e;const[t,s,i,n,a,l]=e;r.stencilFuncSeparate(1028,t,s,i),r.stencilFuncSeparate(1029,n,a,l)},stencilOp:(r,e)=>{e=H(e)&&e.length===3?[...e,...e]:e;const[t,s,i,n,a,l]=e;r.stencilOpSeparate(1028,t,s,i),r.stencilOpSeparate(1029,n,a,l)},viewport:(r,e)=>r.viewport(...e)};function b(r,e,t){return e[r]!==void 0?e[r]:t[r]}const Bt={blendEquation:(r,e,t)=>r.blendEquationSeparate(b(32777,e,t),b(34877,e,t)),blendFunc:(r,e,t)=>r.blendFuncSeparate(b(32969,e,t),b(32968,e,t),b(32971,e,t),b(32970,e,t)),polygonOffset:(r,e,t)=>r.polygonOffset(b(32824,e,t),b(10752,e,t)),sampleCoverage:(r,e,t)=>r.sampleCoverage(b(32938,e,t),b(32939,e,t)),stencilFuncFront:(r,e,t)=>r.stencilFuncSeparate(1028,b(2962,e,t),b(2967,e,t),b(2963,e,t)),stencilFuncBack:(r,e,t)=>r.stencilFuncSeparate(1029,b(34816,e,t),b(36003,e,t),b(36004,e,t)),stencilOpFront:(r,e,t)=>r.stencilOpSeparate(1028,b(2964,e,t),b(2965,e,t),b(2966,e,t)),stencilOpBack:(r,e,t)=>r.stencilOpSeparate(1029,b(34817,e,t),b(34818,e,t),b(34819,e,t))},ce={enable:(r,e)=>r({[e]:!0}),disable:(r,e)=>r({[e]:!1}),pixelStorei:(r,e,t)=>r({[e]:t}),hint:(r,e,t)=>r({[e]:t}),useProgram:(r,e)=>r({35725:e}),bindRenderbuffer:(r,e,t)=>r({36007:t}),bindTransformFeedback:(r,e,t)=>r({36389:t}),bindVertexArray:(r,e)=>r({34229:e}),bindFramebuffer:(r,e,t)=>{switch(e){case 36160:return r({36006:t,36010:t});case 36009:return r({36006:t});case 36008:return r({36010:t});default:return null}},bindBuffer:(r,e,t)=>{const s={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return s?r({[s]:t}):{valueChanged:!0}},blendColor:(r,e,t,s,i)=>r({32773:new Float32Array([e,t,s,i])}),blendEquation:(r,e)=>r({32777:e,34877:e}),blendEquationSeparate:(r,e,t)=>r({32777:e,34877:t}),blendFunc:(r,e,t)=>r({32969:e,32968:t,32971:e,32970:t}),blendFuncSeparate:(r,e,t,s,i)=>r({32969:e,32968:t,32971:s,32970:i}),clearColor:(r,e,t,s,i)=>r({3106:new Float32Array([e,t,s,i])}),clearDepth:(r,e)=>r({2931:e}),clearStencil:(r,e)=>r({2961:e}),colorMask:(r,e,t,s,i)=>r({3107:[e,t,s,i]}),cullFace:(r,e)=>r({2885:e}),depthFunc:(r,e)=>r({2932:e}),depthRange:(r,e,t)=>r({2928:new Float32Array([e,t])}),depthMask:(r,e)=>r({2930:e}),frontFace:(r,e)=>r({2886:e}),lineWidth:(r,e)=>r({2849:e}),polygonOffset:(r,e,t)=>r({32824:e,10752:t}),sampleCoverage:(r,e,t)=>r({32938:e,32939:t}),scissor:(r,e,t,s,i)=>r({3088:new Int32Array([e,t,s,i])}),stencilMask:(r,e)=>r({2968:e,36005:e}),stencilMaskSeparate:(r,e,t)=>r({[e===1028?2968:36005]:t}),stencilFunc:(r,e,t,s)=>r({2962:e,2967:t,2963:s,34816:e,36003:t,36004:s}),stencilFuncSeparate:(r,e,t,s,i)=>r({[e===1028?2962:34816]:t,[e===1028?2967:36003]:s,[e===1028?2963:36004]:i}),stencilOp:(r,e,t,s)=>r({2964:e,2965:t,2966:s,34817:e,34818:t,34819:s}),stencilOpSeparate:(r,e,t,s,i)=>r({[e===1028?2964:34817]:t,[e===1028?2965:34818]:s,[e===1028?2966:34819]:i}),viewport:(r,e,t,s,i)=>r({2978:[e,t,s,i]})},T=(r,e)=>r.isEnabled(e),ue={3042:T,2884:T,2929:T,3024:T,32823:T,32926:T,32928:T,3089:T,2960:T,35977:T},Ft=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function O(r,e){if(Ct(e))return;const t={};for(const i in e){const n=Number(i),a=At[i];a&&(typeof a=="string"?t[a]=!0:a(r,e[i],n))}const s=r.state&&r.state.cache;if(s)for(const i in t){const n=Bt[i];n(r,e,s)}}function Ie(r,e=J){if(typeof e=="number"){const i=e,n=ue[i];return n?n(r,i):r.getParameter(i)}const t=Array.isArray(e)?e:Object.keys(e),s={};for(const i of t){const n=ue[i];s[i]=n?n(r,Number(i)):r.getParameter(Number(i))}return s}function Lt(r){O(r,J)}function Ct(r){for(const e in r)return!1;return!0}function kt(r,e){if(r===e)return!0;if(he(r)&&he(e)&&r.length===e.length){for(let t=0;t{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}static get(e){return e.state}push(e={}){this.stateStack.push({})}pop(){const e=this.stateStack[this.stateStack.length-1];O(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t!=null&&t.copyState?Ie(e):Object.assign({},J),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.state=this,Dt(e);for(const s in ce){const i=ce[s];Et(e,s,i)}de(e,"getParameter"),de(e,"isEnabled")}_updateCache(e){let t=!1,s;const i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const n in e){const a=e[n],l=this.cache[n];kt(a,l)||(t=!0,s=l,i&&!(n in i)&&(i[n]=l),this.cache[n]=a)}return{valueChanged:t,oldValue:s}}}function de(r,e){const t=r[e].bind(r);r[e]=function(s){if(s===void 0||Ft.has(s))return t(s);const i=L.get(r);return s in i.cache||(i.cache[s]=t(s)),i.enable?i.cache[s]:t(s)},Object.defineProperty(r[e],"name",{value:`${e}-from-cache`,configurable:!1})}function Et(r,e,t){if(!r[e])return;const s=r[e].bind(r);r[e]=function(...i){const n=L.get(r),{valueChanged:a,oldValue:l}=t(n._updateCache,...i);return a&&s(...i),l},Object.defineProperty(r[e],"name",{value:`${e}-to-cache`,configurable:!1})}function Dt(r){const e=r.useProgram.bind(r);r.useProgram=function(t){const s=L.get(r);s.program!==t&&(e(t),s.program=t)}}function Wt(r,e,t){let s="";const i={preserveDrawingBuffer:!0,...t};let n=null;if(n||(n=r.getContext("webgl2",i)),i.failIfMajorPerformanceCaveat&&(s||(s="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.")),!n&&!t.failIfMajorPerformanceCaveat&&(i.failIfMajorPerformanceCaveat=!1,n=r.getContext("webgl2",i),n.luma||(n.luma={}),n.luma.softwareRenderer=!0),n||(n=r.getContext("webgl",{}),n&&(n=null,s||(s="Your browser only supports WebGL1"))),!n)throw s||(s="Your browser does not support WebGL"),new Error(`Failed to create WebGL context: ${s}`);const{onContextLost:a,onContextRestored:l}=e;return r.addEventListener("webglcontextlost",c=>a(c),!1),r.addEventListener("webglcontextrestored",c=>l(c),!1),n.luma||(n.luma={}),n}function W(r,e,t){return t[e]===void 0&&(t[e]=r.getExtension(e)||null),t[e]}function Ot(r,e){const t=r.getParameter(7936),s=r.getParameter(7937);W(r,"WEBGL_debug_renderer_info",e);const i=e.WEBGL_debug_renderer_info,n=r.getParameter(i?i.UNMASKED_VENDOR_WEBGL:7936),a=r.getParameter(i?i.UNMASKED_RENDERER_WEBGL:7937),l=n||t,c=a||s,u=r.getParameter(7938),h=Ge(l,c),f=Mt(l,c),d=Rt(l,c);return{type:"webgl",gpu:h,gpuType:d,gpuBackend:f,vendor:l,renderer:c,version:u,shadingLanguage:"glsl",shadingLanguageVersion:300}}function Ge(r,e){return/NVIDIA/i.exec(r)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(r)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(r)||/Apple/i.exec(e)?"apple":/AMD/i.exec(r)||/AMD/i.exec(e)||/ATI/i.exec(r)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(r)||/SwiftShader/i.exec(e)?"software":"unknown"}function Mt(r,e){return/Metal/i.exec(r)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(r)||/ANGLE/i.exec(e)?"opengl":"unknown"}function Rt(r,e){if(/SwiftShader/i.exec(r)||/SwiftShader/i.exec(e))return"cpu";switch(Ge(r,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function ze(r){switch(r){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(r))}const $="WEBGL_compressed_texture_s3tc",I="WEBGL_compressed_texture_s3tc_srgb",k="EXT_texture_compression_rgtc",E="EXT_texture_compression_bptc",$t="WEBGL_compressed_texture_etc",It="WEBGL_compressed_texture_astc",Gt="WEBGL_compressed_texture_etc1",zt="WEBGL_compressed_texture_pvrtc",Vt="WEBGL_compressed_texture_atc",fe="EXT_texture_norm16",ge="EXT_render_snorm",Ut="EXT_color_buffer_float",Z={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat-renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[ge],"norm16-renderable-webgl":[fe],"snorm16-renderable-webgl":[fe,ge],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[$,I,k,E],"texture-compression-bc5-webgl":[k],"texture-compression-bc7-webgl":[E],"texture-compression-etc2":[$t],"texture-compression-astc":[It],"texture-compression-etc1-webgl":[Gt],"texture-compression-pvrtc-webgl":[zt],"texture-compression-atc-webgl":[Vt]};function Nt(r){return r in Z}function Ht(r,e,t){return(Z[e]||[]).every(s=>W(r,s,t))}const ee={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0},r16unorm:{gl:33322,rb:!0},r16snorm:{gl:36760},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0},rg16unorm:{gl:33324},rg16snorm:{gl:36761},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326},rgb9e5ufloat:{gl:35901},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852},"rgb16snorm-webgl":{gl:36762},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842},rgba16unorm:{gl:32859,rb:!0},rgba16snorm:{gl:36763},"rgb32float-webgl":{gl:34837,x:Ut,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:$},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:I},"bc1-rgba-unorm":{gl:33777,x:$},"bc1-rgba-unorm-srgb":{gl:35916,x:I},"bc2-rgba-unorm":{gl:33778,x:$},"bc2-rgba-unorm-srgb":{gl:35918,x:I},"bc3-rgba-unorm":{gl:33779,x:$},"bc3-rgba-unorm-srgb":{gl:35919,x:I},"bc4-r-unorm":{gl:36283,x:k},"bc4-r-snorm":{gl:36284,x:k},"bc5-rg-unorm":{gl:36285,x:k},"bc5-rg-snorm":{gl:36286,x:k},"bc6h-rgb-ufloat":{gl:36495,x:E},"bc6h-rgb-float":{gl:36494,x:E},"bc7-rgba-unorm":{gl:36492,x:E},"bc7-rgba-unorm-srgb":{gl:36493,x:E},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37819},"astc-10x5-unorm-srgb":{gl:37851},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rbg2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}};function jt(r,e,t){let s=e.create;const i=ee[e.format];return(i==null?void 0:i.gl)===void 0&&(s=!1),i!=null&&i.x&&(s=s&&!!W(r,i.x,t)),{format:e.format,create:s&&e.create,render:s&&e.render,filter:s&&e.filter,blend:s&&e.blend,store:s&&e.store}}function Ve(r){var e;const t=ee[r],s=Xt(r),i=Se.getInfo(r);return i.compressed&&(t.dataFormat=s),{internalFormat:s,format:(t==null?void 0:t.dataFormat)||qt(i.channels,i.integer,i.normalized,s),type:i.dataType?ze(i.dataType):((e=t==null?void 0:t.types)==null?void 0:e[0])||5121,compressed:i.compressed||!1}}function Qt(r){switch(Se.getInfo(r).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${r}`)}}function qt(r,e,t,s){if(s===6408||s===6407)return s;switch(r){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function Xt(r){const e=ee[r],t=e==null?void 0:e.gl;if(t===void 0)throw new Error(`Unsupported texture format ${r}`);return t}const pe={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class Kt extends Ze{constructor(e,t,s){super([],s),o(this,"gl"),o(this,"extensions"),o(this,"testedFeatures",new Set),this.gl=e,this.extensions=t,W(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){const e=this.getFeatures();for(const t of e)this.has(t)&&(yield t);return[]}has(e){var t;return(t=this.disabledFeatures)!=null&&t[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),Nt(e)&&Ht(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){const e=this.getFeatures().filter(t=>t!=="polygon-mode-webgl");for(const t of e)this.has(t)}getFeatures(){return[...Object.keys(pe),...Object.keys(Z)]}getWebGLFeature(e){const t=pe[e];return typeof t=="string"?!!W(this.gl,t,this.extensions):!!t}}class Yt extends Je{constructor(e){super(),o(this,"gl"),o(this,"limits",{}),this.gl=e}get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}class G extends Fe{constructor(e,t){super(e,t),o(this,"device"),o(this,"gl"),o(this,"handle"),o(this,"colorAttachments",[]),o(this,"depthStencilAttachment",null);const s=t.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||s?this.props.handle:this.gl.createFramebuffer(),s||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.autoCreateAttachmentTextures(),this.updateAttachments())}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){const e=this.gl.bindFramebuffer(36160,this.handle);for(let t=0;t(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){const e=this.device.gl.getShaderInfoLog(this.handle);return e?ir(e):[]}getTranslatedSource(){const e=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return(e==null?void 0:e.getTranslatedShaderSource(this.handle))||null}async _compile(e){e=e.startsWith("#version ")?e:`#version 300 es +import{N as ie,B as p,c as Ke,u as Ye,s as Je,o as Ze,$ as F,e as B,D as et,K as tt,l as rt,a as st,h as it,T as Se,j as nt,U as _e,J as at,r as ot,d as lt,b as S,f as ct,H as ut,I as ht}from"./MeshGraph-DJIb7g1_.js";import"./index-D33fcA3L.js";import"./max-CkBnBUwN.js";import"./consumer-registry-DXaeZxMm.js";import"./variants-ByRhxIcL.js";import"./git-branch-Ryinnbc1.js";import"./clock-D_m2QiHa.js";import"./database-Bm4-qoOy.js";import"./badge-colors-Dl76Mz8m.js";import"./meshcore-tx-constants-DgpFTAmf.js";import"./target-B3CHoIpd.js";import"./layers-DguV5fdN.js";import"./search-DN8guzpX.js";import"./settings-2-C5Lvk9-M.js";import"./rotate-ccw-B3SnN1wY.js";import"./chevron-right-D4kUPDBw.js";import"./network-Btok3jeo.js";var dt=Object.defineProperty,ft=(r,e,t)=>e in r?dt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,o=(r,e,t)=>ft(r,typeof e!="symbol"?e+"":e,t);function gt(r){return _e()?at()?"Electron":(ot.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node"}function pt(){let r,e;return{promise:new Promise((t,s)=>{r=t,e=s}),resolve:r,reject:e}}const Pe=class R{constructor(e){o(this,"id"),o(this,"props"),o(this,"canvas"),o(this,"htmlCanvas"),o(this,"offscreenCanvas"),o(this,"type"),o(this,"initialized"),o(this,"isInitialized",!1),o(this,"isVisible",!0),o(this,"cssWidth"),o(this,"cssHeight"),o(this,"devicePixelRatio"),o(this,"devicePixelWidth"),o(this,"devicePixelHeight"),o(this,"drawingBufferWidth"),o(this,"drawingBufferHeight"),o(this,"_initializedResolvers",pt()),o(this,"_resizeObserver"),o(this,"_intersectionObserver"),o(this,"_position"),o(this,"destroyed",!1);var t,s;if(this.props={...R.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,_e()?e.canvas?typeof e.canvas=="string"?this.canvas=bt(e.canvas):this.canvas=e.canvas:this.canvas=vt(e):this.canvas={width:e.width||1,height:e.height||1},R.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):R.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=((t=this.htmlCanvas)==null?void 0:t.clientWidth)||this.canvas.width,this.cssHeight=((s=this.htmlCanvas)==null?void 0:s.clientHeight)||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],R.isHTMLCanvas(this.canvas)){this._intersectionObserver=new IntersectionObserver(i=>this._handleIntersection(i)),this._intersectionObserver.observe(this.canvas),this._resizeObserver=new ResizeObserver(i=>this._handleResize(i));try{this._resizeObserver.observe(this.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.canvas,{box:"content-box"})}setTimeout(()=>this._observeDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}destroy(){this.destroyed=!0}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){const e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){this.canvas.width=e,this.canvas.height=t,this.drawingBufferWidth=e,this.drawingBufferHeight=t}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){const s=this.cssToDeviceRatio(),[i,n]=this.getDrawingBufferSize();return yt(e,s,i,n,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){const[e,t]=this.getDevicePixelSize();return e/t}cssToDeviceRatio(){try{const[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){var t;((t=this.htmlCanvas)==null?void 0:t.id)==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_handleIntersection(e){const t=e.find(i=>i.target===this.canvas);if(!t)return;const s=t.isIntersecting;this.isVisible!==s&&(this.isVisible=s,this.device.props.onVisibilityChange(this))}_handleResize(e){var t,s;const i=e.find(h=>h.target===this.canvas);if(!i)return;this.cssWidth=i.contentBoxSize[0].inlineSize,this.cssHeight=i.contentBoxSize[0].blockSize;const n=this.getDevicePixelSize(),a=((t=i.devicePixelContentBoxSize)==null?void 0:t[0].inlineSize)||i.contentBoxSize[0].inlineSize*devicePixelRatio,l=((s=i.devicePixelContentBoxSize)==null?void 0:s[0].blockSize)||i.contentBoxSize[0].blockSize*devicePixelRatio,[c,u]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(a,c)),this.devicePixelHeight=Math.max(1,Math.min(l,u)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:n})}_updateDrawingBufferSize(){if(this.props.autoResize){if(typeof this.props.useDevicePixels=="number"){const e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._updateDevice()}this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_observeDevicePixelRatio(){const e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange(this,{oldRatio:e}),matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener("change",()=>this._observeDevicePixelRatio(),{once:!0})}_trackPosition(e=100){const t=setInterval(()=>{this.destroyed?clearInterval(t):this.updatePosition()},e)}updatePosition(){var e,t,s;const i=(e=this.htmlCanvas)==null?void 0:e.getBoundingClientRect();if(i){const n=[i.left,i.top];if(this._position??(this._position=n),n[0]!==this._position[0]||n[1]!==this._position[1]){const a=this._position;this._position=n,(s=(t=this.device.props).onPositionChange)==null||s.call(t,this,{oldPosition:a})}}}};o(Pe,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1});let Te=Pe;function mt(r){if(typeof r=="string"){const e=document.getElementById(r);if(!e)throw new Error(`${r} is not an HTML element`);return e}return r||document.body}function bt(r){const e=document.getElementById(r);if(!Te.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function vt(r){const{width:e,height:t}=r,s=document.createElement("canvas");s.id=ht("lumagl-auto-created-canvas"),s.width=e||1,s.height=t||1,s.style.width=Number.isFinite(e)?`${e}px`:"100%",s.style.height=Number.isFinite(t)?`${t}px`:"100%",r!=null&&r.visible||(s.style.visibility="hidden");const i=mt((r==null?void 0:r.container)||null);return i.insertBefore(s,i.firstChild),s}function yt(r,e,t,s,i){const n=r,a=ne(n[0],e,t);let l=ae(n[1],e,s,i),c=ne(n[0]+1,e,t);const u=c===t-1?c:c-1;c=ae(n[1]+1,e,s,i);let h;return i?(c=c===0?c:c+1,h=l,l=c):h=c===s-1?c:c-1,{x:a,y:l,width:Math.max(u-a+1,1),height:Math.max(h-l+1,1)}}function ne(r,e,t){return Math.min(Math.round(r*e),t-1)}function ae(r,e,t,s){return s?Math.max(0,t-1-Math.round(r*e)):Math.min(Math.round(r*e),t-1)}const Ae=class Be extends S{constructor(e,t={}){super(e,t,Be.defaultProps),o(this,"width"),o(this,"height"),this.width=this.props.width,this.height=this.props.height}get[Symbol.toStringTag](){return"Framebuffer"}clone(e){const t=this.colorAttachments.map(i=>i.texture.clone(e)),s=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,colorAttachments:t,depthStencilAttachment:s})}resize(e){let t=!e;if(e){const[s,i]=Array.isArray(e)?e:[e.width,e.height];t=t||i!==this.height||s!==this.width,this.width=s,this.height=i}t&&(p.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((t,s)=>{if(typeof t=="string"){const i=this.createColorTexture(t,s);return this.attachResource(i),i.view}return t instanceof B?t.view:t});const e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){const t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof B?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:B.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:B.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let s=0;se?r.enable(t):r.disable(t),oe=(r,e,t)=>r.hint(t,e),P=(r,e,t)=>r.pixelStorei(t,e),le=(r,e,t)=>{const s=t===36006?36009:36008;return r.bindFramebuffer(s,e)},M=(r,e,t)=>{const s={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[t];r.bindBuffer(s,e)};function H(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}const At={3042:y,32773:(r,e)=>r.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(r,e)=>r.clearColor(...e),3107:(r,e)=>r.colorMask(...e),2884:y,2885:(r,e)=>r.cullFace(e),2929:y,2931:(r,e)=>r.clearDepth(e),2932:(r,e)=>r.depthFunc(e),2928:(r,e)=>r.depthRange(...e),2930:(r,e)=>r.depthMask(e),3024:y,35723:oe,35725:(r,e)=>r.useProgram(e),36007:(r,e)=>r.bindRenderbuffer(36161,e),36389:(r,e)=>{var t;return(t=r.bindTransformFeedback)==null?void 0:t.call(r,36386,e)},34229:(r,e)=>r.bindVertexArray(e),36006:le,36010:le,34964:M,36662:M,36663:M,35053:M,35055:M,2886:(r,e)=>r.frontFace(e),33170:oe,2849:(r,e)=>r.lineWidth(e),32823:y,32824:"polygonOffset",10752:"polygonOffset",35977:y,32926:y,32928:y,32938:"sampleCoverage",32939:"sampleCoverage",3089:y,3088:(r,e)=>r.scissor(...e),2960:y,2961:(r,e)=>r.clearStencil(e),2968:(r,e)=>r.stencilMaskSeparate(1028,e),36005:(r,e)=>r.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(r,e)=>r.viewport(...e),34383:y,10754:y,12288:y,12289:y,12290:y,12291:y,12292:y,12293:y,12294:y,12295:y,3333:P,3317:P,37440:P,37441:P,37443:P,3330:P,3332:P,3331:P,3314:P,32878:P,3316:P,3315:P,32877:P,framebuffer:(r,e)=>{const t=e&&"handle"in e?e.handle:e;return r.bindFramebuffer(36160,t)},blend:(r,e)=>e?r.enable(3042):r.disable(3042),blendColor:(r,e)=>r.blendColor(...e),blendEquation:(r,e)=>{const t=typeof e=="number"?[e,e]:e;r.blendEquationSeparate(...t)},blendFunc:(r,e)=>{const t=(e==null?void 0:e.length)===2?[...e,...e]:e;r.blendFuncSeparate(...t)},clearColor:(r,e)=>r.clearColor(...e),clearDepth:(r,e)=>r.clearDepth(e),clearStencil:(r,e)=>r.clearStencil(e),colorMask:(r,e)=>r.colorMask(...e),cull:(r,e)=>e?r.enable(2884):r.disable(2884),cullFace:(r,e)=>r.cullFace(e),depthTest:(r,e)=>e?r.enable(2929):r.disable(2929),depthFunc:(r,e)=>r.depthFunc(e),depthMask:(r,e)=>r.depthMask(e),depthRange:(r,e)=>r.depthRange(...e),dither:(r,e)=>e?r.enable(3024):r.disable(3024),derivativeHint:(r,e)=>{r.hint(35723,e)},frontFace:(r,e)=>r.frontFace(e),mipmapHint:(r,e)=>r.hint(33170,e),lineWidth:(r,e)=>r.lineWidth(e),polygonOffsetFill:(r,e)=>e?r.enable(32823):r.disable(32823),polygonOffset:(r,e)=>r.polygonOffset(...e),sampleCoverage:(r,e)=>r.sampleCoverage(e[0],e[1]||!1),scissorTest:(r,e)=>e?r.enable(3089):r.disable(3089),scissor:(r,e)=>r.scissor(...e),stencilTest:(r,e)=>e?r.enable(2960):r.disable(2960),stencilMask:(r,e)=>{e=H(e)?e:[e,e];const[t,s]=e;r.stencilMaskSeparate(1028,t),r.stencilMaskSeparate(1029,s)},stencilFunc:(r,e)=>{e=H(e)&&e.length===3?[...e,...e]:e;const[t,s,i,n,a,l]=e;r.stencilFuncSeparate(1028,t,s,i),r.stencilFuncSeparate(1029,n,a,l)},stencilOp:(r,e)=>{e=H(e)&&e.length===3?[...e,...e]:e;const[t,s,i,n,a,l]=e;r.stencilOpSeparate(1028,t,s,i),r.stencilOpSeparate(1029,n,a,l)},viewport:(r,e)=>r.viewport(...e)};function b(r,e,t){return e[r]!==void 0?e[r]:t[r]}const Bt={blendEquation:(r,e,t)=>r.blendEquationSeparate(b(32777,e,t),b(34877,e,t)),blendFunc:(r,e,t)=>r.blendFuncSeparate(b(32969,e,t),b(32968,e,t),b(32971,e,t),b(32970,e,t)),polygonOffset:(r,e,t)=>r.polygonOffset(b(32824,e,t),b(10752,e,t)),sampleCoverage:(r,e,t)=>r.sampleCoverage(b(32938,e,t),b(32939,e,t)),stencilFuncFront:(r,e,t)=>r.stencilFuncSeparate(1028,b(2962,e,t),b(2967,e,t),b(2963,e,t)),stencilFuncBack:(r,e,t)=>r.stencilFuncSeparate(1029,b(34816,e,t),b(36003,e,t),b(36004,e,t)),stencilOpFront:(r,e,t)=>r.stencilOpSeparate(1028,b(2964,e,t),b(2965,e,t),b(2966,e,t)),stencilOpBack:(r,e,t)=>r.stencilOpSeparate(1029,b(34817,e,t),b(34818,e,t),b(34819,e,t))},ce={enable:(r,e)=>r({[e]:!0}),disable:(r,e)=>r({[e]:!1}),pixelStorei:(r,e,t)=>r({[e]:t}),hint:(r,e,t)=>r({[e]:t}),useProgram:(r,e)=>r({35725:e}),bindRenderbuffer:(r,e,t)=>r({36007:t}),bindTransformFeedback:(r,e,t)=>r({36389:t}),bindVertexArray:(r,e)=>r({34229:e}),bindFramebuffer:(r,e,t)=>{switch(e){case 36160:return r({36006:t,36010:t});case 36009:return r({36006:t});case 36008:return r({36010:t});default:return null}},bindBuffer:(r,e,t)=>{const s={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return s?r({[s]:t}):{valueChanged:!0}},blendColor:(r,e,t,s,i)=>r({32773:new Float32Array([e,t,s,i])}),blendEquation:(r,e)=>r({32777:e,34877:e}),blendEquationSeparate:(r,e,t)=>r({32777:e,34877:t}),blendFunc:(r,e,t)=>r({32969:e,32968:t,32971:e,32970:t}),blendFuncSeparate:(r,e,t,s,i)=>r({32969:e,32968:t,32971:s,32970:i}),clearColor:(r,e,t,s,i)=>r({3106:new Float32Array([e,t,s,i])}),clearDepth:(r,e)=>r({2931:e}),clearStencil:(r,e)=>r({2961:e}),colorMask:(r,e,t,s,i)=>r({3107:[e,t,s,i]}),cullFace:(r,e)=>r({2885:e}),depthFunc:(r,e)=>r({2932:e}),depthRange:(r,e,t)=>r({2928:new Float32Array([e,t])}),depthMask:(r,e)=>r({2930:e}),frontFace:(r,e)=>r({2886:e}),lineWidth:(r,e)=>r({2849:e}),polygonOffset:(r,e,t)=>r({32824:e,10752:t}),sampleCoverage:(r,e,t)=>r({32938:e,32939:t}),scissor:(r,e,t,s,i)=>r({3088:new Int32Array([e,t,s,i])}),stencilMask:(r,e)=>r({2968:e,36005:e}),stencilMaskSeparate:(r,e,t)=>r({[e===1028?2968:36005]:t}),stencilFunc:(r,e,t,s)=>r({2962:e,2967:t,2963:s,34816:e,36003:t,36004:s}),stencilFuncSeparate:(r,e,t,s,i)=>r({[e===1028?2962:34816]:t,[e===1028?2967:36003]:s,[e===1028?2963:36004]:i}),stencilOp:(r,e,t,s)=>r({2964:e,2965:t,2966:s,34817:e,34818:t,34819:s}),stencilOpSeparate:(r,e,t,s,i)=>r({[e===1028?2964:34817]:t,[e===1028?2965:34818]:s,[e===1028?2966:34819]:i}),viewport:(r,e,t,s,i)=>r({2978:[e,t,s,i]})},T=(r,e)=>r.isEnabled(e),ue={3042:T,2884:T,2929:T,3024:T,32823:T,32926:T,32928:T,3089:T,2960:T,35977:T},Ft=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function O(r,e){if(Ct(e))return;const t={};for(const i in e){const n=Number(i),a=At[i];a&&(typeof a=="string"?t[a]=!0:a(r,e[i],n))}const s=r.state&&r.state.cache;if(s)for(const i in t){const n=Bt[i];n(r,e,s)}}function Ie(r,e=J){if(typeof e=="number"){const i=e,n=ue[i];return n?n(r,i):r.getParameter(i)}const t=Array.isArray(e)?e:Object.keys(e),s={};for(const i of t){const n=ue[i];s[i]=n?n(r,Number(i)):r.getParameter(Number(i))}return s}function Lt(r){O(r,J)}function Ct(r){for(const e in r)return!1;return!0}function kt(r,e){if(r===e)return!0;if(he(r)&&he(e)&&r.length===e.length){for(let t=0;t{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}static get(e){return e.state}push(e={}){this.stateStack.push({})}pop(){const e=this.stateStack[this.stateStack.length-1];O(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t!=null&&t.copyState?Ie(e):Object.assign({},J),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.state=this,Dt(e);for(const s in ce){const i=ce[s];Et(e,s,i)}de(e,"getParameter"),de(e,"isEnabled")}_updateCache(e){let t=!1,s;const i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const n in e){const a=e[n],l=this.cache[n];kt(a,l)||(t=!0,s=l,i&&!(n in i)&&(i[n]=l),this.cache[n]=a)}return{valueChanged:t,oldValue:s}}}function de(r,e){const t=r[e].bind(r);r[e]=function(s){if(s===void 0||Ft.has(s))return t(s);const i=L.get(r);return s in i.cache||(i.cache[s]=t(s)),i.enable?i.cache[s]:t(s)},Object.defineProperty(r[e],"name",{value:`${e}-from-cache`,configurable:!1})}function Et(r,e,t){if(!r[e])return;const s=r[e].bind(r);r[e]=function(...i){const n=L.get(r),{valueChanged:a,oldValue:l}=t(n._updateCache,...i);return a&&s(...i),l},Object.defineProperty(r[e],"name",{value:`${e}-to-cache`,configurable:!1})}function Dt(r){const e=r.useProgram.bind(r);r.useProgram=function(t){const s=L.get(r);s.program!==t&&(e(t),s.program=t)}}function Wt(r,e,t){let s="";const i={preserveDrawingBuffer:!0,...t};let n=null;if(n||(n=r.getContext("webgl2",i)),i.failIfMajorPerformanceCaveat&&(s||(s="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.")),!n&&!t.failIfMajorPerformanceCaveat&&(i.failIfMajorPerformanceCaveat=!1,n=r.getContext("webgl2",i),n.luma||(n.luma={}),n.luma.softwareRenderer=!0),n||(n=r.getContext("webgl",{}),n&&(n=null,s||(s="Your browser only supports WebGL1"))),!n)throw s||(s="Your browser does not support WebGL"),new Error(`Failed to create WebGL context: ${s}`);const{onContextLost:a,onContextRestored:l}=e;return r.addEventListener("webglcontextlost",c=>a(c),!1),r.addEventListener("webglcontextrestored",c=>l(c),!1),n.luma||(n.luma={}),n}function W(r,e,t){return t[e]===void 0&&(t[e]=r.getExtension(e)||null),t[e]}function Ot(r,e){const t=r.getParameter(7936),s=r.getParameter(7937);W(r,"WEBGL_debug_renderer_info",e);const i=e.WEBGL_debug_renderer_info,n=r.getParameter(i?i.UNMASKED_VENDOR_WEBGL:7936),a=r.getParameter(i?i.UNMASKED_RENDERER_WEBGL:7937),l=n||t,c=a||s,u=r.getParameter(7938),h=Ge(l,c),f=Mt(l,c),d=Rt(l,c);return{type:"webgl",gpu:h,gpuType:d,gpuBackend:f,vendor:l,renderer:c,version:u,shadingLanguage:"glsl",shadingLanguageVersion:300}}function Ge(r,e){return/NVIDIA/i.exec(r)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(r)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(r)||/Apple/i.exec(e)?"apple":/AMD/i.exec(r)||/AMD/i.exec(e)||/ATI/i.exec(r)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(r)||/SwiftShader/i.exec(e)?"software":"unknown"}function Mt(r,e){return/Metal/i.exec(r)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(r)||/ANGLE/i.exec(e)?"opengl":"unknown"}function Rt(r,e){if(/SwiftShader/i.exec(r)||/SwiftShader/i.exec(e))return"cpu";switch(Ge(r,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function ze(r){switch(r){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(r))}const $="WEBGL_compressed_texture_s3tc",I="WEBGL_compressed_texture_s3tc_srgb",k="EXT_texture_compression_rgtc",E="EXT_texture_compression_bptc",$t="WEBGL_compressed_texture_etc",It="WEBGL_compressed_texture_astc",Gt="WEBGL_compressed_texture_etc1",zt="WEBGL_compressed_texture_pvrtc",Vt="WEBGL_compressed_texture_atc",fe="EXT_texture_norm16",ge="EXT_render_snorm",Ut="EXT_color_buffer_float",Z={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat-renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[ge],"norm16-renderable-webgl":[fe],"snorm16-renderable-webgl":[fe,ge],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[$,I,k,E],"texture-compression-bc5-webgl":[k],"texture-compression-bc7-webgl":[E],"texture-compression-etc2":[$t],"texture-compression-astc":[It],"texture-compression-etc1-webgl":[Gt],"texture-compression-pvrtc-webgl":[zt],"texture-compression-atc-webgl":[Vt]};function Nt(r){return r in Z}function Ht(r,e,t){return(Z[e]||[]).every(s=>W(r,s,t))}const ee={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0},r16unorm:{gl:33322,rb:!0},r16snorm:{gl:36760},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0},rg16unorm:{gl:33324},rg16snorm:{gl:36761},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326},rgb9e5ufloat:{gl:35901},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852},"rgb16snorm-webgl":{gl:36762},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842},rgba16unorm:{gl:32859,rb:!0},rgba16snorm:{gl:36763},"rgb32float-webgl":{gl:34837,x:Ut,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:$},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:I},"bc1-rgba-unorm":{gl:33777,x:$},"bc1-rgba-unorm-srgb":{gl:35916,x:I},"bc2-rgba-unorm":{gl:33778,x:$},"bc2-rgba-unorm-srgb":{gl:35918,x:I},"bc3-rgba-unorm":{gl:33779,x:$},"bc3-rgba-unorm-srgb":{gl:35919,x:I},"bc4-r-unorm":{gl:36283,x:k},"bc4-r-snorm":{gl:36284,x:k},"bc5-rg-unorm":{gl:36285,x:k},"bc5-rg-snorm":{gl:36286,x:k},"bc6h-rgb-ufloat":{gl:36495,x:E},"bc6h-rgb-float":{gl:36494,x:E},"bc7-rgba-unorm":{gl:36492,x:E},"bc7-rgba-unorm-srgb":{gl:36493,x:E},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37819},"astc-10x5-unorm-srgb":{gl:37851},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rbg2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}};function jt(r,e,t){let s=e.create;const i=ee[e.format];return(i==null?void 0:i.gl)===void 0&&(s=!1),i!=null&&i.x&&(s=s&&!!W(r,i.x,t)),{format:e.format,create:s&&e.create,render:s&&e.render,filter:s&&e.filter,blend:s&&e.blend,store:s&&e.store}}function Ve(r){var e;const t=ee[r],s=Xt(r),i=Se.getInfo(r);return i.compressed&&(t.dataFormat=s),{internalFormat:s,format:(t==null?void 0:t.dataFormat)||qt(i.channels,i.integer,i.normalized,s),type:i.dataType?ze(i.dataType):((e=t==null?void 0:t.types)==null?void 0:e[0])||5121,compressed:i.compressed||!1}}function Qt(r){switch(Se.getInfo(r).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${r}`)}}function qt(r,e,t,s){if(s===6408||s===6407)return s;switch(r){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function Xt(r){const e=ee[r],t=e==null?void 0:e.gl;if(t===void 0)throw new Error(`Unsupported texture format ${r}`);return t}const pe={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class Kt extends Ze{constructor(e,t,s){super([],s),o(this,"gl"),o(this,"extensions"),o(this,"testedFeatures",new Set),this.gl=e,this.extensions=t,W(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){const e=this.getFeatures();for(const t of e)this.has(t)&&(yield t);return[]}has(e){var t;return(t=this.disabledFeatures)!=null&&t[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),Nt(e)&&Ht(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){const e=this.getFeatures().filter(t=>t!=="polygon-mode-webgl");for(const t of e)this.has(t)}getFeatures(){return[...Object.keys(pe),...Object.keys(Z)]}getWebGLFeature(e){const t=pe[e];return typeof t=="string"?!!W(this.gl,t,this.extensions):!!t}}class Yt extends Je{constructor(e){super(),o(this,"gl"),o(this,"limits",{}),this.gl=e}get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}class G extends Fe{constructor(e,t){super(e,t),o(this,"device"),o(this,"gl"),o(this,"handle"),o(this,"colorAttachments",[]),o(this,"depthStencilAttachment",null);const s=t.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||s?this.props.handle:this.gl.createFramebuffer(),s||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.autoCreateAttachmentTextures(),this.updateAttachments())}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){const e=this.gl.bindFramebuffer(36160,this.handle);for(let t=0;t(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){const e=this.device.gl.getShaderInfoLog(this.handle);return e?ir(e):[]}getTranslatedSource(){const e=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return(e==null?void 0:e.getTranslatedShaderSource(this.handle))||null}async _compile(e){e=e.startsWith("#version ")?e:`#version 300 es ${e}`;const{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}p.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),p.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){const e=async s=>await new Promise(i=>setTimeout(i,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}const{gl:t}=this.device;for(;;){if(t.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}function ar(r,e,t,s){if(ur(e))return s(r);const i=r;i.pushState();try{return or(r,e),O(i.gl,t),s(r)}finally{i.popState()}}function or(r,e){const t=r,{gl:s}=t;if(e.cullMode)switch(e.cullMode){case"none":s.disable(2884);break;case"front":s.enable(2884),s.cullFace(1028);break;case"back":s.enable(2884),s.cullFace(1029);break}if(e.frontFace&&s.frontFace(C("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&r.features.has("depth-clip-control")&&s.enable(34383),e.depthBias!==void 0&&(s.enable(32823),s.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&r.features.has("provoking-vertex-webgl")){const i=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,n=C("provokingVertex",e.provokingVertex,{first:36429,last:36430});i==null||i.provokingVertexWEBGL(n)}if((e.polygonMode||e.polygonOffsetLine)&&r.features.has("polygon-mode-webgl")){if(e.polygonMode){const i=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,n=C("polygonMode",e.polygonMode,{fill:6914,line:6913});i==null||i.polygonModeWEBGL(1028,n),i==null||i.polygonModeWEBGL(1029,n)}e.polygonOffsetLine&&s.enable(10754)}if(r.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&s.enable(12288),e.clipDistance1&&s.enable(12289),e.clipDistance2&&s.enable(12290),e.clipDistance3&&s.enable(12291),e.clipDistance4&&s.enable(12292),e.clipDistance5&&s.enable(12293),e.clipDistance6&&s.enable(12294),e.clipDistance7&&s.enable(12295)),e.depthWriteEnabled!==void 0&&s.depthMask(cr("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?s.enable(2929):s.disable(2929),s.depthFunc(K("depthCompare",e.depthCompare))),e.stencilWriteMask){const i=e.stencilWriteMask;s.stencilMaskSeparate(1028,i),s.stencilMaskSeparate(1029,i)}if(e.stencilReadMask&&p.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){const i=e.stencilReadMask||4294967295,n=K("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?s.enable(2960):s.disable(2960),s.stencilFuncSeparate(1028,n,0,i),s.stencilFuncSeparate(1029,n,0,i)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){const i=Q("stencilPassOperation",e.stencilPassOperation),n=Q("stencilFailOperation",e.stencilFailOperation),a=Q("stencilDepthFailOperation",e.stencilDepthFailOperation);s.stencilOpSeparate(1028,n,a,i),s.stencilOpSeparate(1029,n,a,i)}switch(e.blend){case!0:s.enable(3042);break;case!1:s.disable(3042);break}if(e.blendColorOperation||e.blendAlphaOperation){const i=be("blendColorOperation",e.blendColorOperation||"add"),n=be("blendAlphaOperation",e.blendAlphaOperation||"add");s.blendEquationSeparate(i,n);const a=N("blendColorSrcFactor",e.blendColorSrcFactor||"one"),l=N("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=N("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),u=N("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");s.blendFuncSeparate(a,l,c,u)}}function K(r,e){return C(r,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Q(r,e){return C(r,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function be(r,e){return C(r,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function N(r,e,t="color"){return C(r,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:t==="color"?32769:32771,"one-minus-constant":t==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function lr(r,e){return`Illegal parameter ${e} for ${r}`}function C(r,e,t){if(!(e in t))throw new Error(lr(r,e));return t[e]}function cr(r,e){return e}function ur(r){let e=!0;for(const t in r){e=!1;break}return e}function Ue(r){const e={};return r.addressModeU&&(e[10242]=q(r.addressModeU)),r.addressModeV&&(e[10243]=q(r.addressModeV)),r.addressModeW&&(e[32882]=q(r.addressModeW)),r.magFilter&&(e[10240]=Y(r.magFilter)),(r.minFilter||r.mipmapFilter)&&(e[10241]=hr(r.minFilter||"linear",r.mipmapFilter)),r.lodMinClamp!==void 0&&(e[33082]=r.lodMinClamp),r.lodMaxClamp!==void 0&&(e[33083]=r.lodMaxClamp),r.type==="comparison-sampler"&&(e[34892]=34894),r.compare&&(e[34893]=K("compare",r.compare)),r.maxAnisotropy&&(e[34046]=r.maxAnisotropy),e}function q(r){switch(r){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function Y(r){switch(r){case"nearest":return 9728;case"linear":return 9729}}function hr(r,e="none"){if(!e)return Y(r);switch(e){case"none":return Y(r);case"nearest":switch(r){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(r){case"nearest":return 9986;case"linear":return 9987}}}class dr extends et{constructor(e,t){super(e,t),o(this,"device"),o(this,"handle"),o(this,"parameters"),this.device=e,this.parameters=Ue(t),this.handle=t.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(const[t,s]of Object.entries(e)){const i=Number(t);switch(i){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,i,s);break;default:this.device.gl.samplerParameteri(this.handle,i,s);break}}}}function U(r,e,t){if(fr(e))return t(r);const{nocatch:s=!0}=e,i=L.get(r);i.push(),O(r,e);let n;if(s)n=t(r),i.pop();else try{n=t(r)}finally{i.pop()}return n}function fr(r){for(const e in r)return!1;return!0}class D extends nt{constructor(e,t){super(e,{...B.defaultProps,...t}),o(this,"device"),o(this,"gl"),o(this,"handle"),o(this,"texture"),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}class V extends B{constructor(e,t){super(e,t),o(this,"device"),o(this,"gl"),o(this,"handle"),o(this,"sampler"),o(this,"view"),o(this,"glTarget"),o(this,"glFormat"),o(this,"glType"),o(this,"glInternalFormat"),o(this,"compressed"),o(this,"_textureUnit",0),this.device=e,this.gl=this.device.gl;const s=Ve(this.props.format);this.glTarget=gr(this.props.dimension),this.glInternalFormat=s.internalFormat,this.glFormat=s.format,this.glType=s.type,this.compressed=s.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);const{dimension:i,width:n,height:a,depth:l,mipLevels:c,glTarget:u,glInternalFormat:h}=this;switch(i){case"2d":case"cube":this.gl.texStorage2D(u,c,h,n,a);break;case"2d-array":case"3d":this.gl.texStorage3D(u,c,h,n,a,l);break;default:throw new Error(i)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data),this.setSampler(this.props.sampler),this.view=new D(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}createView(e){return new D(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);const t=Ue(this.sampler.props);this._setSamplerParameters(t)}copyImageData(e){const t=this._normalizeCopyImageDataOptions(e),s=t.data,{width:i,height:n,depth:a}=this,{mipLevel:l=0,byteOffset:c=0,x:u=0,y:h=0,z:f=0}=t,{glFormat:d,glType:g,compressed:m}=this,v=ve(this.glTarget,this.dimension,f);let x;if(!this.compressed){const{bytesPerPixel:_}=this.device.getTextureFormatInfo(this.format);if(_){if(t.bytesPerRow%_!==0)throw new Error(`bytesPerRow (${t.bytesPerRow}) must be a multiple of bytesPerPixel (${_}) for ${this.format}`);x=t.bytesPerRow/_}}const w=this.compressed?{}:{...x!==void 0?{3314:x}:{},32878:t.rowsPerImage};this.gl.bindTexture(v,this.handle),U(this.gl,w,()=>{switch(this.dimension){case"2d":case"cube":m?this.gl.compressedTexSubImage2D(v,l,u,h,i,n,d,s,c):this.gl.texSubImage2D(v,l,u,h,i,n,d,g,s,c);break;case"2d-array":case"3d":m?this.gl.compressedTexSubImage3D(v,l,u,h,f,i,n,a,d,s,c):this.gl.texSubImage3D(v,l,u,h,f,i,n,a,d,g,s,c);break;default:}}),this.gl.bindTexture(v,null)}copyExternalImage(e){const t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");const{glFormat:s,glType:i}=this,{image:n,depth:a,mipLevel:l,x:c,y:u,z:h,width:f,height:d}=t,g=ve(this.glTarget,this.dimension,a),m=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),U(this.gl,m,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(g,l,c,u,f,d,s,i,n);break;case"2d-array":case"3d":this.gl.texSubImage3D(g,l,c,u,h,f,d,a,s,i,n);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}generateMipmapsWebGL(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(p.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!(e!=null&&e.force))))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(t){p.warn(`Error generating mipmap for ${this}: ${t.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){p.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(const[t,s]of Object.entries(e)){const i=Number(t),n=s;switch(i){case 33082:case 33083:this.gl.texParameterf(this.glTarget,i,n);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,i,n);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,i,n);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,i,n);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,i,n);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){const{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){const{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}}function gr(r){switch(r){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866}throw new Error(r)}function ve(r,e,t){return e==="cube"?34069+t:r}function pr(r){return yr[r]}function te(r){return vr[r]}function mr(r){return!!Ne[r]}function br(r){return Ne[r]}const vr={5126:"f32",35664:"vec2",35665:"vec3",35666:"vec4",5124:"i32",35667:"vec2",35668:"vec3",35669:"vec4",5125:"u32",36294:"vec2",36295:"vec3",36296:"vec4",35670:"f32",35671:"vec2",35672:"vec3",35673:"vec4",35674:"mat2x2",35685:"mat2x3",35686:"mat2x4",35687:"mat3x2",35675:"mat3x3",35688:"mat3x4",35689:"mat4x2",35690:"mat4x3",35676:"mat4x4"},Ne={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},yr={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126};function xr(r,e){const t={attributes:[],bindings:[]};t.attributes=wr(r,e);const s=Pr(r,e);for(const l of s){const c=l.uniforms.map(u=>({name:u.name,format:u.format,byteOffset:u.byteOffset,byteStride:u.byteStride,arrayLength:u.arrayLength}));t.bindings.push({type:"uniform",name:l.name,group:0,location:l.location,visibility:(l.vertex?1:0)&(l.fragment?2:0),minBindingSize:l.byteLength,uniforms:c})}const i=_r(r,e);let n=0;for(const l of i)if(mr(l.type)){const{viewDimension:c,sampleType:u}=br(l.type);t.bindings.push({type:"texture",name:l.name,group:0,location:n,viewDimension:c,sampleType:u}),l.textureUnit=n,n+=1}i.length&&(t.uniforms=i);const a=Sr(r,e);return a!=null&&a.length&&(t.varyings=a),t}function wr(r,e){const t=[],s=r.getProgramParameter(e,35721);for(let i=0;i=0){const u=te(l),h=/instance/i.test(a)?"instance":"vertex";t.push({name:a,location:c,stepMode:h,type:u})}}return t.sort((i,n)=>i.location-n.location),t}function Sr(r,e){const t=[],s=r.getProgramParameter(e,35971);for(let i=0;ii.location-n.location),t}function _r(r,e){const t=[],s=r.getProgramParameter(e,35718);for(let i=0;i1)for(let g=0;gr.getActiveUniformBlockParameter(e,n,a),s=[],i=r.getProgramParameter(e,35382);for(let n=0;nn.location-a.location),s}function Tr(r){if(r[r.length-1]!=="]")return{name:r,length:1,isArray:!1};const e=/([^[]*)(\[[0-9]+\])?/.exec(r);if(!e||e.length<2)throw new Error(`Failed to parse GLSL uniform name ${r}`);return{name:e[1],length:e[2]?1:0,isArray:!!e[2]}}function Ar(r,e,t,s){const i=r;let n=s;n===!0&&(n=1),n===!1&&(n=0);const a=typeof n=="number"?[n]:n;switch(t){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof s!="number")throw new Error("samplers must be set to integers");return r.uniform1i(e,s);case 5126:return r.uniform1fv(e,a);case 35664:return r.uniform2fv(e,a);case 35665:return r.uniform3fv(e,a);case 35666:return r.uniform4fv(e,a);case 5124:return r.uniform1iv(e,a);case 35667:return r.uniform2iv(e,a);case 35668:return r.uniform3iv(e,a);case 35669:return r.uniform4iv(e,a);case 35670:return r.uniform1iv(e,a);case 35671:return r.uniform2iv(e,a);case 35672:return r.uniform3iv(e,a);case 35673:return r.uniform4iv(e,a);case 5125:return i.uniform1uiv(e,a,1);case 36294:return i.uniform2uiv(e,a,2);case 36295:return i.uniform3uiv(e,a,3);case 36296:return i.uniform4uiv(e,a,4);case 35674:return r.uniformMatrix2fv(e,!1,a);case 35675:return r.uniformMatrix3fv(e,!1,a);case 35676:return r.uniformMatrix4fv(e,!1,a);case 35685:return i.uniformMatrix2x3fv(e,!1,a);case 35686:return i.uniformMatrix2x4fv(e,!1,a);case 35687:return i.uniformMatrix3x2fv(e,!1,a);case 35688:return i.uniformMatrix3x4fv(e,!1,a);case 35689:return i.uniformMatrix4x2fv(e,!1,a);case 35690:return i.uniformMatrix4x3fv(e,!1,a)}throw new Error("Illegal uniform")}function Br(r){switch(r){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(r)}}function Fr(r){switch(r){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(r)}}const ye=4;class Lr extends st{constructor(e,t){super(e,t),o(this,"device"),o(this,"handle"),o(this,"vs"),o(this,"fs"),o(this,"introspectedLayout"),o(this,"uniforms",{}),o(this,"bindings",{}),o(this,"varyings",null),o(this,"_uniformCount",0),o(this,"_uniformSetters",{}),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.vs=t.vs,this.fs=t.fs;const{varyings:s,bufferMode:i=35981}=t;s&&s.length>0&&(this.varyings=s,this.device.gl.transformFeedbackVaryings(this.handle,s,i)),this._linkShaders(),p.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=xr(this.device.gl,this.handle),p.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=t.shaderLayout?Cr(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}destroy(){this.handle&&(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.destroyed=!0,this.handle.destroyed=!0,this.handle=null)}setBindings(e,t){for(const[s,i]of Object.entries(e)){const n=this.shaderLayout.bindings.find(a=>a.name===s)||this.shaderLayout.bindings.find(a=>a.name===`${s}Uniforms`);if(!n){const a=this.shaderLayout.bindings.map(l=>`"${l.name}"`).join(", ");t!=null&&t.disableWarnings||p.warn(`No binding "${s}" in render pipeline "${this.id}", expected one of ${a}`,i)();continue}switch(i||p.warn(`Unsetting binding "${s}" in render pipeline "${this.id}"`)(),n.type){case"uniform":if(!(i instanceof z)&&!(i.buffer instanceof z))throw new Error("buffer value");break;case"texture":if(!(i instanceof D||i instanceof V||i instanceof G))throw new Error(`${this} Bad texture binding for ${s}`);break;case"sampler":p.warn(`Ignoring sampler ${s}`)();break;default:throw new Error(n.type)}this.bindings[s]=i}}draw(e){var t;const{renderPass:s,parameters:i=this.props.parameters,topology:n=this.props.topology,vertexArray:a,vertexCount:l,instanceCount:c,isInstanced:u=!1,firstVertex:h=0,transformFeedback:f}=e,d=Br(n),g=!!a.indexBuffer,m=(t=a.indexBuffer)==null?void 0:t.glIndexType;if(this.linkStatus!=="success")return p.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable())return p.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),a.bindBeforeRender(s),f&&f.begin(this.props.topology),this._applyBindings(),this._applyUniforms();const v=s;return ar(this.device,i,v.glParameters,()=>{g&&u?this.device.gl.drawElementsInstanced(d,l||0,m,h,c||0):g?this.device.gl.drawElements(d,l||0,m,h):u?this.device.gl.drawArraysInstanced(d,h,l||0,c||0):this.device.gl.drawArrays(d,h,l||0),f&&f.end()}),a.unbindAfterRender(s),!0}async _linkShaders(){const{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),p.time(ye,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),p.timeEnd(ye,`linkProgram for ${this.id}`)(),p.level,!this.device.features.has("compilation-status-async-webgl")){const s=this._getLinkStatus();this._reportLinkStatus(s);return}p.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),p.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){var t;switch(e){case"success":return;default:const s=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${s} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break}switch((t=this.fs)==null?void 0:t.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${s} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break}const i=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${s} during ${e}: ${i}`),this)(),this.device.debug()}}_getLinkStatus(){const{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}async _waitForLinkComplete(){const e=async s=>await new Promise(i=>setTimeout(i,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}const{gl:t}=this.device;for(;;){if(t.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(const t of this.shaderLayout.bindings)!this.bindings[t.name]&&!this.bindings[t.name.replace(/Uniforms$/,"")]&&(p.warn(`Binding ${t.name} not found in ${this.id}`)(),e=!1);return e}_applyBindings(){if(this.linkStatus!=="success")return;const{gl:e}=this.device;e.useProgram(this.handle);let t=0,s=0;for(const i of this.shaderLayout.bindings){const n=this.bindings[i.name]||this.bindings[i.name.replace(/Uniforms$/,"")];if(!n)throw new Error(`No value for binding ${i.name} in ${this.id}`);switch(i.type){case"uniform":const{name:a}=i,l=e.getUniformBlockIndex(this.handle,a);if(l===4294967295)throw new Error(`Invalid uniform block name ${a}`);e.uniformBlockBinding(this.handle,s,l),n instanceof z?e.bindBufferBase(35345,s,n.handle):e.bindBufferRange(35345,s,n.buffer.handle,n.offset||0,n.size||n.buffer.byteLength-n.offset),s+=1;break;case"texture":if(!(n instanceof D||n instanceof V||n instanceof G))throw new Error("texture");let c;if(n instanceof D)c=n.texture;else if(n instanceof V)c=n;else if(n instanceof G&&n.colorAttachments[0]instanceof D)p.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),c=n.colorAttachments[0].texture;else throw new Error("No texture");e.activeTexture(33984+t),e.bindTexture(c.glTarget,c.handle),t+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${i.type}' not supported in WebGL`)}}}_applyUniforms(){for(const e of this.shaderLayout.uniforms||[]){const{name:t,location:s,type:i,textureUnit:n}=e,a=this.uniforms[t]??n;a!==void 0&&Ar(this.device.gl,s,i,a)}}}function Cr(r,e){const t={...r,attributes:r.attributes.map(s=>({...s}))};for(const s of(e==null?void 0:e.attributes)||[]){const i=t.attributes.find(n=>n.name===s.name);i?(i.type=s.type||i.type,i.stepMode=s.stepMode||i.stepMode):p.warn(`shader layout attribute ${s.name} not present in shader`)}return t}class kr extends St{constructor(e){super(e,{}),o(this,"device"),o(this,"handle",null),o(this,"commands",[]),this.device=e}_executeCommands(e=this.commands){for(const t of e)switch(t.name){case"copy-buffer-to-buffer":Er(this.device,t.options);break;case"copy-buffer-to-texture":Dr(this.device,t.options);break;case"copy-texture-to-buffer":Wr(this.device,t.options);break;case"copy-texture-to-texture":Or(this.device,t.options);break;default:throw new Error(t.name)}}}function Er(r,e){const t=e.sourceBuffer,s=e.destinationBuffer;r.gl.bindBuffer(36662,t.handle),r.gl.bindBuffer(36663,s.handle),r.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),r.gl.bindBuffer(36662,null),r.gl.bindBuffer(36663,null)}function Dr(r,e){throw new Error("Not implemented")}function Wr(r,e){const{sourceTexture:t,mipLevel:s=0,aspect:i="all",width:n=e.sourceTexture.width,height:a=e.sourceTexture.height,depthOrArrayLayers:l=0,origin:c=[0,0],destinationBuffer:u,byteOffset:h=0,bytesPerRow:f,rowsPerImage:d}=e;if(i!=="all")throw new Error("aspect not supported in WebGL");if(s!==0||l!==0||f||d)throw new Error("not implemented");const{framebuffer:g,destroyFramebuffer:m}=He(t);let v;try{const x=u,w=n||g.width,_=a||g.height,se=Ve(g.colorAttachments[0].texture.props.format),qe=se.format,Xe=se.type;r.gl.bindBuffer(35051,x.handle),v=r.gl.bindFramebuffer(36160,g.handle),r.gl.readPixels(c[0],c[1],w,_,qe,Xe,h)}finally{r.gl.bindBuffer(35051,null),v!==void 0&&r.gl.bindFramebuffer(36160,v),m&&g.destroy()}}function Or(r,e){const{sourceTexture:t,destinationMipLevel:s=0,origin:i=[0,0],destinationOrigin:n=[0,0],destinationTexture:a}=e;let{width:l=e.destinationTexture.width,height:c=e.destinationTexture.height}=e;const{framebuffer:u,destroyFramebuffer:h}=He(t),[f,d]=i,[g,m,v]=n,x=r.gl.bindFramebuffer(36160,u.handle);let w,_;if(a instanceof V)w=a,l=Number.isFinite(l)?l:w.width,c=Number.isFinite(c)?c:w.height,w._bind(0),_=w.glTarget;else throw new Error("invalid destination");switch(_){case 3553:case 34067:r.gl.copyTexSubImage2D(_,s,g,m,f,d,l,c);break;case 35866:case 32879:r.gl.copyTexSubImage3D(_,s,g,m,v,f,d,l,c);break}w&&w._unbind(),r.gl.bindFramebuffer(36160,x),h&&u.destroy()}function He(r){if(r instanceof B){const{width:e,height:t,id:s}=r;return{framebuffer:r.device.createFramebuffer({id:`framebuffer-for-${s}`,width:e,height:t,colorAttachments:[r]}),destroyFramebuffer:!0}}return{framebuffer:r,destroyFramebuffer:!1}}const Mr=[1,2,4,8];class Rr extends xt{constructor(e,t){var s;super(e,t),o(this,"device"),o(this,"handle",null),o(this,"glParameters",{}),this.device=e;let i;if(!((s=t==null?void 0:t.parameters)!=null&&s.viewport))if(t!=null&&t.framebuffer){const{width:a,height:l}=t.framebuffer;i=[0,0,a,l]}else{const[a,l]=e.getDefaultCanvasContext().getDrawingBufferSize();i=[0,0,a,l]}this.device.pushState(),this.setParameters({viewport:i,...this.props.parameters});const n=this.props.framebuffer;if(this.props.framebuffer&&n!=null&&n.handle){const a=this.props.framebuffer.colorAttachments.map((l,c)=>36064+c);this.device.gl.drawBuffers(a)}else this.device.gl.drawBuffers([1029]);this.clear()}end(){this.device.popState()}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){const t={...this.glParameters};t.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),t[2967]=e.stencilReference),"colorMask"in e&&(t.colorMask=Mr.map(s=>!!(s&e.colorMask))),this.glParameters=t,O(this.device.gl,t)}beginOcclusionQuery(e){const t=this.props.occlusionQuerySet;t==null||t.beginOcclusionQuery()}endOcclusionQuery(){const e=this.props.occlusionQuerySet;e==null||e.endOcclusionQuery()}clear(){const e={...this.glParameters};let t=0;this.props.clearColors&&this.props.clearColors.forEach((s,i)=>{s&&this.clearColorBuffer(i,s)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(t|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=1024,e.clearStencil=this.props.clearStencil),t!==0&&U(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){U(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,t);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,t);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,t);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}class xe extends wt{constructor(e,t){super(e,t),o(this,"device"),o(this,"handle",null),o(this,"commandBuffer"),this.device=e,this.commandBuffer=new kr(e)}destroy(){}finish(){return this.commandBuffer}beginRenderPass(e){return new Rr(this.device,e)}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,s){}}function $r(r){const{target:e,source:t,start:s=0,count:i=1}=r,n=t.length,a=i*n;let l=0;for(let c=s;l{for(const t in e)this.setBuffer(t,e[t])})}setBuffer(e,t){const s=this._getVaryingIndex(e),{buffer:i,byteLength:n,byteOffset:a}=this._getBufferRange(t);if(s<0){this.unusedBuffers[e]=i,p.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[s]={buffer:i,byteLength:n,byteOffset:a},this.bindOnUse||this._bindBuffer(s,i,a,n)}getBuffer(e){if(we(e))return this.buffers[e]||null;const t=this._getVaryingIndex(e);return t>=0?this.buffers[t]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof z)return{buffer:e,byteOffset:0,byteLength:e.byteLength};const{buffer:t,byteOffset:s=0,byteLength:i=e.buffer.byteLength}=e;return{buffer:t,byteOffset:s,byteLength:i}}_getVaryingIndex(e){if(we(e))return Number(e);for(const t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(const e in this.buffers){const{buffer:t,byteLength:s,byteOffset:i}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),t,i,s)}}_unbindBuffers(){for(const e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,s=0,i){const n=t&&t.handle;!n||i===void 0?this.gl.bindBufferBase(35982,e,n):this.gl.bindBufferRange(35982,e,n,s,i)}}function we(r){return typeof r=="number"?Number.isInteger(r):/^\d+$/.test(r)}class Vr extends Tt{constructor(e,t){if(super(e,t),o(this,"device"),o(this,"handle"),o(this,"target",null),o(this,"_queryPending",!1),o(this,"_pollingPromise",null),this.device=e,t.count>1)throw new Error("WebGL QuerySet can only have one value");const s=this.device.gl.createQuery();if(!s)throw new Error("WebGL query not supported");this.handle=s,Object.seal(this)}get[Symbol.toStringTag](){return"Query"}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e!=null&&e.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;const e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let t=0;return this._pollingPromise=new Promise((s,i)=>{const n=()=>{this.isResultAvailable()?(s(this.getResult()),this._pollingPromise=null):t++>e?(i("Timed out"),this._pollingPromise=null):requestAnimationFrame(n)};requestAnimationFrame(n)}),this._pollingPromise}}function je(r){switch(r){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function Ur(r){switch(r){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}function Nr(r){return Hr[r]}const Hr={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"};function jr(r,e){var t;const{sourceX:s=0,sourceY:i=0,sourceAttachment:n=0}=e||{};let{target:a=null,sourceWidth:l,sourceHeight:c,sourceDepth:u,sourceFormat:h,sourceType:f}=e||{};const{framebuffer:d,deleteFramebuffer:g}=Qe(r),{gl:m,handle:v}=d;l||(l=d.width),c||(c=d.height);const x=(t=d.colorAttachments[n])==null?void 0:t.texture;if(!x)throw new Error(`Invalid framebuffer attachment ${n}`);u=(x==null?void 0:x.depth)||1,h||(h=(x==null?void 0:x.glFormat)||6408),f||(f=(x==null?void 0:x.glType)||5121),a=Xr(a,f,h,l,c);const w=it(a);f=f||pr(w);const _=m.bindFramebuffer(36160,v);return m.readBuffer(36064+n),m.readPixels(s,i,l,c,h,f,a),m.readBuffer(36064),m.bindFramebuffer(36160,_||null),g&&d.destroy(),a}function Qr(r,e){const{target:t,sourceX:s=0,sourceY:i=0,sourceFormat:n=6408,targetByteOffset:a=0}=e||{};let{sourceWidth:l,sourceHeight:c,sourceType:u}=e||{};const{framebuffer:h,deleteFramebuffer:f}=Qe(r);l=l||h.width,c=c||h.height;const d=h;u=u||5121;let g=t;if(!g){const v=je(n),x=Ur(u),w=a+l*c*v*x;g=d.device.createBuffer({byteLength:w})}const m=r.device.createCommandEncoder();return m.copyTextureToBuffer({sourceTexture:r,width:l,height:c,origin:[s,i],destinationBuffer:g,byteOffset:a}),m.destroy(),f&&h.destroy(),g}function Qe(r){return r instanceof Fe?{framebuffer:r,deleteFramebuffer:!1}:{framebuffer:qr(r),deleteFramebuffer:!0}}function qr(r,e){const{device:t,width:s,height:i,id:n}=r;return t.createFramebuffer({...e,id:`framebuffer-for-${n}`,width:s,height:i,colorAttachments:[r]})}function Xr(r,e,t,s,i,n){if(r)return r;e||(e=5121);const a=Nr(e),l=lt(a),c=je(t);return new l(s*i*c)}class bs extends ie{constructor(e){var t,s;super({...e,id:e.id||tr("webgl-device")}),o(this,"type","webgl"),o(this,"handle"),o(this,"features"),o(this,"limits"),o(this,"info"),o(this,"canvasContext"),o(this,"preferredColorFormat","rgba8unorm"),o(this,"preferredDepthFormat","depth24plus"),o(this,"commandEncoder"),o(this,"lost"),o(this,"_resolveContextLost"),o(this,"gl"),o(this,"_constants"),o(this,"_extensions",{}),o(this,"_polyfilled",!1),o(this,"spectorJS");const i=ie._getCanvasContextProps(e);if(!i)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let n=(s=(t=i.canvas)==null?void 0:t.gl)==null?void 0:s.device;if(n)throw new Error(`WebGL context already attached to device ${n.id}`);this.canvasContext=new er(this,i),this.lost=new Promise(h=>{this._resolveContextLost=h});const a={...e.webgl};i.alphaMode==="premultiplied"&&(a.premultipliedAlpha=!0),e.powerPreference!==void 0&&(a.powerPreference=e.powerPreference);const l=this.props._handle||Wt(this.canvasContext.canvas,{onContextLost:h=>{var f;return(f=this._resolveContextLost)==null?void 0:f.call(this,{reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})},onContextRestored:h=>console.log("WebGL context restored")},a);if(!l)throw new Error("WebGL context creation failed");if(n=l.device,n){if(e._reuseDevices)return p.log(1,`Not creating a new Device, instead returning a reference to Device ${n.id} already attached to WebGL context`,n)(),n._reused=!0,n;throw new Error(`WebGL context already attached to device ${n.id}`)}this.handle=l,this.gl=l,this.spectorJS=Ke({...this.props,gl:this.handle}),this.gl.device=this,this.gl._version=2,this.info=Ot(this.gl,this._extensions),this.limits=new Yt(this.gl),this.features=new Kt(this.gl,this._extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new L(this.gl,{log:(...h)=>p.log(1,...h)()}).trackState(this.gl,{copyState:!1});const c=e.debugWebGL||e.debug,u=e.debugWebGL;c&&(this.gl=Ye(this.gl,{debugWebGL:c,traceWebGL:u}),p.warn("WebGL debug mode activated. Performance reduced.")(),e.debugWebGL&&(p.level=Math.max(p.level,1))),this.commandEncoder=new xe(this,{id:`${this}-command-encoder`})}get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case"unorm8x4-bgra":return!1;default:return!0}}destroy(){!this.props._reuseDevices&&!this._reused&&delete this.gl.device}get isLost(){return this.gl.isContextLost()}getTextureByteAlignment(){return 4}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){const t=this._normalizeBufferProps(e);return new z(this,t)}createTexture(e){return new V(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new dr(this,e)}createShader(e){return new nr(this,e)}createFramebuffer(e){return new G(this,e)}createVertexArray(e){return new re(this,e)}createTransformFeedback(e){return new zr(this,e)}createQuerySet(e){return new Vr(this,e)}createRenderPipeline(e){return new Lr(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(e={}){return new xe(this,e)}submit(e){e||(e=this.commandEncoder.finish(),this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:`${this.id}-default-encoder`})),e._executeCommands()}readPixelsToArrayWebGL(e,t){return jr(e,t)}readPixelsToBufferWebGL(e,t){return Qr(e,t)}setParametersWebGL(e){O(this.gl,e)}getParametersWebGL(e){return Ie(this.gl,e)}withParametersWebGL(e,t){return U(this.gl,e,t)}resetWebGL(){p.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),Lt(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return jt(this.gl,e,this._extensions)}loseDevice(){var e;let t=!1;const s=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return s&&(t=!0,s.loseContext()),(e=this._resolveContextLost)==null||e.call(this,{reason:"destroyed",message:"Application triggered context loss"}),t}pushState(){L.get(this.gl).push()}popState(){L.get(this.gl).pop()}getGLKey(e,t){const s=Number(e);for(const i in this.gl)if(this.gl[i]===s)return`GL.${i}`;return t!=null&&t.emptyIfUnknown?"":String(e)}getGLKeys(e){const t={emptyIfUnknown:!0};return Object.entries(e).reduce((s,[i,n])=>(s[`${i}:${this.getGLKey(i,t)}`]=`${n}:${this.getGLKey(n,t)}`,s),{})}setConstantAttributeWebGL(e,t){const s=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(s).fill(null);const i=this._constants[e];switch(i&&Zr(i,t)&&p.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:Kr(this,e,t);break;case Int32Array:Yr(this,e,t);break;case Uint32Array:Jr(this,e,t);break;default:throw new Error("constant")}}getExtension(e){return W(this.gl,e,this._extensions),this._extensions}_setWebGLDebugMetadata(e,t,s){e.luma=t;const i={props:s.spector,id:s.spector.id};e.__SPECTOR_Metadata=i}}function Kr(r,e,t){switch(t.length){case 1:r.gl.vertexAttrib1fv(e,t);break;case 2:r.gl.vertexAttrib2fv(e,t);break;case 3:r.gl.vertexAttrib3fv(e,t);break;case 4:r.gl.vertexAttrib4fv(e,t);break}}function Yr(r,e,t){r.gl.vertexAttribI4iv(e,t)}function Jr(r,e,t){r.gl.vertexAttribI4uiv(e,t)}function Zr(r,e){if(!r||!e||r.length!==e.length||r.constructor!==e.constructor)return!1;for(let t=0;t - + diff --git a/frontend/package.json b/frontend/package.json index 98753830..4bd5e49d 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "pymc_console", - "version": "0.9.318", + "version": "0.9.319", "description": "Vite + React Dashboard for pyMC_Repeater", "private": true, "type": "module",