From 34ec91849e3e1fc85a690e65b72571b12f2bdac1 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Fri, 24 Jul 2026 08:00:05 +0000 Subject: [PATCH] Release v0.9.339 Automated sync from private repository. Built with obfuscation enabled. --- frontend/dist/VERSION | 2 +- .../assets/AnalyzerFilterPanel-CrV3kw8n.js | 14 + .../assets/AnalyzerFilterPanel-CxNRg_pb.js | 14 - ...WjM.js => AutoConfigureDialog-yPaPohCI.js} | 2 +- ...-uZ-hrJ-I.js => BackupRestore-D9KC5Ou7.js} | 2 +- ...r-BQjI_o60.js => BasemapLayer-DEvncc0Q.js} | 4 +- .../dist/assets/CADCalibration-D6nEV-hE.js | 6 - .../dist/assets/CADCalibration-DEpvVgmC.js | 6 + frontend/dist/assets/ChatBubble-CL_NnCFm.js | 1 + frontend/dist/assets/ChatBubble-Cto97fJB.js | 1 - .../assets/CollisionExplorerModal-BPdmq3zY.js | 1 + .../assets/CollisionExplorerModal-CXE65Kgs.js | 1 - frontend/dist/assets/Companion--88Y1QxY.js | 81 ----- frontend/dist/assets/Companion-CJJQvP9m.js | 81 +++++ .../dist/assets/CompanionEchoMap-CwrYV0II.js | 1 - .../dist/assets/CompanionEchoMap-DGz3ueVV.js | 1 + .../dist/assets/CompanionPathMap-BXnFAxbT.js | 1 - .../dist/assets/CompanionPathMap-BjSrbG5W.js | 1 + .../dist/assets/Configuration-4fw93R2m.js | 27 -- .../dist/assets/Configuration-DoXqskWq.js | 32 ++ ...l-N7ejcMF0.js => ConfirmModal-DdfUdqSh.js} | 2 +- frontend/dist/assets/Contacts-B7pOt7vw.js | 23 -- frontend/dist/assets/Contacts-BgIs_Jxv.js | 23 ++ .../assets/ContactsMapMapLibre-B7iu4Wrl.js | 120 +++++++ .../assets/ContactsMapMapLibre-uomeHQBw.js | 120 ------- frontend/dist/assets/Dashboard-C3FaH0Qe.js | 59 --- frontend/dist/assets/Dashboard-CuqinQI8.js | 59 +++ frontend/dist/assets/DataValue-BKTY-MRe.js | 6 - frontend/dist/assets/DataValue-CLb9j6Y2.js | 6 + .../assets/DatabaseManagement-BCcWi9fg.js | 1 + .../assets/DatabaseManagement-DGsq9tQy.js | 1 - ...CRB1nddk.js => GPSDiagnostics-DN0ovGGX.js} | 4 +- .../{Grid-BkuFQpqe.js => Grid-DKZX3hrI.js} | 2 +- ...n-Bf0Xqhiv.js => KeycapButton-DCfzKeVs.js} | 2 +- ...C-2jB_F1.js => LightSparkline-D_Ijf43d.js} | 2 +- .../{Login-uzprgO4o.js => Login-Dn_n6X4m.js} | 2 +- frontend/dist/assets/Logs-BaMVrclR.js | 6 + frontend/dist/assets/Logs-BtSxheTm.js | 6 - ...ug-CIKTDDAa.js => MemoryDebug-BcvLJ4e2.js} | 4 +- ...raph-DzS7BXkH.js => MeshGraph-o55Zj95w.js} | 218 ++++++------ frontend/dist/assets/Mqtt-DTDhF2ua.js | 14 + frontend/dist/assets/Mqtt-uCJwfeVZ.js | 14 - .../dist/assets/MqttModeBadge-B4hQyJL0.js | 1 - .../dist/assets/MqttModeBadge-Bi4reIK5.js | 1 + ...erver-Dl0Zgx2Q.js => Observer-ByW6o2EO.js} | 4 +- frontend/dist/assets/PacketList-CpAI_DO7.js | 43 +++ frontend/dist/assets/PacketList-oxG3OP6G.js | 43 --- .../dist/assets/PacketObservatory-DWRq0Fon.js | 10 + .../dist/assets/PacketObservatory-D_VfQnXA.js | 10 - frontend/dist/assets/Packets-B30-MXcv.js | 6 + frontend/dist/assets/Packets-YB_Gdtg_.js | 6 - ...out-CIUNh3-q.js => PageLayout-BB80XCAa.js} | 2 +- .../dist/assets/PathMapMapLibre-DCSY02VW.js | 1 + .../dist/assets/PathMapMapLibre-DLvyZG1q.js | 1 - ...e-Djrimidm.js => PolicyEngine-D_T7t4ZE.js} | 4 +- ...-1Hg2MB1y.js => RadioHardware-BEOwqzrn.js} | 4 +- ...gV5.js => RfHealthCorrelation-DeArgl0x.js} | 4 +- frontend/dist/assets/RoomServer-CYBBp3Hj.js | 21 ++ frontend/dist/assets/RoomServer-D83Fxg-R.js | 21 -- frontend/dist/assets/Sensors-BlHZX952.js | 1 - frontend/dist/assets/Sensors-DaOlo-d3.js | 1 + frontend/dist/assets/Sessions-C-rDq-V5.js | 21 ++ frontend/dist/assets/Sessions-WPFvFfrz.js | 21 -- .../{Setup-B3cBVubH.js => Setup-BcJR9kVZ.js} | 2 +- ...xssCk5q.js => SignalIndicator-ouvwsHYL.js} | 12 +- frontend/dist/assets/Statistics-BcYpb1vm.js | 41 +++ frontend/dist/assets/Statistics-DOyt9nxv.js | 41 --- frontend/dist/assets/System-BhAH8I_W.js | 6 + frontend/dist/assets/System-C7KPZLI3.js | 6 - ...minal-2Tkr8WjQ.js => Terminal-D7_s4Aik.js} | 182 +++++----- frontend/dist/assets/Test-CAIak1KY.js | 12 - frontend/dist/assets/Test-CBFjSyTN.js | 12 + ...EoUoXy.js => TimeRangeStepper-DpFgHm1c.js} | 2 +- frontend/dist/assets/WorkspaceNav-DR8N-VVk.js | 11 - frontend/dist/assets/WorkspaceNav-ZTG5UTjF.js | 11 + ...ivity-BkgN42Nd.js => activity-Uf5hjDsb.js} | 2 +- ...ntenna-CLTumJYG.js => antenna-DGc7zBO5.js} | 2 +- ...own-D3Og9nmH.js => arrow-down-BSET2HFf.js} | 2 +- ...ht-DWDq16dR.js => arrow-right-CKd6FEys.js} | 2 +- ...ow-up-BTjk9GGV.js => arrow-up-BhkqGmoP.js} | 2 +- frontend/dist/assets/backup-COxwEanx.js | 1 + frontend/dist/assets/backup-fw4AXrb3.js | 1 - .../{car-a6j4OITc.js => car-DIm4EGM2.js} | 2 +- frontend/dist/assets/chat-utils-CSGjqJAH.js | 1 + frontend/dist/assets/chat-utils-cUFDkDW9.js | 1 - ...ck-pAz6zpcW.js => check-check-ai3mrJDi.js} | 2 +- ...-up-DnvCDHr4.js => chevron-up-5j_tGU02.js} | 2 +- ...t-ChQ9pkTw.js => circle-alert-BYJOlPMS.js} | 2 +- ...Dj.js => circle-question-mark-BCu1neoJ.js} | 2 +- ...op-DvWDpVYR.js => circle-stop-DpTN2RLr.js} | 2 +- .../{clock-B5Mz4CYE.js => clock-BDyTFNOi.js} | 2 +- ...ompass-BgtU0bsV.js => compass-D1WTkLry.js} | 2 +- ...Z8uUk.js => consumer-registry-CcmnLgp9.js} | 2 +- ...abase-CmaQi6im.js => database-DdztsIWz.js} | 2 +- ...{easing-t1ilSJHb.js => easing-CZi_Z9ob.js} | 2 +- .../dist/assets/element-movement-BoSGi6nG.js | 1 - .../dist/assets/element-movement-CCLCtDhK.js | 1 + .../{eye-BFnCwXMu.js => eye-CrxD2Rly.js} | 2 +- frontend/dist/assets/fieldset-C4AcLahj.js | 1 + frontend/dist/assets/fieldset-aUG70RJO.js | 1 - ...ating-CZl1NkX5.js => floating-wXUaY1-5.js} | 2 +- frontend/dist/assets/folder-lock-zGoUhhVc.js | 6 - ...{frozen-QwMVzSxT.js => frozen-DKHgF7-0.js} | 2 +- ...{funnel-DYG0Qmvo.js => funnel-CubiYDNe.js} | 2 +- ...nch-CjkWLr6F.js => git-branch-B0JLmrv3.js} | 2 +- .../{hash-ErPI6vfz.js => hash-0CI2pLT2.js} | 2 +- frontend/dist/assets/index-6Dqm8vG_.css | 1 + frontend/dist/assets/index-BdFZD4tW.js | 336 ------------------ frontend/dist/assets/index-BmiOWPPt.js | 1 - frontend/dist/assets/index-Ch85h29t.js | 336 ++++++++++++++++++ .../{index-CP2gQEIq.js => index-DT64AA0T.js} | 2 +- frontend/dist/assets/index-Ds7D6791.js | 1 + frontend/dist/assets/index-GZXSFQwe.css | 1 - ...ound-Ca3f2GE6.js => key-round-DLgdhdTl.js} | 2 +- .../{layer-Cmi1sSNL.js => layer-Xsjnvj9G.js} | 2 +- ...{layers-Bb9q2u_U.js => layers-CX8YDGoV.js} | 2 +- ...g-B9O-D6Nl.js => link-scoring-CktBMF1N.js} | 2 +- frontend/dist/assets/listbox-BSlt6lH8.js | 1 + frontend/dist/assets/listbox-CXq_NRiz.js | 1 - ...ce-CrkUSa23.js => maintenance-C9dRHitM.js} | 2 +- ...ap-pin-tb6dvUSl.js => map-pin-c0Hi1adb.js} | 2 +- ...ff-pPPXHu6z.js => map-pin-off-D_9hye06.js} | 2 +- ...gl-CCzDK-FD.js => maplibre-gl-BeaixZtx.js} | 2 +- .../{max-E5sjxGXN.js => max-BLfoWvHq.js} | 4 +- ...DHQyMVSe.js => message-square-qYH6IQrI.js} | 2 +- ...Ko0.js => message-square-text-nk0L_Lnn.js} | 2 +- ...2jiR.js => monitor-smartphone-CTx9MPdz.js} | 2 +- ...etwork-B6X_McVo.js => network-BXaAs0UE.js} | 2 +- ...pes-BqQm1p4f.js => node-types-CUHPebtj.js} | 2 +- ...-84fg8Ib.js => payload-detail-CX4NrBt7.js} | 2 +- ...{pencil-CsCVD6uI.js => pencil-BZOxTwpZ.js} | 2 +- .../{ping-BDEGZvTB.js => ping-RnwmT7Gq.js} | 2 +- .../{plus-J10T9_Ph.js => plus-C7tLXNBe.js} | 2 +- ...ves-DerYNiT_.js => primitives-0kpEEJAy.js} | 2 +- frontend/dist/assets/radio-group-elwRJEn2.js | 6 + ...{repeat-D_z9MmTf.js => repeat-DVY-bBc4.js} | 2 +- ...ccw-3--rrl0z.js => rotate-ccw-Bkw4kxED.js} | 2 +- ...e-cw-QA6rmNUy.js => rotate-cw-BaBee29m.js} | 2 +- .../{route-CfTN_kyx.js => route-P3Lngy7n.js} | 2 +- ...lite-CTrgJkff.js => satellite-NJmZkhU-.js} | 2 +- .../{save-CUUX0zl8.js => save-Ci6Me-tl.js} | 2 +- ...{search-83w2lV8z.js => search-Dp7kJbPL.js} | 2 +- ...-B3HlOVfd.js => setting-field-C4EiJNDk.js} | 2 +- ...s-2-BLMb3pBn.js => settings-2-CA3-slil.js} | 2 +- .../{setup-Bj5by3EZ.js => setup-BmP9ApFU.js} | 2 +- ...hare-2-KLAGGeDO.js => share-2-xeKwph2s.js} | 2 +- ...{shield-Jo4379LI.js => shield-651xYu1q.js} | 2 +- ...k-DqZm2nm3.js => shield-check-DF8MawhL.js} | 2 +- ...rkles-CBpWDpkg.js => sparkles-DLR0cBlA.js} | 2 +- frontend/dist/assets/system-D8kFotbu.js | 1 + frontend/dist/assets/system-DPP-2Czb.js | 1 - ...{target-B6gSZQdg.js => target-ISEIkLpl.js} | 2 +- ...er-BVVRGJpK.js => thermometer-B01w9TEg.js} | 2 +- .../{timer-BRW2IWL3.js => timer-BakEn2KK.js} | 2 +- .../dist/assets/topology.worker-BkgWZxgB.js | 9 + .../dist/assets/topology.worker-ByPK8c9Q.js | 9 - frontend/dist/assets/transport-50jRpUgK.js | 1 - frontend/dist/assets/transport-DFlFRyLO.js | 1 + ...rash-2-B1G94Z60.js => trash-2-D_NWmP0i.js} | 2 +- ...{upload-DqygZ61q.js => upload-BOBY87np.js} | 2 +- .../dist/assets/use-by-comparator-DeUfymOv.js | 1 + ...DuhO7-HX.js => use-text-value-CQ3ua4o5.js} | 2 +- .../dist/assets/use-tree-walker-BovUPEpi.js | 1 - .../dist/assets/use-tree-walker-CT3tHYMm.js | 1 + .../dist/assets/useMapViewStore-CaKi0BBI.js | 6 + .../dist/assets/useMapViewStore-Cx-3a39J.js | 6 - ...C5u-iu.js => usePipelineStore-BfPa6Qak.js} | 6 +- ...-XUa2wZbr.js => useReplayTick-DnxaulGE.js} | 2 +- ...iants-FYWzMom7.js => variants-DSc9sq6e.js} | 4 +- ...-DJklHh-3.js => wand-sparkles-Br5G9OBm.js} | 2 +- .../{waves-B2Nk_ZbB.js => waves-gijYhx2Q.js} | 2 +- ...i.js => webgl-device-QoBMYpnS-C-cGmNtG.js} | 2 +- .../{wifi-BYutYmlw.js => wifi-N54J6ORS.js} | 2 +- ...i-off-NXSZOryN.js => wifi-off-8456H55-.js} | 2 +- ...{wrench-wNCT0Kep.js => wrench-CwAAn8Ca.js} | 2 +- .../{zap-CpJxzJYo.js => zap-B2tEMCsA.js} | 2 +- frontend/dist/index.html | 4 +- frontend/package.json | 2 +- 178 files changed, 1218 insertions(+), 1212 deletions(-) create mode 100644 frontend/dist/assets/AnalyzerFilterPanel-CrV3kw8n.js delete mode 100644 frontend/dist/assets/AnalyzerFilterPanel-CxNRg_pb.js rename frontend/dist/assets/{AutoConfigureDialog-C3FQqWjM.js => AutoConfigureDialog-yPaPohCI.js} (90%) rename frontend/dist/assets/{BackupRestore-uZ-hrJ-I.js => BackupRestore-D9KC5Ou7.js} (93%) rename frontend/dist/assets/{BasemapLayer-BQjI_o60.js => BasemapLayer-DEvncc0Q.js} (98%) delete mode 100644 frontend/dist/assets/CADCalibration-D6nEV-hE.js create mode 100644 frontend/dist/assets/CADCalibration-DEpvVgmC.js create mode 100644 frontend/dist/assets/ChatBubble-CL_NnCFm.js delete mode 100644 frontend/dist/assets/ChatBubble-Cto97fJB.js create mode 100644 frontend/dist/assets/CollisionExplorerModal-BPdmq3zY.js delete mode 100644 frontend/dist/assets/CollisionExplorerModal-CXE65Kgs.js delete mode 100644 frontend/dist/assets/Companion--88Y1QxY.js create mode 100644 frontend/dist/assets/Companion-CJJQvP9m.js delete mode 100644 frontend/dist/assets/CompanionEchoMap-CwrYV0II.js create mode 100644 frontend/dist/assets/CompanionEchoMap-DGz3ueVV.js delete mode 100644 frontend/dist/assets/CompanionPathMap-BXnFAxbT.js create mode 100644 frontend/dist/assets/CompanionPathMap-BjSrbG5W.js delete mode 100644 frontend/dist/assets/Configuration-4fw93R2m.js create mode 100644 frontend/dist/assets/Configuration-DoXqskWq.js rename frontend/dist/assets/{ConfirmModal-N7ejcMF0.js => ConfirmModal-DdfUdqSh.js} (50%) delete mode 100644 frontend/dist/assets/Contacts-B7pOt7vw.js create mode 100644 frontend/dist/assets/Contacts-BgIs_Jxv.js create mode 100644 frontend/dist/assets/ContactsMapMapLibre-B7iu4Wrl.js delete mode 100644 frontend/dist/assets/ContactsMapMapLibre-uomeHQBw.js delete mode 100644 frontend/dist/assets/Dashboard-C3FaH0Qe.js create mode 100644 frontend/dist/assets/Dashboard-CuqinQI8.js delete mode 100644 frontend/dist/assets/DataValue-BKTY-MRe.js create mode 100644 frontend/dist/assets/DataValue-CLb9j6Y2.js create mode 100644 frontend/dist/assets/DatabaseManagement-BCcWi9fg.js delete mode 100644 frontend/dist/assets/DatabaseManagement-DGsq9tQy.js rename frontend/dist/assets/{GPSDiagnostics-CRB1nddk.js => GPSDiagnostics-DN0ovGGX.js} (79%) rename frontend/dist/assets/{Grid-BkuFQpqe.js => Grid-DKZX3hrI.js} (95%) rename frontend/dist/assets/{KeycapButton-Bf0Xqhiv.js => KeycapButton-DCfzKeVs.js} (98%) rename frontend/dist/assets/{LightSparkline-C-2jB_F1.js => LightSparkline-D_Ijf43d.js} (96%) rename frontend/dist/assets/{Login-uzprgO4o.js => Login-Dn_n6X4m.js} (99%) create mode 100644 frontend/dist/assets/Logs-BaMVrclR.js delete mode 100644 frontend/dist/assets/Logs-BtSxheTm.js rename frontend/dist/assets/{MemoryDebug-CIKTDDAa.js => MemoryDebug-BcvLJ4e2.js} (92%) rename frontend/dist/assets/{MeshGraph-DzS7BXkH.js => MeshGraph-o55Zj95w.js} (54%) create mode 100644 frontend/dist/assets/Mqtt-DTDhF2ua.js delete mode 100644 frontend/dist/assets/Mqtt-uCJwfeVZ.js delete mode 100644 frontend/dist/assets/MqttModeBadge-B4hQyJL0.js create mode 100644 frontend/dist/assets/MqttModeBadge-Bi4reIK5.js rename frontend/dist/assets/{Observer-Dl0Zgx2Q.js => Observer-ByW6o2EO.js} (91%) create mode 100644 frontend/dist/assets/PacketList-CpAI_DO7.js delete mode 100644 frontend/dist/assets/PacketList-oxG3OP6G.js create mode 100644 frontend/dist/assets/PacketObservatory-DWRq0Fon.js delete mode 100644 frontend/dist/assets/PacketObservatory-D_VfQnXA.js create mode 100644 frontend/dist/assets/Packets-B30-MXcv.js delete mode 100644 frontend/dist/assets/Packets-YB_Gdtg_.js rename frontend/dist/assets/{PageLayout-CIUNh3-q.js => PageLayout-BB80XCAa.js} (92%) create mode 100644 frontend/dist/assets/PathMapMapLibre-DCSY02VW.js delete mode 100644 frontend/dist/assets/PathMapMapLibre-DLvyZG1q.js rename frontend/dist/assets/{PolicyEngine-Djrimidm.js => PolicyEngine-D_T7t4ZE.js} (94%) rename frontend/dist/assets/{RadioHardware-1Hg2MB1y.js => RadioHardware-BEOwqzrn.js} (93%) rename frontend/dist/assets/{RfHealthCorrelation-D-I53gV5.js => RfHealthCorrelation-DeArgl0x.js} (84%) create mode 100644 frontend/dist/assets/RoomServer-CYBBp3Hj.js delete mode 100644 frontend/dist/assets/RoomServer-D83Fxg-R.js delete mode 100644 frontend/dist/assets/Sensors-BlHZX952.js create mode 100644 frontend/dist/assets/Sensors-DaOlo-d3.js create mode 100644 frontend/dist/assets/Sessions-C-rDq-V5.js delete mode 100644 frontend/dist/assets/Sessions-WPFvFfrz.js rename frontend/dist/assets/{Setup-B3cBVubH.js => Setup-BcJR9kVZ.js} (94%) rename frontend/dist/assets/{SignalIndicator-CxssCk5q.js => SignalIndicator-ouvwsHYL.js} (74%) create mode 100644 frontend/dist/assets/Statistics-BcYpb1vm.js delete mode 100644 frontend/dist/assets/Statistics-DOyt9nxv.js create mode 100644 frontend/dist/assets/System-BhAH8I_W.js delete mode 100644 frontend/dist/assets/System-C7KPZLI3.js rename frontend/dist/assets/{Terminal-2Tkr8WjQ.js => Terminal-D7_s4Aik.js} (75%) delete mode 100644 frontend/dist/assets/Test-CAIak1KY.js create mode 100644 frontend/dist/assets/Test-CBFjSyTN.js rename frontend/dist/assets/{TimeRangeStepper-DKEoUoXy.js => TimeRangeStepper-DpFgHm1c.js} (50%) delete mode 100644 frontend/dist/assets/WorkspaceNav-DR8N-VVk.js create mode 100644 frontend/dist/assets/WorkspaceNav-ZTG5UTjF.js rename frontend/dist/assets/{activity-BkgN42Nd.js => activity-Uf5hjDsb.js} (89%) rename frontend/dist/assets/{antenna-CLTumJYG.js => antenna-DGc7zBO5.js} (91%) rename frontend/dist/assets/{arrow-down-D3Og9nmH.js => arrow-down-BSET2HFf.js} (86%) rename frontend/dist/assets/{arrow-right-DWDq16dR.js => arrow-right-CKd6FEys.js} (86%) rename frontend/dist/assets/{arrow-up-BTjk9GGV.js => arrow-up-BhkqGmoP.js} (86%) create mode 100644 frontend/dist/assets/backup-COxwEanx.js delete mode 100644 frontend/dist/assets/backup-fw4AXrb3.js rename frontend/dist/assets/{car-a6j4OITc.js => car-DIm4EGM2.js} (92%) create mode 100644 frontend/dist/assets/chat-utils-CSGjqJAH.js delete mode 100644 frontend/dist/assets/chat-utils-cUFDkDW9.js rename frontend/dist/assets/{check-check-pAz6zpcW.js => check-check-ai3mrJDi.js} (88%) rename frontend/dist/assets/{chevron-up-DnvCDHr4.js => chevron-up-5j_tGU02.js} (99%) rename frontend/dist/assets/{circle-alert-ChQ9pkTw.js => circle-alert-BYJOlPMS.js} (90%) rename frontend/dist/assets/{circle-question-mark-_koL3DDj.js => circle-question-mark-BCu1neoJ.js} (89%) rename frontend/dist/assets/{circle-stop-DvWDpVYR.js => circle-stop-DpTN2RLr.js} (94%) rename frontend/dist/assets/{clock-B5Mz4CYE.js => clock-BDyTFNOi.js} (87%) rename frontend/dist/assets/{compass-BgtU0bsV.js => compass-D1WTkLry.js} (89%) rename frontend/dist/assets/{consumer-registry-CtGZ8uUk.js => consumer-registry-CcmnLgp9.js} (92%) rename frontend/dist/assets/{database-CmaQi6im.js => database-DdztsIWz.js} (90%) rename frontend/dist/assets/{easing-t1ilSJHb.js => easing-CZi_Z9ob.js} (57%) delete mode 100644 frontend/dist/assets/element-movement-BoSGi6nG.js create mode 100644 frontend/dist/assets/element-movement-CCLCtDhK.js rename frontend/dist/assets/{eye-BFnCwXMu.js => eye-CrxD2Rly.js} (89%) create mode 100644 frontend/dist/assets/fieldset-C4AcLahj.js delete mode 100644 frontend/dist/assets/fieldset-aUG70RJO.js rename frontend/dist/assets/{floating-CZl1NkX5.js => floating-wXUaY1-5.js} (93%) delete mode 100644 frontend/dist/assets/folder-lock-zGoUhhVc.js rename frontend/dist/assets/{frozen-QwMVzSxT.js => frozen-DKHgF7-0.js} (78%) rename frontend/dist/assets/{funnel-DYG0Qmvo.js => funnel-CubiYDNe.js} (90%) rename frontend/dist/assets/{git-branch-CjkWLr6F.js => git-branch-B0JLmrv3.js} (90%) rename frontend/dist/assets/{hash-ErPI6vfz.js => hash-0CI2pLT2.js} (91%) create mode 100644 frontend/dist/assets/index-6Dqm8vG_.css delete mode 100644 frontend/dist/assets/index-BdFZD4tW.js delete mode 100644 frontend/dist/assets/index-BmiOWPPt.js create mode 100644 frontend/dist/assets/index-Ch85h29t.js rename frontend/dist/assets/{index-CP2gQEIq.js => index-DT64AA0T.js} (87%) create mode 100644 frontend/dist/assets/index-Ds7D6791.js delete mode 100644 frontend/dist/assets/index-GZXSFQwe.css rename frontend/dist/assets/{key-round-Ca3f2GE6.js => key-round-DLgdhdTl.js} (92%) rename frontend/dist/assets/{layer-Cmi1sSNL.js => layer-Xsjnvj9G.js} (95%) rename frontend/dist/assets/{layers-Bb9q2u_U.js => layers-CX8YDGoV.js} (92%) rename frontend/dist/assets/{link-scoring-B9O-D6Nl.js => link-scoring-CktBMF1N.js} (94%) create mode 100644 frontend/dist/assets/listbox-BSlt6lH8.js delete mode 100644 frontend/dist/assets/listbox-CXq_NRiz.js rename frontend/dist/assets/{maintenance-CrkUSa23.js => maintenance-C9dRHitM.js} (90%) rename frontend/dist/assets/{map-pin-tb6dvUSl.js => map-pin-c0Hi1adb.js} (89%) rename frontend/dist/assets/{map-pin-off-pPPXHu6z.js => map-pin-off-D_9hye06.js} (93%) rename frontend/dist/assets/{maplibre-gl-CCzDK-FD.js => maplibre-gl-BeaixZtx.js} (99%) rename frontend/dist/assets/{max-E5sjxGXN.js => max-BLfoWvHq.js} (93%) rename frontend/dist/assets/{message-square-DHQyMVSe.js => message-square-qYH6IQrI.js} (90%) rename frontend/dist/assets/{message-square-text-zU23jKo0.js => message-square-text-nk0L_Lnn.js} (92%) rename frontend/dist/assets/{monitor-smartphone-B-al2jiR.js => monitor-smartphone-CTx9MPdz.js} (92%) rename frontend/dist/assets/{network-B6X_McVo.js => network-BXaAs0UE.js} (92%) rename frontend/dist/assets/{node-types-BqQm1p4f.js => node-types-CUHPebtj.js} (85%) rename frontend/dist/assets/{payload-detail--84fg8Ib.js => payload-detail-CX4NrBt7.js} (58%) rename frontend/dist/assets/{pencil-CsCVD6uI.js => pencil-BZOxTwpZ.js} (90%) rename frontend/dist/assets/{ping-BDEGZvTB.js => ping-RnwmT7Gq.js} (95%) rename frontend/dist/assets/{plus-J10T9_Ph.js => plus-C7tLXNBe.js} (87%) rename frontend/dist/assets/{primitives-DerYNiT_.js => primitives-0kpEEJAy.js} (81%) create mode 100644 frontend/dist/assets/radio-group-elwRJEn2.js rename frontend/dist/assets/{repeat-D_z9MmTf.js => repeat-DVY-bBc4.js} (91%) rename frontend/dist/assets/{rotate-ccw-3--rrl0z.js => rotate-ccw-Bkw4kxED.js} (89%) rename frontend/dist/assets/{rotate-cw-QA6rmNUy.js => rotate-cw-BaBee29m.js} (88%) rename frontend/dist/assets/{route-CfTN_kyx.js => route-P3Lngy7n.js} (94%) rename frontend/dist/assets/{satellite-CTrgJkff.js => satellite-NJmZkhU-.js} (94%) rename frontend/dist/assets/{save-CUUX0zl8.js => save-Ci6Me-tl.js} (91%) rename frontend/dist/assets/{search-83w2lV8z.js => search-Dp7kJbPL.js} (87%) rename frontend/dist/assets/{setting-field-B3HlOVfd.js => setting-field-C4EiJNDk.js} (71%) rename frontend/dist/assets/{settings-2-BLMb3pBn.js => settings-2-CA3-slil.js} (89%) rename frontend/dist/assets/{setup-Bj5by3EZ.js => setup-BmP9ApFU.js} (88%) rename frontend/dist/assets/{share-2-KLAGGeDO.js => share-2-xeKwph2s.js} (91%) rename frontend/dist/assets/{shield-Jo4379LI.js => shield-651xYu1q.js} (91%) rename frontend/dist/assets/{shield-check-DqZm2nm3.js => shield-check-DF8MawhL.js} (92%) rename frontend/dist/assets/{sparkles-CBpWDpkg.js => sparkles-DLR0cBlA.js} (93%) create mode 100644 frontend/dist/assets/system-D8kFotbu.js delete mode 100644 frontend/dist/assets/system-DPP-2Czb.js rename frontend/dist/assets/{target-B6gSZQdg.js => target-ISEIkLpl.js} (88%) rename frontend/dist/assets/{thermometer-BVVRGJpK.js => thermometer-B01w9TEg.js} (88%) rename frontend/dist/assets/{timer-BRW2IWL3.js => timer-BakEn2KK.js} (90%) create mode 100644 frontend/dist/assets/topology.worker-BkgWZxgB.js delete mode 100644 frontend/dist/assets/topology.worker-ByPK8c9Q.js delete mode 100644 frontend/dist/assets/transport-50jRpUgK.js create mode 100644 frontend/dist/assets/transport-DFlFRyLO.js rename frontend/dist/assets/{trash-2-B1G94Z60.js => trash-2-D_NWmP0i.js} (91%) rename frontend/dist/assets/{upload-DqygZ61q.js => upload-BOBY87np.js} (89%) create mode 100644 frontend/dist/assets/use-by-comparator-DeUfymOv.js rename frontend/dist/assets/{use-text-value-DuhO7-HX.js => use-text-value-CQ3ua4o5.js} (93%) delete mode 100644 frontend/dist/assets/use-tree-walker-BovUPEpi.js create mode 100644 frontend/dist/assets/use-tree-walker-CT3tHYMm.js create mode 100644 frontend/dist/assets/useMapViewStore-CaKi0BBI.js delete mode 100644 frontend/dist/assets/useMapViewStore-Cx-3a39J.js rename frontend/dist/assets/{usePipelineStore-BbC5u-iu.js => usePipelineStore-BfPa6Qak.js} (73%) rename frontend/dist/assets/{useReplayTick-XUa2wZbr.js => useReplayTick-DnxaulGE.js} (97%) rename frontend/dist/assets/{variants-FYWzMom7.js => variants-DSc9sq6e.js} (82%) rename frontend/dist/assets/{wand-sparkles-DJklHh-3.js => wand-sparkles-Br5G9OBm.js} (93%) rename frontend/dist/assets/{waves-B2Nk_ZbB.js => waves-gijYhx2Q.js} (92%) rename frontend/dist/assets/{webgl-device-QoBMYpnS-Ddj5m3ui.js => webgl-device-QoBMYpnS-C-cGmNtG.js} (99%) rename frontend/dist/assets/{wifi-BYutYmlw.js => wifi-N54J6ORS.js} (91%) rename frontend/dist/assets/{wifi-off-NXSZOryN.js => wifi-off-8456H55-.js} (93%) rename frontend/dist/assets/{wrench-wNCT0Kep.js => wrench-CwAAn8Ca.js} (90%) rename frontend/dist/assets/{zap-CpJxzJYo.js => zap-B2tEMCsA.js} (89%) diff --git a/frontend/dist/VERSION b/frontend/dist/VERSION index 56832607..a5d984c0 100644 --- a/frontend/dist/VERSION +++ b/frontend/dist/VERSION @@ -1 +1 @@ -0.9.338 +0.9.339 diff --git a/frontend/dist/assets/AnalyzerFilterPanel-CrV3kw8n.js b/frontend/dist/assets/AnalyzerFilterPanel-CrV3kw8n.js new file mode 100644 index 00000000..f75bc063 --- /dev/null +++ b/frontend/dist/assets/AnalyzerFilterPanel-CrV3kw8n.js @@ -0,0 +1,14 @@ +import{e as q,d3 as G,at as Q,R as V,cy as Y,z as J,r as i,j as n,bO as X,B as Z,N as W,cL as ee}from"./index-Ch85h29t.js";import{c as te}from"./node-types-CUHPebtj.js";import{M as se}from"./monitor-smartphone-CTx9MPdz.js";import{C as ne}from"./circle-question-mark-BCu1neoJ.js";import{F as oe}from"./funnel-CubiYDNe.js";import{S as re}from"./search-Dp7kJbPL.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 ae=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],le=q("circle",ae);/** + * @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 ie=[["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"}]],de=q("droplets",ie);function ye(){return{timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}}function ce(d,a){const{timeStart:c,timeEnd:s,deviceTypes:o,nodeIds:x,disabledNodeIds:y,nodeFilterMode:N}=d,w=!0,u=o.size>0;let v;if(y.size>0){v=new Set;for(const M of x)y.has(M)||v.add(M)}else v=x;const g=v.size>0;let S=null;return g&&(S=G(v)),{hasTime:w,hasDevice:u,hasNode:g,tStart:c??a.start,tEnd:s??a.end,deviceTypes:o,effectiveNodeIds:v,nodeIdPrefixes:S,nodeFilterMode:N,needsDisambiguation:u||g}}function ue(d,a,c){if(d.timestampa.tEnd)return!1;if(a.needsDisambiguation){const s=c(d);if(a.hasDevice&&!a.deviceTypes.has(s.type))return!1;if(a.hasNode){if(a.nodeFilterMode==="observed"){let o=!1;if(s.hash&&a.effectiveNodeIds.has(s.hash)&&(o=!0),!o&&d.dst_hash)if(a.effectiveNodeIds.has(d.dst_hash))o=!0;else{const x=Q(d.dst_hash);a.nodeIdPrefixes.has(x)&&(o=!0)}if(!o){const x=d.forwarded_path??d.original_path;if(x&&Array.isArray(x))for(const y of x){const N=String(y).toUpperCase();if(a.nodeIdPrefixes.has(N)){o=!0;break}}}if(!o)return!1}else if(!s.hash||!a.effectiveNodeIds.has(s.hash))return!1}}return!0}function we(d,a,c,s){const o=ce(a,s);return d.filter(x=>ue(x,o,c))}function B(d,a,c){const s=new Date(d*1e3),o=W(s,c);return a<24?o:`${ee(s,c,{month:"short",day:"numeric"})} ${o}`}const me=[{type:"repeater",label:"Repeater",icon:V,buttonColor:"primary",iconColor:"text-sys-blue",hoverClass:"hover:border-sys-blue hover:text-sys-blue hover:!bg-transparent"},{type:"companion",label:"Companion",icon:se,buttonColor:"indigo",iconColor:"text-sys-indigo",hoverClass:"hover:border-sys-indigo hover:text-sys-indigo hover:!bg-transparent"},{type:"room_server",label:"Room",icon:Y,buttonColor:"purple",iconColor:"text-sys-purple",hoverClass:"hover:border-sys-purple hover:text-sys-purple hover:!bg-transparent"},{type:"unknown",label:"Unknown",icon:ne,buttonColor:"zinc",iconColor:"text-zinc-400",hoverClass:"hover:border-zinc-400 hover:text-zinc-400 hover:!bg-transparent"}],D=60,E=.005;function pe({min:d,max:a,valueStart:c,valueEnd:s,onChange:o}){const x=J(),y=i.useRef(null),[N,w]=i.useState(null),u=i.useRef({valueStart:c,valueEnd:s,min:d,max:a});u.current={valueStart:c,valueEnd:s,min:d,max:a};const v=i.useRef({offset:0,width:0}),g=a-d||1,S=g/3600,M=c??d,C=s??a,_=(M-d)/g*100,P=(C-d)/g*100,F=c!==null||s!==null,I=i.useCallback(l=>{const e=y.current.getBoundingClientRect(),t=Math.max(0,Math.min(1,(l-e.left)/e.width)),{min:r,max:m}=u.current;return Math.round(r+t*(m-r||1))},[]),R=i.useCallback((l,e)=>{e.preventDefault(),e.stopPropagation();const t=e.currentTarget;t.setPointerCapture(e.pointerId),w(l);const r=h=>{const f=I(h.clientX),{valueStart:p,valueEnd:j,min:b,max:L}=u.current,z=L-b||1;if(l==="start"){const k=Math.min(f,(j??L)-D);o(k<=b+z*E?null:k,j)}else{const k=Math.max(f,(p??b)+D);o(p,k>=L-z*E?null:k)}},m=()=>{w(null),t.removeEventListener("pointermove",r),t.removeEventListener("pointerup",m),t.removeEventListener("pointercancel",m)};t.addEventListener("pointermove",r),t.addEventListener("pointerup",m),t.addEventListener("pointercancel",m)},[I,o]),O=i.useCallback(l=>{l.preventDefault(),l.stopPropagation();const e=l.currentTarget;e.setPointerCapture(l.pointerId),w("range");const t=u.current.valueStart??u.current.min,r=u.current.valueEnd??u.current.max;v.current={offset:I(l.clientX)-t,width:r-t};const m=f=>{const p=I(f.clientX),{min:j,max:b}=u.current,{offset:L,width:z}=v.current;let k=p-L;k=Math.max(j,Math.min(b-z,k));const K=k+z;o(Math.round(k)<=j?null:Math.round(k),Math.round(K)>=b?null:Math.round(K))},h=()=>{w(null),e.removeEventListener("pointermove",m),e.removeEventListener("pointerup",h),e.removeEventListener("pointercancel",h)};e.addEventListener("pointermove",m),e.addEventListener("pointerup",h),e.addEventListener("pointercancel",h)},[I,o]),T=i.useCallback(l=>{const e=I(l.clientX),{valueStart:t,valueEnd:r,min:m,max:h}=u.current,f=h-m||1,p=t??m,j=r??h;if(Math.abs(e-p)<=Math.abs(e-j)){const b=Math.min(e,j-D);o(b<=m+f*E?null:b,r)}else{const b=Math.max(e,p+D);o(t,b>=h-f*E?null:b)}},[I,o]),H=i.useCallback(()=>o(null,null),[o]),A=i.useCallback((l,e)=>{const t=e.key==="ArrowRight"||e.key==="ArrowUp"?1:e.key==="ArrowLeft"||e.key==="ArrowDown"?-1:0;if(!t)return;e.preventDefault();const r=(e.shiftKey?.1:.01)*g,{valueStart:m,valueEnd:h,min:f,max:p}=u.current,j=p-f||1;if(l==="start"){const b=Math.max(f,Math.min((m??f)+t*r,(h??p)-D));o(b<=f+j*E?null:b,h)}else{const b=Math.min(p,Math.max((h??p)+t*r,(m??f)+D));o(m,b>=p-j*E?null:b)}},[g,o]),$=l=>{const e=l==="start"?c!==null:s!==null,t=N===l;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",t?"cursor-grabbing":"cursor-ew-resize",t?"bg-sys-blue shadow-[0_0_8px_var(--sys-blue)] scale-x-150 z-20":e?"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",t?"":"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&&c!==null?"text-sys-blue":"",children:B(M,S,x)}),n.jsx("span",{className:F&&s!==null?"text-sys-blue":"",children:B(C,S,x)})]}),n.jsxs("div",{ref:y,className:"relative h-5 select-none",onPointerDown:T,onDoubleClick:H,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",N==="range"?"cursor-grabbing":"cursor-grab"].join(" "),style:{left:`${_}%`,right:`${100-P}%`},onPointerDown:O,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",N==="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:$("start"),style:{left:`${_}%`},onPointerDown:l=>R("start",l),onKeyDown:l=>A("start",l)}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range end","aria-valuenow":C,className:$("end"),style:{left:`${P}%`},onPointerDown:l=>R("end",l),onKeyDown:l=>A("end",l)})]})]})}function Ne({parentStartTs:d,parentEndTs:a,neighbors:c,filter:s,onChange:o,scatterDotSize:x,onScatterDotSizeChange:y,scatterOpacity:N,onScatterOpacityChange:w}){const[u,v]=i.useState(""),[g,S]=i.useState(!1),M=i.useRef(null);i.useEffect(()=>{function e(t){M.current&&!M.current.contains(t.target)&&S(!1)}if(g)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[g]);const C=i.useMemo(()=>Object.entries(c).map(([e,t])=>{const r=te(t);return{hash:e,name:t.name??t.node_name??e.slice(0,8),type:r.type,label:r.label}}).sort((e,t)=>e.name.localeCompare(t.name)),[c]),_=i.useMemo(()=>{if(!u)return C;const e=u.toLowerCase();return C.filter(t=>t.name.toLowerCase().includes(e)||t.hash.toLowerCase().includes(e))},[C,u]),P=s.timeStart!==null||s.timeEnd!==null||s.deviceTypes.size>0||s.nodeIds.size>0,F=i.useCallback((e,t)=>{o({...s,timeStart:e,timeEnd:t})},[s,o]),I=i.useCallback(e=>{const t=new Set(s.deviceTypes);t.has(e)?t.delete(e):t.add(e),o({...s,deviceTypes:t})},[s,o]),R=i.useCallback(e=>{const t=new Set(s.nodeIds);t.has(e)?t.delete(e):t.add(e),o({...s,nodeIds:t}),v("")},[s,o]),O=i.useCallback(e=>{const t=new Set(s.nodeIds);t.delete(e);const r=new Set(s.disabledNodeIds);r.delete(e),o({...s,nodeIds:t,disabledNodeIds:r})},[s,o]),T=i.useCallback(e=>{const t=new Set(s.disabledNodeIds);t.has(e)?t.delete(e):t.add(e),o({...s,disabledNodeIds:t})},[s,o]),H=i.useCallback(()=>{o({...s,nodeFilterMode:s.nodeFilterMode==="source"?"observed":"source"})},[s,o]),A=i.useCallback(()=>{o({timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}),v("")},[o]),$=i.useMemo(()=>{const e=new Map;for(const t of s.nodeIds){const r=c[t];e.set(t,(r==null?void 0:r.name)??(r==null?void 0:r.node_name)??t.slice(0,8))}return e},[s.nodeIds,c]),l=!!(y&&w);return n.jsxs("div",{className:"flex flex-col gap-2 card-padding",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[l&&n.jsxs(n.Fragment,{children:[n.jsx(U,{icon:n.jsx(le,{className:"w-3 h-3"}),label:"Size",value:x??.8,onChange:y,min:.3,max:3,step:.1,format:e=>e.toFixed(1)}),n.jsx(U,{icon:n.jsx(de,{className:"w-3 h-3"}),label:"Opacity",value:N??50,onChange:w,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(oe,{className:"w-3.5 h-3.5"})}),n.jsx("div",{className:"flex-1 min-w-[120px]",children:n.jsx(pe,{min:d,max:a,valueStart:s.timeStart,valueEnd:s.timeEnd,onChange:F})}),P&&n.jsxs("button",{type:"button",onClick:A,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(X,{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:me.map(({type:e,label:t,icon:r,buttonColor:m,iconColor:h,hoverClass:f})=>{const p=s.deviceTypes.has(e);return n.jsxs(Z,{color:p?m:"zinc",outline:!p,className:`!h-8 !py-0 ${p?"":f}`,onClick:()=>I(e),title:`Filter by ${t}`,children:[n.jsx(r,{"data-slot":"icon",className:p?"":h}),n.jsx("span",{className:`hidden sm:inline ${p?"":"text-fg-muted"}`,children:t})]},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:M,children:[n.jsx(re,{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:u,onChange:e=>{v(e.target.value),S(!0)},onFocus:()=>S(!0)}),g&&_.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 t=s.nodeIds.has(e.hash);return n.jsxs("button",{type:"button",onClick:()=>R(e.hash),className:` + w-full flex items-center gap-2 px-2.5 py-1.5 type-data-xs text-left transition-colors + ${t?"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)})})]})]}),s.nodeIds.size>0&&n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Array.from(s.nodeIds).map(e=>{const t=s.disabledNodeIds.has(e);return n.jsxs("span",{role:"button",tabIndex:0,onClick:()=>T(e),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),T(e))},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors select-none ${t?"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:[$.get(e)??e.slice(0,8),n.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),O(e)},className:"hover:text-fg-primary transition-colors -mr-0.5",title:"Remove from filter",children:n.jsx(X,{className:"w-3 h-3"})})]},e)}),n.jsx("button",{type:"button",onClick:H,className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors ${s.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:s.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:s.nodeFilterMode==="source"?"Source Only":"Total Observed"})]})]})}const U=i.memo(function({icon:a,label:c,value:s,onChange:o,min:x,max:y,step:N,format:w}){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:[a,n.jsx("span",{className:"type-data-xs font-medium hidden sm:inline",children:c})]}),n.jsx("input",{type:"range",min:x,max:y,step:N,value:s,onChange:u=>o(parseFloat(u.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:w?w(s):s})]})});export{Ne as A,me as D,we as a,pe as b,ye as c}; diff --git a/frontend/dist/assets/AnalyzerFilterPanel-CxNRg_pb.js b/frontend/dist/assets/AnalyzerFilterPanel-CxNRg_pb.js deleted file mode 100644 index e2c9158b..00000000 --- a/frontend/dist/assets/AnalyzerFilterPanel-CxNRg_pb.js +++ /dev/null @@ -1,14 +0,0 @@ -import{e as J,cV as U,aq as q,R as G,cs as V,r as d,j as n,bJ as K,B as Q}from"./index-BdFZD4tW.js";import{c as Y}from"./node-types-BqQm1p4f.js";import{M as Z}from"./monitor-smartphone-B-al2jiR.js";import{C as W}from"./circle-question-mark-_koL3DDj.js";import{F as ee}from"./funnel-DYG0Qmvo.js";import{S as te}from"./search-83w2lV8z.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 se=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ne=J("circle",se);/** - * @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 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=J("droplets",oe);function he(){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=U(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 fe(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:Z,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]),R=d.useCallback(()=>o(null,null),[o]),A=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:R,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=>A("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=>A("end",i)})]})]})}function ve({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=Y(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]),R=d.useCallback(e=>{const s=new Set(t.disabledNodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,disabledNodeIds:s})},[t,o]),A=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(Q,{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:()=>R(e),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),R(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:A,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{ve as A,ie as D,fe as a,de as b,he as c}; diff --git a/frontend/dist/assets/AutoConfigureDialog-C3FQqWjM.js b/frontend/dist/assets/AutoConfigureDialog-yPaPohCI.js similarity index 90% rename from frontend/dist/assets/AutoConfigureDialog-C3FQqWjM.js rename to frontend/dist/assets/AutoConfigureDialog-yPaPohCI.js index a23e780c..c27bebc2 100644 --- a/frontend/dist/assets/AutoConfigureDialog-C3FQqWjM.js +++ b/frontend/dist/assets/AutoConfigureDialog-yPaPohCI.js @@ -1 +1 @@ -import{r as y,ec as K,j as e,f as X,R as Z,c3 as M,cs as V,dn as G,ev as ee,ax as ae,aG as se,ay as te,a6 as U,bV as ne,B as S,c as N,aA as le}from"./index-BdFZD4tW.js";import{C as ie}from"./PageLayout-CIUNh3-q.js";import{M as J}from"./monitor-smartphone-B-al2jiR.js";import{W as re}from"./wand-sparkles-DJklHh-3.js";import{A as oe}from"./arrow-right-DWDq16dR.js";const ce={0:"1-byte",1:"2-byte",2:"3-byte"};function de(s){return ce[s]??`${s+1}-byte`}function ge({nodeName:s,publicKey:a,pathHashMode:o,compact:i=!1}){const[l,m]=y.useState(null),[c,h]=y.useState(null);y.useEffect(()=>{let n=!1;return(async()=>{try{const u=await K();if(n)return;if(u.success&&u.data){const _=u.data;m(Array.isArray(_.configured)?_.configured:[]),h(Array.isArray(_.configured_companions)?_.configured_companions:[])}}catch{}})(),()=>{n=!0}},[]);const f=n=>{var u;return((u=n.settings)==null?void 0:u.node_name)||n.name};return e.jsxs(ie,{neomorphic:!0,compact:i,children:[e.jsx(X,{icon:e.jsx(Z,{}),title:"Node Information",className:i?"mb-2":void 0}),e.jsxs("div",{className:`grid grid-cols-1 sm:grid-cols-3 ${i?"gap-3 sm:gap-4":"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 ${i?"space-y-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})})]})}),o!=null&&e.jsxs("div",{className:i?"mt-2":"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(o)})]})]}),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 ${i?"space-y-1":"space-y-2"}`,children:l===null?e.jsx("span",{className:"type-data text-fg-muted",children:"—"}):l.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-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:"None"})]}):l.map(n=>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-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary truncate",title:f(n),children:f(n)})]}),(n.public_key||n.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:n.public_key||n.identity_key})})]},n.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 ${i?"space-y-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(J,{className:"w-3.5 h-3.5 text-sys-cyan flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:"None"})]}):c.map(n=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-sys-cyan flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary truncate",title:f(n),children:f(n)})]}),(n.public_key||n.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:n.public_key||n.identity_key})})]},n.name))})]})]})]})}const k=168,w={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 sr.type===4))==null?void 0:u.count)??0,i=a.drop_reasons??[],l=((_=i.find(r=>r.reason==="advert rate limit exceeded"))==null?void 0:_.count)??0,m=i.filter(r=>r.reason.startsWith("advert penalty box")).reduce((r,d)=>r+d.count,0),c=((b=i.find(r=>r.reason==="Duplicate"))==null?void 0:b.count)??0;let h=0;try{const r=await G("/api/advert_rate_limit_stats");r.success&&r.data&&(h=r.data.tracked_pubkeys??Object.keys(r.data.bucket_states??{}).length)}catch{h=Math.max(1,Math.round(o/k/12))}const f=a.total_packets/k,n=o/k;return{hours:k,totalPackets:a.total_packets,transmittedPackets:a.transmitted_packets,droppedPackets:a.dropped_packets,packetsPerHour:f,advertsPerHour:n,advertPercent:a.total_packets>0?o/a.total_packets*100:0,advertCount:o,trackedSources:Math.max(1,h),advertsPerSourcePerHour:n/Math.max(1,h),rateLimitDrops:l,penaltyBoxDrops:m,duplicateDrops:c,meshDensity:pe(f)}}function ue(s){const a=me[s.meshDensity],o=s.packetsPerHour/60,i=Math.max(.01,B(o*.2)),l=Math.max(i+.01,B(o*.5)),m=Math.max(l+.01,B(o*.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:i,normal_max:l,busy_max:m}}}}async function ye(s){const a=await xe(),o=ue(a);return{analysis:a,recommended:o,current:{tokenBucket:s.tokenBucket??null,penaltyBox:s.penaltyBox??null,adaptive:s.adaptive??null}}}function B(s){return Math.round(s*100)/100}function g(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"},Ne={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},Se=["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:o=!1,children:i}){const[l,m]=y.useState(o);return e.jsxs("div",{className:"bg-subtle-fill radius-inner overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>m(!l),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:N("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:N("w-4 h-4 text-fg-muted transition-transform",l&&"rotate-180")})]}),l&&e.jsx("div",{className:"px-4 pb-4 pt-1 space-y-1",children:i})]})}function x({label:s,current:a,recommended:o,format:i=l=>String(l)}){const l=a!=null?i(a):"—",m=i(o),c=a!=null&&l!==m;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:N("data-box data-box-compact",c?"text-fg-muted line-through opacity-60":"text-fg-secondary"),children:l}),c&&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:m})]})]})]})}function we({open:s,onClose:a,currentConfig:o,onApplied:i}){var C,H,P,T,I,R,L,$,E,z,F,O,q,Y;const[l,m]=y.useState("idle"),[c,h]=y.useState(null),[f,n]=y.useState(null),u=y.useCallback(async()=>{m("analyzing"),n(null);try{const t=await ye(o);h(t),m("ready")}catch(t){n(t instanceof Error?t.message:"Analysis failed"),m("error")}},[o]),_=y.useCallback(async()=>{if(!c)return;m("applying"),n(null);const{tokenBucket:t,penaltyBox:v,adaptive:j}=c.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:v.enabled,violation_threshold:v.violation_threshold,base_penalty_seconds:v.base_penalty_seconds,penalty_multiplier:v.penalty_multiplier,max_penalty_seconds:v.max_penalty_seconds,violation_decay_seconds:v.violation_decay_seconds,adaptive_enabled:j.enabled,ewma_alpha:j.ewma_alpha,hysteresis_seconds:j.hysteresis_seconds,quiet_max:j.thresholds.quiet_max,normal_max:j.thresholds.normal_max,busy_max:j.thresholds.busy_max};try{const W=await ee(Q);W.success?(m("applied"),i==null||i()):(n(W.error||"Failed to apply settings"),m("error"))}catch{n("Failed to apply settings"),m("error")}},[c,i]),b=y.useCallback(()=>{a(),setTimeout(()=>{m("idle"),h(null),n(null)},300)},[a]);s&&l==="idle"&&u();const r=c==null?void 0:c.analysis,d=c==null?void 0:c.recommended,p=c==null?void 0:c.current;return e.jsxs(ae,{open:s,onClose:b,size:"lg",children:[e.jsx(se,{icon:e.jsx(re,{size:20}),title:"Auto-Configure",onClose:b}),e.jsxs(te,{className:"flex flex-col gap-5 max-h-[70vh] overflow-y-auto",children:[l==="analyzing"&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12",children:[e.jsx(U,{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…"})]}),l==="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:f}),e.jsx(S,{plain:!0,onClick:u,className:"text-sys-blue",children:"Retry"})]}),(l==="ready"||l==="applying"||l==="applied")&&r&&d&&p&&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(r.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(r.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:r.trackedSources})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Density"}),e.jsx("div",{className:N("data-box data-box-fill data-box-left",fe[r.meshDensity]),children:he[r.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(x,{label:"Bucket Capacity",current:(C=p.tokenBucket)==null?void 0:C.bucket_capacity,recommended:d.tokenBucket.bucket_capacity,format:t=>`${t} tokens`}),e.jsx(x,{label:"Refill Tokens",current:(H=p.tokenBucket)==null?void 0:H.refill_tokens,recommended:d.tokenBucket.refill_tokens,format:t=>`${t} tokens`}),e.jsx(x,{label:"Refill Interval",current:(P=p.tokenBucket)==null?void 0:P.refill_interval_seconds,recommended:d.tokenBucket.refill_interval_seconds,format:t=>g(t)}),e.jsx(x,{label:"Min Interval",current:(T=p.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(x,{label:"Violation Threshold",current:(I=p.penaltyBox)==null?void 0:I.violation_threshold,recommended:d.penaltyBox.violation_threshold,format:t=>`${t} violations`}),e.jsx(x,{label:"Base Penalty",current:(R=p.penaltyBox)==null?void 0:R.base_penalty_seconds,recommended:d.penaltyBox.base_penalty_seconds,format:t=>g(t)}),e.jsx(x,{label:"Multiplier",current:(L=p.penaltyBox)==null?void 0:L.penalty_multiplier,recommended:d.penaltyBox.penalty_multiplier,format:t=>`${t}×`}),e.jsx(x,{label:"Max Penalty",current:($=p.penaltyBox)==null?void 0:$.max_penalty_seconds,recommended:d.penaltyBox.max_penalty_seconds,format:t=>g(t)}),e.jsx(x,{label:"Violation Decay",current:(E=p.penaltyBox)==null?void 0:E.violation_decay_seconds,recommended:d.penaltyBox.violation_decay_seconds,format:t=>g(t)})]}),e.jsxs(D,{title:"Adaptive Tiers",enabled:d.adaptive.enabled,children:[e.jsx(x,{label:"EWMA α",current:(z=p.adaptive)==null?void 0:z.ewma_alpha,recommended:d.adaptive.ewma_alpha}),e.jsx(x,{label:"Hysteresis",current:(F=p.adaptive)==null?void 0:F.hysteresis_seconds,recommended:d.adaptive.hysteresis_seconds,format:t=>g(t)}),e.jsx(x,{label:"Quiet Max",current:(O=p.adaptive)==null?void 0:O.thresholds.quiet_max,recommended:d.adaptive.thresholds.quiet_max,format:t=>`${t} pkts/min`}),e.jsx(x,{label:"Normal Max",current:(q=p.adaptive)==null?void 0:q.thresholds.normal_max,recommended:d.adaptive.thresholds.normal_max,format:t=>`${t} pkts/min`}),e.jsx(x,{label:"Busy Max",current:(Y=p.adaptive)==null?void 0:Y.thresholds.busy_max,recommended:d.adaptive.thresholds.busy_max,format:t=>`${t} pkts/min`})]})]}),e.jsxs("div",{className:N("flex justify-between gap-4 pt-1",l==="applied"?"items-center":"items-end"),children:[l==="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(r.totalPackets)," packets"]})]}),e.jsx("div",{className:"flex items-center gap-2",children:l==="applied"?e.jsx(S,{color:"primary",onClick:b,children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx(S,{plain:!0,onClick:b,children:"Cancel"}),e.jsx(S,{color:"primary",onClick:_,disabled:l==="applying",children:l==="applying"?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(U,{className:"w-4 h-4 animate-spin"}),"Applying…"]}):"Apply All"})]})})]})]})]})]})}export{we as A,ge as N,Ne as S,Se as a}; +import{r as y,eq as K,j as e,f as X,R as Z,c8 as M,cy as J,dy as U,eJ as ee,aB as ae,aL as se,aC as te,a9 as V,b_ as ne,B as S,c as N,aE as le}from"./index-Ch85h29t.js";import{C as ie}from"./PageLayout-BB80XCAa.js";import{M as G}from"./monitor-smartphone-CTx9MPdz.js";import{W as re}from"./wand-sparkles-Br5G9OBm.js";import{A as oe}from"./arrow-right-CKd6FEys.js";const ce={0:"1-byte",1:"2-byte",2:"3-byte"};function de(s){return ce[s]??`${s+1}-byte`}function ge({nodeName:s,publicKey:a,pathHashMode:o,compact:i=!1}){const[l,m]=y.useState(null),[c,h]=y.useState(null);y.useEffect(()=>{let n=!1;return(async()=>{try{const u=await K();if(n)return;if(u.success&&u.data){const _=u.data;m(Array.isArray(_.configured)?_.configured:[]),h(Array.isArray(_.configured_companions)?_.configured_companions:[])}}catch{}})(),()=>{n=!0}},[]);const f=n=>{var u;return((u=n.settings)==null?void 0:u.node_name)||n.name};return e.jsxs(ie,{neomorphic:!0,compact:i,children:[e.jsx(X,{icon:e.jsx(Z,{}),title:"Node Information",className:i?"mb-2":void 0}),e.jsxs("div",{className:`grid grid-cols-1 sm:grid-cols-3 ${i?"gap-3 sm:gap-4":"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 ${i?"space-y-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})})]})}),o!=null&&e.jsxs("div",{className:i?"mt-2":"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(o)})]})]}),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 ${i?"space-y-1":"space-y-2"}`,children:l===null?e.jsx("span",{className:"type-data text-fg-muted",children:"—"}):l.length===0?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:"None"})]}):l.map(n=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary truncate",title:f(n),children:f(n)})]}),(n.public_key||n.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:n.public_key||n.identity_key})})]},n.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 ${i?"space-y-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(G,{className:"w-3.5 h-3.5 text-sys-cyan flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:"None"})]}):c.map(n=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(G,{className:"w-3.5 h-3.5 text-sys-cyan flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary truncate",title:f(n),children:f(n)})]}),(n.public_key||n.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:n.public_key||n.identity_key})})]},n.name))})]})]})]})}const k=168,w={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 sr.type===4))==null?void 0:u.count)??0,i=a.drop_reasons??[],l=((_=i.find(r=>r.reason==="advert rate limit exceeded"))==null?void 0:_.count)??0,m=i.filter(r=>r.reason.startsWith("advert penalty box")).reduce((r,d)=>r+d.count,0),c=((b=i.find(r=>r.reason==="Duplicate"))==null?void 0:b.count)??0;let h=0;try{const r=await U("/api/advert_rate_limit_stats");r.success&&r.data&&(h=r.data.tracked_pubkeys??Object.keys(r.data.bucket_states??{}).length)}catch{h=Math.max(1,Math.round(o/k/12))}const f=a.total_packets/k,n=o/k;return{hours:k,totalPackets:a.total_packets,transmittedPackets:a.transmitted_packets,droppedPackets:a.dropped_packets,packetsPerHour:f,advertsPerHour:n,advertPercent:a.total_packets>0?o/a.total_packets*100:0,advertCount:o,trackedSources:Math.max(1,h),advertsPerSourcePerHour:n/Math.max(1,h),rateLimitDrops:l,penaltyBoxDrops:m,duplicateDrops:c,meshDensity:pe(f)}}function ue(s){const a=me[s.meshDensity],o=s.packetsPerHour/60,i=Math.max(.01,B(o*.2)),l=Math.max(i+.01,B(o*.5)),m=Math.max(l+.01,B(o*.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:i,normal_max:l,busy_max:m}}}}async function ye(s){const a=await xe(),o=ue(a);return{analysis:a,recommended:o,current:{tokenBucket:s.tokenBucket??null,penaltyBox:s.penaltyBox??null,adaptive:s.adaptive??null}}}function B(s){return Math.round(s*100)/100}function g(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"},Ne={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},Se=["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 C({title:s,enabled:a,defaultOpen:o=!1,children:i}){const[l,m]=y.useState(o);return e.jsxs("div",{className:"bg-subtle-fill radius-inner overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>m(!l),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:N("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:N("w-4 h-4 text-fg-muted transition-transform",l&&"rotate-180")})]}),l&&e.jsx("div",{className:"px-4 pb-4 pt-1 space-y-1",children:i})]})}function x({label:s,current:a,recommended:o,format:i=l=>String(l)}){const l=a!=null?i(a):"—",m=i(o),c=a!=null&&l!==m;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:N("data-box data-box-compact",c?"text-fg-muted line-through opacity-60":"text-fg-secondary"),children:l}),c&&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:m})]})]})]})}function we({open:s,onClose:a,currentConfig:o,onApplied:i}){var D,H,P,T,I,R,L,E,$,z,F,O,q,Y;const[l,m]=y.useState("idle"),[c,h]=y.useState(null),[f,n]=y.useState(null),u=y.useCallback(async()=>{m("analyzing"),n(null);try{const t=await ye(o);h(t),m("ready")}catch(t){n(t instanceof Error?t.message:"Analysis failed"),m("error")}},[o]),_=y.useCallback(async()=>{if(!c)return;m("applying"),n(null);const{tokenBucket:t,penaltyBox:v,adaptive:j}=c.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:v.enabled,violation_threshold:v.violation_threshold,base_penalty_seconds:v.base_penalty_seconds,penalty_multiplier:v.penalty_multiplier,max_penalty_seconds:v.max_penalty_seconds,violation_decay_seconds:v.violation_decay_seconds,adaptive_enabled:j.enabled,ewma_alpha:j.ewma_alpha,hysteresis_seconds:j.hysteresis_seconds,quiet_max:j.thresholds.quiet_max,normal_max:j.thresholds.normal_max,busy_max:j.thresholds.busy_max};try{const W=await ee(Q);W.success?(m("applied"),i==null||i()):(n(W.error||"Failed to apply settings"),m("error"))}catch{n("Failed to apply settings"),m("error")}},[c,i]),b=y.useCallback(()=>{a(),setTimeout(()=>{m("idle"),h(null),n(null)},300)},[a]);s&&l==="idle"&&u();const r=c==null?void 0:c.analysis,d=c==null?void 0:c.recommended,p=c==null?void 0:c.current;return e.jsxs(ae,{open:s,onClose:b,size:"lg",children:[e.jsx(se,{icon:e.jsx(re,{size:20}),title:"Auto-Configure",onClose:b}),e.jsxs(te,{className:"flex flex-col gap-5 max-h-[70vh] overflow-y-auto",children:[l==="analyzing"&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12",children:[e.jsx(V,{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…"})]}),l==="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:f}),e.jsx(S,{plain:!0,onClick:u,className:"text-sys-blue",children:"Retry"})]}),(l==="ready"||l==="applying"||l==="applied")&&r&&d&&p&&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(r.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(r.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:r.trackedSources})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Density"}),e.jsx("div",{className:N("data-box data-box-fill data-box-left",fe[r.meshDensity]),children:he[r.meshDensity]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{title:"Token Bucket of Shame",enabled:d.tokenBucket.enabled,defaultOpen:!0,children:[e.jsx(x,{label:"Bucket Capacity",current:(D=p.tokenBucket)==null?void 0:D.bucket_capacity,recommended:d.tokenBucket.bucket_capacity,format:t=>`${t} tokens`}),e.jsx(x,{label:"Refill Tokens",current:(H=p.tokenBucket)==null?void 0:H.refill_tokens,recommended:d.tokenBucket.refill_tokens,format:t=>`${t} tokens`}),e.jsx(x,{label:"Refill Interval",current:(P=p.tokenBucket)==null?void 0:P.refill_interval_seconds,recommended:d.tokenBucket.refill_interval_seconds,format:t=>g(t)}),e.jsx(x,{label:"Min Interval",current:(T=p.tokenBucket)==null?void 0:T.min_interval_seconds,recommended:d.tokenBucket.min_interval_seconds,format:t=>`${t}s`})]}),e.jsxs(C,{title:"Jail",enabled:d.penaltyBox.enabled,children:[e.jsx(x,{label:"Violation Threshold",current:(I=p.penaltyBox)==null?void 0:I.violation_threshold,recommended:d.penaltyBox.violation_threshold,format:t=>`${t} violations`}),e.jsx(x,{label:"Base Penalty",current:(R=p.penaltyBox)==null?void 0:R.base_penalty_seconds,recommended:d.penaltyBox.base_penalty_seconds,format:t=>g(t)}),e.jsx(x,{label:"Multiplier",current:(L=p.penaltyBox)==null?void 0:L.penalty_multiplier,recommended:d.penaltyBox.penalty_multiplier,format:t=>`${t}×`}),e.jsx(x,{label:"Max Penalty",current:(E=p.penaltyBox)==null?void 0:E.max_penalty_seconds,recommended:d.penaltyBox.max_penalty_seconds,format:t=>g(t)}),e.jsx(x,{label:"Violation Decay",current:($=p.penaltyBox)==null?void 0:$.violation_decay_seconds,recommended:d.penaltyBox.violation_decay_seconds,format:t=>g(t)})]}),e.jsxs(C,{title:"Adaptive Tiers",enabled:d.adaptive.enabled,children:[e.jsx(x,{label:"EWMA α",current:(z=p.adaptive)==null?void 0:z.ewma_alpha,recommended:d.adaptive.ewma_alpha}),e.jsx(x,{label:"Hysteresis",current:(F=p.adaptive)==null?void 0:F.hysteresis_seconds,recommended:d.adaptive.hysteresis_seconds,format:t=>g(t)}),e.jsx(x,{label:"Quiet Max",current:(O=p.adaptive)==null?void 0:O.thresholds.quiet_max,recommended:d.adaptive.thresholds.quiet_max,format:t=>`${t} pkts/min`}),e.jsx(x,{label:"Normal Max",current:(q=p.adaptive)==null?void 0:q.thresholds.normal_max,recommended:d.adaptive.thresholds.normal_max,format:t=>`${t} pkts/min`}),e.jsx(x,{label:"Busy Max",current:(Y=p.adaptive)==null?void 0:Y.thresholds.busy_max,recommended:d.adaptive.thresholds.busy_max,format:t=>`${t} pkts/min`})]})]}),e.jsxs("div",{className:N("flex justify-between gap-4 pt-1",l==="applied"?"items-center":"items-end"),children:[l==="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(r.totalPackets)," packets"]})]}),e.jsx("div",{className:"flex items-center gap-2",children:l==="applied"?e.jsx(S,{color:"primary",onClick:b,children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx(S,{plain:!0,onClick:b,children:"Cancel"}),e.jsx(S,{color:"primary",onClick:_,disabled:l==="applying",children:l==="applying"?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(V,{className:"w-4 h-4 animate-spin"}),"Applying…"]}):"Apply All"})]})})]})]})]})]})}export{we as A,ge as N,Ne as S,Se as a}; diff --git a/frontend/dist/assets/BackupRestore-uZ-hrJ-I.js b/frontend/dist/assets/BackupRestore-D9KC5Ou7.js similarity index 93% rename from frontend/dist/assets/BackupRestore-uZ-hrJ-I.js rename to frontend/dist/assets/BackupRestore-D9KC5Ou7.js index edd0f972..33726bf0 100644 --- a/frontend/dist/assets/BackupRestore-uZ-hrJ-I.js +++ b/frontend/dist/assets/BackupRestore-D9KC5Ou7.js @@ -1 +1 @@ -import{r as p,j as e,az as R,c$ as B,f as b,B as l}from"./index-BdFZD4tW.js";import{e as H,a as K,i as $}from"./backup-fw4AXrb3.js";import{P as D,a as q,B as Y,C as x}from"./PageLayout-CIUNh3-q.js";import{R as y,C as T}from"./Grid-BkuFQpqe.js";import{U as O}from"./upload-DqygZ61q.js";import{K as M}from"./key-round-Ca3f2GE6.js";import"./WorkspaceNav-DR8N-VVk.js";function W(t,o){const f=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),c=URL.createObjectURL(f),n=document.createElement("a");n.href=c,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(c)}function z(t,o){const f=new Blob([o],{type:"text/plain"}),c=URL.createObjectURL(f),n=document.createElement("a");n.href=c,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(c)}function U(t){var o;return String(((o=t==null?void 0:t.meta)==null?void 0:o.exported_at)||new Date().toISOString()).replace(/[:.]/g,"-")}function se(){var E,I;const[t,o]=p.useState(null),[f,c]=p.useState(!1),[n,w]=p.useState(!1),[a,h]=p.useState(null),[_,j]=p.useState(!1),[N,m]=p.useState(null),[v,d]=p.useState(null),k=p.useRef(null),C=window.location.protocol==="http:",F=p.useMemo(()=>a?Object.keys(a.config).join(", "):"",[a]),J=((E=a==null?void 0:a.meta)==null?void 0:E.includes_secrets)===!0||((I=a==null?void 0:a.meta)==null?void 0:I.includes_secrets)==="true",S=async s=>{o(s?"full":"settings"),d(null),m(null);try{const r=await H(s);if(!r.success||!r.data)throw new Error(r.error||"Export failed");W(s?`openhop-repeater-full-backup-${U(r.data)}.json`:`openhop-repeater-settings-${U(r.data)}.json`,r.data),m(s?"Full backup exported. Store it securely.":"Settings export downloaded with secrets redacted."),c(!1)}catch(r){d(r instanceof Error?r.message:"Export failed")}finally{o(null)}},L=async()=>{o("identity"),d(null),m(null);try{const s=await K();if(!s.success||!s.data)throw new Error(s.error||"Identity export failed");z(`openhop-identity-${s.data.node_address||"key"}.hex`,s.data.identity_key_hex),m(`Identity key exported (${s.data.key_length_bytes} bytes). Store it securely.`),w(!1)}catch(s){d(s instanceof Error?s.message:"Identity export failed")}finally{o(null)}},P=s=>{var g;const r=(g=s.target.files)==null?void 0:g[0];if(!r)return;d(null),m(null),h(null),j(!1);const i=new FileReader;i.onload=()=>{try{const u=JSON.parse(String(i.result));u&&typeof u=="object"&&!Array.isArray(u)?u.config&&typeof u.config=="object"?h({config:u.config,meta:u.meta}):h({config:u}):d("Invalid file format — expected a JSON object.")}catch{d("Invalid JSON file.")}},i.readAsText(r)},A=async()=>{var s,r;if(a){o("import"),d(null),m(null);try{const i=await $(a.config);if(!i.success)throw new Error(i.error||"Import failed");const g=(s=i.data)!=null&&s.restart_required?" A service restart is required for some changes.":"";m(((r=i.data)==null?void 0:r.message)||`Configuration imported.${g}`),h(null),j(!1),k.current&&(k.current.value="")}catch(i){d(i instanceof Error?i.message:"Import failed")}finally{o(null)}}};return e.jsxs(D,{children:[e.jsx(q,{title:"Backup / Restore",icon:e.jsx(R,{}),subtitle:e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Export, import, and restore Repeater configuration with explicit secret warnings."})}),e.jsxs(Y,{ready:!0,children:[C&&e.jsx(y,{template:"auto",children:e.jsx(x,{neomorphic:!0,className:"border border-sys-red/30",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(B,{className:"w-5 h-5 text-sys-red"}),e.jsx("p",{className:"type-body-sm text-sys-red",children:"This page is served over HTTP. Secret-bearing backups and identity keys are transmitted in plain text; only use this on a trusted local network."})]})})}),v&&e.jsx(y,{template:"auto",children:e.jsx(x,{neomorphic:!0,className:"text-sys-red",children:v})}),N&&e.jsx(y,{template:"auto",children:e.jsx(x,{neomorphic:!0,className:"text-sys-green",children:N})}),e.jsxs(y,{template:"standard",children:[e.jsx(T,{span:"full",md:6,children:e.jsxs(x,{neomorphic:!0,children:[e.jsx(b,{icon:e.jsx(R,{}),title:"Export Settings"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Downloads current configuration with passwords, JWT secrets, and identity keys redacted."}),e.jsx(l,{color:"primary",onClick:()=>S(!1),disabled:!!t,children:t==="settings"?"Exporting…":"Export Settings"})]})}),e.jsx(T,{span:"full",md:6,children:e.jsxs(x,{neomorphic:!0,children:[e.jsx(b,{icon:e.jsx(B,{}),title:"Full Backup"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Includes passwords, JWT secrets, and identity keys. Store securely and never share."}),f?e.jsxs("div",{className:"bg-sys-red/10 border border-sys-red/30 radius-inner p-3",children:[e.jsxs("p",{className:"type-body-sm text-sys-red mb-3",children:["Confirm exporting all secrets",C?" over HTTP":"","."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{color:"danger",onClick:()=>S(!0),disabled:!!t,children:t==="full"?"Exporting…":"Yes, Export Full Backup"}),e.jsx(l,{color:"muted",outline:!0,onClick:()=>c(!1),disabled:!!t,children:"Cancel"})]})]}):e.jsx(l,{color:"danger",outline:!0,onClick:()=>c(!0),children:"Full Backup"})]})})]}),e.jsx(y,{template:"auto",children:e.jsxs(x,{neomorphic:!0,children:[e.jsx(b,{icon:e.jsx(O,{}),title:"Import Configuration"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Import a settings export or full backup. Restore requires confirmation and never auto-restarts the service."}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer bg-subtle-fill radius-card p-4 border border-edge-subtle",children:[e.jsx(O,{className:"w-5 h-5 text-sys-blue"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Choose JSON file…"}),e.jsx("input",{ref:k,type:"file",accept:".json,application/json",className:"hidden",onChange:P})]}),a&&e.jsxs("div",{className:"mt-4 bg-subtle-fill radius-card p-4",children:[e.jsx("p",{className:"type-body text-fg-primary",children:"Import preview"}),e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1",children:["Sections: ",e.jsx("span",{className:"type-code",children:F||"unknown"})]}),J&&e.jsx("p",{className:"type-body-sm text-sys-amber mt-2",children:"This full backup may overwrite passwords and identity keys."}),_?e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx(l,{color:"warning",onClick:A,disabled:!!t,children:t==="import"?"Importing…":"Yes, Import"}),e.jsx(l,{color:"muted",outline:!0,onClick:()=>j(!1),disabled:!!t,children:"Cancel"})]}):e.jsx(l,{className:"mt-3",color:"warning",outline:!0,onClick:()=>j(!0),children:"Review & Import"})]})]})}),e.jsx(y,{template:"auto",children:e.jsxs(x,{neomorphic:!0,children:[e.jsx(b,{icon:e.jsx(M,{}),title:"Export Identity Key"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Downloads the repeater private identity key as hex. Anyone with this key can impersonate your node."}),n?e.jsxs("div",{className:"bg-sys-red/10 border border-sys-red/30 radius-inner p-3",children:[e.jsxs("p",{className:"type-body-sm text-sys-red mb-3",children:["Confirm exporting the private key",C?" over HTTP":"","."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{color:"danger",onClick:L,disabled:!!t,children:t==="identity"?"Exporting…":"Yes, Export Key"}),e.jsx(l,{color:"muted",outline:!0,onClick:()=>w(!1),disabled:!!t,children:"Cancel"})]})]}):e.jsx(l,{color:"danger",outline:!0,onClick:()=>w(!0),children:"Export Identity Key"})]})})]})]})}export{se as default}; +import{r as p,j as e,aD as R,d9 as B,f as b,B as l}from"./index-Ch85h29t.js";import{e as H,a as K,i as D}from"./backup-COxwEanx.js";import{P as $,a as q,B as Y,C as x}from"./PageLayout-BB80XCAa.js";import{R as y,C as T}from"./Grid-DKZX3hrI.js";import{U as O}from"./upload-BOBY87np.js";import{K as M}from"./key-round-DLgdhdTl.js";import"./WorkspaceNav-ZTG5UTjF.js";function W(t,o){const f=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),c=URL.createObjectURL(f),n=document.createElement("a");n.href=c,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(c)}function z(t,o){const f=new Blob([o],{type:"text/plain"}),c=URL.createObjectURL(f),n=document.createElement("a");n.href=c,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(c)}function U(t){var o;return String(((o=t==null?void 0:t.meta)==null?void 0:o.exported_at)||new Date().toISOString()).replace(/[:.]/g,"-")}function se(){var E,I;const[t,o]=p.useState(null),[f,c]=p.useState(!1),[n,w]=p.useState(!1),[a,h]=p.useState(null),[_,j]=p.useState(!1),[N,m]=p.useState(null),[v,d]=p.useState(null),k=p.useRef(null),C=window.location.protocol==="http:",F=p.useMemo(()=>a?Object.keys(a.config).join(", "):"",[a]),J=((E=a==null?void 0:a.meta)==null?void 0:E.includes_secrets)===!0||((I=a==null?void 0:a.meta)==null?void 0:I.includes_secrets)==="true",S=async s=>{o(s?"full":"settings"),d(null),m(null);try{const r=await H(s);if(!r.success||!r.data)throw new Error(r.error||"Export failed");W(s?`openhop-repeater-full-backup-${U(r.data)}.json`:`openhop-repeater-settings-${U(r.data)}.json`,r.data),m(s?"Full backup exported. Store it securely.":"Settings export downloaded with secrets redacted."),c(!1)}catch(r){d(r instanceof Error?r.message:"Export failed")}finally{o(null)}},L=async()=>{o("identity"),d(null),m(null);try{const s=await K();if(!s.success||!s.data)throw new Error(s.error||"Identity export failed");z(`openhop-identity-${s.data.node_address||"key"}.hex`,s.data.identity_key_hex),m(`Identity key exported (${s.data.key_length_bytes} bytes). Store it securely.`),w(!1)}catch(s){d(s instanceof Error?s.message:"Identity export failed")}finally{o(null)}},P=s=>{var g;const r=(g=s.target.files)==null?void 0:g[0];if(!r)return;d(null),m(null),h(null),j(!1);const i=new FileReader;i.onload=()=>{try{const u=JSON.parse(String(i.result));u&&typeof u=="object"&&!Array.isArray(u)?u.config&&typeof u.config=="object"?h({config:u.config,meta:u.meta}):h({config:u}):d("Invalid file format — expected a JSON object.")}catch{d("Invalid JSON file.")}},i.readAsText(r)},A=async()=>{var s,r;if(a){o("import"),d(null),m(null);try{const i=await D(a.config);if(!i.success)throw new Error(i.error||"Import failed");const g=(s=i.data)!=null&&s.restart_required?" A service restart is required for some changes.":"";m(((r=i.data)==null?void 0:r.message)||`Configuration imported.${g}`),h(null),j(!1),k.current&&(k.current.value="")}catch(i){d(i instanceof Error?i.message:"Import failed")}finally{o(null)}}};return e.jsxs($,{children:[e.jsx(q,{title:"Backup / Restore",icon:e.jsx(R,{}),subtitle:e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Export, import, and restore Repeater configuration with explicit secret warnings."})}),e.jsxs(Y,{ready:!0,children:[C&&e.jsx(y,{template:"auto",children:e.jsx(x,{neomorphic:!0,className:"border border-sys-red/30",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(B,{className:"w-5 h-5 text-sys-red"}),e.jsx("p",{className:"type-body-sm text-sys-red",children:"This page is served over HTTP. Secret-bearing backups and identity keys are transmitted in plain text; only use this on a trusted local network."})]})})}),v&&e.jsx(y,{template:"auto",children:e.jsx(x,{neomorphic:!0,className:"text-sys-red",children:v})}),N&&e.jsx(y,{template:"auto",children:e.jsx(x,{neomorphic:!0,className:"text-sys-green",children:N})}),e.jsxs(y,{template:"standard",children:[e.jsx(T,{span:"full",md:6,children:e.jsxs(x,{neomorphic:!0,children:[e.jsx(b,{icon:e.jsx(R,{}),title:"Export Settings"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Downloads current configuration with passwords, JWT secrets, and identity keys redacted."}),e.jsx(l,{color:"primary",onClick:()=>S(!1),disabled:!!t,children:t==="settings"?"Exporting…":"Export Settings"})]})}),e.jsx(T,{span:"full",md:6,children:e.jsxs(x,{neomorphic:!0,children:[e.jsx(b,{icon:e.jsx(B,{}),title:"Full Backup"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Includes passwords, JWT secrets, and identity keys. Store securely and never share."}),f?e.jsxs("div",{className:"bg-sys-red/10 border border-sys-red/30 radius-inner p-3",children:[e.jsxs("p",{className:"type-body-sm text-sys-red mb-3",children:["Confirm exporting all secrets",C?" over HTTP":"","."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{color:"danger",onClick:()=>S(!0),disabled:!!t,children:t==="full"?"Exporting…":"Yes, Export Full Backup"}),e.jsx(l,{color:"muted",outline:!0,onClick:()=>c(!1),disabled:!!t,children:"Cancel"})]})]}):e.jsx(l,{color:"danger",outline:!0,onClick:()=>c(!0),children:"Full Backup"})]})})]}),e.jsx(y,{template:"auto",children:e.jsxs(x,{neomorphic:!0,children:[e.jsx(b,{icon:e.jsx(O,{}),title:"Import Configuration"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Import a settings export or full backup. Restore requires confirmation and never auto-restarts the service."}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer bg-subtle-fill radius-card p-4 border border-edge-subtle",children:[e.jsx(O,{className:"w-5 h-5 text-sys-blue"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Choose JSON file…"}),e.jsx("input",{ref:k,type:"file",accept:".json,application/json",className:"hidden",onChange:P})]}),a&&e.jsxs("div",{className:"mt-4 bg-subtle-fill radius-card p-4",children:[e.jsx("p",{className:"type-body text-fg-primary",children:"Import preview"}),e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1",children:["Sections: ",e.jsx("span",{className:"type-code",children:F||"unknown"})]}),J&&e.jsx("p",{className:"type-body-sm text-sys-amber mt-2",children:"This full backup may overwrite passwords and identity keys."}),_?e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx(l,{color:"warning",onClick:A,disabled:!!t,children:t==="import"?"Importing…":"Yes, Import"}),e.jsx(l,{color:"muted",outline:!0,onClick:()=>j(!1),disabled:!!t,children:"Cancel"})]}):e.jsx(l,{className:"mt-3",color:"warning",outline:!0,onClick:()=>j(!0),children:"Review & Import"})]})]})}),e.jsx(y,{template:"auto",children:e.jsxs(x,{neomorphic:!0,children:[e.jsx(b,{icon:e.jsx(M,{}),title:"Export Identity Key"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Downloads the repeater private identity key as hex. Anyone with this key can impersonate your node."}),n?e.jsxs("div",{className:"bg-sys-red/10 border border-sys-red/30 radius-inner p-3",children:[e.jsxs("p",{className:"type-body-sm text-sys-red mb-3",children:["Confirm exporting the private key",C?" over HTTP":"","."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{color:"danger",onClick:L,disabled:!!t,children:t==="identity"?"Exporting…":"Yes, Export Key"}),e.jsx(l,{color:"muted",outline:!0,onClick:()=>w(!1),disabled:!!t,children:"Cancel"})]})]}):e.jsx(l,{color:"danger",outline:!0,onClick:()=>w(!0),children:"Export Identity Key"})]})})]})]})}export{se as default}; diff --git a/frontend/dist/assets/BasemapLayer-BQjI_o60.js b/frontend/dist/assets/BasemapLayer-DEvncc0Q.js similarity index 98% rename from frontend/dist/assets/BasemapLayer-BQjI_o60.js rename to frontend/dist/assets/BasemapLayer-DEvncc0Q.js index 4f3d0586..690aa62c 100644 --- a/frontend/dist/assets/BasemapLayer-BQjI_o60.js +++ b/frontend/dist/assets/BasemapLayer-DEvncc0Q.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BdFZD4tW.js","assets/index-GZXSFQwe.css"])))=>i.map(i=>d[i]); -import{r as a,_ as H,b6 as D}from"./index-BdFZD4tW.js";const W=a.createContext(null);function B(){var s;const e=(s=a.useContext(W))==null?void 0:s.maps,n=a.useContext(x);return a.useMemo(()=>({...e,current:n==null?void 0:n.map}),[e,n])}function Z(e,n){const t=Array.isArray(e)?e[0]:e?e.x:0,s=Array.isArray(e)?e[1]:e?e.y:0,o=Array.isArray(n)?n[0]:n?n.x:0,r=Array.isArray(n)?n[1]:n?n.y:0;return t===o&&s===r}function L(e,n){if(e===n)return!0;if(!e||!n)return!1;if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let t=0;t{let o=null;"interactive"in s&&(o=Object.assign({},s),delete o.interactive);const r=n[s.ref];if(r){o=o||Object.assign({},s),delete o.ref;for(const i of V)i in r&&(o[i]=r[i])}return o||s});return{...e,layers:t}}const O={version:8,sources:{},layers:[]},A={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"},N={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"],G=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class w{constructor(n,t,s){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||I(this._map.transform);const r=this.props[N[o.type]];r&&r(o)},this._onCameraUpdate=o=>this._internalUpdate?o:(this._propsedCameraUpdate=I(o),T(o,this.props)),this._onPointerEvent=o=>{(o.type==="mousemove"||o.type==="mouseout")&&this._updateHover(o);const r=this.props[A[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=n,this.props=t,this._initialize(s)}get map(){return this._map}setProps(n){const t=this.props;this.props=n;const s=this._updateSettings(n,t),o=this._updateSize(n),r=this._updateViewState(n);this._updateStyle(n,t),this._updateStyleComponents(n),this._updateHandlers(n,t),(s||o||r&&!this._map.isMoving())&&this.redraw()}static reuse(n,t){const s=w.savedMaps.pop();if(!s)return null;const o=s.map,r=o.getContainer();for(t.className=r.className;r.childNodes.length>0;)t.appendChild(r.childNodes[0]);o._container=t;const i=o._resizeObserver;i&&(i.disconnect(),i.observe(t)),s.setProps({...n,styleDiffing:!1}),o.resize();const{initialViewState:c}=n;return c&&(c.bounds?o.fitBounds(c.bounds,{...c.fitBoundsOptions,duration:0}):s._updateViewState(c)),o.isStyleLoaded()?o.fire("load"):o.once("style.load",()=>o.fire("load")),o._update(),s}_initialize(n){const{props:t}=this,{mapStyle:s=O}=t,o={...t,...t.initialViewState,container:n,style:z(s)},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}),t.gl){const c=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=c,t.gl)}const i=new this._MapClass(o);r.padding&&i.setPadding(r.padding),t.cursor&&(i.getCanvas().style.cursor=t.cursor),i.transformCameraUpdate=this._onCameraUpdate,i.on("style.load",()=>{var c;this._styleComponents={light:i.getLight(),sky:i.getSky(),projection:(c=i.getProjection)==null?void 0:c.call(i),terrain:i.getTerrain()},this._updateStyleComponents(this.props)}),i.on("sourcedata",()=>{this._updateStyleComponents(this.props)});for(const c in A)i.on(c,this._onPointerEvent);for(const c in N)i.on(c,this._onCameraEvent);for(const c in U)i.on(c,this._onEvent);this._map=i}recycle(){const t=this.map.getContainer().querySelector("[mapboxgl-children]");t==null||t.remove(),w.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const n=this._map;n.style&&(n._frame&&(n._frame.cancel(),n._frame=null),n._render())}_updateSize(n){const{viewState:t}=n;if(t){const s=this._map;if(t.width!==s.transform.width||t.height!==s.transform.height)return s.resize(),!0}return!1}_updateViewState(n){const t=this._map,s=t.transform;if(!t.isMoving()){const r=T(s,n);if(Object.keys(r).length>0)return this._internalUpdate=!0,t.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(n,t){const s=this._map;let o=!1;for(const r of q)if(r in n&&!L(n[r],t[r])){o=!0;const i=s[`set${r[0].toUpperCase()}${r.slice(1)}`];i==null||i.call(s,n[r])}return o}_updateStyle(n,t){if(n.cursor!==t.cursor&&(this._map.getCanvas().style.cursor=n.cursor||""),n.mapStyle!==t.mapStyle){const{mapStyle:s=O,styleDiffing:o=!0}=n,r={diff:o};"localIdeographFontFamily"in n&&(r.localIdeographFontFamily=n.localIdeographFontFamily),this._map.setStyle(z(s),r)}}_updateStyleComponents({light:n,projection:t,sky:s,terrain:o}){var c,l;const r=this._map,i=this._styleComponents;r.style._loaded&&(n&&!L(n,i.light)&&(i.light=n,r.setLight(n)),t&&!L(t,i.projection)&&t!==((c=i.projection)==null?void 0:c.type)&&(i.projection=typeof t=="string"?{type:t}:t,(l=r.setProjection)==null||l.call(r,i.projection)),s&&!L(s,i.sky)&&(i.sky=s,r.setSky(s)),o!==void 0&&!L(o,i.terrain)&&(!o||r.getSource(o.source))&&(i.terrain=o,r.setTerrain(o)))}_updateHandlers(n,t){const s=this._map;for(const o of G){const r=n[o]??!0,i=t[o]??!0;L(r,i)||(r?s[o].enable(r):s[o].disable())}}_queryRenderedFeatures(n){const t=this._map,{interactiveLayerIds:s=[]}=this.props;try{return t.queryRenderedFeatures(n,{layers:s.filter(t.getLayer.bind(t))})}catch{return[]}}_updateHover(n){var o;const{props:t}=this;if(t.interactiveLayerIds&&(t.onMouseMove||t.onMouseEnter||t.onMouseLeave)){const r=n.type,i=((o=this._hoveredFeatures)==null?void 0:o.length)>0,c=this._queryRenderedFeatures(n.point),l=c.length>0;!l&&i&&(n.type="mouseleave",this._onPointerEvent(n)),this._hoveredFeatures=c,l&&!i&&(n.type="mouseenter",this._onPointerEvent(n)),n.type=r}else this._hoveredFeatures=null}}w.savedMaps=[];const $=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function J(e){if(!e)return null;const n=e.map,t={getMap:()=>n};for(const s of K(n))!(s in t)&&!$.includes(s)&&(t[s]=n[s].bind(n));return t}function K(e){const n=new Set;let t=e;for(;t;){for(const s of Object.getOwnPropertyNames(t))s[0]!=="_"&&typeof e[s]=="function"&&s!=="fire"&&s!=="setEventedParent"&&n.add(s);t=Object.getPrototypeOf(t)}return Array.from(n)}const Y=typeof document<"u"?a.useLayoutEffect:a.useEffect;function X(e,n){const{RTLTextPlugin:t,maxParallelImageRequests:s,workerCount:o,workerUrl:r}=n;if(t&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()==="unavailable"){const{pluginUrl:i,lazy:c=!0}=typeof t=="string"?{pluginUrl:t}:t;e.setRTLTextPlugin(i,l=>{l&&console.error(l)},c)}s!==void 0&&e.setMaxParallelImageRequests(s),o!==void 0&&e.setWorkerCount(o),r!==void 0&&e.setWorkerUrl(r)}const x=a.createContext(null);function Q(e,n){const t=a.useContext(W),[s,o]=a.useState(null),r=a.useRef(),{current:i}=a.useRef({mapLib:null,map:null});a.useEffect(()=>{const f=e.mapLib;let u=!0,d;return Promise.resolve(f||H(()=>import("./maplibre-gl-CCzDK-FD.js").then(h=>h.m),__vite__mapDeps([0,1]))).then(h=>{if(!u)return;if(!h)throw new Error("Invalid mapLib");const m="Map"in h?h:h.default;if(!m.Map)throw new Error("Invalid mapLib");X(m,e),e.reuseMaps&&(d=w.reuse(e,r.current)),d||(d=new w(m.Map,e,r.current)),i.map=J(d),i.mapLib=m,o(d),t==null||t.onMapMount(i.map,e.id)}).catch(h=>{const{onError:m}=e;m?m({type:"error",target:null,originalEvent:null,error:h}):console.error(h)}),()=>{u=!1,d&&(t==null||t.onMapUnmount(e.id),e.reuseMaps?d.recycle():d.destroy())}},[]),Y(()=>{s&&s.setProps(e)}),a.useImperativeHandle(n,()=>i.map,[s]);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},s&&a.createElement(x.Provider,{value:i},a.createElement("div",{"mapboxgl-children":"",style:l},e.children)))}const de=a.forwardRef(Q),ee=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function E(e,n){if(!e||!n)return;const t=e.style;for(const s in n){const o=n[s];Number.isFinite(o)&&!ee.test(s)?t[s]=`${o}px`:t[s]=o}}function j(e,n){if(e===n)return null;const t=F(e),s=F(n),o=[];for(const r of s)t.has(r)||o.push(r);for(const r of t)s.has(r)||o.push(r);return o.length===0?null:o}function F(e){return new Set(e?e.trim().split(/\s+/):[])}const me=a.memo(a.forwardRef((e,n)=>{const{map:t,mapLib:s}=a.useContext(x),o=a.useRef({props:e}),r=a.useMemo(()=>{let b=!1;a.Children.forEach(e.children,p=>{p&&(b=!0)});const k={...e,element:b?document.createElement("div"):void 0},_=new s.Marker(k);return _.setLngLat([e.longitude,e.latitude]),_.getElement().addEventListener("click",p=>{var y,g;(g=(y=o.current.props).onClick)==null||g.call(y,{type:"click",target:_,originalEvent:p})}),_.on("dragstart",p=>{var g,C;const y=p;y.lngLat=r.getLngLat(),(C=(g=o.current.props).onDragStart)==null||C.call(g,y)}),_.on("drag",p=>{var g,C;const y=p;y.lngLat=r.getLngLat(),(C=(g=o.current.props).onDrag)==null||C.call(g,y)}),_.on("dragend",p=>{var g,C;const y=p;y.lngLat=r.getLngLat(),(C=(g=o.current.props).onDragEnd)==null||C.call(g,y)}),_},[]);a.useEffect(()=>(r.addTo(t.getMap()),()=>{r.remove()}),[]);const{longitude:i,latitude:c,offset:l,style:f,draggable:u=!1,popup:d=null,rotation:h=0,rotationAlignment:m="auto",pitchAlignment:v="auto"}=e;a.useEffect(()=>{E(r.getElement(),f)},[f]),a.useImperativeHandle(n,()=>r,[]);const S=o.current.props;(r.getLngLat().lng!==i||r.getLngLat().lat!==c)&&r.setLngLat([i,c]),l&&!Z(r.getOffset(),l)&&r.setOffset(l),r.isDraggable()!==u&&r.setDraggable(u),r.getRotation()!==h&&r.setRotation(h),r.getRotationAlignment()!==m&&r.setRotationAlignment(m),r.getPitchAlignment()!==v&&r.setPitchAlignment(v),r.getPopup()!==d&&r.setPopup(d);const R=j(S.className,e.className);if(R)for(const b of R)r.toggleClassName(b);return o.current.props=e,D.createPortal(e.children,r.getElement())})),he=a.memo(a.forwardRef((e,n)=>{const{map:t,mapLib:s}=a.useContext(x),o=a.useMemo(()=>document.createElement("div"),[]),r=a.useRef({props:e}),i=a.useMemo(()=>{const c={...e},l=new s.Popup(c);return l.setLngLat([e.longitude,e.latitude]),l.once("open",f=>{var u,d;(d=(u=r.current.props).onOpen)==null||d.call(u,f)}),l},[]);if(a.useEffect(()=>{const c=l=>{var f,u;(u=(f=r.current.props).onClose)==null||u.call(f,l)};return i.on("close",c),i.setDOMContent(o).addTo(t.getMap()),()=>{i.off("close",c),i.isOpen()&&i.remove()}},[]),a.useEffect(()=>{E(i.getElement(),e.style)},[e.style]),a.useImperativeHandle(n,()=>i,[]),i.isOpen()){const c=r.current.props;(i.getLngLat().lng!==e.longitude||i.getLngLat().lat!==e.latitude)&&i.setLngLat([e.longitude,e.latitude]),e.offset&&!L(c.offset,e.offset)&&i.setOffset(e.offset),(c.anchor!==e.anchor||c.maxWidth!==e.maxWidth)&&(i.options.anchor=e.anchor,i.setMaxWidth(e.maxWidth));const l=j(c.className,e.className);if(l)for(const f of l)i.toggleClassName(f);r.current.props=e}return D.createPortal(e.children,o)}));function M(e,n,t,s){const o=a.useContext(x),r=a.useMemo(()=>e(o),[]);return a.useEffect(()=>{const i=n,c=null,l=typeof n=="function"?n:null,{map:f}=o;return f.hasControl(r)||(f.addControl(r,i==null?void 0:i.position),c&&c(o)),()=>{l&&l(o),f.hasControl(r)&&f.removeControl(r)}},[]),r}function te(e){const n=M(({mapLib:t})=>new t.AttributionControl(e),{position:e.position});return a.useEffect(()=>{E(n._container,e.style)},[e.style]),null}a.memo(te);function ne(e){const n=M(({mapLib:t})=>new t.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return a.useEffect(()=>{E(n._controlContainer,e.style)},[e.style]),null}a.memo(ne);function oe(e,n){const t=a.useRef({props:e}),s=M(({mapLib:o})=>{const r=new o.GeolocateControl(e),i=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||i()},r.on("geolocate",c=>{var l,f;(f=(l=t.current.props).onGeolocate)==null||f.call(l,c)}),r.on("error",c=>{var l,f;(f=(l=t.current.props).onError)==null||f.call(l,c)}),r.on("outofmaxbounds",c=>{var l,f;(f=(l=t.current.props).onOutOfMaxBounds)==null||f.call(l,c)}),r.on("trackuserlocationstart",c=>{var l,f;(f=(l=t.current.props).onTrackUserLocationStart)==null||f.call(l,c)}),r.on("trackuserlocationend",c=>{var l,f;(f=(l=t.current.props).onTrackUserLocationEnd)==null||f.call(l,c)}),r},{position:e.position});return t.current.props=e,a.useImperativeHandle(n,()=>s,[]),a.useEffect(()=>{E(s._container,e.style)},[e.style]),null}a.memo(a.forwardRef(oe));function re(e){const n=M(({mapLib:t})=>new t.NavigationControl(e),{position:e.position});return a.useEffect(()=>{E(n._container,e.style)},[e.style]),null}a.memo(re);function se(e){const n=M(({mapLib:r})=>new r.ScaleControl(e),{position:e.position}),t=a.useRef(e),s=t.current;t.current=e;const{style:o}=e;return e.maxWidth!==void 0&&e.maxWidth!==s.maxWidth&&(n.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==s.unit&&n.setUnit(e.unit),a.useEffect(()=>{E(n._container,o)},[o]),null}const ge=a.memo(se);function ie(e){const n=M(({mapLib:t})=>new t.TerrainControl(e),{position:e.position});return a.useEffect(()=>{E(n._container,e.style)},[e.style]),null}a.memo(ie);function ae(e){const n=M(({mapLib:t})=>new t.LogoControl(e),{position:e.position});return a.useEffect(()=>{E(n._container,e.style)},[e.style]),null}a.memo(ae);const ce={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},le={light:"basemap-light-",dark:"basemap-dark-"},P={};async function ue(e){if(P[e])return P[e];const t=await(await fetch(ce[e])).json();return P[e]=t,t}function ye({mode:e}){const{current:n}=B(),[t,s]=a.useState(null),o=a.useRef({light:!1,dark:!1}),r=a.useRef({light:[],dark:[]}),i=a.useRef(e);a.useEffect(()=>{i.current=e},[e]),a.useEffect(()=>{const u=()=>{var v;const m=(v=n==null?void 0:n.getMap)==null?void 0:v.call(n);m&&!t&&s(m)};u();const d=setInterval(u,50),h=setTimeout(()=>clearInterval(d),5e3);return()=>{clearInterval(d),clearTimeout(h)}},[n,t]);const c=a.useCallback(async(u,d,h)=>{var k,_;if(o.current[d])return;const m=le[d],v=await ue(d),S=[];for(const[p,y]of Object.entries(v.sources||{})){const g=m+p;u.getSource(g)||u.addSource(g,y)}const b=(_=(((k=u.getStyle())==null?void 0:k.layers)||[]).find(p=>!p.id.startsWith("basemap-light-")&&!p.id.startsWith("basemap-dark-")))==null?void 0:_.id;for(const p of v.layers||[]){const y=m+p.id;if(S.push(y),u.getLayer(y))continue;const g={...p,id:y};"source"in g&&typeof g.source=="string"&&(g.source=m+g.source),g.layout||(g.layout={}),g.layout.visibility=h?"visible":"none";try{u.addLayer(g,b)}catch(C){console.warn(`[BasemapLayer] Failed to add layer ${y}:`,C)}}r.current[d]=S,o.current[d]=!0},[]),l=a.useCallback((u,d,h)=>{const m=r.current[d],v=h?"visible":"none";for(const S of m)if(u.getLayer(S))try{u.setLayoutProperty(S,"visibility",v)}catch{}},[]),f=a.useCallback(u=>{var m;const h=(((m=u.getStyle())==null?void 0:m.layers)||[]).filter(v=>!v.id.startsWith("basemap-light-")&&!v.id.startsWith("basemap-dark-"));for(const v of h)try{u.moveLayer(v.id)}catch{}},[]);return a.useEffect(()=>{if(!t)return;const u=d=>{t.hasImage(d.id)||t.addImage(d.id,{width:1,height:1,data:new Uint8Array([0,0,0,0])})};return t.on("styleimagemissing",u),()=>{t.off("styleimagemissing",u)}},[t]),a.useEffect(()=>{if(!t)return;let u=!1;const d=async()=>{if(!u)try{const m=i.current;await Promise.all([c(t,"light",m==="light"),c(t,"dark",m==="dark")]),u||(l(t,"light",i.current==="light"),l(t,"dark",i.current==="dark"),f(t),t.resize())}catch(m){console.error("[BasemapLayer] Setup error:",m)}};t.isStyleLoaded()?d():(t.once("style.load",d),t.once("load",()=>{!u&&!o.current.light&&d()}));const h=()=>{u||setTimeout(()=>{!u&&o.current.light&&o.current.dark&&f(t)},100)};return t.on("styledata",h),()=>{u=!0,t.off("styledata",h)}},[t,c,f,l]),a.useEffect(()=>{t&&(!o.current.light||!o.current.dark||(l(t,"light",e==="light"),l(t,"dark",e==="dark"),t.resize(),t.triggerRepaint()))},[t,e,l]),null}export{ye as B,de as M,he as P,ge as S,me as a,x as b,L as d,B as u}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Ch85h29t.js","assets/index-6Dqm8vG_.css"])))=>i.map(i=>d[i]); +import{r as a,_ as H,bb as D}from"./index-Ch85h29t.js";const W=a.createContext(null);function B(){var s;const e=(s=a.useContext(W))==null?void 0:s.maps,n=a.useContext(x);return a.useMemo(()=>({...e,current:n==null?void 0:n.map}),[e,n])}function Z(e,n){const t=Array.isArray(e)?e[0]:e?e.x:0,s=Array.isArray(e)?e[1]:e?e.y:0,o=Array.isArray(n)?n[0]:n?n.x:0,r=Array.isArray(n)?n[1]:n?n.y:0;return t===o&&s===r}function L(e,n){if(e===n)return!0;if(!e||!n)return!1;if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let t=0;t{let o=null;"interactive"in s&&(o=Object.assign({},s),delete o.interactive);const r=n[s.ref];if(r){o=o||Object.assign({},s),delete o.ref;for(const i of V)i in r&&(o[i]=r[i])}return o||s});return{...e,layers:t}}const O={version:8,sources:{},layers:[]},A={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"},N={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"],G=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class w{constructor(n,t,s){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||I(this._map.transform);const r=this.props[N[o.type]];r&&r(o)},this._onCameraUpdate=o=>this._internalUpdate?o:(this._propsedCameraUpdate=I(o),T(o,this.props)),this._onPointerEvent=o=>{(o.type==="mousemove"||o.type==="mouseout")&&this._updateHover(o);const r=this.props[A[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=n,this.props=t,this._initialize(s)}get map(){return this._map}setProps(n){const t=this.props;this.props=n;const s=this._updateSettings(n,t),o=this._updateSize(n),r=this._updateViewState(n);this._updateStyle(n,t),this._updateStyleComponents(n),this._updateHandlers(n,t),(s||o||r&&!this._map.isMoving())&&this.redraw()}static reuse(n,t){const s=w.savedMaps.pop();if(!s)return null;const o=s.map,r=o.getContainer();for(t.className=r.className;r.childNodes.length>0;)t.appendChild(r.childNodes[0]);o._container=t;const i=o._resizeObserver;i&&(i.disconnect(),i.observe(t)),s.setProps({...n,styleDiffing:!1}),o.resize();const{initialViewState:c}=n;return c&&(c.bounds?o.fitBounds(c.bounds,{...c.fitBoundsOptions,duration:0}):s._updateViewState(c)),o.isStyleLoaded()?o.fire("load"):o.once("style.load",()=>o.fire("load")),o._update(),s}_initialize(n){const{props:t}=this,{mapStyle:s=O}=t,o={...t,...t.initialViewState,container:n,style:z(s)},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}),t.gl){const c=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=c,t.gl)}const i=new this._MapClass(o);r.padding&&i.setPadding(r.padding),t.cursor&&(i.getCanvas().style.cursor=t.cursor),i.transformCameraUpdate=this._onCameraUpdate,i.on("style.load",()=>{var c;this._styleComponents={light:i.getLight(),sky:i.getSky(),projection:(c=i.getProjection)==null?void 0:c.call(i),terrain:i.getTerrain()},this._updateStyleComponents(this.props)}),i.on("sourcedata",()=>{this._updateStyleComponents(this.props)});for(const c in A)i.on(c,this._onPointerEvent);for(const c in N)i.on(c,this._onCameraEvent);for(const c in U)i.on(c,this._onEvent);this._map=i}recycle(){const t=this.map.getContainer().querySelector("[mapboxgl-children]");t==null||t.remove(),w.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const n=this._map;n.style&&(n._frame&&(n._frame.cancel(),n._frame=null),n._render())}_updateSize(n){const{viewState:t}=n;if(t){const s=this._map;if(t.width!==s.transform.width||t.height!==s.transform.height)return s.resize(),!0}return!1}_updateViewState(n){const t=this._map,s=t.transform;if(!t.isMoving()){const r=T(s,n);if(Object.keys(r).length>0)return this._internalUpdate=!0,t.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(n,t){const s=this._map;let o=!1;for(const r of q)if(r in n&&!L(n[r],t[r])){o=!0;const i=s[`set${r[0].toUpperCase()}${r.slice(1)}`];i==null||i.call(s,n[r])}return o}_updateStyle(n,t){if(n.cursor!==t.cursor&&(this._map.getCanvas().style.cursor=n.cursor||""),n.mapStyle!==t.mapStyle){const{mapStyle:s=O,styleDiffing:o=!0}=n,r={diff:o};"localIdeographFontFamily"in n&&(r.localIdeographFontFamily=n.localIdeographFontFamily),this._map.setStyle(z(s),r)}}_updateStyleComponents({light:n,projection:t,sky:s,terrain:o}){var c,l;const r=this._map,i=this._styleComponents;r.style._loaded&&(n&&!L(n,i.light)&&(i.light=n,r.setLight(n)),t&&!L(t,i.projection)&&t!==((c=i.projection)==null?void 0:c.type)&&(i.projection=typeof t=="string"?{type:t}:t,(l=r.setProjection)==null||l.call(r,i.projection)),s&&!L(s,i.sky)&&(i.sky=s,r.setSky(s)),o!==void 0&&!L(o,i.terrain)&&(!o||r.getSource(o.source))&&(i.terrain=o,r.setTerrain(o)))}_updateHandlers(n,t){const s=this._map;for(const o of G){const r=n[o]??!0,i=t[o]??!0;L(r,i)||(r?s[o].enable(r):s[o].disable())}}_queryRenderedFeatures(n){const t=this._map,{interactiveLayerIds:s=[]}=this.props;try{return t.queryRenderedFeatures(n,{layers:s.filter(t.getLayer.bind(t))})}catch{return[]}}_updateHover(n){var o;const{props:t}=this;if(t.interactiveLayerIds&&(t.onMouseMove||t.onMouseEnter||t.onMouseLeave)){const r=n.type,i=((o=this._hoveredFeatures)==null?void 0:o.length)>0,c=this._queryRenderedFeatures(n.point),l=c.length>0;!l&&i&&(n.type="mouseleave",this._onPointerEvent(n)),this._hoveredFeatures=c,l&&!i&&(n.type="mouseenter",this._onPointerEvent(n)),n.type=r}else this._hoveredFeatures=null}}w.savedMaps=[];const $=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function J(e){if(!e)return null;const n=e.map,t={getMap:()=>n};for(const s of K(n))!(s in t)&&!$.includes(s)&&(t[s]=n[s].bind(n));return t}function K(e){const n=new Set;let t=e;for(;t;){for(const s of Object.getOwnPropertyNames(t))s[0]!=="_"&&typeof e[s]=="function"&&s!=="fire"&&s!=="setEventedParent"&&n.add(s);t=Object.getPrototypeOf(t)}return Array.from(n)}const Y=typeof document<"u"?a.useLayoutEffect:a.useEffect;function X(e,n){const{RTLTextPlugin:t,maxParallelImageRequests:s,workerCount:o,workerUrl:r}=n;if(t&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()==="unavailable"){const{pluginUrl:i,lazy:c=!0}=typeof t=="string"?{pluginUrl:t}:t;e.setRTLTextPlugin(i,l=>{l&&console.error(l)},c)}s!==void 0&&e.setMaxParallelImageRequests(s),o!==void 0&&e.setWorkerCount(o),r!==void 0&&e.setWorkerUrl(r)}const x=a.createContext(null);function Q(e,n){const t=a.useContext(W),[s,o]=a.useState(null),r=a.useRef(),{current:i}=a.useRef({mapLib:null,map:null});a.useEffect(()=>{const f=e.mapLib;let u=!0,d;return Promise.resolve(f||H(()=>import("./maplibre-gl-BeaixZtx.js").then(h=>h.m),__vite__mapDeps([0,1]))).then(h=>{if(!u)return;if(!h)throw new Error("Invalid mapLib");const m="Map"in h?h:h.default;if(!m.Map)throw new Error("Invalid mapLib");X(m,e),e.reuseMaps&&(d=w.reuse(e,r.current)),d||(d=new w(m.Map,e,r.current)),i.map=J(d),i.mapLib=m,o(d),t==null||t.onMapMount(i.map,e.id)}).catch(h=>{const{onError:m}=e;m?m({type:"error",target:null,originalEvent:null,error:h}):console.error(h)}),()=>{u=!1,d&&(t==null||t.onMapUnmount(e.id),e.reuseMaps?d.recycle():d.destroy())}},[]),Y(()=>{s&&s.setProps(e)}),a.useImperativeHandle(n,()=>i.map,[s]);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},s&&a.createElement(x.Provider,{value:i},a.createElement("div",{"mapboxgl-children":"",style:l},e.children)))}const de=a.forwardRef(Q),ee=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function E(e,n){if(!e||!n)return;const t=e.style;for(const s in n){const o=n[s];Number.isFinite(o)&&!ee.test(s)?t[s]=`${o}px`:t[s]=o}}function j(e,n){if(e===n)return null;const t=F(e),s=F(n),o=[];for(const r of s)t.has(r)||o.push(r);for(const r of t)s.has(r)||o.push(r);return o.length===0?null:o}function F(e){return new Set(e?e.trim().split(/\s+/):[])}const me=a.memo(a.forwardRef((e,n)=>{const{map:t,mapLib:s}=a.useContext(x),o=a.useRef({props:e}),r=a.useMemo(()=>{let b=!1;a.Children.forEach(e.children,p=>{p&&(b=!0)});const k={...e,element:b?document.createElement("div"):void 0},_=new s.Marker(k);return _.setLngLat([e.longitude,e.latitude]),_.getElement().addEventListener("click",p=>{var y,g;(g=(y=o.current.props).onClick)==null||g.call(y,{type:"click",target:_,originalEvent:p})}),_.on("dragstart",p=>{var g,C;const y=p;y.lngLat=r.getLngLat(),(C=(g=o.current.props).onDragStart)==null||C.call(g,y)}),_.on("drag",p=>{var g,C;const y=p;y.lngLat=r.getLngLat(),(C=(g=o.current.props).onDrag)==null||C.call(g,y)}),_.on("dragend",p=>{var g,C;const y=p;y.lngLat=r.getLngLat(),(C=(g=o.current.props).onDragEnd)==null||C.call(g,y)}),_},[]);a.useEffect(()=>(r.addTo(t.getMap()),()=>{r.remove()}),[]);const{longitude:i,latitude:c,offset:l,style:f,draggable:u=!1,popup:d=null,rotation:h=0,rotationAlignment:m="auto",pitchAlignment:v="auto"}=e;a.useEffect(()=>{E(r.getElement(),f)},[f]),a.useImperativeHandle(n,()=>r,[]);const S=o.current.props;(r.getLngLat().lng!==i||r.getLngLat().lat!==c)&&r.setLngLat([i,c]),l&&!Z(r.getOffset(),l)&&r.setOffset(l),r.isDraggable()!==u&&r.setDraggable(u),r.getRotation()!==h&&r.setRotation(h),r.getRotationAlignment()!==m&&r.setRotationAlignment(m),r.getPitchAlignment()!==v&&r.setPitchAlignment(v),r.getPopup()!==d&&r.setPopup(d);const R=j(S.className,e.className);if(R)for(const b of R)r.toggleClassName(b);return o.current.props=e,D.createPortal(e.children,r.getElement())})),he=a.memo(a.forwardRef((e,n)=>{const{map:t,mapLib:s}=a.useContext(x),o=a.useMemo(()=>document.createElement("div"),[]),r=a.useRef({props:e}),i=a.useMemo(()=>{const c={...e},l=new s.Popup(c);return l.setLngLat([e.longitude,e.latitude]),l.once("open",f=>{var u,d;(d=(u=r.current.props).onOpen)==null||d.call(u,f)}),l},[]);if(a.useEffect(()=>{const c=l=>{var f,u;(u=(f=r.current.props).onClose)==null||u.call(f,l)};return i.on("close",c),i.setDOMContent(o).addTo(t.getMap()),()=>{i.off("close",c),i.isOpen()&&i.remove()}},[]),a.useEffect(()=>{E(i.getElement(),e.style)},[e.style]),a.useImperativeHandle(n,()=>i,[]),i.isOpen()){const c=r.current.props;(i.getLngLat().lng!==e.longitude||i.getLngLat().lat!==e.latitude)&&i.setLngLat([e.longitude,e.latitude]),e.offset&&!L(c.offset,e.offset)&&i.setOffset(e.offset),(c.anchor!==e.anchor||c.maxWidth!==e.maxWidth)&&(i.options.anchor=e.anchor,i.setMaxWidth(e.maxWidth));const l=j(c.className,e.className);if(l)for(const f of l)i.toggleClassName(f);r.current.props=e}return D.createPortal(e.children,o)}));function M(e,n,t,s){const o=a.useContext(x),r=a.useMemo(()=>e(o),[]);return a.useEffect(()=>{const i=n,c=null,l=typeof n=="function"?n:null,{map:f}=o;return f.hasControl(r)||(f.addControl(r,i==null?void 0:i.position),c&&c(o)),()=>{l&&l(o),f.hasControl(r)&&f.removeControl(r)}},[]),r}function te(e){const n=M(({mapLib:t})=>new t.AttributionControl(e),{position:e.position});return a.useEffect(()=>{E(n._container,e.style)},[e.style]),null}a.memo(te);function ne(e){const n=M(({mapLib:t})=>new t.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return a.useEffect(()=>{E(n._controlContainer,e.style)},[e.style]),null}a.memo(ne);function oe(e,n){const t=a.useRef({props:e}),s=M(({mapLib:o})=>{const r=new o.GeolocateControl(e),i=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||i()},r.on("geolocate",c=>{var l,f;(f=(l=t.current.props).onGeolocate)==null||f.call(l,c)}),r.on("error",c=>{var l,f;(f=(l=t.current.props).onError)==null||f.call(l,c)}),r.on("outofmaxbounds",c=>{var l,f;(f=(l=t.current.props).onOutOfMaxBounds)==null||f.call(l,c)}),r.on("trackuserlocationstart",c=>{var l,f;(f=(l=t.current.props).onTrackUserLocationStart)==null||f.call(l,c)}),r.on("trackuserlocationend",c=>{var l,f;(f=(l=t.current.props).onTrackUserLocationEnd)==null||f.call(l,c)}),r},{position:e.position});return t.current.props=e,a.useImperativeHandle(n,()=>s,[]),a.useEffect(()=>{E(s._container,e.style)},[e.style]),null}a.memo(a.forwardRef(oe));function re(e){const n=M(({mapLib:t})=>new t.NavigationControl(e),{position:e.position});return a.useEffect(()=>{E(n._container,e.style)},[e.style]),null}a.memo(re);function se(e){const n=M(({mapLib:r})=>new r.ScaleControl(e),{position:e.position}),t=a.useRef(e),s=t.current;t.current=e;const{style:o}=e;return e.maxWidth!==void 0&&e.maxWidth!==s.maxWidth&&(n.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==s.unit&&n.setUnit(e.unit),a.useEffect(()=>{E(n._container,o)},[o]),null}const ge=a.memo(se);function ie(e){const n=M(({mapLib:t})=>new t.TerrainControl(e),{position:e.position});return a.useEffect(()=>{E(n._container,e.style)},[e.style]),null}a.memo(ie);function ae(e){const n=M(({mapLib:t})=>new t.LogoControl(e),{position:e.position});return a.useEffect(()=>{E(n._container,e.style)},[e.style]),null}a.memo(ae);const ce={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},le={light:"basemap-light-",dark:"basemap-dark-"},P={};async function ue(e){if(P[e])return P[e];const t=await(await fetch(ce[e])).json();return P[e]=t,t}function ye({mode:e}){const{current:n}=B(),[t,s]=a.useState(null),o=a.useRef({light:!1,dark:!1}),r=a.useRef({light:[],dark:[]}),i=a.useRef(e);a.useEffect(()=>{i.current=e},[e]),a.useEffect(()=>{const u=()=>{var v;const m=(v=n==null?void 0:n.getMap)==null?void 0:v.call(n);m&&!t&&s(m)};u();const d=setInterval(u,50),h=setTimeout(()=>clearInterval(d),5e3);return()=>{clearInterval(d),clearTimeout(h)}},[n,t]);const c=a.useCallback(async(u,d,h)=>{var k,_;if(o.current[d])return;const m=le[d],v=await ue(d),S=[];for(const[p,y]of Object.entries(v.sources||{})){const g=m+p;u.getSource(g)||u.addSource(g,y)}const b=(_=(((k=u.getStyle())==null?void 0:k.layers)||[]).find(p=>!p.id.startsWith("basemap-light-")&&!p.id.startsWith("basemap-dark-")))==null?void 0:_.id;for(const p of v.layers||[]){const y=m+p.id;if(S.push(y),u.getLayer(y))continue;const g={...p,id:y};"source"in g&&typeof g.source=="string"&&(g.source=m+g.source),g.layout||(g.layout={}),g.layout.visibility=h?"visible":"none";try{u.addLayer(g,b)}catch(C){console.warn(`[BasemapLayer] Failed to add layer ${y}:`,C)}}r.current[d]=S,o.current[d]=!0},[]),l=a.useCallback((u,d,h)=>{const m=r.current[d],v=h?"visible":"none";for(const S of m)if(u.getLayer(S))try{u.setLayoutProperty(S,"visibility",v)}catch{}},[]),f=a.useCallback(u=>{var m;const h=(((m=u.getStyle())==null?void 0:m.layers)||[]).filter(v=>!v.id.startsWith("basemap-light-")&&!v.id.startsWith("basemap-dark-"));for(const v of h)try{u.moveLayer(v.id)}catch{}},[]);return a.useEffect(()=>{if(!t)return;const u=d=>{t.hasImage(d.id)||t.addImage(d.id,{width:1,height:1,data:new Uint8Array([0,0,0,0])})};return t.on("styleimagemissing",u),()=>{t.off("styleimagemissing",u)}},[t]),a.useEffect(()=>{if(!t)return;let u=!1;const d=async()=>{if(!u)try{const m=i.current;await Promise.all([c(t,"light",m==="light"),c(t,"dark",m==="dark")]),u||(l(t,"light",i.current==="light"),l(t,"dark",i.current==="dark"),f(t),t.resize())}catch(m){console.error("[BasemapLayer] Setup error:",m)}};t.isStyleLoaded()?d():(t.once("style.load",d),t.once("load",()=>{!u&&!o.current.light&&d()}));const h=()=>{u||setTimeout(()=>{!u&&o.current.light&&o.current.dark&&f(t)},100)};return t.on("styledata",h),()=>{u=!0,t.off("styledata",h)}},[t,c,f,l]),a.useEffect(()=>{t&&(!o.current.light||!o.current.dark||(l(t,"light",e==="light"),l(t,"dark",e==="dark"),t.resize(),t.triggerRepaint()))},[t,e,l]),null}export{ye as B,de as M,he as P,ge as S,me as a,x as b,L as d,B as u}; diff --git a/frontend/dist/assets/CADCalibration-D6nEV-hE.js b/frontend/dist/assets/CADCalibration-D6nEV-hE.js deleted file mode 100644 index e4530583..00000000 --- a/frontend/dist/assets/CADCalibration-D6nEV-hE.js +++ /dev/null @@ -1,6 +0,0 @@ -import{e as G,dn as S,dp as J,dq as V,r as c,j as e,B as b,dt as W,az as X,f as C,R as K}from"./index-BdFZD4tW.js";import{P as Q,a as Y,B as Z,C as u}from"./PageLayout-CIUNh3-q.js";import{C as I}from"./ConfirmModal-N7ejcMF0.js";import{r as ee}from"./system-DPP-2Czb.js";import{A as te}from"./activity-BkgN42Nd.js";import{R as _,C as D}from"./Grid-BkuFQpqe.js";import{S as se}from"./save-CUUX0zl8.js";import{S as ae}from"./sparkles-CBpWDpkg.js";import{T as $}from"./target-B6gSZQdg.js";import{T as re}from"./timer-BRW2IWL3.js";import"./WorkspaceNav-DR8N-VVk.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 ie=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ne=G("square",ie);async function le(a={}){return S("/api/cad_calibration_start",{method:"POST",body:JSON.stringify({samples:a.samples??10,delay_ms:a.delay_ms??50})})}async function oe(){return S("/api/cad_calibration_stop",{method:"POST",body:"{}"})}async function ce(a){return S("/api/save_cad_settings",{method:"POST",body:JSON.stringify(a)})}function de(a,o){const i=J(),x=i?`?token=${encodeURIComponent(i)}`:"",r=new EventSource(`${V}/api/cad_calibration_stream${x}`);return r.onmessage=d=>{try{a(JSON.parse(d.data))}catch(n){console.warn("[cad] Failed to parse CAD stream payload",n)}},o&&(r.onerror=o),r}function me(a){return!a||typeof a!="object"||Array.isArray(a)?null:a}function N(a,o){return a==null||o==null?"auto":`${a}–${o}`}function xe(a){return a>=80?"var(--sys-green)":a>=55?"var(--sys-cyan)":a>=25?"var(--sys-blue)":a>0?"var(--sys-indigo)":"var(--fg-muted)"}function pe(a){if(!a)return;const i=new XMLSerializer().serializeToString(a),x=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),r=URL.createObjectURL(x),d=document.createElement("a");d.href=r,d.download=`cad-calibration-heatmap-${new Date().toISOString().replace(/[:.]/g,"-")}.svg`,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(r)}function he({results:a,best:o,rangeInfo:i,svgRef:x}){const r=c.useMemo(()=>{const s=a.map(h=>h.det_peak),p=a.map(h=>h.det_min);return{peakMin:(i==null?void 0:i.peak_min)??Math.min(...s,0),peakMax:(i==null?void 0:i.peak_max)??Math.max(...s,1),minMin:(i==null?void 0:i.min_min)??Math.min(...p,0),minMax:(i==null?void 0:i.min_max)??Math.max(...p,1)}},[i,a]),d=s=>80+(s-r.peakMin)/Math.max(1,r.peakMax-r.peakMin)*620,n=s=>320-(s-r.minMin)/Math.max(1,r.minMax-r.minMin)*240,j=[...a].sort((s,p)=>s.detection_rate-p.detection_rate);return e.jsx("div",{className:"relative min-h-[380px] overflow-hidden rounded-2xl bg-subtle-fill p-2 ring-1 ring-inset ring-edge-subtle",children:e.jsxs("svg",{ref:x,viewBox:"0 0 800 380",className:"h-[380px] w-full",role:"img","aria-label":"CAD calibration detection-rate scatter heatmap",children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"cad-chart-glow",cx:"50%",cy:"45%",r:"65%",children:[e.jsx("stop",{offset:"0%",stopColor:"rgba(14, 165, 233, 0.18)"}),e.jsx("stop",{offset:"100%",stopColor:"rgba(14, 165, 233, 0)"})]}),e.jsxs("linearGradient",{id:"cad-rate-gradient",x1:"0",y1:"1",x2:"0",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--fg-muted)"}),e.jsx("stop",{offset:"30%",stopColor:"var(--sys-indigo)"}),e.jsx("stop",{offset:"58%",stopColor:"var(--sys-blue)"}),e.jsx("stop",{offset:"78%",stopColor:"var(--sys-cyan)"}),e.jsx("stop",{offset:"100%",stopColor:"var(--sys-green)"})]})]}),e.jsx("rect",{width:"800",height:"380",rx:"22",fill:"transparent"}),e.jsx("rect",{x:"64",y:"40",width:"660",height:"300",rx:"16",fill:"url(#cad-chart-glow)",stroke:"var(--edge-subtle)"}),[0,1,2,3,4].map(s=>{const p=80+s*155,h=80+s*60;return e.jsxs("g",{children:[e.jsx("line",{x1:p,y1:"80",x2:p,y2:"320",stroke:"var(--edge-subtle)",strokeOpacity:"0.55"}),e.jsx("line",{x1:"80",y1:h,x2:"700",y2:h,stroke:"var(--edge-subtle)",strokeOpacity:"0.55"})]},s)}),e.jsx("line",{x1:"80",y1:"320",x2:"700",y2:"320",stroke:"var(--fg-muted)",strokeOpacity:"0.65"}),e.jsx("line",{x1:"80",y1:"80",x2:"80",y2:"320",stroke:"var(--fg-muted)",strokeOpacity:"0.65"}),e.jsx("text",{x:"390",y:"362",textAnchor:"middle",className:"fill-fg-muted text-[13px] font-semibold",children:"CAD Peak Threshold"}),e.jsx("text",{x:"24",y:"205",textAnchor:"middle",transform:"rotate(-90 24 205)",className:"fill-fg-muted text-[13px] font-semibold",children:"CAD Min Threshold"}),e.jsx("text",{x:"80",y:"342",textAnchor:"middle",className:"fill-fg-muted text-[11px]",children:r.peakMin}),e.jsx("text",{x:"700",y:"342",textAnchor:"middle",className:"fill-fg-muted text-[11px]",children:r.peakMax}),e.jsx("text",{x:"66",y:"324",textAnchor:"end",className:"fill-fg-muted text-[11px]",children:r.minMin}),e.jsx("text",{x:"66",y:"84",textAnchor:"end",className:"fill-fg-muted text-[11px]",children:r.minMax}),j.map((s,p)=>{const h=(o==null?void 0:o.det_peak)===s.det_peak&&o.det_min===s.det_min&&o.detection_rate===s.detection_rate,y=8+Math.min(14,Math.max(0,s.detection_rate/7));return e.jsxs("g",{children:[h&&e.jsx("circle",{cx:d(s.det_peak),cy:n(s.det_min),r:y+8,fill:"none",stroke:"var(--sys-green)",strokeWidth:"2",strokeDasharray:"4 4"}),e.jsx("circle",{cx:d(s.det_peak),cy:n(s.det_min),r:y,fill:xe(s.detection_rate),fillOpacity:"0.82",stroke:"rgba(255,255,255,0.68)",strokeWidth:"1.4",children:e.jsx("title",{children:`Peak ${s.det_peak}, Min ${s.det_min}, Rate ${s.detection_rate.toFixed(1)}%`})}),h&&e.jsx("text",{x:d(s.det_peak),y:n(s.det_min)-y-12,textAnchor:"middle",className:"fill-sys-green text-[11px] font-bold",children:"BEST"})]},`${s.det_peak}-${s.det_min}-${p}`)}),e.jsx("rect",{x:"742",y:"86",width:"16",height:"220",rx:"8",fill:"url(#cad-rate-gradient)",stroke:"var(--edge-subtle)"}),e.jsx("text",{x:"770",y:"92",className:"fill-fg-muted text-[11px]",children:"100%"}),e.jsx("text",{x:"770",y:"308",className:"fill-fg-muted text-[11px]",children:"0%"}),a.length===0&&e.jsx("text",{x:"390",y:"205",textAnchor:"middle",className:"fill-fg-muted text-[15px]",children:"Start calibration to populate the detection-rate heatmap."})]})})}function Se(){const[a,o]=c.useState(!1),[i,x]=c.useState("Ready to start calibration"),[r,d]=c.useState({current:0,total:0}),[n,j]=c.useState([]),[s,p]=c.useState(null),[h,y]=c.useState(null),[,P]=c.useState(0),[w,g]=c.useState(null),[m,v]=c.useState(null),[T,k]=c.useState(!1),[E,R]=c.useState(!1),M=c.useRef(null);c.useEffect(()=>()=>{m==null||m.close()},[m]),c.useEffect(()=>{if(!a)return;const t=window.setInterval(()=>P(f=>f+1),1e3);return()=>window.clearInterval(t)},[a]);const l=c.useMemo(()=>n.reduce((t,f)=>!t||f.detection_rate>t.detection_rate?f:t,null),[n]),O=n.length?n.reduce((t,f)=>t+f.detection_rate,0)/n.length:0,B=r.total>0?Math.min(100,Math.round(r.current/r.total*100)):0,A=h?Math.max(0,Math.floor((Date.now()-h)/1e3)):0,F=c.useMemo(()=>[...n].sort((t,f)=>f.detection_rate-t.detection_rate),[n]),L=t=>{t.message&&x(t.message),t.test_ranges&&p(me(t.test_ranges)),t.type==="progress"&&d({current:t.current??0,total:t.total??0}),t.type==="result"&&t.det_peak!==void 0&&t.det_min!==void 0&&t.detection_rate!==void 0&&j(f=>[...f,{det_peak:t.det_peak,det_min:t.det_min,detection_rate:t.detection_rate,detections:t.detections,samples:t.samples}]),(t.type==="complete"||t.type==="completed")&&(o(!1),m==null||m.close(),v(null)),t.type==="error"&&(g(t.message||"Calibration failed"),o(!1))},U=async()=>{g(null),j([]),d({current:0,total:0}),p(null),y(Date.now()),x("Starting calibration…");try{const t=await le({samples:10,delay_ms:50});if(t.success===!1)throw new Error(t.error||"Backend rejected calibration start");m==null||m.close(),v(de(L,()=>g("CAD calibration stream disconnected."))),o(!0)}catch(t){g(t instanceof Error?t.message:"CAD calibration endpoint unavailable"),x("Unable to start calibration")}},z=async()=>{await oe().catch(()=>{}),m==null||m.close(),v(null),o(!1),x("Calibration stopped")},q=async()=>{if(l)try{const t=await ce({peak:l.det_peak,min_val:l.det_min,detection_rate:l.detection_rate});if(t.success===!1)throw new Error(t.error||"Save failed");x("CAD settings saved. Restart the Repeater service for them to take effect."),k(!0)}catch(t){g(t instanceof Error?t.message:"Failed to save CAD settings")}},H=async()=>{R(!0);try{await ee(),x("Restart requested. The UI will reconnect after the service comes back."),k(!1)}catch(t){g(t instanceof Error?t.message:"Failed to request service restart")}finally{R(!1)}};return e.jsxs(Q,{children:[e.jsx(Y,{title:"CAD Calibration Tool",icon:e.jsx(te,{}),subtitle:e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Default-UI style Channel Activity Detection calibration with live threshold heatmap and restart prompt."})}),e.jsxs(Z,{ready:!0,children:[e.jsx(_,{template:"auto",children:e.jsxs(u,{neomorphic:!0,children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"type-body text-fg-primary",children:i}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:s?`SF${s.spreading_factor??"auto"} · Peak ${N(s.peak_min,s.peak_max)} · Min ${N(s.min_min,s.min_max)}`:"Awaiting calibration…"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(b,{color:"success",onClick:U,disabled:a,children:[e.jsx(W,{"data-slot":"icon"}),"Start Calibration"]}),e.jsxs(b,{color:"danger",outline:!0,onClick:z,disabled:!a,children:[e.jsx(ne,{"data-slot":"icon"}),"Stop"]}),e.jsxs(b,{color:"primary",outline:!0,onClick:q,disabled:!l,children:[e.jsx(se,{"data-slot":"icon"}),"Save Settings"]}),e.jsxs(b,{color:"muted",outline:!0,onClick:()=>pe(M.current),disabled:n.length===0,children:[e.jsx(X,{"data-slot":"icon"}),"Export SVG"]})]})]}),e.jsx("div",{className:"mt-4 h-2 rounded-full bg-subtle-fill overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${B}%`,background:"linear-gradient(90deg, var(--sys-blue), var(--sys-green))"}})}),e.jsxs("p",{className:"mt-2 type-data-xs text-fg-muted",children:[r.current," / ",r.total||"—"," tests completed"]})]})}),w&&e.jsx(_,{template:"auto",children:e.jsx(u,{neomorphic:!0,className:"text-sys-red",children:w})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-4",children:[e.jsxs(u,{compact:!0,className:"min-h-0 p-3",children:[e.jsx("p",{className:"type-data-xs text-fg-muted",children:"Tests Completed"}),e.jsx("p",{className:"mt-1 text-sm font-semibold leading-tight text-fg-primary",children:n.length})]}),e.jsxs(u,{compact:!0,className:"min-h-0 p-3",children:[e.jsx("p",{className:"type-data-xs text-fg-muted",children:"Best Detection Rate"}),e.jsx("p",{className:"mt-1 text-sm font-semibold leading-tight text-fg-primary",children:l?`${l.detection_rate.toFixed(1)}%`:"n/a"})]}),e.jsxs(u,{compact:!0,className:"min-h-0 p-3",children:[e.jsx("p",{className:"type-data-xs text-fg-muted",children:"Average Rate"}),e.jsx("p",{className:"mt-1 text-sm font-semibold leading-tight text-fg-primary",children:n.length?`${O.toFixed(1)}%`:"n/a"})]}),e.jsxs(u,{compact:!0,className:"min-h-0 p-3",children:[e.jsx("p",{className:"type-data-xs text-fg-muted",children:"Elapsed Time"}),e.jsxs("p",{className:"mt-1 text-sm font-semibold leading-tight text-fg-primary",children:[A,"s"]})]})]}),e.jsxs(_,{template:"auto",children:[e.jsx(D,{span:"full",lg:8,children:e.jsxs(u,{neomorphic:!0,className:"space-y-4",children:[e.jsx(C,{icon:e.jsx(ae,{}),title:"CAD Detection Rate Heatmap",actions:l&&e.jsxs("span",{className:"rounded-full border border-sys-green/30 bg-sys-green/10 px-3 py-1 type-data-xs text-sys-green",children:["Best P",l.det_peak,"/M",l.det_min," · ",l.detection_rate.toFixed(1),"%"]})}),e.jsx(he,{results:n,best:l,rangeInfo:s,svgRef:M})]})}),e.jsx(D,{span:"full",lg:4,children:e.jsxs(u,{neomorphic:!0,className:"space-y-5",children:[e.jsx(C,{icon:e.jsx($,{}),title:"Calibration Result"}),l?e.jsxs("div",{className:"rounded-2xl bg-sys-green/10 ring-1 ring-inset ring-sys-green/30 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sys-green type-label",children:[e.jsx($,{className:"size-4"}),"Recommended Thresholds"]}),e.jsxs("p",{className:"mt-2 type-heading text-fg-primary tabular-nums",children:["Peak ",l.det_peak," · Min ",l.det_min]}),e.jsxs("p",{className:"type-body-sm text-fg-muted",children:[l.detections??"n/a"," / ",l.samples??"n/a"," detections at ",l.detection_rate.toFixed(1),"%."]})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"No optimal settings yet. Start calibration to collect results."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"rounded-xl bg-subtle-fill p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-fg-muted type-data-xs",children:[e.jsx(K,{className:"size-3.5"}),"SF"]}),e.jsx("p",{className:"type-heading text-fg-primary",children:(s==null?void 0:s.spreading_factor)??"auto"})]}),e.jsxs("div",{className:"rounded-xl bg-subtle-fill p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-fg-muted type-data-xs",children:[e.jsx(re,{className:"size-3.5"}),"Elapsed"]}),e.jsxs("p",{className:"type-heading text-fg-primary",children:[A,"s"]})]}),e.jsxs("div",{className:"rounded-xl bg-subtle-fill p-3",children:[e.jsx("p",{className:"type-data-xs text-fg-muted",children:"Peak range"}),e.jsx("p",{className:"type-body-sm text-fg-primary tabular-nums",children:N(s==null?void 0:s.peak_min,s==null?void 0:s.peak_max)})]}),e.jsxs("div",{className:"rounded-xl bg-subtle-fill p-3",children:[e.jsx("p",{className:"type-data-xs text-fg-muted",children:"Min range"}),e.jsx("p",{className:"type-body-sm text-fg-primary tabular-nums",children:N(s==null?void 0:s.min_min,s==null?void 0:s.min_max)})]})]})]})})]}),e.jsx(_,{template:"auto",children:e.jsxs(u,{neomorphic:!0,children:[e.jsx(C,{title:"Raw Results"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-fg-muted",children:[e.jsx("th",{className:"p-2 text-left",children:"Peak"}),e.jsx("th",{className:"p-2 text-left",children:"Min"}),e.jsx("th",{className:"p-2 text-left",children:"Detection Rate"}),e.jsx("th",{className:"p-2 text-left",children:"Detections"})]})}),e.jsxs("tbody",{children:[F.map((t,f)=>e.jsxs("tr",{className:"border-t border-edge-subtle",children:[e.jsx("td",{className:"p-2",children:t.det_peak}),e.jsx("td",{className:"p-2",children:t.det_min}),e.jsxs("td",{className:"p-2",children:[t.detection_rate.toFixed(1),"%"]}),e.jsxs("td",{className:"p-2",children:[t.detections??"n/a"," / ",t.samples??"n/a"]})]},`${t.det_peak}-${t.det_min}-${f}`)),n.length===0&&e.jsx("tr",{children:e.jsx("td",{className:"p-3 text-fg-muted",colSpan:4,children:"No calibration samples yet."})})]})]})})]})})]}),e.jsx(I,{isOpen:T,title:"CAD Calibration Saved: Restart Required",message:"In order for the CAD Calibration settings to take effect and the noise floor to return to normal, the openHop Repeater service needs to be restarted.",confirmLabel:E?"Restarting…":"Restart Service",cancelLabel:"Later",variant:"warning",onConfirm:H,onCancel:()=>k(!1)})]})}export{Se as default}; diff --git a/frontend/dist/assets/CADCalibration-DEpvVgmC.js b/frontend/dist/assets/CADCalibration-DEpvVgmC.js new file mode 100644 index 00000000..02823eee --- /dev/null +++ b/frontend/dist/assets/CADCalibration-DEpvVgmC.js @@ -0,0 +1,6 @@ +import{e as G,dy as S,dz as J,dA as V,r as c,j as e,B as b,dG as W,aD as X,f as C,R as K}from"./index-Ch85h29t.js";import{P as Q,a as Y,B as Z,C as u}from"./PageLayout-BB80XCAa.js";import{C as I}from"./ConfirmModal-DdfUdqSh.js";import{r as ee}from"./system-D8kFotbu.js";import{A as te}from"./activity-Uf5hjDsb.js";import{R as _,C as D}from"./Grid-DKZX3hrI.js";import{S as se}from"./save-Ci6Me-tl.js";import{S as ae}from"./sparkles-DLR0cBlA.js";import{T as $}from"./target-ISEIkLpl.js";import{T as re}from"./timer-BakEn2KK.js";import"./WorkspaceNav-ZTG5UTjF.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 ie=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ne=G("square",ie);async function le(a={}){return S("/api/cad_calibration_start",{method:"POST",body:JSON.stringify({samples:a.samples??10,delay:a.delay??50})})}async function oe(){return S("/api/cad_calibration_stop",{method:"POST",body:"{}"})}async function ce(a){return S("/api/save_cad_settings",{method:"POST",body:JSON.stringify(a)})}function de(a,o){const i=J(),x=i?`?token=${encodeURIComponent(i)}`:"",r=new EventSource(`${V}/api/cad_calibration_stream${x}`);return r.onmessage=d=>{try{a(JSON.parse(d.data))}catch(n){console.warn("[cad] Failed to parse CAD stream payload",n)}},o&&(r.onerror=o),r}function me(a){return!a||typeof a!="object"||Array.isArray(a)?null:a}function N(a,o){return a==null||o==null?"auto":`${a}–${o}`}function xe(a){return a>=80?"var(--sys-green)":a>=55?"var(--sys-cyan)":a>=25?"var(--sys-blue)":a>0?"var(--sys-indigo)":"var(--fg-muted)"}function pe(a){if(!a)return;const i=new XMLSerializer().serializeToString(a),x=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),r=URL.createObjectURL(x),d=document.createElement("a");d.href=r,d.download=`cad-calibration-heatmap-${new Date().toISOString().replace(/[:.]/g,"-")}.svg`,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(r)}function he({results:a,best:o,rangeInfo:i,svgRef:x}){const r=c.useMemo(()=>{const s=a.map(h=>h.det_peak),p=a.map(h=>h.det_min);return{peakMin:(i==null?void 0:i.peak_min)??Math.min(...s,0),peakMax:(i==null?void 0:i.peak_max)??Math.max(...s,1),minMin:(i==null?void 0:i.min_min)??Math.min(...p,0),minMax:(i==null?void 0:i.min_max)??Math.max(...p,1)}},[i,a]),d=s=>80+(s-r.peakMin)/Math.max(1,r.peakMax-r.peakMin)*620,n=s=>320-(s-r.minMin)/Math.max(1,r.minMax-r.minMin)*240,j=[...a].sort((s,p)=>s.detection_rate-p.detection_rate);return e.jsx("div",{className:"relative min-h-[380px] overflow-hidden rounded-2xl bg-subtle-fill p-2 ring-1 ring-inset ring-edge-subtle",children:e.jsxs("svg",{ref:x,viewBox:"0 0 800 380",className:"h-[380px] w-full",role:"img","aria-label":"CAD calibration detection-rate scatter heatmap",children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"cad-chart-glow",cx:"50%",cy:"45%",r:"65%",children:[e.jsx("stop",{offset:"0%",stopColor:"rgba(14, 165, 233, 0.18)"}),e.jsx("stop",{offset:"100%",stopColor:"rgba(14, 165, 233, 0)"})]}),e.jsxs("linearGradient",{id:"cad-rate-gradient",x1:"0",y1:"1",x2:"0",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--fg-muted)"}),e.jsx("stop",{offset:"30%",stopColor:"var(--sys-indigo)"}),e.jsx("stop",{offset:"58%",stopColor:"var(--sys-blue)"}),e.jsx("stop",{offset:"78%",stopColor:"var(--sys-cyan)"}),e.jsx("stop",{offset:"100%",stopColor:"var(--sys-green)"})]})]}),e.jsx("rect",{width:"800",height:"380",rx:"22",fill:"transparent"}),e.jsx("rect",{x:"64",y:"40",width:"660",height:"300",rx:"16",fill:"url(#cad-chart-glow)",stroke:"var(--edge-subtle)"}),[0,1,2,3,4].map(s=>{const p=80+s*155,h=80+s*60;return e.jsxs("g",{children:[e.jsx("line",{x1:p,y1:"80",x2:p,y2:"320",stroke:"var(--edge-subtle)",strokeOpacity:"0.55"}),e.jsx("line",{x1:"80",y1:h,x2:"700",y2:h,stroke:"var(--edge-subtle)",strokeOpacity:"0.55"})]},s)}),e.jsx("line",{x1:"80",y1:"320",x2:"700",y2:"320",stroke:"var(--fg-muted)",strokeOpacity:"0.65"}),e.jsx("line",{x1:"80",y1:"80",x2:"80",y2:"320",stroke:"var(--fg-muted)",strokeOpacity:"0.65"}),e.jsx("text",{x:"390",y:"362",textAnchor:"middle",className:"fill-fg-muted text-[13px] font-semibold",children:"CAD Peak Threshold"}),e.jsx("text",{x:"24",y:"205",textAnchor:"middle",transform:"rotate(-90 24 205)",className:"fill-fg-muted text-[13px] font-semibold",children:"CAD Min Threshold"}),e.jsx("text",{x:"80",y:"342",textAnchor:"middle",className:"fill-fg-muted text-[11px]",children:r.peakMin}),e.jsx("text",{x:"700",y:"342",textAnchor:"middle",className:"fill-fg-muted text-[11px]",children:r.peakMax}),e.jsx("text",{x:"66",y:"324",textAnchor:"end",className:"fill-fg-muted text-[11px]",children:r.minMin}),e.jsx("text",{x:"66",y:"84",textAnchor:"end",className:"fill-fg-muted text-[11px]",children:r.minMax}),j.map((s,p)=>{const h=(o==null?void 0:o.det_peak)===s.det_peak&&o.det_min===s.det_min&&o.detection_rate===s.detection_rate,y=8+Math.min(14,Math.max(0,s.detection_rate/7));return e.jsxs("g",{children:[h&&e.jsx("circle",{cx:d(s.det_peak),cy:n(s.det_min),r:y+8,fill:"none",stroke:"var(--sys-green)",strokeWidth:"2",strokeDasharray:"4 4"}),e.jsx("circle",{cx:d(s.det_peak),cy:n(s.det_min),r:y,fill:xe(s.detection_rate),fillOpacity:"0.82",stroke:"rgba(255,255,255,0.68)",strokeWidth:"1.4",children:e.jsx("title",{children:`Peak ${s.det_peak}, Min ${s.det_min}, Rate ${s.detection_rate.toFixed(1)}%`})}),h&&e.jsx("text",{x:d(s.det_peak),y:n(s.det_min)-y-12,textAnchor:"middle",className:"fill-sys-green text-[11px] font-bold",children:"BEST"})]},`${s.det_peak}-${s.det_min}-${p}`)}),e.jsx("rect",{x:"742",y:"86",width:"16",height:"220",rx:"8",fill:"url(#cad-rate-gradient)",stroke:"var(--edge-subtle)"}),e.jsx("text",{x:"770",y:"92",className:"fill-fg-muted text-[11px]",children:"100%"}),e.jsx("text",{x:"770",y:"308",className:"fill-fg-muted text-[11px]",children:"0%"}),a.length===0&&e.jsx("text",{x:"390",y:"205",textAnchor:"middle",className:"fill-fg-muted text-[15px]",children:"Start calibration to populate the detection-rate heatmap."})]})})}function Se(){const[a,o]=c.useState(!1),[i,x]=c.useState("Ready to start calibration"),[r,d]=c.useState({current:0,total:0}),[n,j]=c.useState([]),[s,p]=c.useState(null),[h,y]=c.useState(null),[,P]=c.useState(0),[w,g]=c.useState(null),[m,v]=c.useState(null),[T,k]=c.useState(!1),[E,R]=c.useState(!1),M=c.useRef(null);c.useEffect(()=>()=>{m==null||m.close()},[m]),c.useEffect(()=>{if(!a)return;const t=window.setInterval(()=>P(f=>f+1),1e3);return()=>window.clearInterval(t)},[a]);const l=c.useMemo(()=>n.reduce((t,f)=>!t||f.detection_rate>t.detection_rate?f:t,null),[n]),O=n.length?n.reduce((t,f)=>t+f.detection_rate,0)/n.length:0,B=r.total>0?Math.min(100,Math.round(r.current/r.total*100)):0,A=h?Math.max(0,Math.floor((Date.now()-h)/1e3)):0,F=c.useMemo(()=>[...n].sort((t,f)=>f.detection_rate-t.detection_rate),[n]),L=t=>{t.message&&x(t.message),t.test_ranges&&p(me(t.test_ranges)),t.type==="progress"&&d({current:t.current??0,total:t.total??0}),t.type==="result"&&t.det_peak!==void 0&&t.det_min!==void 0&&t.detection_rate!==void 0&&j(f=>[...f,{det_peak:t.det_peak,det_min:t.det_min,detection_rate:t.detection_rate,detections:t.detections,samples:t.samples}]),(t.type==="complete"||t.type==="completed")&&(o(!1),m==null||m.close(),v(null)),t.type==="error"&&(g(t.message||"Calibration failed"),o(!1))},U=async()=>{g(null),j([]),d({current:0,total:0}),p(null),y(Date.now()),x("Starting calibration…");try{const t=await le({samples:10,delay:50});if(t.success===!1)throw new Error(t.error||"Backend rejected calibration start");m==null||m.close(),v(de(L,()=>g("CAD calibration stream disconnected."))),o(!0)}catch(t){g(t instanceof Error?t.message:"CAD calibration endpoint unavailable"),x("Unable to start calibration")}},z=async()=>{await oe().catch(()=>{}),m==null||m.close(),v(null),o(!1),x("Calibration stopped")},H=async()=>{if(l)try{const t=await ce({peak:l.det_peak,min_val:l.det_min,detection_rate:l.detection_rate});if(t.success===!1)throw new Error(t.error||"Save failed");x("CAD settings saved. Restart the Repeater service for them to take effect."),k(!0)}catch(t){g(t instanceof Error?t.message:"Failed to save CAD settings")}},q=async()=>{R(!0);try{await ee(),x("Restart requested. The UI will reconnect after the service comes back."),k(!1)}catch(t){g(t instanceof Error?t.message:"Failed to request service restart")}finally{R(!1)}};return e.jsxs(Q,{children:[e.jsx(Y,{title:"CAD Calibration Tool",icon:e.jsx(te,{}),subtitle:e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Default-UI style Channel Activity Detection calibration with live threshold heatmap and restart prompt."})}),e.jsxs(Z,{ready:!0,children:[e.jsx(_,{template:"auto",children:e.jsxs(u,{neomorphic:!0,children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"type-body text-fg-primary",children:i}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:s?`SF${s.spreading_factor??"auto"} · Peak ${N(s.peak_min,s.peak_max)} · Min ${N(s.min_min,s.min_max)}`:"Awaiting calibration…"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(b,{color:"success",onClick:U,disabled:a,children:[e.jsx(W,{"data-slot":"icon"}),"Start Calibration"]}),e.jsxs(b,{color:"danger",outline:!0,onClick:z,disabled:!a,children:[e.jsx(ne,{"data-slot":"icon"}),"Stop"]}),e.jsxs(b,{color:"primary",outline:!0,onClick:H,disabled:!l,children:[e.jsx(se,{"data-slot":"icon"}),"Save Settings"]}),e.jsxs(b,{color:"muted",outline:!0,onClick:()=>pe(M.current),disabled:n.length===0,children:[e.jsx(X,{"data-slot":"icon"}),"Export SVG"]})]})]}),e.jsx("div",{className:"mt-4 h-2 rounded-full bg-subtle-fill overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${B}%`,background:"linear-gradient(90deg, var(--sys-blue), var(--sys-green))"}})}),e.jsxs("p",{className:"mt-2 type-data-xs text-fg-muted",children:[r.current," / ",r.total||"—"," tests completed"]})]})}),w&&e.jsx(_,{template:"auto",children:e.jsx(u,{neomorphic:!0,className:"text-sys-red",children:w})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-4",children:[e.jsxs(u,{compact:!0,className:"min-h-0 p-3",children:[e.jsx("p",{className:"type-data-xs text-fg-muted",children:"Tests Completed"}),e.jsx("p",{className:"mt-1 text-sm font-semibold leading-tight text-fg-primary",children:n.length})]}),e.jsxs(u,{compact:!0,className:"min-h-0 p-3",children:[e.jsx("p",{className:"type-data-xs text-fg-muted",children:"Best Detection Rate"}),e.jsx("p",{className:"mt-1 text-sm font-semibold leading-tight text-fg-primary",children:l?`${l.detection_rate.toFixed(1)}%`:"n/a"})]}),e.jsxs(u,{compact:!0,className:"min-h-0 p-3",children:[e.jsx("p",{className:"type-data-xs text-fg-muted",children:"Average Rate"}),e.jsx("p",{className:"mt-1 text-sm font-semibold leading-tight text-fg-primary",children:n.length?`${O.toFixed(1)}%`:"n/a"})]}),e.jsxs(u,{compact:!0,className:"min-h-0 p-3",children:[e.jsx("p",{className:"type-data-xs text-fg-muted",children:"Elapsed Time"}),e.jsxs("p",{className:"mt-1 text-sm font-semibold leading-tight text-fg-primary",children:[A,"s"]})]})]}),e.jsxs(_,{template:"auto",children:[e.jsx(D,{span:"full",lg:8,children:e.jsxs(u,{neomorphic:!0,className:"space-y-4",children:[e.jsx(C,{icon:e.jsx(ae,{}),title:"CAD Detection Rate Heatmap",actions:l&&e.jsxs("span",{className:"rounded-full border border-sys-green/30 bg-sys-green/10 px-3 py-1 type-data-xs text-sys-green",children:["Best P",l.det_peak,"/M",l.det_min," · ",l.detection_rate.toFixed(1),"%"]})}),e.jsx(he,{results:n,best:l,rangeInfo:s,svgRef:M})]})}),e.jsx(D,{span:"full",lg:4,children:e.jsxs(u,{neomorphic:!0,className:"space-y-5",children:[e.jsx(C,{icon:e.jsx($,{}),title:"Calibration Result"}),l?e.jsxs("div",{className:"rounded-2xl bg-sys-green/10 ring-1 ring-inset ring-sys-green/30 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sys-green type-label",children:[e.jsx($,{className:"size-4"}),"Recommended Thresholds"]}),e.jsxs("p",{className:"mt-2 type-heading text-fg-primary tabular-nums",children:["Peak ",l.det_peak," · Min ",l.det_min]}),e.jsxs("p",{className:"type-body-sm text-fg-muted",children:[l.detections??"n/a"," / ",l.samples??"n/a"," detections at ",l.detection_rate.toFixed(1),"%."]})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"No optimal settings yet. Start calibration to collect results."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"rounded-xl bg-subtle-fill p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-fg-muted type-data-xs",children:[e.jsx(K,{className:"size-3.5"}),"SF"]}),e.jsx("p",{className:"type-heading text-fg-primary",children:(s==null?void 0:s.spreading_factor)??"auto"})]}),e.jsxs("div",{className:"rounded-xl bg-subtle-fill p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-fg-muted type-data-xs",children:[e.jsx(re,{className:"size-3.5"}),"Elapsed"]}),e.jsxs("p",{className:"type-heading text-fg-primary",children:[A,"s"]})]}),e.jsxs("div",{className:"rounded-xl bg-subtle-fill p-3",children:[e.jsx("p",{className:"type-data-xs text-fg-muted",children:"Peak range"}),e.jsx("p",{className:"type-body-sm text-fg-primary tabular-nums",children:N(s==null?void 0:s.peak_min,s==null?void 0:s.peak_max)})]}),e.jsxs("div",{className:"rounded-xl bg-subtle-fill p-3",children:[e.jsx("p",{className:"type-data-xs text-fg-muted",children:"Min range"}),e.jsx("p",{className:"type-body-sm text-fg-primary tabular-nums",children:N(s==null?void 0:s.min_min,s==null?void 0:s.min_max)})]})]})]})})]}),e.jsx(_,{template:"auto",children:e.jsxs(u,{neomorphic:!0,children:[e.jsx(C,{title:"Raw Results"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-fg-muted",children:[e.jsx("th",{className:"p-2 text-left",children:"Peak"}),e.jsx("th",{className:"p-2 text-left",children:"Min"}),e.jsx("th",{className:"p-2 text-left",children:"Detection Rate"}),e.jsx("th",{className:"p-2 text-left",children:"Detections"})]})}),e.jsxs("tbody",{children:[F.map((t,f)=>e.jsxs("tr",{className:"border-t border-edge-subtle",children:[e.jsx("td",{className:"p-2",children:t.det_peak}),e.jsx("td",{className:"p-2",children:t.det_min}),e.jsxs("td",{className:"p-2",children:[t.detection_rate.toFixed(1),"%"]}),e.jsxs("td",{className:"p-2",children:[t.detections??"n/a"," / ",t.samples??"n/a"]})]},`${t.det_peak}-${t.det_min}-${f}`)),n.length===0&&e.jsx("tr",{children:e.jsx("td",{className:"p-3 text-fg-muted",colSpan:4,children:"No calibration samples yet."})})]})]})})]})})]}),e.jsx(I,{isOpen:T,title:"CAD Calibration Saved: Restart Required",message:"In order for the CAD Calibration settings to take effect and the noise floor to return to normal, the openHop Repeater service needs to be restarted.",confirmLabel:E?"Restarting…":"Restart Service",cancelLabel:"Later",variant:"warning",onConfirm:q,onCancel:()=>k(!1)})]})}export{Se as default}; diff --git a/frontend/dist/assets/ChatBubble-CL_NnCFm.js b/frontend/dist/assets/ChatBubble-CL_NnCFm.js new file mode 100644 index 00000000..2569eb08 --- /dev/null +++ b/frontend/dist/assets/ChatBubble-CL_NnCFm.js @@ -0,0 +1 @@ +import{r as M,j as e,c as s,z as W}from"./index-Ch85h29t.js";import{e as E,g as S,a as V,c as F,f as b,b as y}from"./chat-utils-CSGjqJAH.js";const v=["","text-[42px]","text-[36px]","text-[30px]"],z=M.memo(function({senderName:x,text:n,timestamp:d,nameAccessory:N,bubbleAccessory:c,className:o,isOutgoing:w,status:t,onRetry:m,onRetryAsFlood:h,retryAttempt:p,maxRetries:l,signed:k,echoCount:r,bubbleVariant:I="accent",onMentionClick:f}){const u=W(),{emoji:j,cleanName:g}=E(x),C=S(g),B=V(x),a=F(n);return w?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:b(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:y(d,u)})]})]}):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",j?"text-lg":"text-white text-[13px] font-bold tracking-tight"),style:{"--avatar-color":C},children:j||B}),e.jsx("span",{className:"text-xs text-chat-timestamp tabular-nums h-4 leading-4",children:y(d,u)})]}),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:g}),k&&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"})]}),N]}),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:b(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{z as C,T as S}; diff --git a/frontend/dist/assets/ChatBubble-Cto97fJB.js b/frontend/dist/assets/ChatBubble-Cto97fJB.js deleted file mode 100644 index 7728d94c..00000000 --- a/frontend/dist/assets/ChatBubble-Cto97fJB.js +++ /dev/null @@ -1 +0,0 @@ -import{r as B,j as e,c as s}from"./index-BdFZD4tW.js";import{e as M,g as W,a as E,c as S,f as g,b}from"./chat-utils-cUFDkDW9.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-BPdmq3zY.js b/frontend/dist/assets/CollisionExplorerModal-BPdmq3zY.js new file mode 100644 index 00000000..9f6f7c3b --- /dev/null +++ b/frontend/dist/assets/CollisionExplorerModal-BPdmq3zY.js @@ -0,0 +1 @@ +import{r as c,ad as L,cm as S,ag as H,j as e,aB as k,b_ as R,aC as B,d4 as E,c3 as T,c as N,at as P,a2 as M,aa as _,a7 as D,a8 as z,cy as I}from"./index-Ch85h29t.js";import{M as W,B as F,a as q}from"./BasemapLayer-DEvncc0Q.js";import{S as A,L as U}from"./layer-Xsjnvj9G.js";import{M as Y}from"./map-pin-c0Hi1adb.js";import{S as $}from"./share-2-xeKwph2s.js";import{M as G}from"./monitor-smartphone-CTx9MPdz.js";const J={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),b=c.useCallback(async d=>{d.stopPropagation(),await _(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=$,r="text-sys-blue";return m?(n=I,r="text-signal-fair"):l?(n=G,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:b,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(D,{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),b=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]),y=b&&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",y?"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",y?"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:J,attributionControl:!1,onLoad:j,children:[e.jsx(F,{mode:g}),d&&e.jsx(A,{id:"collision-edges",type:"geojson",data:d,children:e.jsx(U,{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=P(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 Q({isOpen:o,prefix:v,candidateHashes:f,onClose:g}){const p=L(),b=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:b.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,b]),j=c.useMemo(()=>d.some(s=>s.latitude!=null&&s.longitude!=null&&(s.latitude!==0||s.longitude!==0)),[d]),y=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:y})}),e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(w,{node:s,isHovered:m===s.hash,onHover:y},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:y},s.hash))})}),e.jsx("div",{className:"overflow-hidden p-2",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:y})})]}):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:y},s.hash))})})]})]}):null}const se=c.memo(Q);export{se as C}; diff --git a/frontend/dist/assets/CollisionExplorerModal-CXE65Kgs.js b/frontend/dist/assets/CollisionExplorerModal-CXE65Kgs.js deleted file mode 100644 index 72d11b98..00000000 --- a/frontend/dist/assets/CollisionExplorerModal-CXE65Kgs.js +++ /dev/null @@ -1 +0,0 @@ -import{r as c,aa as L,ch as S,ad as H,j as e,ax as k,bV as R,ay as B,cW as E,b_ as T,c as N,aq as P,$ as M,a7 as _,a4 as D,a5 as z,cs as I}from"./index-BdFZD4tW.js";import{M as W,B as q,a as F}from"./BasemapLayer-BQjI_o60.js";import{S as $,L as A}from"./layer-Cmi1sSNL.js";import{M as U}from"./map-pin-tb6dvUSl.js";import{S as V}from"./share-2-KLAGGeDO.js";import{M as Y}from"./monitor-smartphone-B-al2jiR.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 _(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=Y,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(D,{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(W,{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(q,{mode:g}),d&&e.jsx($,{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=P(a.hash);return e.jsx(F,{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 se=c.memo(J);export{se as C}; diff --git a/frontend/dist/assets/Companion--88Y1QxY.js b/frontend/dist/assets/Companion--88Y1QxY.js deleted file mode 100644 index 492fa2ba..00000000 --- a/frontend/dist/assets/Companion--88Y1QxY.js +++ /dev/null @@ -1,81 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CompanionPathMap-BXnFAxbT.js","assets/index-BdFZD4tW.js","assets/BasemapLayer-BQjI_o60.js","assets/layer-Cmi1sSNL.js","assets/usePipelineStore-BbC5u-iu.js","assets/node-types-BqQm1p4f.js","assets/useReplayTick-XUa2wZbr.js","assets/payload-detail--84fg8Ib.js","assets/car-a6j4OITc.js","assets/map-pin-off-pPPXHu6z.js","assets/monitor-smartphone-B-al2jiR.js","assets/index-GZXSFQwe.css","assets/BasemapLayer-B1CfjdFi.css","assets/CompanionEchoMap-CwrYV0II.js"])))=>i.map(i=>d[i]); -import{aU as qa,fv as ws,aW as mn,aX as Va,aV as Pt,aY as pn,r as l,aZ as Ja,a_ as xe,b1 as Se,aQ as Z,b5 as Q,b2 as pe,bf as Qa,b6 as _t,ba as Tt,bb as $t,bg as Xa,bc as Ie,bd as ut,bh as Ya,be as he,bi as ks,bj as Za,bk as er,bl as ot,bm as tr,bn as sr,bo as nr,aT as at,b3 as ar,fx as rr,d7 as Fe,fz as xn,bq as lr,br as ne,bs as ir,bz as or,dk as cr,dl as dr,bB as ur,fA as mr,bp as Oe,bA as mt,bu as pr,fB as At,bD as Cs,fC as pt,a$ as Ye,bw as hn,bx as xr,by as hr,d5 as Ss,d8 as Is,fw as fr,bC as gr,b0 as yr,b8 as br,b9 as vr,bt as fn,d3 as gn,e as ae,j as e,c as M,a4 as be,fD as jr,w as Nr,cU as re,cs as xt,R as Ge,bJ as ht,eY as _e,eZ as Re,e_ as Me,d as ge,fE as wr,fF as kr,fG as se,m as le,fH as Cr,cO as Ke,ax as we,aG as Ee,az as qe,ay as ke,a6 as ce,bV as Ve,eD as Pe,B as U,fI as yn,fJ as ft,au as Sr,W as Ir,fK as _s,_ as bn,c9 as _r,$ as De,fL as Ft,fM as Rr,dD as Mr,fN as Ot,fO as Er,fP as Pr,bF as Rt,fQ as Tr,fR as $r,fS as Ar,c$ as Fr,a5 as Dt,ec as Or,fT as Dr,fU as Lr,fV as vn,fW as zr,ab as Hr,fX as Br,fY as jn,fk as Wr,fZ as Ur,f_ as Gr,I as me,C as Rs,f$ as Nn,g0 as Kr,g1 as qr,g2 as Vr,g3 as Jr,g4 as Qr,g5 as Xr,g6 as Yr,g7 as Zr,g8 as el,g9 as tl,aa as sl,ga as nl,gb as al,gc as rl,gd as ll,ge as il,gf as ol,gg as cl,gh as dl,gi as ul,gj as ml,gk as pl,gl as xl,ey as hl}from"./index-BdFZD4tW.js";import{P as Ms,a as Es,B as Ps,C as Ts}from"./PageLayout-CIUNh3-q.js";import{e as gt,g as yt,a as bt,f as fl,b as gl}from"./chat-utils-cUFDkDW9.js";import{c as $s,S as yl,a as bl}from"./SignalIndicator-CxssCk5q.js";import{b as vl,F as jl,y as Nl,R as wl,T as kl,w as Cl,A as Sl}from"./floating-CZl1NkX5.js";import{p as Il,a as rt,c as X,f as st,b as _l,L as Rl,S as nt,s as Ml,u as El,d as Pl}from"./element-movement-BoSGi6nG.js";import{s as Tl}from"./use-text-value-DuhO7-HX.js";import{F as $l}from"./use-tree-walker-BovUPEpi.js";import{a as lt}from"./index-BmiOWPPt.js";import{M as ye}from"./monitor-smartphone-B-al2jiR.js";import{S as As}from"./search-83w2lV8z.js";import{S as Al}from"./share-2-KLAGGeDO.js";import{R as Je,L as Fl}from"./route-CfTN_kyx.js";import{R as wn}from"./rotate-ccw-3--rrl0z.js";import{T as Qe}from"./trash-2-B1G94Z60.js";import{H as Le}from"./hash-ErPI6vfz.js";import{C as Ol}from"./check-check-pAz6zpcW.js";import{P as Xe}from"./plus-J10T9_Ph.js";import{S as Dl,C as Ll}from"./ChatBubble-Cto97fJB.js";import{p as zl}from"./payload-detail--84fg8Ib.js";import{A as Hl}from"./arrow-down-D3Og9nmH.js";import{C as Bl}from"./WorkspaceNav-DR8N-VVk.js";import{C as kn}from"./circle-alert-ChQ9pkTw.js";import{f as Wl,c as Ul,a as Gl,M as Kl}from"./variants-FYWzMom7.js";import{M as Cn}from"./map-pin-tb6dvUSl.js";import{C as Sn}from"./clock-B5Mz4CYE.js";import{A as In}from"./activity-BkgN42Nd.js";import{T as _n}from"./thermometer-BVVRGJpK.js";import{U as Lt}from"./upload-DqygZ61q.js";import{S as ql}from"./shield-check-DqZm2nm3.js";import{W as Fs}from"./wand-sparkles-DJklHh-3.js";import{S as Vl}from"./save-CUUX0zl8.js";import{C as Jl}from"./compass-BgtU0bsV.js";import{G as Os}from"./git-branch-CjkWLr6F.js";import{F as ie,L as oe,D as Ce}from"./fieldset-aUG70RJO.js";import{C as Rn}from"./ConfirmModal-N7ejcMF0.js";import{K as Mn}from"./key-round-Ca3f2GE6.js";import{F as En}from"./folder-lock-zGoUhhVc.js";import{P as Ql}from"./pencil-CsCVD6uI.js";var Xl=Object.defineProperty,Yl=(s,t,n)=>t in s?Xl(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n,Ds=(s,t,n)=>(Yl(s,typeof t!="symbol"?t+"":t,n),n),te=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(te||{}),ct=(s=>(s[s.Pointer=0]="Pointer",s[s.Other=1]="Other",s))(ct||{}),K=(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))(K||{});function Ls(s,t=n=>n){let n=s.activeItemIndex!==null?s.items[s.activeItemIndex]:null,a=pn(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 Zl={1(s){if(s.menuState===1)return s;let t=s.buttonElement?rt.Tracked(_l(s.buttonElement)):s.buttonPositionState;return{...s,activeItemIndex:null,pendingFocus:{focus:X.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===X.Nothing)return{...u,activeItemIndex:null};if(t.focus===X.Specific)return{...u,activeItemIndex:s.items.findIndex(d=>d.id===t.id)};if(t.focus===X.Previous){let d=s.activeItemIndex;if(d!==null){let x=s.items[d].dataRef.current.domRef,f=st(t,{resolveItems:()=>s.items,resolveActiveIndex:()=>s.activeItemIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(f!==null){let h=s.items[f].dataRef.current.domRef;if(((a=x.current)==null?void 0:a.previousElementSibling)===h.current||((r=h.current)==null?void 0:r.previousElementSibling)===null)return{...u,activeItemIndex:f}}}}else if(t.focus===X.Next){let d=s.activeItemIndex;if(d!==null){let x=s.items[d].dataRef.current.domRef,f=st(t,{resolveItems:()=>s.items,resolveActiveIndex:()=>s.activeItemIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(f!==null){let h=s.items[f].dataRef.current.domRef;if(((i=x.current)==null?void 0:i.nextElementSibling)===h.current||((o=h.current)==null?void 0:o.nextElementSibling)===null)return{...u,activeItemIndex:f}}}}let c=Ls(s),g=st(t,{resolveItems:()=>c.items,resolveActiveIndex:()=>c.activeItemIndex,resolveId:d=>d.id,resolveDisabled:d=>d.dataRef.current.disabled});return{...u,...c,activeItemIndex:g}},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!==X.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:X.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,...Ls(s),pendingShouldSort:!1}:s,10(s){return s.buttonPositionState.kind!=="Tracked"?s:{...s,buttonPositionState:rt.Moved}}};class zt extends qa{constructor(t){super(t),Ds(this,"actions",{registerItem:ws(()=>{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:ws(()=>{let n=[];return[a=>n.push(a),()=>this.send({type:6,items:n.splice(0)})]})}),Ds(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=mn.get(null);this.disposables.add(a.on(Va.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(Il(a.buttonElement,a.buttonPositionState,()=>{this.send({type:10})})))})})}static new({id:t,__demoMode:n=!1}){return new zt({id:t,__demoMode:n,menuState:n?0:1,buttonElement:null,itemsElement:null,items:[],searchQuery:"",activeItemIndex:null,activationTrigger:1,pendingShouldSort:!1,pendingFocus:{focus:X.Nothing},buttonPositionState:rt.Idle})}reduce(t,n){return Pt(n.type,Zl,t,n)}}const Pn=l.createContext(null);function Ht(s){let t=l.useContext(Pn);if(t===null){let n=new Error(`<${s} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Tn),n}return t}function Tn({id:s,__demoMode:t=!1}){let n=l.useMemo(()=>zt.new({id:s,__demoMode:t}),[]);return Ja(()=>n.dispose()),n}let ei=l.Fragment;function ti(s,t){let n=l.useId(),{__demoMode:a=!1,...r}=s,i=Tn({id:n,__demoMode:a}),[o,u,c]=pe(i,w=>[w.menuState,w.itemsElement,w.buttonElement]),g=Se(t),d=mn.get(null),x=pe(d,l.useCallback(w=>d.selectors.isTop(w,n),[d,n]));or(x,[c,u],(w,y)=>{var E;i.send({type:K.CloseMenu}),cr(y,dr.Loose)||(w.preventDefault(),(E=i.state.buttonElement)==null||E.focus())});let f=Z(()=>{i.send({type:K.CloseMenu})}),h=Ie({open:o===te.Open,close:f}),m={ref:g},j=he();return ne.createElement(Sl,null,ne.createElement(Pn.Provider,{value:i},ne.createElement(ur,{value:Pt(o,{[te.Open]:ot.Open,[te.Closed]:ot.Closed})},j({ourProps:m,theirProps:r,slot:h,defaultTag:ei,name:"Menu"}))))}let si="button";function ni(s,t){let n=Ht("Menu.Button"),a=l.useId(),{id:r=`headlessui-menu-button-${a}`,disabled:i=!1,autoFocus:o=!1,...u}=s,c=l.useRef(null),g=vl(),d=Se(t,c,jl(),Z(b=>n.send({type:K.SetButtonElement,element:b}))),x=Z(b=>{switch(b.key){case Q.Space:case Q.Enter:case Q.ArrowDown:b.preventDefault(),b.stopPropagation(),n.send({type:K.OpenMenu,focus:{focus:X.First}});break;case Q.ArrowUp:b.preventDefault(),b.stopPropagation(),n.send({type:K.OpenMenu,focus:{focus:X.Last}});break}}),f=Z(b=>{switch(b.key){case Q.Space:b.preventDefault();break}}),[h,m,j]=pe(n,b=>[b.menuState,b.buttonElement,b.itemsElement]),w=h===te.Open;Rl(w,{trigger:m,action:l.useCallback(b=>{if(m!=null&&m.contains(b.target))return nt.Ignore;let S=b.target.closest('[role="menuitem"]:not([data-disabled])');return Qa(S)?nt.Select(S):j!=null&&j.contains(b.target)?nt.Ignore:nt.Close},[m,j]),close:l.useCallback(()=>n.send({type:K.CloseMenu}),[]),select:l.useCallback(b=>b.click(),[])});let y=Ml(b=>{var S;i||(h===te.Open?(_t.flushSync(()=>n.send({type:K.CloseMenu})),(S=c.current)==null||S.focus({preventScroll:!0})):(b.preventDefault(),n.send({type:K.OpenMenu,focus:{focus:X.Nothing},trigger:ct.Pointer})))}),{isFocusVisible:E,focusProps:I}=Tt({autoFocus:o}),{isHovered:R,hoverProps:v}=$t({isDisabled:i}),{pressed:_,pressProps:$}=Xa({disabled:i}),k=Ie({open:h===te.Open,active:_||h===te.Open,disabled:i,hover:R,focus:E,autofocus:o}),p=ut(g(),{ref:d,id:r,type:Ya(s,c.current),"aria-haspopup":"menu","aria-controls":j==null?void 0:j.id,"aria-expanded":h===te.Open,disabled:i||void 0,autoFocus:o,onKeyDown:x,onKeyUp:f},y,I,v,$);return he()({ourProps:p,theirProps:u,slot:k,defaultTag:si,name:"Menu.Button"})}let ai="div",ri=Cs.RenderStrategy|Cs.Static;function li(s,t){let n=l.useId(),{id:a=`headlessui-menu-items-${n}`,anchor:r,portal:i=!1,modal:o=!0,transition:u=!1,...c}=s,g=Nl(r),d=Ht("Menu.Items"),[x,f]=wl(g),h=kl(),[m,j]=l.useState(null),w=Se(t,g?x:null,Z(O=>d.send({type:K.SetItemsElement,element:O})),j),[y,E]=pe(d,O=>[O.menuState,O.buttonElement]),I=ks(E),R=ks(m);g&&(i=!0);let v=Za(),[_,$]=er(u,m,v!==null?(v&ot.Open)===ot.Open:y===te.Open);tr(_,E,()=>{d.send({type:K.CloseMenu})});let k=pe(d,O=>O.__demoMode),p=k?!1:o&&y===te.Open;sr(p,R);let b=k?!1:o&&y===te.Open;nr(b,{allowed:l.useCallback(()=>[E,m],[E,m])});let S=pe(d,d.selectors.didButtonMove)?!1:_;l.useEffect(()=>{let O=m;O&&y===te.Open&&(at(O)||O.focus({preventScroll:!0}))},[y,m]),$l(y===te.Open,{container:m,accept(O){return O.getAttribute("role")==="menuitem"?NodeFilter.FILTER_REJECT:O.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(O){O.setAttribute("role","none")}});let N=ar(),F=Z(O=>{var G,H,A;switch(N.dispose(),O.key){case Q.Space:if(d.state.searchQuery!=="")return O.preventDefault(),O.stopPropagation(),d.send({type:K.Search,value:O.key});case Q.Enter:if(O.preventDefault(),O.stopPropagation(),d.state.activeItemIndex!==null){let{dataRef:D}=d.state.items[d.state.activeItemIndex];(H=(G=D.current)==null?void 0:G.domRef.current)==null||H.click()}d.send({type:K.CloseMenu}),xn(d.state.buttonElement);break;case Q.ArrowDown:return O.preventDefault(),O.stopPropagation(),d.send({type:K.GoToItem,focus:X.Next});case Q.ArrowUp:return O.preventDefault(),O.stopPropagation(),d.send({type:K.GoToItem,focus:X.Previous});case Q.Home:case Q.PageUp:return O.preventDefault(),O.stopPropagation(),d.send({type:K.GoToItem,focus:X.First});case Q.End:case Q.PageDown:return O.preventDefault(),O.stopPropagation(),d.send({type:K.GoToItem,focus:X.Last});case Q.Escape:O.preventDefault(),O.stopPropagation(),_t.flushSync(()=>d.send({type:K.CloseMenu})),(A=d.state.buttonElement)==null||A.focus({preventScroll:!0});break;case Q.Tab:O.preventDefault(),O.stopPropagation(),_t.flushSync(()=>d.send({type:K.CloseMenu})),rr(d.state.buttonElement,O.shiftKey?Fe.Previous:Fe.Next);break;default:O.key.length===1&&(d.send({type:K.Search,value:O.key}),N.setTimeout(()=>d.send({type:K.ClearSearch}),350));break}}),C=Z(O=>{switch(O.key){case Q.Space:O.preventDefault();break}}),L=Ie({open:y===te.Open}),q=ut(g?h():{},{"aria-activedescendant":pe(d,d.selectors.activeDescendantId),"aria-labelledby":pe(d,O=>{var G;return(G=O.buttonElement)==null?void 0:G.id}),id:a,onKeyDown:F,onKeyUp:C,role:"menu",tabIndex:y===te.Open?0:void 0,ref:w,style:{...c.style,...f,"--button-width":Cl(_,E,!0).width},...lr($)}),T=he();return ne.createElement(ir,{enabled:i?s.static||_:!1,ownerDocument:I},T({ourProps:q,theirProps:c,slot:L,defaultTag:ai,features:ri,visible:S,name:"Menu.Items"}))}let ii=l.Fragment;function oi(s,t){let n=l.useId(),{id:a=`headlessui-menu-item-${n}`,disabled:r=!1,...i}=s,o=Ht("Menu.Item"),u=pe(o,S=>o.selectors.isActive(S,a)),c=l.useRef(null),g=Se(t,c),d=pe(o,S=>o.selectors.shouldScrollIntoView(S,a));Oe(()=>{if(d)return pr().requestAnimationFrame(()=>{var S,N;(N=(S=c.current)==null?void 0:S.scrollIntoView)==null||N.call(S,{block:"nearest"})})},[d,c]);let x=Tl(c),f=l.useRef({disabled:r,domRef:c,get textValue(){return x()}});Oe(()=>{f.current.disabled=r},[f,r]),Oe(()=>(o.actions.registerItem(a,f),()=>o.actions.unregisterItem(a)),[f,a]);let h=Z(()=>{o.send({type:K.CloseMenu})}),m=Z(S=>{if(r)return S.preventDefault();o.send({type:K.CloseMenu}),xn(o.state.buttonElement)}),j=Z(()=>{if(r)return o.send({type:K.GoToItem,focus:X.Nothing});o.send({type:K.GoToItem,focus:X.Specific,id:a})}),w=El(),y=Z(S=>w.update(S)),E=Z(S=>{w.wasMoved(S)&&(r||u||o.send({type:K.GoToItem,focus:X.Specific,id:a,trigger:ct.Pointer}))}),I=Z(S=>{w.wasMoved(S)&&(r||u&&o.state.activationTrigger===ct.Pointer&&o.send({type:K.GoToItem,focus:X.Nothing}))}),[R,v]=mt(),[_,$]=At(),k=Ie({active:u,focus:u,disabled:r,close:h}),p={id:a,ref:g,role:"menuitem",tabIndex:r===!0?void 0:-1,"aria-disabled":r===!0?!0:void 0,"aria-labelledby":R,"aria-describedby":_,disabled:void 0,onClick:m,onFocus:j,onPointerEnter:y,onMouseEnter:y,onPointerMove:E,onMouseMove:E,onPointerLeave:I,onMouseLeave:I},b=he();return ne.createElement(v,null,ne.createElement($,null,b({ourProps:p,theirProps:i,slot:k,defaultTag:ii,name:"Menu.Item"})))}let ci="div";function di(s,t){let[n,a]=mt(),r=s,i={ref:t,"aria-labelledby":n,role:"group"},o=he();return ne.createElement(a,null,o({ourProps:i,theirProps:r,slot:{},defaultTag:ci,name:"Menu.Section"}))}let ui="header";function mi(s,t){let n=l.useId(),{id:a=`headlessui-menu-heading-${n}`,...r}=s,i=mr();Oe(()=>i.register(a),[a,i.register]);let o={id:a,ref:t,role:"presentation",...i.props};return he()({ourProps:o,theirProps:r,slot:{},defaultTag:ui,name:"Menu.Heading"})}let pi="div";function xi(s,t){let n=s,a={ref:t,role:"separator"};return he()({ourProps:a,theirProps:n,slot:{},defaultTag:pi,name:"Menu.Separator"})}let hi=xe(ti),$n=xe(ni),An=xe(li),Mt=xe(oi),fi=xe(di),gi=xe(mi),Fn=xe(xi),yi=Object.assign(hi,{Button:$n,Items:An,Item:Mt,Section:fi,Heading:gi,Separator:Fn});var bi=(s=>(s[s.RegisterOption=0]="RegisterOption",s[s.UnregisterOption=1]="UnregisterOption",s))(bi||{});let vi={0(s,t){let n=[...s.options,{id:t.id,element:t.element,propsRef:t.propsRef}];return{...s,options:pn(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})}},Bt=l.createContext(null);Bt.displayName="RadioGroupDataContext";function Wt(s){let t=l.useContext(Bt);if(t===null){let n=new Error(`<${s} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Wt),n}return t}let Ut=l.createContext(null);Ut.displayName="RadioGroupActionsContext";function Gt(s){let t=l.useContext(Ut);if(t===null){let n=new Error(`<${s} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Gt),n}return t}function ji(s,t){return Pt(t.type,vi,s,t)}let Ni="div";function wi(s,t){let n=l.useId(),a=hn(),{id:r=`headlessui-radiogroup-${n}`,value:i,form:o,name:u,onChange:c,by:g,disabled:d=a||!1,defaultValue:x,tabIndex:f=0,...h}=s,m=Pl(g),[j,w]=l.useReducer(ji,{options:[]}),y=j.options,[E,I]=mt(),[R,v]=At(),_=l.useRef(null),$=Se(_,t),k=xr(x),[p,b]=hr(i,c,k),S=l.useMemo(()=>y.find(D=>!D.propsRef.current.disabled),[y]),N=l.useMemo(()=>y.some(D=>m(D.propsRef.current.value,p)),[y,p]),F=Z(D=>{var z;if(d||m(D,p))return!1;let W=(z=y.find(J=>m(J.propsRef.current.value,D)))==null?void 0:z.propsRef.current;return W!=null&&W.disabled?!1:(b==null||b(D),!0)}),C=Z(D=>{if(!_.current)return;let z=y.filter(W=>W.propsRef.current.disabled===!1).map(W=>W.element.current);switch(D.key){case Q.Enter:fr(D.currentTarget);break;case Q.ArrowLeft:case Q.ArrowUp:if(D.preventDefault(),D.stopPropagation(),Ss(z,Fe.Previous|Fe.WrapAround)===Is.Success){let W=y.find(J=>at(J.element.current));W&&F(W.propsRef.current.value)}break;case Q.ArrowRight:case Q.ArrowDown:if(D.preventDefault(),D.stopPropagation(),Ss(z,Fe.Next|Fe.WrapAround)===Is.Success){let W=y.find(J=>at(J.element.current));W&&F(W.propsRef.current.value)}break;case Q.Space:{D.preventDefault(),D.stopPropagation();let W=y.find(J=>at(J.element.current));W&&F(W.propsRef.current.value)}break}}),L=Z(D=>(w({type:0,...D}),()=>w({type:1,id:D.id}))),q=l.useMemo(()=>({value:p,firstOption:S,containsCheckedOption:N,disabled:d,compare:m,tabIndex:f,...j}),[p,S,N,d,m,f,j]),T=l.useMemo(()=>({registerOption:L,change:F}),[L,F]),O={ref:$,id:r,role:"radiogroup","aria-labelledby":E,"aria-describedby":R,onKeyDown:C},G=Ie({value:p}),H=l.useCallback(()=>{if(k!==void 0)return F(k)},[F,k]),A=he();return ne.createElement(v,{name:"RadioGroup.Description"},ne.createElement(I,{name:"RadioGroup.Label"},ne.createElement(Ut.Provider,{value:T},ne.createElement(Bt.Provider,{value:q},u!=null&&ne.createElement(gr,{disabled:d,data:{[u]:p||"on"},overrides:{type:"radio",checked:p!=null},form:o,onReset:H}),A({ourProps:O,theirProps:h,slot:G,defaultTag:Ni,name:"RadioGroup"})))))}let ki="div";function Ci(s,t){var n;let a=Wt("RadioGroup.Option"),r=Gt("RadioGroup.Option"),i=l.useId(),{id:o=`headlessui-radiogroup-option-${i}`,value:u,disabled:c=a.disabled||!1,autoFocus:g=!1,...d}=s,x=l.useRef(null),f=Se(x,t),[h,m]=mt(),[j,w]=At(),y=fn({value:u,disabled:c});Oe(()=>r.registerOption({id:o,element:x,propsRef:y}),[o,r,x,y]);let E=Z(N=>{var F;if(gn(N.currentTarget))return N.preventDefault();r.change(u)&&((F=x.current)==null||F.focus())}),I=((n=a.firstOption)==null?void 0:n.id)===o,{isFocusVisible:R,focusProps:v}=Tt({autoFocus:g}),{isHovered:_,hoverProps:$}=$t({isDisabled:c}),k=a.compare(a.value,u),p=ut({ref:f,id:o,role:"radio","aria-checked":k?"true":"false","aria-labelledby":h,"aria-describedby":j,"aria-disabled":c?!0:void 0,tabIndex:c?-1:k||!a.containsCheckedOption&&I?a.tabIndex:-1,onClick:c?void 0:E,autoFocus:g},v,$),b=Ie({checked:k,disabled:c,active:R,hover:_,focus:R,autofocus:g}),S=he();return ne.createElement(w,{name:"RadioGroup.Description"},ne.createElement(m,{name:"RadioGroup.Label"},S({ourProps:p,theirProps:d,slot:b,defaultTag:ki,name:"RadioGroup.Option"})))}let Si="span";function Ii(s,t){var n;let a=Wt("Radio"),r=Gt("Radio"),i=l.useId(),o=yr(),u=hn(),{id:c=o||`headlessui-radio-${i}`,value:g,disabled:d=a.disabled||u||!1,autoFocus:x=!1,...f}=s,h=l.useRef(null),m=Se(h,t),j=br(),w=vr(),y=fn({value:g,disabled:d});Oe(()=>r.registerOption({id:c,element:h,propsRef:y}),[c,r,h,y]);let E=Z(S=>{var N;if(gn(S.currentTarget))return S.preventDefault();r.change(g)&&((N=h.current)==null||N.focus())}),{isFocusVisible:I,focusProps:R}=Tt({autoFocus:x}),{isHovered:v,hoverProps:_}=$t({isDisabled:d}),$=((n=a.firstOption)==null?void 0:n.id)===c,k=a.compare(a.value,g),p=ut({ref:m,id:c,role:"radio","aria-checked":k?"true":"false","aria-labelledby":j,"aria-describedby":w,"aria-disabled":d?!0:void 0,tabIndex:d?-1:k||!a.containsCheckedOption&&$?a.tabIndex:-1,autoFocus:x,onClick:d?void 0:E},R,_),b=Ie({checked:k,disabled:d,hover:v,focus:I,autofocus:x});return he()({ourProps:p,theirProps:f,slot:b,defaultTag:Si,name:"Radio"})}let _i=xe(wi),Ri=xe(Ci),vt=xe(Ii),Mi=Ye,Ei=pt,Pi=Object.assign(_i,{Option:Ri,Radio:vt,Label:Mi,Description:Ei});/** - * @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 Ti=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],$i=ae("arrow-left",Ti);/** - * @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 Ai=[["path",{d:"M13.67 8H18a2 2 0 0 1 2 2v4.33",key:"7az073"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}],["path",{d:"M8 8H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 1.414-.586",key:"s09a7a"}],["path",{d:"M9 13v2",key:"rq6x2g"}],["path",{d:"M9.67 4H12v2.33",key:"110xot"}]],Fi=ae("bot-off",Ai);/** - * @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 Oi=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],zs=ae("bot",Oi);/** - * @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 Di=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],On=ae("circle-dot",Di);/** - * @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 Li=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],zi=ae("crosshair",Li);/** - * @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 Hi=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Bi=ae("ellipsis-vertical",Hi);/** - * @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 Wi=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Ui=ae("key",Wi);/** - * @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 Gi=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],Et=ae("log-in",Gi);/** - * @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 Ki=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],qi=ae("panel-left-close",Ki);/** - * @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 Vi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Ji=ae("panel-left-open",Vi);/** - * @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 Qi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Hs=ae("panel-right-close",Qi);/** - * @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 Xi=[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]],Yi=ae("radar",Xi);/** - * @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 Zi=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],eo=ae("star",Zi);/** - * @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 to=[["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:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],so=ae("user-plus",to),Ze={sm:{radio:"h-4 w-4",dot:"h-1.5 w-1.5",text:"text-sm",descText:"text-xs",padding:"py-2 px-3",segmentPadding:"py-1.5 px-2.5"},md:{radio:"h-5 w-5",dot:"h-2 w-2",text:"text-sm",descText:"text-xs",padding:"py-3 px-4",segmentPadding:"py-2 px-3"},lg:{radio:"h-6 w-6",dot:"h-2.5 w-2.5",text:"text-base",descText:"text-sm",padding:"py-4 px-5",segmentPadding:"py-2.5 px-4"}};function Dn({checked:s,size:t,disabled:n}){const a=Ze[t];return e.jsx("span",{className:M("relative flex shrink-0 items-center justify-center rounded-full border-2 transition-all duration-150",a.radio,s?"border-sys-blue bg-sys-blue":"border-edge-subtle bg-subtle",!s&&!n&&"group-hover:border-edge-strong",n&&"opacity-50"),children:s&&e.jsx("span",{className:M(a.dot,"rounded-full bg-white")})})}function no({option:s,size:t}){const n=Ze[t];return e.jsx(vt,{value:s.value,disabled:s.disabled,className:"group flex items-start gap-3 cursor-pointer ring-focus rounded-lg",children:({checked:a,disabled:r})=>e.jsxs(e.Fragment,{children:[e.jsx(Dn,{checked:a,size:t,disabled:r}),e.jsxs("div",{className:"flex-1 min-w-0 select-none",children:[e.jsx(Ye,{className:M(n.text,"font-medium cursor-pointer",r?"text-fg-muted":"text-fg-primary"),children:s.label}),s.description&&e.jsx(pt,{className:M(n.descText,"text-fg-muted mt-0.5"),children:s.description})]})]})})}function ao({option:s,size:t}){const n=Ze[t];return e.jsx(vt,{value:s.value,disabled:s.disabled,className:M("group relative flex cursor-pointer ring-focus","radius-inset border-2 transition-all duration-150",n.padding),children:({checked:a,disabled:r})=>e.jsxs(e.Fragment,{children:[e.jsx("span",{className:M("absolute inset-0 radius-inset transition-colors",a?"border-sys-blue bg-sys-blue/5":"border-edge-subtle bg-subtle",!a&&!r&&"group-hover:border-edge-strong group-hover:bg-elevated",r&&"opacity-50"),style:{borderWidth:"inherit"}}),e.jsxs("div",{className:"relative flex items-start gap-3 w-full",children:[s.icon&&e.jsx("span",{className:M("shrink-0",a?"text-sys-blue":"text-fg-muted"),children:s.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Ye,{className:M(n.text,"font-medium cursor-pointer",r?"text-fg-muted":a?"text-sys-blue":"text-fg-primary"),children:s.label}),s.description&&e.jsx(pt,{className:M(n.descText,"text-fg-muted mt-0.5"),children:s.description})]}),e.jsx(Dn,{checked:a,size:t,disabled:r})]})]})})}function ro({option:s,size:t,isFirst:n,isLast:a}){const r=Ze[t];return e.jsx(vt,{value:s.value,disabled:s.disabled,className:M("group relative flex items-center justify-center cursor-pointer ring-focus","transition-all duration-150",r.segmentPadding,n&&"rounded-l-lg",a&&"rounded-r-lg"),children:({checked:i,disabled:o})=>e.jsxs(e.Fragment,{children:[e.jsx("span",{className:M("absolute inset-0 transition-colors",i?"bg-sys-blue":"bg-transparent",!i&&!o&&"group-hover:bg-subtle-fill",n&&"rounded-l-lg",a&&"rounded-r-lg",o&&"opacity-50")}),e.jsxs(Ye,{className:M("relative z-10 font-medium cursor-pointer select-none",r.text,i?"text-white":o?"text-fg-muted":"text-fg-primary"),children:[s.icon&&e.jsx("span",{className:"mr-1.5 inline-flex",children:s.icon}),s.label]})]})})}function lo({label:s,description:t,options:n,value:a,onChange:r,size:i="md",variant:o="simple",orientation:u="vertical",name:c,disabled:g,className:d}){const x=Ze[i];return e.jsxs(Pi,{value:a,onChange:r,name:c,disabled:g,className:M("space-y-3",d),children:[s&&e.jsx(Ye,{className:M(x.text,"font-medium text-fg-primary"),children:s}),t&&e.jsx(pt,{className:M(x.descText,"text-fg-muted -mt-1"),children:t}),o==="segmented"?e.jsx("div",{className:"inline-flex rounded-lg bg-subtle-fill-strong p-0.5",children:n.map((f,h)=>e.jsx(ro,{option:f,size:i,isFirst:h===0,isLast:h===n.length-1},f.value))}):e.jsx("div",{className:M(o==="card"&&u==="horizontal"&&"grid grid-cols-2 gap-3 sm:grid-cols-3",o==="card"&&u==="vertical"&&"space-y-3",o==="simple"&&u==="horizontal"&&"flex flex-wrap gap-4",o==="simple"&&u==="vertical"&&"space-y-2"),children:n.map(f=>o==="card"?e.jsx(ao,{option:f,size:i},f.value):e.jsx(no,{option:f,size:i},f.value))})]})}function Ne({children:s,className:t,onClick:n,disabled:a=!1,destructive:r=!1,icon:i,trailing:o,href:u,checked:c}){const g=e.jsxs(e.Fragment,{children:[(i||c!==void 0)&&e.jsx("span",{className:M("flex-shrink-0 w-4 h-4 flex items-center justify-center","text-fg-muted",r&&"text-sys-red","group-data-[focus]:text-white"),children:c!==void 0?c?e.jsx(be,{className:"h-4 w-4 text-sys-blue group-data-[focus]:text-white"}):null:i}),e.jsx("span",{className:"flex-1 truncate",children:s}),o&&e.jsx("span",{className:"flex-shrink-0 text-fg-muted group-data-[focus]:text-white/70 text-xs",children:o})]}),d=M("group flex items-center gap-2 w-full","px-3 py-2 radius-control cursor-default","text-sm text-left","transition-colors","focus:outline-none",a?"opacity-50 cursor-not-allowed":[r?["text-sys-red","data-[focus]:bg-sys-red data-[focus]:text-white"]:["text-fg-primary","data-[focus]:bg-sys-blue data-[focus]:text-white"]],t);return u&&!a?e.jsx(Mt,{children:e.jsx("a",{href:u,className:d,children:g})}):e.jsx(Mt,{disabled:a,children:e.jsx("button",{type:"button",onClick:n,disabled:a,className:d,children:g})})}function io({className:s}){return e.jsx(Fn,{className:M("my-1 h-px bg-border-subtle",s)})}const oo=100,co=101,uo=102,mo=103,po=104,xo=115,ho=116,fo=117,go=120,yo=125,bo=128,vo=136;function jo(s){const t=new jr(s),n=[];for(;t.getRemainingBytesCount()>=2;){const a=t.readUInt8(),r=t.readUInt8();if(a===0&&r===0)break;switch(r){case oo:n.push({channel:a,type:r,value:t.readUInt32BE()});break;case co:n.push({channel:a,type:r,value:t.readInt16BE()});break;case uo:n.push({channel:a,type:r,value:t.readUInt8()});break;case mo:n.push({channel:a,type:r,value:t.readInt16BE()/10});break;case po:n.push({channel:a,type:r,value:t.readUInt8()/2});break;case xo:n.push({channel:a,type:r,value:t.readUInt16BE()/10});break;case ho:n.push({channel:a,type:r,value:t.readInt16BE()/100});break;case fo:n.push({channel:a,type:r,value:t.readInt16BE()/1e3});break;case go:n.push({channel:a,type:r,value:t.readUInt8()});break;case yo:n.push({channel:a,type:r,value:t.readUInt16BE()});break;case bo:n.push({channel:a,type:r,value:t.readUInt16BE()});break;case vo:n.push({channel:a,type:r,value:{latitude:t.readInt24BE()/1e4,longitude:t.readInt24BE()/1e4,altitude:t.readInt24BE()/100}});break;default:return n}}return n}const jt=new Set(["☀️","🌤","🌤️","⛅","⛅️","☁️","🌫","🌫️","🌦","🌦️","🌧","🌧️","❄️","🌨","🌨️","⛈","⛈️","🌩","🌩️","🌪","🌪️"]),No="🌬";function wo(s){const t=s.trim();if(!t)return null;let n="",a=t;const r=t.match(/^([^:]+):\s*/);r&&(n=r[1].trim(),a=t.slice(r[0].length));let i="";for(const I of jt)if(a.includes(I)){i=I,a=a.replace(I,"").trim();break}if(!i)return null;a=a.replace(No,"").replace(/\uFE0F/g,"").trim();const o=a.match(/(-?\d+)\s*°\s*([FC]?)/);if(!o)return null;const u=parseInt(o[1],10),c=o[2]==="C"?"°C":"°F",d=a.slice(0,a.indexOf(o[0])).trim()||"Unknown",x=a.match(/([NSEW]{1,2}\d+)/),f=x==null?void 0:x[1],h=a.match(/(\d+%)\s*RH/i),m=a.match(/💧\s*(-?\d+°)/),j=a.match(/👁️?\s*(\d+\s*mi)/),w=a.match(/📊\s*([\d.]+)/),y=a.match(/H:\s*(-?\d+)°/),E=a.match(/L:\s*(-?\d+)°/);return{label:n||"Now",conditionEmoji:i,condition:d,temp:u,unit:c,wind:f,humidity:h==null?void 0:h[1],dewPoint:m==null?void 0:m[1],visibility:j==null?void 0:j[1],pressure:w==null?void 0:w[1],high:y?parseInt(y[1],10):void 0,low:E?parseInt(E[1],10):void 0}}function Ln(s){if(!s.includes("|"))return null;let t=!1;for(const r of jt)if(s.includes(r)){t=!0;break}if(!t||!/\d+\s*°/.test(s))return null;const n=s.split("|").map(r=>r.trim()),a=[];for(const r of n){if(/^H:\s*-?\d+°/.test(r)&&!r.match(/[☀🌤⛅☁🌫🌦🌧❄🌨⛈]/)){const o=r.match(/H:\s*(-?\d+)°/),u=r.match(/L:\s*(-?\d+)°/);a.length>0&&(o&&(a[a.length-1].high=parseInt(o[1],10)),u&&(a[a.length-1].low=parseInt(u[1],10)));continue}const i=wo(r);i&&a.push(i)}return a.length===0?null:{periods:a,rawSections:n}}function zn(s){if(!s.includes("|"))return null;const t=/SNR:\s*[-+]?[\d.]+/i.test(s),n=/RSSI:\s*[-+]?\d+/i.test(s);if(!t&&!n)return null;const a=/^ack\s/i.test(s.trim()),r=s.split("|").map(v=>v.trim());let i,o;const u=r[0];if(a)i=u.replace(/^ack\s+/i,"").trim()||void 0;else{const v=u.match(/^Rx\s+([^:]+):\s*(.*)/i);v&&(i=v[1].trim(),o=v[2].trim()||void 0)}let c,g,d;for(const v of r){const _=v.match(/\((\d+)\s*hops?\)/i)??v.match(/(\d+)\s*hops?\s*via/i);_&&(d=parseInt(_[1],10));const $=v.match(/([0-9a-f]{2}(?:\s*,\s*[0-9a-f]{2})+)/i);$&&(c=$[1],g=c.split(",").map(k=>k.trim()))}const x=s.match(/SNR:\s*([-+]?[\d.]+)\s*d[Bb]/i),f=x?parseFloat(x[1]):void 0,h=s.match(/RSSI:\s*([-+]?\d+)\s*dBm/i),m=h?parseInt(h[1],10):void 0,j=s.match(/(\d+\.?\d*)\s*(km|mi|miles?|m)\b/i),w=j?`${j[1]} ${j[2]}`:void 0,y=s.match(/Received\s*at:\s*(\S+)/i),E=y==null?void 0:y[1],I=s.match(/elapsed:\s*(\S+)/i),R=I==null?void 0:I[1];return{target:i,isAck:a,pathRaw:c,pathHops:g,hops:d,snr:f,rssi:m,distance:w,receivedAt:E,phrase:o,elapsed:R}}function Hn(s){if(!s.includes("🎲"))return null;const t=[],n=[],a=/(\d+)d(\d+):\s*\[([^\]]+)\]\s*=\s*(\d+)/g;let r;for(;(r=a.exec(s))!==null;){const g=parseInt(r[1],10),d=r[3].split(",").map(x=>parseInt(x.trim(),10));t.push({dieType:`d${r[2]}`,count:g,results:d,total:parseInt(r[4],10)}),n.push([r.index,r.index+r[0].length])}const i=/(\d*)d(\d+):\s*(\d+)/g;let o;for(;(o=i.exec(s))!==null;){if(n.some(([d,x])=>o.index>=d&&o.index=2?{text:t,setup:n[0].trim(),delivery:n.slice(1).join(` -`).trim(),isTwoPart:!0}:{text:t,isTwoPart:!1}}function Wn(s){if(!s.includes("🥸"))return null;const t=s.replace(/🥸\s*/,"").trim();if(!t)return null;const n=t.split(/\n\s*\n/);return n.length>=2?{text:t,setup:n[0].trim(),delivery:n.slice(1).join(` -`).trim(),isTwoPart:!0}:{text:t,isTwoPart:!1}}function Un(s){return s.includes("🎱")&&s.replace(/🎱\s*/,"").trim()||null}function Gn(s){if(!s.startsWith("⚠️")&&!s.startsWith("⚠"))return null;const t=s.replace(/^⚠️?\s*/,"").trim();if(!t)return null;const n=t.match(/^([A-Z][A-Z\s]+):\s*(.*)/s);return n?{severity:n[1].trim(),headline:n[2].trim()}:{headline:t}}function Kn(s){const t=s.split(` -`).map(a=>a.trim()).filter(Boolean);if(t.length<2)return null;const n=[];for(const a of t){const r=a.match(/^([A-Za-z]{1,3}):\s*/);if(!r)continue;let i=a.slice(r[0].length),o="";for(const x of jt)if(i.includes(x)){o=x,i=i.replace(x,"").trim();break}if(!o)continue;const u=i.match(/H:\s*(-?\d+)°/),c=i.match(/L:\s*(-?\d+)°/),g=i.search(/H:|\d+°/),d=g>0?i.slice(0,g).trim():"";n.push({dayAbbrev:r[1],conditionEmoji:o,condition:d||"Unknown",high:u?parseInt(u[1],10):void 0,low:c?parseInt(c[1],10):void 0})}return n.length>=2?n:null}function qn(s){const t=s.split(` -`).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 h of jt)if(i.includes(h)){o=h,i=i.replace(h,"").trim();break}if(!o)continue;let u;const c=i.match(/(\d+)%/);c&&(u=parseInt(c[1],10),i=i.replace(c[0],"").trim());const g=i.match(/(-?\d+)°/);if(!g)continue;const d=parseInt(g[1],10),x=i.indexOf(g[0]),f=x>0?i.slice(0,x).trim():"";n.push({hour:r[1].toUpperCase(),conditionEmoji:o,condition:f||"Unknown",temp:d,precipChance:u})}return n.length>=2?n:null}function Vn(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,c=o;c.includes("🎯")?(u="high",c=c.replace("🎯","").trim()):c.includes("📍")?(u="medium",c=c.replace("📍","").trim()):c.includes("❓")&&(u="low",c=c.replace("❓","").trim()),n.push({hex:i,name:c,confidence:u})}}return n.length>=2?{hops:n}:null}const ko=new Set(["🟢","🟡","🟠","🔴","🟣","🟤"]);function Jn(s){let t="";for(const x of ko)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,c=[],g=/(PM2\.5|PM10|O3|NO2|CO|SO2):\s*([\d.]+)/gi;let d;for(;(d=g.exec(s))!==null;)c.push({name:d[1].toUpperCase(),value:parseFloat(d[2])});return{location:u,aqi:a,category:r,colorEmoji:t,pollutants:c}}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),c=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:c==null?void 0:c[1]}}function Xn(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 c;for(;(c=u.exec(i[2]))!==null;)t.push({time:o,name:c[1],condition:c[2]})}return t.length>=2?{bands:t}:null}function Yn(s){var h,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),c=s.match(/Azimuth:?\s*([\d.]+)/i),g=s.match(/Altitude:?\s*(-?[\d.]+)/i),d=s.search(/Sun\s*Rise/i),x=s.search(/Sun\s*Set/i),f=x>=0&&(d<0||xa.trim()).filter(Boolean),n=[];for(const a of t){let r="";for(const c of So)if(a.startsWith(c)){r=c;break}if(!r)continue;const i=a.slice(r.length).trim(),o=i.match(/^(.+?)\s+(\d+)\s*[-–]\s*(.+?)\s+(\d+)\s*\((.+)\)$/);if(o){const c=o[5].trim(),g=/final/i.test(c),d=!g&&/\d/.test(c);n.push({sportEmoji:r,away:o[1].trim(),home:o[3].trim(),awayScore:parseInt(o[2],10),homeScore:parseInt(o[4],10),status:c,isLive:d,isFinal:g});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 na(s){var g,d,x,f;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 h=s.match(/^(.+?)\n/i);return{type:"leaderboard",entries:t,title:(g=h==null?void 0:h[1])==null?void 0:g.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),c=s.match(/^(.+?)\n/i);return{type:"basic",commands:r?parseInt(r[1],10):void 0,replies:i?parseInt(i[1],10):void 0,topCommand:(d=o==null?void 0:o[1])==null?void 0:d.trim(),topUser:(x=u==null?void 0:u[1])==null?void 0:x.trim(),title:(f=c==null?void 0:c[1])==null?void 0:f.replace(/📊\s*/,"").trim()}}const Io=new Set(["🐱","🐈","😺","😸","😹","😻","😼","😽","🙀","😿","😾","🐾","👂","🐟","🧶","🥛"]);function aa(s){if(!/\bcats?\b/i.test(s))return null;const t=s.slice(-4);for(const n of Io)if(t.includes(n))return s;return null}const _o=[{type:"dice",test:Hn},{type:"joke",test:Bn},{type:"dadjoke",test:Wn},{type:"magic8",test:Un},{type:"weather-alert",test:Gn},{type:"satpass",test:ea},{type:"aurora",test:ta},{type:"moon",test:Zn},{type:"sun",test:Yn},{type:"hfcond",test:Xn},{type:"solar",test:Qn},{type:"aqi",test:Jn},{type:"sports",test:sa},{type:"stats",test:na},{type:"path",test:Vn},{type:"weather-multiday",test:Kn},{type:"weather-hourly",test:qn},{type:"test",test:zn},{type:"weather",test:Ln},{type:"catfact",test:aa}];function ra(s){for(const{type:t,test:n}of _o)if(n(s)!=null)return t;return null}function Ro(s,t){switch(t){case"weather":return Ln(s);case"weather-multiday":return Kn(s);case"weather-hourly":return qn(s);case"weather-alert":return Gn(s);case"test":return zn(s);case"path":return Vn(s);case"aqi":return Jn(s);case"solar":return Qn(s);case"hfcond":return Xn(s);case"sun":return Yn(s);case"moon":return Zn(s);case"satpass":return ea(s);case"aurora":return ta(s);case"dice":return Hn(s);case"joke":return Bn(s);case"dadjoke":return Wn(s);case"magic8":return Un(s);case"sports":return sa(s);case"stats":return na(s);case"catfact":return aa(s);default:return null}}const la=/[\u{1F916}\u{1F9BE}\u{1F9BF}]/u;function Mo(s,t,n){if(t==="bot")return!0;if(t==="not-bot")return!1;if(la.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)ra(i)!=null&&a++;if(a>=Math.ceil(r.length*.6))return!0}return!1}function ia(s){return la.test(s)||/bot\b/i.test(s)}const oa="pymc_howl_bot_overrides";function Eo(){try{const s=localStorage.getItem(oa);if(!s)return new Map;const t=JSON.parse(s);return new Map(t)}catch{return new Map}}function Bs(s){try{localStorage.setItem(oa,JSON.stringify([...s]))}catch{}}const ca=Nr(s=>({overrides:Eo(),setOverride:(t,n)=>s(a=>{const r=new Map(a.overrides);return r.set(t,n),Bs(r),{overrides:r}}),clearOverride:t=>s(n=>{const a=new Map(n.overrides);return a.delete(t),Bs(a),{overrides:a}})}));function da(s){return ca(t=>t.overrides.get(s))}function Po(){return ca(s=>s.setOverride)}const ua="pymc_companion_contacts_micro",ma="pymc_companion_favorites",Ct=56;function Ws(){try{return localStorage.getItem(ua)==="1"}catch{return!1}}function To(s){try{localStorage.setItem(ua,s?"1":"0")}catch{}}function $o(){try{const s=localStorage.getItem(ma);return s?new Set(JSON.parse(s)):new Set}catch{return new Set}}function Ao(s){try{localStorage.setItem(ma,JSON.stringify([...s]))}catch{}}function Fo({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,f=x?`RSSI: ${r.rssi} dBm · SNR: ${r.snr.toFixed(1)} dB`:void 0;return e.jsx("div",{className:M(o,"relative rounded-full flex items-center justify-center flex-shrink-0 ring-[1.5px]",x?"ring-transparent":"ring-sys-blue"),title:f,children:x?e.jsx(yl,{rssi:r.rssi,snr:r.snr,compact:!0,showValues:!1}):e.jsx(Ge,{className:M(u,"text-sys-blue")})})}if(i===3)return e.jsx("div",{className:M(o,"relative rounded-full flex items-center justify-center flex-shrink-0 ring-[1.5px] ring-sys-pink"),children:e.jsx(xt,{className:M(u,"text-sys-pink")})});if(!s)return e.jsx("div",{className:M(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:c}=gt(s),g=yt(s),d=bt(s);return e.jsx("div",{className:M(o,"relative clay-avatar",c?"text-base":"text-white text-[11px] font-bold"),style:{"--avatar-color":g},children:c||d})}const Us=[{key:"companion",label:"Companions",icon:ye,color:"text-sys-blue"},{key:"room",label:"Room Servers",icon:xt,color:"text-sys-pink"},{key:"repeater",label:"Repeaters",icon:Ge,color:"text-sys-blue"}];function pa(s){const t=(s.adv_type??0)&15;return t===3?"room":t===2?"repeater":"companion"}const Oo=4e3,Do=5e3,Lo=2e3,zo=8,Ho=l.forwardRef(function({contact:t,isActive:n,unread:a,lastMsg:r,isFav:i,microContent:o,onSelect:u,onShowDetails:c,onShareContact:g,onResetPath:d,onRemoveContact:x,onPingContact:f,repeaterSignal:h,toggleFavorite:m},j){const w=wr(t.public_key),y=kr(t.public_key),E=da(t.public_key),I=Po(),R=E==="bot"||E==null&&ia(t.name||""),[v,_]=l.useState(!1),[$,k]=l.useState(!1),p=l.useRef(null),[b,S]=l.useState("idle"),N=l.useRef(!1),F=l.useRef(null),[C,L]=l.useState({w:0,h:0});l.useEffect(()=>{let z=!1,W=null;return w?(N.current=!0,W="idle"):N.current&&(N.current=!1,W=se.getState().pingResults.get(t.public_key)!=null?"success":"failed"),W&&queueMicrotask(()=>{z||S(W)}),()=>{z=!0}},[w,t.public_key]),l.useEffect(()=>{if(b==="idle")return;const W=setTimeout(()=>S("idle"),b==="success"?Do:Lo);return()=>clearTimeout(W)},[b]);const q=(w||b!=="idle")&&!v;l.useEffect(()=>{if(!q)return;const z=F.current;if(!z)return;const W=()=>{const ve=z.offsetWidth,Te=z.offsetHeight;L(ze=>ze.w===ve&&ze.h===Te?ze:{w:ve,h:Te})};W();const J=new ResizeObserver(W);return J.observe(z),()=>J.disconnect()},[q]);const T=l.useCallback(()=>{_(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>_(!1),Oo)},[]),O=l.useCallback(()=>{_(!1),p.current&&clearTimeout(p.current)},[]),G=l.useCallback(async()=>{x&&(p.current&&clearTimeout(p.current),k(!0),await x(t.public_key),k(!1),_(!1))},[x,t.public_key]),H=l.useMemo(()=>h&&h.rssi!==0?{rssi:h.rssi,snr:h.snr}:null,[h]),A=l.useCallback(z=>{F.current=z,typeof j=="function"?j(z):j&&(j.current=z)},[j]),D=v?"":b==="success"?"bg-sys-green/5":b==="failed"?"bg-sys-red/5":w?"bg-sys-blue/5":n?"bg-sys-blue":"hover:bg-elevated";return e.jsxs(le.div,{ref:A,layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:re.fade,className:M("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",D),children:[e.jsx(ge,{children:q&&C.w>0&&(b!=="idle"?e.jsx(le.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{opacity:{duration:.15}},className:M("absolute inset-0 radius-inner ring-2 ring-inset pointer-events-none z-[2]",b==="success"?"ring-sys-green":"ring-sys-red")},`ping-${b}`):e.jsx(Cr,{borderRadius:zo,width:C.w,height:C.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:M("flex items-center gap-2.5",v&&!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(Fo,{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"}),R&&!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(zs,{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:M("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)+"…"})}),b==="success"&&y?e.jsxs("div",{className:"text-[11px] text-sys-green font-medium truncate tabular-nums",children:[y.snr_db.toFixed(1)," dB SNR · ",y.rtt_ms," ms · ",y.hop_count," ",y.hop_count===1?"hop":"hops"]}):b==="failed"?e.jsx("div",{className:"text-[11px] text-sys-red font-medium truncate",children:"No response"}):r?e.jsx("div",{className:M("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(yi,{as:"div",className:"absolute inset-0",children:({open:z})=>e.jsxs(e.Fragment,{children:[e.jsx($n,{className:M("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",z?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":"Contact options",children:e.jsx(Bi,{className:M("h-3.5 w-3.5 transition-colors",n?"text-white/60 hover:text-white":"text-fg-muted hover:text-sys-blue")})}),e.jsxs(An,{anchor:"right start",transition:!0,className:M("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(Ne,{icon:e.jsx(Ke,{className:"w-4 h-4"}),onClick:()=>{c==null||c({type:"contact",id:t.public_key})},children:"Details"}),g&&e.jsx(Ne,{icon:e.jsx(Al,{className:"w-4 h-4"}),onClick:()=>g(t.public_key),children:"Share"}),e.jsx(Ne,{icon:e.jsx(Je,{className:"w-4 h-4"}),onClick:()=>u({type:"contact",id:t.public_key}),children:"Set Path"}),d&&e.jsx(Ne,{icon:e.jsx(wn,{className:"w-4 h-4"}),onClick:()=>d(t.public_key),children:"Reset Path"}),f&&pa(t)==="repeater"&&e.jsx(Ne,{icon:e.jsx(zi,{className:"w-4 h-4"}),onClick:()=>f(t.public_key),disabled:w,children:w?"Pinging…":"Ping"}),x&&e.jsx(Ne,{icon:e.jsx(Qe,{className:"w-4 h-4"}),destructive:!0,onClick:T,children:"Remove Contact"}),e.jsx(io,{}),e.jsx(Ne,{icon:R?e.jsx(Fi,{className:"w-4 h-4 text-fg-muted"}):e.jsx(zs,{className:"w-4 h-4 text-sys-violet"}),onClick:()=>I(t.public_key,R?"not-bot":"bot"),children:R?"Not a Bot":"Mark as HOWL Bot"}),e.jsx(Ne,{icon:e.jsx(eo,{className:M("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:()=>m(t.public_key),children:i?"Unfavorite":"Favorite"})]})]})})})]}),!o&&e.jsx("div",{className:M("flex items-center gap-1.5 self-center",!v&&"invisible pointer-events-none"),children:$?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:O,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:G,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)}),Gs={excellent:4,good:3,fair:2,weak:1,poor:0};function Ks(s,t){const n=t==null?void 0:t.get(s);return n&&n.rssi!==0?n.rssi:null}function Bo(s,t,n,a){return[...s].sort((r,i)=>{const o=t.has(r.public_key)?0:1,u=t.has(i.public_key)?0:1;if(o!==u)return o-u;if(n){const c=n.get(r.public_key),g=c&&c.length>0?c[c.length-1].timestamp:0,d=n.get(i.public_key),x=d&&d.length>0?d[d.length-1].timestamp:0;if(g!==x)return x-g}if(a){const c=Ks(r.public_key,a),g=Ks(i.public_key,a);if(c!=null&&g==null)return-1;if(c==null&&g!=null)return 1;if(c!=null&&g!=null){const d=Gs[$s(c)]??0,x=Gs[$s(g)]??0;if(d!==x)return x-d}}return(r.name||"").localeCompare(i.name||"")})}const Wo=l.memo(l.forwardRef(function({contacts:t,selectedConversation:n,unreadMap:a,messages:r,onSelect:i,onShowDetails:o,onShareContact:u,onResetPath:c,onRemoveContact:g,onPingContact:d,repeaterSignalMap:x,isLoading:f,splitPercent:h=50,onMicroChange:m,className:j},w){const[y,E]=l.useState(Ws),[I,R]=l.useState(Ws),[v,_]=l.useState(""),[$,k]=l.useState(!1),[p,b]=l.useState($o),S=l.useRef(null),N=l.useRef(null),F=l.useCallback(H=>{N.current=H,typeof w=="function"?w(H):w&&(w.current=H)},[w]),C=l.useCallback(()=>{E(H=>{const A=!H;To(A);const D=N.current;if(A&&R(!0),D){let z=0;const W=D.parentElement;if(A)z=(W==null?void 0:W.offsetWidth)??D.offsetWidth;else if(W){const ve=W.style.width;W.style.width="var(--companion-side)",z=W.offsetWidth,W.style.width=ve}const J=A?Ct:Math.round(h/100*z);lt(D,{width:`${J}px`},{...re.layoutResize,onComplete(){D.style.width=A?`${Ct}px`:`${h}%`,A||R(!1)}})}return m==null||m(A),A})},[h,m]),L=l.useCallback(H=>{b(A=>{const D=new Set(A);return D.has(H)?D.delete(H):D.add(H),Ao(D),D})},[]),q=$||v.length>0,T=l.useMemo(()=>{const H=new Set,A=t.filter(z=>H.has(z.public_key)?!1:(H.add(z.public_key),!0));if(!v.trim())return A;const D=v.toLowerCase();return A.filter(z=>{var W;return((W=z.name)==null?void 0:W.toLowerCase().includes(D))||z.public_key.toLowerCase().includes(D)})},[t,v]),O=l.useMemo(()=>{const H=new Map;for(const A of Us)H.set(A.key,[]);for(const A of T)H.get(pa(A)).push(A);return Us.map(A=>({...A,items:Bo(H.get(A.key),p,r,A.key==="repeater"?x:void 0)})).filter(A=>A.items.length>0)},[T,p,r,x]),G=(n==null?void 0:n.type)==="contact"?n.id:null;return e.jsxs("div",{ref:F,className:M("flex-shrink-0 overflow-hidden flex flex-col h-full",j),style:{width:y?Ct:`${h}%`},children:[e.jsx("div",{className:M("flex items-center border-b border-edge-subtle flex-shrink-0",I?"justify-center p-2":"gap-2 px-3 py-2"),children:I?e.jsx("button",{onClick:C,className:"p-1 hover:bg-subtle-fill rounded transition-colors",title:"Expand contacts",children:e.jsx(Ji,{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:()=>{q?(_(""),k(!1)):(k(!0),setTimeout(()=>{var H;return(H=S.current)==null?void 0:H.focus()},50))},className:M("p-1 rounded transition-colors flex-shrink-0",q?"bg-sys-blue/10 text-sys-blue":"hover:bg-subtle-fill text-fg-muted"),title:q?"Close search":"Search contacts",children:e.jsx(As,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:C,className:"p-1 hover:bg-subtle-fill rounded transition-colors flex-shrink-0",title:"Collapse contacts",children:e.jsx(qi,{className:"w-3.5 h-3.5 text-fg-muted"})})]})]})}),!I&&q&&e.jsxs("div",{className:"relative px-2.5 py-2 border-b border-edge-subtle/50 flex-shrink-0",children:[e.jsx(As,{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:S,type:"text",value:v,onChange:H=>_(H.target.value),onFocus:()=>k(!0),onBlur:()=>k(!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:()=>{_(""),k(!1)},className:"absolute right-5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-subtle-fill rounded",children:e.jsx(ht,{className:"w-3.5 h-3.5 text-fg-muted"})})]}),f&&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"})}),!f&&e.jsxs("div",{className:M("flex-1 overflow-y-auto min-h-0",I?"px-0":"px-1.5"),style:{contain:"layout style paint"},children:[O.map(H=>{const A=H.icon;return e.jsxs(_e,{defaultOpen:!0,className:"mb-1",children:[e.jsxs(Re,{className:M("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(A,{className:M("w-3.5 h-3.5",H.color)}),!I&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:H.label}),e.jsx("span",{className:"type-data-xs text-fg-muted/50 ml-auto",children:H.items.length})]})]}),e.jsx(Me,{children:e.jsx(ge,{initial:!1,mode:"popLayout",children:H.items.map(D=>e.jsx(Ho,{contact:D,isActive:G===D.public_key,unread:a.get(D.public_key)??0,lastMsg:(()=>{const z=r.get(D.public_key);return z&&z.length>0?z[z.length-1]:void 0})(),isFav:p.has(D.public_key),microContent:I,onSelect:i,onShowDetails:o,onShareContact:u,onResetPath:c,onRemoveContact:g,onPingContact:d,repeaterSignal:x==null?void 0:x.get(D.public_key),toggleFavorite:L},D.public_key))})})]},H.key)}),T.length===0&&e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-sm text-fg-muted",children:v?"No matches":"No contacts yet"})})]})]})}));function Uo({open:s,onClose:t}){const n=se(p=>p.discoverImportableChannels),a=se(p=>p.getEmptyChannelSlots),r=se(p=>p.importChannel),i=se(p=>p.refreshChannels),[o,u]=l.useState("discover"),[c,g]=l.useState([]),[d,x]=l.useState([]),[f,h]=l.useState(null),m=l.useRef(!1);l.useEffect(()=>{if(!s)return;u("discover"),g([]),x([]),h(null),m.current=!1;let p=!1;return(async()=>{try{const[b,S]=await Promise.all([n(),a()]);if(p)return;if(x(S),b.length===0){h("No channels found in repeater history. Decoded messages may still be loading."),u("select");return}S.length===0&&h("No empty channel slots on device. Delete a channel first to make room."),g(b.map(N=>({name:N.name,alreadyOnDevice:N.alreadyOnDevice,selected:!N.alreadyOnDevice,status:"pending"}))),u("select")}catch(b){p||(h(b instanceof Error?b.message:"Discovery failed"),u("select"))}})(),()=>{p=!0}},[s,n,a]);const j=l.useCallback(p=>{g(b=>b.map(S=>S.name===p&&!S.alreadyOnDevice?{...S,selected:!S.selected}:S))},[]),w=l.useCallback(()=>{g(p=>p.map(b=>b.alreadyOnDevice?b:{...b,selected:!0}))},[]),y=l.useCallback(()=>{g(p=>p.map(b=>b.alreadyOnDevice?b:{...b,selected:!1}))},[]),E=l.useMemo(()=>c.filter(p=>!p.alreadyOnDevice).length,[c]),I=l.useMemo(()=>c.filter(p=>p.selected&&!p.alreadyOnDevice).length,[c]),R=l.useMemo(()=>c.filter(p=>p.status==="done").length,[c]),v=l.useMemo(()=>c.filter(p=>p.status==="failed").length,[c]),_=l.useCallback(async()=>{u("import"),m.current=!1;const p=c.filter(S=>S.selected&&!S.alreadyOnDevice),b=[...d];for(const S of p){if(m.current)break;const N=b.shift();if(N===void 0){g(C=>C.map(L=>L.name===S.name&&L.status==="pending"?{...L,status:"failed"}:L));continue}g(C=>C.map(L=>L.name===S.name?{...L,status:"sending"}:L)),await new Promise(C=>setTimeout(C,150));const F=await r(S.name,N);g(C=>C.map(L=>L.name===S.name?{...L,status:F?"done":"failed"}:L)),F||b.unshift(N),m.current||await new Promise(C=>setTimeout(C,300))}await i(),u("complete")},[c,d,r,i]),$=l.useCallback(()=>{m.current=!0},[]),k=p=>{switch(p){case"pending":return e.jsx(On,{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(be,{className:"w-3.5 h-3.5 text-sys-green"});case"failed":return e.jsx(ht,{className:"w-3.5 h-3.5 text-sys-red"})}};return e.jsxs(we,{open:s,onClose:o==="import"?()=>{}:t,size:"sm",children:[e.jsx(Ee,{icon:e.jsx(qe,{className:"w-5 h-5"}),title:"Import Channels",onClose:o==="import"?void 0:t}),e.jsxs(ke,{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:[f&&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:f})]}),c.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:[E," discoverable · ",d.length," slot",d.length!==1?"s":""," free"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:w,className:"text-[11px] text-sys-blue hover:underline",children:"All"}),e.jsx("span",{className:"text-fg-muted/40",children:"·"}),e.jsx("button",{onClick:y,className:"text-[11px] text-sys-blue hover:underline",children:"None"})]})]}),e.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:c.map(p=>e.jsxs("button",{onClick:()=>j(p.name),disabled:p.alreadyOnDevice,className:M("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:M("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(be,{className:"w-3 h-3 text-white"})}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(Le,{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," / ",c.filter(p=>p.selected&&!p.alreadyOnDevice).length]})]}),e.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:c.filter(p=>p.selected&&!p.alreadyOnDevice).map(p=>e.jsxs("div",{className:M("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:k(p.status)}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(Le,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:M("text-sm truncate",p.status==="done"?"text-fg-primary":"text-fg-secondary"),children:p.name})]}),e.jsx("span",{className:M("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(Pe,{children:[o==="select"&&e.jsxs(e.Fragment,{children:[e.jsx(U,{plain:!0,onClick:t,children:"Cancel"}),e.jsxs(U,{color:"primary",onClick:_,disabled:I===0||d.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:$,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(Ol,{className:"w-4 h-4"}),"Done — ",R," imported"]})]})]})]})}const Go=4e3;function Ko(s){const t=s.frequency_hz/1e3,n=s.bandwidth_hz/1e3;return`${t} · SF${s.spreading_factor} · ${n}k`}const qo=l.forwardRef(function({channel:t,isActive:n,unread:a,lastMsg:r,isLoadingMessages:i,selfInfo:o,onSelect:u,onDeleteChannel:c},g){const[d,x]=l.useState(!1),[f,h]=l.useState(!1),m=l.useRef(null),j=l.useCallback(()=>{x(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>x(!1),Go)},[]),w=l.useCallback(()=>{x(!1),m.current&&clearTimeout(m.current)},[]),y=l.useCallback(async()=>{c&&(m.current&&clearTimeout(m.current),h(!0),await c(t.index),h(!1),x(!1))},[c,t.index]),E=t.name.toLowerCase()==="public",I=c&&!E;return e.jsx(le.div,{ref:g,layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:re.fade,className:M("group w-full flex items-center gap-2.5 px-2.5 py-1 radius-inner","transition-[background-color] duration-150",d?"":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:M("flex items-center gap-2.5 min-w-0",d&&"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:M("text-sm flex-shrink-0",n?"text-white font-semibold":r?"text-fg-primary font-semibold":"text-fg-secondary font-normal"),children:t.name}),E&&o&&e.jsx("span",{className:M("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:Ko(o)})]}),r&&e.jsx("div",{className:M("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:M("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:M("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:M("flex items-center gap-1.5 self-center",!d&&"invisible pointer-events-none"),children:f?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:w,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:y,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"})})]})})]})})}),Vo=l.memo(l.forwardRef(function({channels:t,selectedConversation:n,unreadMap:a,messages:r,onSelect:i,onAddChannel:o,onDeleteChannel:u,className:c},g){const d=yn(),x=ft(),[f,h]=l.useState(!1),m=l.useMemo(()=>{const w=new Set,y=t.filter(E=>w.has(E.index)?!1:(w.add(E.index),!0));return y.sort((E,I)=>{const R=E.name.toLowerCase()==="public",v=I.name.toLowerCase()==="public";if(R&&!v)return-1;if(!R&&v)return 1;const _=r.get(`ch:${E.index}`),$=_&&_.length>0?_[_.length-1].timestamp:0,k=r.get(`ch:${I.index}`),p=k&&k.length>0?k[k.length-1].timestamp:0;return $!==p?p-$:E.name.localeCompare(I.name)}),y},[t,r]),j=(n==null?void 0:n.type)==="channel"?n.id:null;return e.jsxs("div",{ref:g,className:M("flex-1 min-w-0 overflow-hidden flex flex-col h-full",c),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:()=>h(!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(Uo,{open:f,onClose:()=>h(!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(ge,{initial:!1,mode:"popLayout",children:m.map(w=>e.jsx(qo,{channel:w,isActive:j===String(w.index),unread:a.get(`ch:${w.index}`)??0,lastMsg:(()=>{const y=r.get(`ch:${w.index}`);return y&&y.length>0?y[y.length-1]:void 0})(),isLoadingMessages:d,selfInfo:x,onSelect:i,onDeleteChannel:u},w.index))})})]})}));function Jo(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),c=`${i.text}:${u}`;n.has(c)||n.set(c,a)}return n}function Qo(s){const t=ft(),n=Sr(),a=Ir(),r=t==null?void 0:t.node_name,i=l.useMemo(()=>r?Jo(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 d of s){if(!d.is_outgoing||!d.is_channel)continue;const x=Math.floor(d.timestamp/30);let f=!1;for(const h of[x-1,x,x+1]){const m=i.get(`${d.text}:${h}`);if(m){const j=u.get(m)??[];j.push(d.id),u.set(m,j),f=!0;break}}}if(u.size===0)return o;const c=new Set(u.keys()),g=new Map;for(const d of a)c.has(d.packet_hash)&&g.set(d.packet_hash,(g.get(d.packet_hash)??0)+1);for(const[d,x]of u){const f=g.get(d)??0,h=Math.max(0,f-1);for(const m of x)o.set(m,h)}return o},[s,r,i,a])}const Y=l.memo(function({children:t,className:n,bgClassName:a,hideBadge:r,compact:i}){return e.jsxs("div",{className:M("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]})}),Xo=new Set(["☀️","🌤","🌤️"]),Yo=new Set(["⛅","⛅️"]),Zo=new Set(["☁️","🌫","🌫️"]),ec=new Set(["🌧","🌧️","🌦","🌦️","⛈","⛈️","🌩","🌩️"]),tc=new Set(["❄️","🌨","🌨️"]);function sc(s){return Xo.has(s)?"bg-gradient-to-br from-[var(--sys-blue)]/20 to-[var(--sys-indigo)]/10":Yo.has(s)?"bg-gradient-to-br from-[var(--zinc-800)]/80 to-[var(--sys-blue)]/15":Zo.has(s)?"bg-gradient-to-br from-[var(--zinc-800)]/80 to-[var(--zinc-700)]/60":ec.has(s)?"bg-gradient-to-br from-[var(--zinc-900)]/80 to-[var(--zinc-700)]/60":tc.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 We({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 nc({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 ac=l.memo(function({data:t}){const n=t.periods[0],a=t.periods.slice(1),r=sc(n.conditionEmoji);return e.jsxs(Y,{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(We,{label:`💨 ${n.wind}`}),n.humidity&&e.jsx(We,{label:`💧 ${n.humidity}`}),n.dewPoint&&e.jsx(We,{label:`💧 ${n.dewPoint}`}),n.visibility&&e.jsx(We,{label:`👁️ ${n.visibility}`}),n.pressure&&e.jsx(We,{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(nc,{period:i},o))})]})}),rc=l.memo(function({data:t}){return e.jsx(Y,{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))})})}),lc=l.memo(function({data:t}){return e.jsx(Y,{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:M("text-[9px] tabular-nums font-medium",n.precipChance>=50?"text-sys-blue":"text-sys-blue/60"),children:[n.precipChance,"%"]})]},a))})})});function ic(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 oc={red:"border-l-sys-red",amber:"border-l-sys-amber"},cc={red:"text-sys-red",amber:"text-sys-amber"},dc=l.memo(function({data:t}){const n=ic(t.severity);return e.jsx(Y,{compact:!0,hideBadge:!0,children:e.jsxs("div",{className:M("border-l-[3px] pl-2.5 -ml-0.5",oc[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:M("text-[10px] font-bold uppercase tracking-wider",cc[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})]})})}),uc={high:"🎯",medium:"📍",low:"❓"};function mc({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:M("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:uc[s.confidence]})]})]})}const pc=l.memo(function({data:t}){return e.jsxs(Y,{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(mc,{hop:n},a))})]})});function xc(s){return s>=10?5:s>=6?4:s>=3?3:s>=0?2:s>=-5?1:0}function hc(s){return s>=4?"bg-sys-green":s>=3?"bg-sys-amber":s>=2?"bg-sys-orange":"bg-sys-red"}function fc({bars:s}){const t=hc(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:M("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 yc(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 bc=l.memo(function({data:t}){const{text:n,bg:a}=yc(t.aqi);return e.jsxs(Y,{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:M("flex items-center justify-center w-12 h-12 rounded-xl",a),children:e.jsx("span",{className:M("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:M("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 vc(s){return s<=3?"text-sys-green":s<=4?"text-sys-amber":s<=6?"text-sys-orange":"text-sys-red"}function Ae({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:M("text-sm font-semibold tabular-nums text-fg-primary",n),children:t})]})}const jc=l.memo(function({data:t}){return e.jsxs(Y,{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(Ae,{label:"A-Index",value:t.aIndex}),t.kIndex!=null&&e.jsx(Ae,{label:"K-Index",value:t.kIndex,className:vc(t.kIndex)}),t.sunspots!=null&&e.jsx(Ae,{label:"Sunspots",value:t.sunspots}),t.xrayFlux!=null&&e.jsx(Ae,{label:"X-Ray",value:t.xrayFlux}),t.solarFlux!=null&&e.jsx(Ae,{label:"Flux",value:t.solarFlux}),t.signalNoise!=null&&e.jsx(Ae,{label:"Noise",value:t.signalNoise})]})]})});function Nc(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 qs({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:M("text-[10px] font-semibold px-1.5 py-0.5 rounded",Nc(s.condition)),children:s.condition})]})}const wc=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(Y,{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(qs,{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(qs,{band:r},i))]})]})]})});function kc({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 Cc=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,c=t.remainingHours*60+t.remainingMinutes;u>0&&(n=1-c/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(Y,{compact:!0,children:[e.jsx(kc,{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),"°"]})]})]})}),Sc=l.memo(function({data:t}){return e.jsxs(Y,{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),"°"]})]})]})}),Ic=l.memo(function({data:t}){return e.jsxs(Y,{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 _c(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 Rc=l.memo(function({data:t}){const n=_c(t.kpIndex);return e.jsxs(Y,{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})]})]})}),Mc=l.memo(function({data:t}){return e.jsxs(Y,{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})]})]})}),Vs=l.memo(function({data:t,isDadJoke:n}){const a=n?"🥸":"🎭";return e.jsx(Y,{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})})]})})}),Ec=l.memo(function({data:t}){return e.jsx(Y,{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))})})}),Pc=l.memo(function({data:t}){var n;return e.jsxs(Y,{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)})})]})}),Tc=l.memo(function({data:t}){return e.jsx(Y,{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 $c({text:s}){return e.jsx(Y,{compact:!0,children:e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed tracking-wide whitespace-pre-wrap break-words",children:fl(s)})})}const Ac=l.memo(function({text:t,messageType:n}){const a=l.useMemo(()=>n?Ro(t,n):null,[t,n]);if(a)switch(n){case"weather":return e.jsx(ac,{data:a});case"weather-multiday":return e.jsx(rc,{data:a});case"weather-hourly":return e.jsx(lc,{data:a});case"weather-alert":return e.jsx(dc,{data:a});case"path":return e.jsx(pc,{data:a});case"test":return e.jsx(gc,{data:a});case"aqi":return e.jsx(bc,{data:a});case"solar":return e.jsx(jc,{data:a});case"hfcond":return e.jsx(wc,{data:a});case"sun":return e.jsx(Cc,{data:a});case"moon":return e.jsx(Sc,{data:a});case"satpass":return e.jsx(Ic,{data:a});case"aurora":return e.jsx(Rc,{data:a});case"dice":return e.jsx(Mc,{data:a});case"joke":return e.jsx(Vs,{data:a});case"dadjoke":return e.jsx(Vs,{data:a,isDadJoke:!0});case"sports":return e.jsx(Ec,{data:a});case"stats":return e.jsx(Pc,{data:a});case"catfact":return e.jsx(Tc,{data:a})}return e.jsx($c,{text:t})}),Fc=l.lazy(()=>bn(()=>import("./CompanionPathMap-BXnFAxbT.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(s=>({default:s.CompanionPathMap}))),Oc=l.lazy(()=>bn(()=>import("./CompanionEchoMap-CwrYV0II.js"),__vite__mapDeps([13,1,2,3,4,5,9,10,11,12])).then(s=>({default:s.CompanionEchoMap}))),Js=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 Dc(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 Lc(s){const t=new Date(s*1e3);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function zc(s){const t=new Map;for(const n of s)n.name&&t.set(n.public_key,n.name);return t}function Hc(s){const t=new Map;for(const n of s)t.set(n.public_key,n);return t}function Bc(s){if(!s)return[];const t=[];for(let n=0;n64?t&63:t}function Uc(s,t){const n=t.find(a=>a.public_key.startsWith(s));return(n==null?void 0:n.name)||null}function Qs(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 Gc=new Set(["🎭","🥸"]);function Kc({senderName:s,timestamp:t,signed:n,children:a}){const{emoji:r,cleanName:i}=gt(s),o=yt(i),u=bt(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:M("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:gl(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 qc=l.memo(function({msg:t,contact:n,contacts:a,selfInfo:r,echoCount:i,channelName:o,allMessages:u,children:c}){const[g,d]=l.useState(!1),[x,f]=l.useState(!1),[h,m]=l.useState(0),j=l.useRef(null),w=Wc(t.path_len),y=!t.is_outgoing,E=y&&w!=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&&y?zl(t.text):null,[R,y,t.text]),_=E||I,$=l.useMemo(()=>{const C=[];if(t.path_hops&&t.path_hops.length>0)C.push({hops:t.path_hops.slice(0,64),snr:t.path_snr,rssi:t.path_rssi});else if(y&&(n!=null&&n.out_path)){const L=Bc(n.out_path);L.length>0&&C.push({hops:L})}if(t.alternate_paths)for(const L of t.alternate_paths)C.push(L);return C},[t.path_hops,t.path_snr,t.path_rssi,t.alternate_paths,y,n]),k=h<$.length?h:0,p=$[k]??$[0],b=$.length>1,S=(p==null?void 0:p.snr)??t.msg_snr,N=()=>{f(!0),d(C=>!C)},F=l.useCallback(C=>{var L;C.propertyName==="grid-template-rows"&&(g?(L=j.current)==null||L.scrollIntoView({block:"nearest",behavior:"smooth"}):f(!1))},[g]);return e.jsxs("div",{ref:j,className:M("rounded-xl px-2 py-1 -mx-2 transition-colors duration-150",_&&"hover:bg-subtle-fill cursor-pointer"),onClick:()=>_&&N(),children:[c,_&&e.jsx("div",{className:"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.83,0,0.17,1)]",style:{gridTemplateRows:g?"1fr":"0fr"},onTransitionEnd:F,children:e.jsxs("div",{className:"overflow-hidden",children:[x&&E&&e.jsxs("div",{className:"mt-1.5 ml-13 space-y-1",children:[b&&e.jsx("div",{className:"flex items-center gap-1 flex-wrap",onClick:C=>C.stopPropagation(),children:$.map((C,L)=>e.jsxs("button",{onClick:()=>m(L),className:M("flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] transition-colors",L===k?"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||w,C.snr!=null&&e.jsxs("span",{className:"ml-0.5 opacity-70",children:[C.snr>0?"+":"",C.snr.toFixed(1)]})]},L))}),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"}),w===0&&!p?e.jsx("span",{className:"text-[10px] text-fg-muted font-medium",children:"Direct"}):p&&p.hops.length>0?p.hops.map((C,L)=>{const q=Uc(C,a);return e.jsxs("span",{className:"contents",children:[L>0&&e.jsx(Bl,{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}),q&&e.jsxs("span",{className:"text-fg-muted",children:["(",q,")"]})]})]},L)}):e.jsxs("span",{className:"text-[10px] text-fg-muted font-medium",children:[w," hop",w>1?"s":""]}),S!=null&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-fg-muted ml-0.5",children:[e.jsx(bl,{className:"w-2.5 h-2.5"}),S>0?"+":"",S.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:Js,children:e.jsx(Fc,{hops:p.hops,contacts:a,selfInfo:r,snr:S,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:Js,children:e.jsx(Oc,{text:t.text,timestamp:t.timestamp,contacts:a})})})]})})]})}),Vc=l.memo(function({messages:t,contacts:n,className:a,conversationKey:r,onRetry:i,onRetryAsFlood:o,onMentionClick:u,isLoading:c,historyLoading:g,historyExhausted:d,onLoadOlder:x,channelName:f,contactPubKey:h}){const m=l.useRef(null),j=l.useRef(null),[w,y]=l.useState(!1),E=l.useRef(t.length),I=l.useRef(0),R=l.useRef(r);l.useEffect(()=>{if(r!==R.current){R.current=r,E.current=t.length,I.current=0;const T=requestAnimationFrame(()=>{y(!1);const O=m.current;O&&(O.scrollTop=O.scrollHeight)});return()=>cancelAnimationFrame(T)}},[r,t.length]);const v=l.useMemo(()=>zc(n),[n]),_=l.useMemo(()=>Hc(n),[n]),$=ft(),k=Qo(t),p=da(h??""),b=h?_.get(h):void 0,S=l.useMemo(()=>{if(!b)return!1;const T=t.filter(O=>!O.is_outgoing).slice(-5).map(O=>O.text);return Mo(b.name,p,T)},[b,p,t]),{combinedTexts:N,skipIds:F}=l.useMemo(()=>{const T=new Map,O=new Set;for(let G=0;G3)continue;const D=[...H.text][0];if(!D||!Gc.has(D)||[...A.text][0]!==D)continue;const z=A.text.slice(D.length).trimStart();T.set(H.id,H.text+` - -`+z),O.add(A.id),G++}return{combinedTexts:T,skipIds:O}},[t]);l.useEffect(()=>{var O;const T=m.current;if(T){if(t.length>E.current&&I.current>0){const G=T.scrollHeight-I.current;if(G>0&&T.scrollTop<200){T.scrollTop+=G,E.current=t.length,I.current=0;return}}E.current=t.length,w||(O=j.current)==null||O.scrollIntoView({behavior:"smooth"})}},[t.length,w]);const C=l.useCallback(()=>{const T=m.current;if(!T)return;const O=T.scrollHeight-T.scrollTop-T.clientHeight;y(O>100),T.scrollTop<80&&x&&!g&&!d&&(I.current=T.scrollHeight,x())},[x,g,d]),L=l.useCallback(()=>{var T;(T=j.current)==null||T.scrollIntoView({behavior:"smooth"}),y(!1)},[]);let q="";return e.jsxs("div",{className:M("relative flex flex-col",a),children:[e.jsxs("div",{ref:m,onScroll:C,className:"flex-1 overflow-y-auto min-h-0 px-4 py-3",style:{contain:"layout style paint"},children:[g&&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:c?"Loading messages…":"No messages yet"})}):t.map(T=>{if(F.has(T.id))return null;const O=Lc(T.timestamp),G=O!==q;q=O;const H=T.unconfirmed&&T.is_channel&&(k.get(T.id)??0)>0,A=T.is_outgoing?T.failed?"failed":T.confirmed||H?"confirmed":T.unconfirmed?"unconfirmed":(T.retryAttempt??0)>0?"retrying":T.sent?"sent":"pending":void 0,D=T.is_channel&&T.channel_idx!=null?`ch:${T.channel_idx}`:T.sender_key;return e.jsxs("div",{children:[G&&e.jsx(Dl,{text:Dc(T.timestamp)}),e.jsx(qc,{msg:T,contact:_.get(T.sender_key),contacts:n,selfInfo:$,echoCount:k.get(T.id),channelName:f,allMessages:f!=null&&f.toLowerCase().includes("wardrive")?t:void 0,children:(()=>{if(!T.is_outgoing){const z=Qs(T,v);if(T.is_channel?ia(z):S){const J=N.get(T.id)??T.text,ve=ra(J);return e.jsx(Kc,{senderName:z,timestamp:T.timestamp,signed:T.txt_type===_s.SignedPlain,children:e.jsx(Ac,{text:J,messageType:ve})})}}return e.jsx(Ll,{senderName:Qs(T,v),text:T.text,timestamp:T.timestamp,isOutgoing:T.is_outgoing,status:A,onRetry:i&&T.failed?()=>i(D,T.id):void 0,onRetryAsFlood:o&&T.failed&&!T.is_channel?()=>o(D,T.id):void 0,retryAttempt:T.retryAttempt,maxRetries:T.maxRetries,echoCount:k.get(T.id),signed:!T.is_outgoing&&T.txt_type===_s.SignedPlain,bubbleVariant:"subtle",onMentionClick:u})})()})]},T.id)}),e.jsx("div",{ref:j})]}),e.jsx("button",{onClick:L,className:M("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",w?"opacity-100 translate-y-0":"opacity-0 translate-y-2 pointer-events-none"),children:e.jsx(Hl,{className:"w-4 h-4 text-white"})})]})}),Jc=6,Qc=l.memo(function({onSend:t,disabled:n,placeholder:a="Type a message…",className:r,mentionNames:i=[]}){const[o,u]=l.useState(""),[c,g]=l.useState(!1),d=l.useRef(null),[x,f]=l.useState(null),[h,m]=l.useState(-1),[j,w]=l.useState(0),y=l.useMemo(()=>{if(x==null)return[];const k=x.toLowerCase();return i.filter(p=>p.toLowerCase().includes(k)).slice(0,Jc)},[x,i]),E=y.length>0;l.useEffect(()=>{w(0)},[y]);const I=l.useCallback(()=>{f(null),m(-1),w(0)},[]),R=l.useCallback(k=>{var C;if(h<0)return;const p=o.slice(0,h),b=((C=d.current)==null?void 0:C.selectionStart)??o.length,S=o.slice(b),N=`@[${k}] `,F=p+N+S;u(F),I(),requestAnimationFrame(()=>{var q,T;const L=p.length+N.length;(q=d.current)==null||q.setSelectionRange(L,L),(T=d.current)==null||T.focus()})},[o,h,I]),v=l.useCallback(async()=>{var p;const k=o.trim();!k||c||n||(g(!0),I(),u(""),await t(k),g(!1),(p=d.current)==null||p.focus())},[o,c,n,t,I]),_=l.useCallback(k=>{const p=k.target.value;u(p);const b=k.target.selectionStart??p.length,S=p.slice(0,b),N=S.lastIndexOf("@");if(N>=0){const F=N>0?S[N-1]:" ";if(/\s/.test(F)||N===0){const C=S.slice(N+1);if(!C.includes(" ")&&!C.includes("[")){f(C),m(N);return}}}I()},[I]),$=l.useCallback(k=>{if(E){if(k.key==="ArrowDown"){k.preventDefault(),w(p=>(p+1)%y.length);return}if(k.key==="ArrowUp"){k.preventDefault(),w(p=>(p-1+y.length)%y.length);return}if(k.key==="Enter"||k.key==="Tab"){k.preventDefault(),R(y[j]);return}if(k.key==="Escape"){k.preventDefault(),I();return}}k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),v())},[v,E,y,j,R,I]);return e.jsxs("div",{className:M("relative flex items-center gap-2 p-3 border-t border-edge-subtle",r),children:[E&&e.jsx("div",{className:"absolute bottom-full left-3 right-3 mb-1 radius-inset surface-elevated depth-raised overflow-hidden z-50",children:y.map((k,p)=>{const b=yt(k),{emoji:S,cleanName:N}=gt(k),F=bt(k);return e.jsxs("button",{onMouseDown:C=>{C.preventDefault(),R(k)},className:M("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:M("clay-avatar w-5 h-5",S?"text-xs":"text-white text-[9px] font-bold"),style:{"--avatar-color":b},children:S||F}),e.jsx("span",{className:"text-sm text-fg-primary truncate",children:N})]},k)})}),e.jsx("input",{ref:d,type:"text",value:o,onChange:_,onKeyDown:$,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()||c||n,className:M("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(_r,{className:"w-4.5 h-4.5 -translate-x-[0.5px] translate-y-[0.5px]",strokeWidth:2.5})})]})}),Kt="pymc_companion_room_pwd_";function Xc(s){try{return localStorage.getItem(`${Kt}${s}`)}catch{return null}}function Yc(s,t){try{localStorage.setItem(`${Kt}${s}`,t)}catch{}}function Xs(s){try{localStorage.removeItem(`${Kt}${s}`)}catch{}}const Zc=l.memo(function({contact:t,loginStatus:n,onLogin:a,className:r}){const[i,o]=l.useState(""),[u,c]=l.useState(!0),[g,d]=l.useState(null),[x,f]=l.useState(!1),h=l.useRef(null),m=l.useRef(!0),j=t.public_key,w=l.useRef(j);w.current!==j&&(w.current=j,f(!1),d(null),o("")),l.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]),l.useEffect(()=>{if(x||n==="success")return;const R=Xc(j);if(!R){f(!0);return}f(!0),(async()=>{const v=await a(j,R);m.current&&(v||(Xs(j),d("Saved password rejected — please re-enter.")))})()},[j,x,n,a]);const y=l.useCallback(async()=>{d(null);const R=await a(j,i);m.current&&(R?u&&i?Yc(j,i):Xs(j):d("Login failed — check your password and try again."))},[j,i,u,a]),E=l.useCallback(R=>{R.key==="Enter"&&(R.preventDefault(),y())},[y]),I=n==="pending";return I&&!i?e.jsxs("div",{className:M("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(le.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:M("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(xt,{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."})]})]}),(g||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(kn,{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:g||"Login failed — check your password and try again."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{ref:h,type:"password",value:i,onChange:R=>o(R.target.value),onKeyDown:E,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=>c(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:y,children:[I?e.jsx(ce,{"data-slot":"icon",className:"animate-spin"}):e.jsx(Et,{"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 Ys(s,t){return[s,t].sort().join("-")}function it(s){return s.substring(0,2)}function ed(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 td(s,t,n,a){const{edgeMap:r}=n;if(r.size===0)return null;const i=new Map;for(const[,v]of r){const _=v.fromHash,$=v.toHash;i.has(_)||i.set(_,[]),i.has($)||i.set($,[]),i.get(_).push({neighbor:$,edge:v}),i.get($).push({neighbor:_,edge:v})}const o=new Set(i.keys()),u=Zs(s,o),c=Zs(t,o);if(!u||!c||u===c)return null;const g=new Map,d=new Map,x=new Set,f=[];for(g.set(u,0),d.set(u,null),f.push({node:u,cost:0});f.length>0;){f.sort(($,k)=>$.cost-k.cost);const v=f.shift();if(x.has(v.node))continue;if(x.add(v.node),v.node===c)break;const _=i.get(v.node)??[];for(const{neighbor:$,edge:k}of _){if(x.has($))continue;const p=ed(k),b=v.cost+1/p,S=g.get($)??1/0;b{var F,C;const $=it(v),k=j.get($);let p=0;const b=h[_],S=Ys(b,v),N=r.get(S);return(C=(F=N==null?void 0:N.traceQuality)==null?void 0:F.composite)!=null&&C.mean?p=N.traceQuality.composite.mean:(N==null?void 0:N.avgSnr)!=null&&(p=N.avgSnr),{hash:v,prefix:$,name:(k==null?void 0:k.name)||null,snr:p}});let E=0,I=0;for(let v=0;v0?E/I:0;return{hops:w.map(it),confidence:R,via:y}}function Zs(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 c=0;cr&&(r=o,a=i)}return a}function en(s){switch(s&15){case 1:return"Companion";case 2:return"Repeater";case 3:return"Room Server";default:return"Unknown"}}function tn(s){switch(s&15){case 1:return"blue";case 2:return"green";case 3:return"indigo";default:return"zinc"}}function sd(s){return(s&15)===2}const sn=l.memo(function({contact:t,channel:n,contacts:a=[],selfPubKey:r,embedded:i=!1,onResetPath:o,onRequestStatus:u,onRequestTelemetry:c,onLoginToRepeater:g,onLogoutFromRepeater:d,onGetNeighbours:x,onTraceContactPath:f,onDiscoverPath:h,onExportContact:m,onSetContactPath:j,className:w}){const[y,E]=l.useState({}),I=(t==null?void 0:t.public_key)??null,[R,v]=l.useState(I);if(I!==R&&(v(I),E({})),!t&&!n)return i?null:e.jsx("div",{className:M("flex items-center justify-center h-full",w),children:e.jsx("p",{className:"text-sm text-fg-muted",children:"Select a conversation"})});async function _(b,S){E(F=>({...F,[b]:"loading"}));const N=await S();E(F=>({...F,[b]:N?"done":"error"})),setTimeout(()=>E(F=>({...F,[b]:"idle"})),2e3)}const $=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(Le,{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(De,{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,k=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(id,{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(an,{pubkey:t.public_key})]}),e.jsx(De,{color:tn(t.adv_type),children:en(t.adv_type)})]})]}),i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{color:tn(t.adv_type),children:en(t.adv_type)}),e.jsx(an,{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>=0?(()=>{const b=Ft(t.out_path_len);return b.hopCount>0?`${b.hopCount} hop${b.hopCount===1?"":"s"} · ${b.hashSize}B`:"direct"})():"unknown"})]}),(t.gps_lat!==0||t.gps_lon!==0)&&e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx(Cn,{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(Sn,{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(cd,{contact:t,contacts:a,selfPubKey:r,onSetContactPath:j,onDiscoverPath:h,actionState:y,setActionState:E,runAction:_}),e.jsxs("div",{className:"space-y-2 pt-2 border-t border-edge-subtle",children:[e.jsxs(U,{color:y.reset==="done"?"success":y.reset==="error"?"danger":"primary",outline:!0,className:"w-full justify-center",disabled:y.reset==="loading",onClick:()=>_("reset",()=>o(t.public_key)),children:[e.jsx(wn,{"data-slot":"icon"}),y.reset==="loading"?"Resetting…":y.reset==="done"?"Reset!":"Reset Path"]}),e.jsxs(U,{color:y.status==="done"?"success":y.status==="error"?"danger":"primary",outline:!0,className:"w-full justify-center",disabled:y.status==="loading",onClick:()=>_("status",()=>u(t.public_key)),children:[e.jsx(In,{"data-slot":"icon"}),y.status==="loading"?"Requesting…":"Request Status"]}),e.jsxs(U,{color:y.telemetry==="done"?"success":y.telemetry==="error"?"danger":"primary",outline:!0,className:"w-full justify-center",disabled:y.telemetry==="loading",onClick:()=>_("telemetry",()=>c(t.public_key)),children:[e.jsx(_n,{"data-slot":"icon"}),y.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(Lt,{"data-slot":"icon"}),"Export Contact"]}),sd(t.adv_type)&&e.jsxs(e.Fragment,{children:[e.jsx(dd,{pubkey:t.public_key,onLogin:g,onLogout:d,actionState:y,runAction:_}),e.jsx(ud,{pubkey:t.public_key,onGetNeighbours:x,actionState:y,runAction:_}),e.jsx(md,{pubkey:t.public_key,contact:t,onTrace:f,actionState:y,runAction:_})]}),e.jsx(nd,{pubkey:t.public_key}),e.jsx(ld,{pubkey:t.public_key})]}):null,p=$??k;return i?e.jsx("div",{className:w,children:p}):e.jsx("div",{className:M("flex flex-col h-full overflow-y-auto",w),children:e.jsx(ge,{mode:"wait",children:n?e.jsx(le.div,{variants:Wl,initial:"hidden",animate:"visible",exit:"exit",className:"p-4",children:$},`ch-${n.index}`):t?e.jsx(le.div,{variants:Ul,initial:"hidden",animate:"visible",exit:"exit",className:"p-4",children:k},`contact-${t.public_key}`):null})})});function nn(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 nd({pubkey:s}){const t=$r(s);return t?e.jsxs(_e,{defaultOpen:!0,className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Re,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(In,{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(Me,{children:e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsx(ee,{label:"Battery",value:`${(t.battMilliVolts/1e3).toFixed(2)}V`}),e.jsx(ee,{label:"Noise Floor",value:`${t.noiseFloor} dBm`}),e.jsx(ee,{label:"Last RSSI",value:`${t.lastRssi} dBm`}),e.jsx(ee,{label:"Last SNR",value:`${(t.lastSnr/4).toFixed(1)} dB`}),e.jsx(ee,{label:"Uptime",value:nn(t.totalUpTimeSecs)}),e.jsx(ee,{label:"Air Time",value:nn(t.totalAirTimeSecs)}),e.jsx(ee,{label:"TX Queue",value:String(t.currTxQueueLen)}),e.jsx(ee,{label:"Packets Rx",value:String(t.nPacketsRecv)}),e.jsx(ee,{label:"Packets Tx",value:String(t.nPacketsSent)}),e.jsx(ee,{label:"Flood Rx/Tx",value:`${t.nRecvFlood}/${t.nSentFlood}`}),e.jsx(ee,{label:"Direct Rx/Tx",value:`${t.nRecvDirect}/${t.nSentDirect}`}),e.jsx(ee,{label:"Dups (D/F)",value:`${t.nDirectDups}/${t.nFloodDups}`}),t.errEvents>0&&e.jsx(ee,{label:"Errors",value:String(t.errEvents)})]})})]}):null}function ee({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 ad(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 rd(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 ld({pubkey:s}){const t=Ar(s);if(!t)return null;const n=jo(t.lppSensorData);return n.length===0?null:e.jsxs(_e,{defaultOpen:!0,className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Re,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(_n,{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(Me,{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(ee,{label:`Ch${a.channel} GPS Lat`,value:a.value.latitude.toFixed(5)}),e.jsx(ee,{label:`Ch${a.channel} GPS Lon`,value:a.value.longitude.toFixed(5)}),e.jsx(ee,{label:`Ch${a.channel} GPS Alt`,value:`${a.value.altitude.toFixed(1)}m`})]},r):e.jsx(ee,{label:`Ch${a.channel} ${ad(a.type)}`,value:`${typeof a.value=="number"?a.value.toFixed(a.type===103||a.type===116?2:0):a.value}${rd(a.type)}`},r))})})]})}function id({contact:s}){const{emoji:t}=gt(s.name||""),n=yt(s.name||s.public_key),a=s.name?bt(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(Ge,{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(xt,{className:"size-7 text-sys-pink"})}):e.jsx("div",{className:M("w-14 h-14 clay-avatar",t?"text-2xl":"text-white text-lg font-bold"),style:{"--avatar-color":n},children:t||a})}function an({pubkey:s}){return Rr().get(s)!==!0?null:e.jsx("span",{title:"Ed25519 verified identity",children:e.jsx(ql,{className:"w-4 h-4 text-sys-green flex-shrink-0"})})}const St=64;function od(s,t=1){if(!s)return[];const n=[],a=t*2;for(let r=0;r=0?Ft(s.out_path_len):null,R=(I==null?void 0:I.hopCount)??0,v=R>0,_=od(s.out_path,I==null?void 0:I.hashSize),$=l.useCallback(async()=>{if(!a)return;const b=d.split(",").map(F=>F.trim()).filter(Boolean);if(b.length===0){h("Enter at least one hop");return}if(b.length>St){h(`Max ${St} hops`);return}if(!b.every(F=>/^[0-9a-fA-F]{1,2}$/.test(F))){h("Each hop must be 1-2 hex characters");return}h(null),o(F=>({...F,path:"loading"}));const N=await a(s.public_key,b);o(F=>({...F,path:N?"done":"error"})),N&&g(!1),setTimeout(()=>o(F=>({...F,path:"idle"})),2e3)},[a,d,s.public_key,o]),k=l.useCallback(()=>{if(!n){y("Self identity not available");return}const b=td(n,s.public_key,E,t);b?(j(b),y(null)):(j(null),y("No route found in topology"))},[n,s.public_key,E,t]),p=l.useCallback(async()=>{if(!a||!m)return;o(S=>({...S,path:"loading"}));const b=await a(s.public_key,m.hops);o(S=>({...S,path:b?"done":"error"})),b&&(j(null),y(null)),setTimeout(()=>o(S=>({...S,path:"idle"})),2e3)},[a,m,s.public_key,o]);return e.jsxs(_e,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Re,{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:v?`${R} hop${R>1?"s":""}`:"direct"})]}),e.jsx(Me,{children:e.jsxs("div",{className:"space-y-2 py-1",children:[_.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"}),_.map((b,S)=>e.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill font-mono text-[10px] text-fg-primary",children:b},S))]}),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(Fs,{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((b,S)=>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:b.prefix}),b.name&&e.jsxs("span",{className:"text-fg-muted",children:["(",b.name,")"]}),b.snr!==0&&e.jsx("span",{className:M("font-mono",dt(b.snr)),children:b.snr.toFixed(1)})]},S))}),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:p,children:[e.jsx(be,{"data-slot":"icon"}),i.path==="loading"?"Saving…":"Accept"]}),e.jsxs(U,{plain:!0,className:"text-xs",onClick:()=>{j(null),y(null)},children:[e.jsx(ht,{"data-slot":"icon"}),"Dismiss"]})]})]}),w&&!m&&e.jsx("p",{className:"text-[9px] text-sys-amber",children:w}),a&&!m&&e.jsx("div",{className:"flex items-center gap-2",children:c?e.jsxs("div",{className:"space-y-1.5 flex-1",children:[e.jsx("input",{type:"text",value:d,onChange:b=>{x(b.target.value),h(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 ",St,")"]}),f&&e.jsx("p",{className:"text-[9px] text-sys-red",children:f}),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"||!d.trim(),onClick:$,children:[e.jsx(Vl,{"data-slot":"icon"}),i.path==="loading"?"Saving…":"Save"]}),e.jsx(U,{plain:!0,className:"text-xs",onClick:()=>{g(!1),h(null)},children:"Cancel"})]})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{g(!0),x(_.length>0?_.join(", "):""),h(null)},className:"text-[10px] text-sys-blue hover:text-sys-blue/80 transition-colors",children:"Edit path…"}),n&&E.edgeMap.size>0&&e.jsxs("button",{onClick:k,className:"inline-flex items-center gap-0.5 text-[10px] text-sys-indigo hover:text-sys-indigo/80 transition-colors",children:[e.jsx(Fs,{className:"w-3 h-3"}),"Auto-route"]}),r&&e.jsxs("button",{onClick:()=>u("discover",()=>r(s.public_key)),disabled:i.discover==="loading",className:M("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(Jl,{className:"w-3 h-3"}),i.discover==="loading"?"Discovering…":i.discover==="done"?"Discovered!":i.discover==="error"?"Failed":"Discover"]})]})})]})})]})}function dd({pubkey:s,onLogin:t,onLogout:n,actionState:a,runAction:r}){const[i,o]=l.useState(""),u=Ot(s);return t?e.jsxs(_e,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Re,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(Et,{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(De,{color:u==="success"?"green":u==="failed"?"red":"amber",className:"ml-auto text-[9px]",children:u})]}),e.jsx(Me,{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(Er,{"data-slot":"icon"}),a.logout==="loading"?"Disconnecting…":"Disconnect"]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"password",value:i,onChange:c=>o(c.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(Et,{"data-slot":"icon"}),a.login==="loading"?"Logging in…":"Login"]})]})})})]}):null}function ud({pubkey:s,onGetNeighbours:t,actionState:n,runAction:a}){const r=Pr(s),i=Ot(s);return t?e.jsxs(_e,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Re,{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(Me,{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:xd(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:M("h-full rounded-full",pd(o.snr)),style:{width:`${Math.min(100,Math.max(5,(o.snr+20)/35*100))}%`}})}),e.jsx("span",{className:M("font-mono text-[9px] w-8 text-right",dt(o.snr)),children:o.snr.toFixed(1)})]})]},u))})]})})]}):null}function md({pubkey:s,contact:t,onTrace:n,actionState:a,runAction:r}){const i=Tr(s);if(!n)return null;const o=t.out_path_len>=0&&Ft(t.out_path_len).hopCount>0;return e.jsxs(_e,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Re,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(Os,{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.hopCount," hops"]})]}),e.jsx(Me,{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(Os,{"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,c)=>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:c+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:M("font-mono text-[10px] ml-auto",dt(u.snr)),children:[u.snr.toFixed(1)," dB"]})]},c)),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:M("font-mono text-[10px]",dt(i.lastSnr)),children:[i.lastSnr.toFixed(1)," dB"]})]})]})]})})]})}function dt(s){return s>5?"text-sys-green":s>0?"text-sys-amber":"text-sys-red"}function pd(s){return s>5?"bg-sys-green":s>0?"bg-sys-amber":"bg-sys-red"}function xd(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 rn=128,ln=/^[0-9a-fA-F]+$/;function hd({open:s,onClose:t}){const n=se(C=>C.exportPrivateKey),a=se(C=>C.importPrivateKey),[r,i]=l.useState("export"),[o,u]=l.useState(null),[c,g]=l.useState(!1),[d,x]=l.useState(!1),[f,h]=l.useState(""),[m,j]=l.useState(!1),[w,y]=l.useState(!1),[E,I]=l.useState(!1),[R,v]=l.useState(!1),[_,$]=l.useState(null),[k,p]=l.useState(!1);s!==k&&(p(s),s&&(i("export"),u(null),g(!1),x(!1),h(""),j(!1),y(!1),I(!1),v(!1),$(null)));const b=l.useCallback(async()=>{g(!0),$(null),v(!1);try{const C=await n();C==="disabled"?v(!0):u(C.hex)}catch(C){$(C instanceof Error?C.message:"Export failed")}finally{g(!1)}},[n]),S=l.useCallback(async()=>{if(o)try{await navigator.clipboard.writeText(o),x(!0),setTimeout(()=>x(!1),2e3)}catch{$("Failed to copy to clipboard")}},[o]),N=f.length===rn&&ln.test(f),F=l.useCallback(async()=>{y(!1),j(!0),$(null),v(!1);try{await a(f)==="disabled"?v(!0):I(!0)}catch(C){$(C instanceof Error?C.message:"Import failed")}finally{j(!1)}},[a,f]);return e.jsxs(e.Fragment,{children:[e.jsxs(we,{open:s,onClose:t,size:"md",solid:!0,children:[e.jsx(Ee,{icon:e.jsx(Mn,{className:"w-5 h-5"}),title:"Key Management",onClose:t}),e.jsxs(ke,{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(Fr,{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),$(null)},className:M("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(Lt,{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:S,className:"absolute top-2 right-2 p-1.5 rounded-md hover:bg-subtle-fill-strong transition-colors",title:"Copy to clipboard",children:d?e.jsx(be,{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(Ce,{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:b,disabled:c||R,children:c?"Exporting…":"Export Private Key"})]})}),r==="import"&&e.jsx("div",{className:"space-y-4",children:E?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(be,{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:f,onChange:C=>h(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(Ce,{children:[f.length>0&&!N&&e.jsx("span",{className:"text-sys-red",children:ln.test(f)?`${f.length}/${rn} characters`:"Invalid characters — hex only (0-9, a-f)"}),f.length>0&&N&&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."]})]})]})}),_&&e.jsx("p",{className:"type-data-xs text-sys-red mt-3",children:_})]}),e.jsxs(Pe,{children:[e.jsx(U,{plain:!0,onClick:t,children:"Close"}),r==="import"&&!E&&e.jsx(U,{color:"danger",onClick:()=>y(!0),disabled:!N||m||R,children:m?"Importing…":"Import Key"})]})]}),e.jsx(Rn,{isOpen:w,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:F,onCancel:()=>y(!1)})]})}function xa(s){return s.settings??{}}const ha="pymc_companion_recent_regions",qt=8;function fa(){try{const s=localStorage.getItem(ha);return s?JSON.parse(s).slice(0,qt):[]}catch{return[]}}function fd(s){try{localStorage.setItem(ha,JSON.stringify(s.slice(0,qt)))}catch{}}function gd(s){const t=fa().filter(a=>a!==s);t.unshift(s);const n=t.slice(0,qt);return fd(n),n}function on(s){return s.toLowerCase().replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}function yd({open:s,onClose:t,mode:n,identity:a,onSave:r}){const i=n==="edit"&&a,[o,u]=l.useState(""),[c,g]=l.useState(""),[d,x]=l.useState(""),[f,h]=l.useState(!1),[m,j]=l.useState(""),[w,y]=l.useState(5e3),[E,I]=l.useState("0.0.0.0"),[R,v]=l.useState(!1),[_,$]=l.useState(null),[k,p]=l.useState(""),b=`${s}-${(a==null?void 0:a.name)??""}-${n}`;if(b!==k)if(p(b),$(null),v(!1),h(!1),i){const N=xa(a);u(a.name),g(""),x(a.identity_key??""),j(N.node_name??a.name),y(N.tcp_port??5e3),I(N.bind_address??"0.0.0.0")}else u(""),g(""),x(""),j(""),y(5e3),I("0.0.0.0");const S=l.useCallback(async()=>{var N,F;if(!i&&!o.trim()){$("Name is required");return}v(!0),$(null);try{if(i){const C={name:a.name,new_name:c,identity_key:d,type:"companion",settings:{node_name:m,tcp_port:w,bind_address:E}},L=await Ur(C);if(!L.success&&!((N=L.data)!=null&&N.message))throw new Error(L.error||"Failed")}else{const C={name:o.trim(),identity_key:d,type:"companion",settings:{node_name:m||o.trim(),tcp_port:w??5e3,bind_address:E||"0.0.0.0"}},L=await Gr(C);if(!L.success&&!((F=L.data)!=null&&F.message))throw new Error(L.error||"Failed")}await r(),t()}catch(C){$(C instanceof Error?C.message:"Operation failed")}finally{v(!1)}},[i,a,o,c,d,m,w,E,r,t]);return e.jsxs(we,{open:s,onClose:t,size:"md",solid:!0,children:[e.jsx(Ee,{icon:i?void 0:e.jsx(ye,{className:"w-5 h-5"}),title:i?"Edit Companion":"Add Companion",onClose:t}),e.jsx(ke,{children:e.jsxs("div",{className:"space-y-5",children:[i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{color:a.registered?"green":"red",children:a.registered?"Configured":"Not registered"}),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(me,{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(me,{value:c,onChange:N=>g(N.target.value),placeholder:"Leave empty to keep current name"})]})]}):e.jsxs(ie,{children:[e.jsx(oe,{children:"Name"}),e.jsx(me,{value:o,onChange:N=>u(N.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:()=>h(N=>!N),className:"type-data-xs text-fg-muted underline hover:text-fg-secondary",children:f?"Hide":"Show"})]}),f&&e.jsxs(e.Fragment,{children:[e.jsx(me,{value:d,onChange:N=>x(N.target.value),placeholder:i?"Leave empty to keep current key":"Leave empty to auto-generate",className:"font-mono"}),e.jsx(Ce,{children:"32 or 64 bytes hex."})]})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Node Name"}),e.jsx(me,{value:m,onChange:N=>j(N.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(me,{type:"number",min:1,max:65535,value:w,onChange:N=>y(parseInt(N.target.value,10)||5e3)})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Bind Address"}),e.jsx(me,{value:E,onChange:N=>I(N.target.value),placeholder:"0.0.0.0"})]})]}),_&&e.jsx("p",{className:"type-data-xs text-sys-red",children:_})]})}),e.jsxs(Pe,{children:[e.jsx(U,{plain:!0,onClick:t,children:"Cancel"}),e.jsx(U,{color:"primary",onClick:S,disabled:R,children:R?"Saving…":i?"Save":"Create"})]})]})}function bd(){const s=Br(),t=jn(),{setFloodScope:n,clearFloodScope:a}=se.getState(),[r,i]=l.useState(""),[o,u]=l.useState(!1),[c,g]=l.useState(fa),[d,x]=l.useState(null),f=l.useRef(null),h=r.trim()?on(r.trim()):"",m=l.useCallback(async y=>{const E=on(y);if(!E)return;u(!0),x(null),i(""),g(gd(E)),await n(E)||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]),w=l.useCallback(y=>{y.key==="Enter"&&h&&(y.preventDefault(),m(h))},[h,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(Ke,{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(En,{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(Cn,{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(ht,{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(Wr,{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:f,type:"text",value:r,onChange:y=>i(y.target.value),onKeyDown:w,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(h),disabled:!h||o||!t,children:[o?e.jsx(ce,{"data-slot":"icon",className:"animate-spin"}):null,"Set"]})]}),h&&h!==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:["#",h]})]})]}),c.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(Sn,{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:c.map(y=>e.jsx("button",{onClick:()=>m(y),disabled:o||!t,className:M("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",y===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:["#",y]})},y))})]}),!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."}),d&&e.jsx("p",{className:"type-data-xs text-sys-red",children:d})]})}function cn({open:s,onClose:t,onRefresh:n}){const[a,r]=l.useState("companions"),[i,o]=l.useState(null),[u,c]=l.useState(!0),[g,d]=l.useState(!1),[x,f]=l.useState("create"),[h,m]=l.useState(null),[j,w]=l.useState(null),[y,E]=l.useState(!1),[I,R]=l.useState(!1),v=l.useRef(!0);l.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const[_,$]=l.useState(!1);s!==_&&($(s),s&&r("companions"));const k=l.useCallback(async()=>{c(!0);try{const A=await Or();v.current&&A.success&&A.data&&o(A.data)}catch{}finally{v.current&&c(!1)}},[]);l.useEffect(()=>{s&&k()},[s,k]);const p=(i==null?void 0:i.configured_companions)??[],b=l.useCallback(async()=>{await k(),n==null||n()},[k,n]),S=l.useCallback(async()=>{if(j){E(!0);try{await Dr(j.name,"companion"),await b()}catch{}finally{v.current&&(E(!1),w(null))}}},[j,b]),N=Lr(),F=vn(),{setCompanionPaused:C}=se.getState(),[L,q]=l.useState({});l.useEffect(()=>{if(!(i!=null&&i.configured_companions))return;const A={};for(const D of i.configured_companions)A[D.name]=zr(D.name);q(A)},[i]);const T=l.useCallback(A=>A===F?N:L[A]??!1,[F,N,L]),[O,G]=l.useState(null),H=l.useCallback(async(A,D)=>{G(A);try{await C(A,!D),q(z=>({...z,[A]:!D}))}finally{v.current&&G(null)}},[C]);return e.jsxs(e.Fragment,{children:[e.jsxs(we,{open:s,onClose:t,size:"md",solid:!0,children:[e.jsx(Ee,{icon:e.jsx(ye,{className:"w-5 h-5"}),title:"Companion Configuration",onClose:t}),e.jsxs(ke,{children:[e.jsx("div",{className:"flex gap-1 mb-4 p-0.5 rounded-lg bg-subtle-fill",children:[["companions","Companions",ye],["transport","Transport Key",En]].map(([A,D,z])=>e.jsxs("button",{onClick:()=>r(A),className:M("flex-1 flex items-center justify-center gap-1.5 py-1.5 px-3 rounded-md text-sm font-medium transition-colors",a===A?"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"}),D]},A))}),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.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 rounded-lg border border-sys-blue/10 bg-sys-blue/5 p-3",children:[e.jsx(Ke,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-sys-blue"}),e.jsx("p",{className:"type-data-xs text-fg-muted",children:"This switch only controls openHop Console's browser companion session. Turning it off releases the browser frame connection so external apps can connect; it does not stop the companion identity or companion service from working in the repeater."})]}),p.map(A=>{const D=xa(A),z=T(A.name),W=O===A.name;return e.jsxs("div",{className:M("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:M("h-2 w-2 rounded-full flex-shrink-0",z?"bg-fg-muted":"bg-sys-blue")}),e.jsx("h3",{className:"type-body-sm text-fg-primary font-medium truncate flex-1",children:A.name}),e.jsx(De,{color:z?"zinc":"blue",children:z?"Browser off":"Browser on"}),e.jsx(U,{color:"primary",plain:!0,onClick:()=>{m(A),f("edit"),d(!0)},children:e.jsx(Ql,{"data-slot":"icon"})}),e.jsx(Hr,{enabled:!z,onChange:J=>H(A.name,J),size:"sm",disabled:W,status:W?"loading":"idle",tooltip:z?"Allow Console to connect in this browser":"Release Console browser connection for external apps",dangerOff:!0}),e.jsx(U,{color:"danger",plain:!0,onClick:()=>w(A),children:e.jsx(Qe,{"data-slot":"icon"})})]}),e.jsxs("div",{className:"mt-1.5 type-data-xs text-fg-muted pl-5",children:[D.node_name||A.name," · Port ",D.tcp_port??5e3," · ",D.bind_address||"0.0.0.0"," · ",z?"external apps can connect":"external apps cannot use this companion while Browser on"]})]},A.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(ye,{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(bd,{})]}),e.jsxs(Pe,{children:[a==="companions"&&e.jsx(U,{plain:!0,onClick:()=>R(!0),title:"Key Management",children:e.jsx(Mn,{"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),f("create"),d(!0)},children:[e.jsx(Xe,{"data-slot":"icon"})," Add Companion"]})]})]}),e.jsx(yd,{open:g,onClose:()=>d(!1),mode:x,identity:h,onSave:b}),e.jsx(Rn,{isOpen:!!j,title:"Delete Companion",message:`Delete '${j==null?void 0:j.name}'? A service restart is required.`,confirmLabel:y?"Deleting…":"Delete",cancelLabel:"Cancel",variant:"danger",onConfirm:S,onCancel:()=>w(null)}),e.jsx(hd,{open:I,onClose:()=>R(!1)})]})}const vd=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))})}),Ue=[{value:"Chat Node",label:"Companions"},{value:"Room Server",label:"Room Servers"},{value:"Repeater",label:"Repeaters"}],jd=[{value:"all",label:"All time"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function Nd(s){switch(s){case"24h":return 24;case"7d":return 168;case"30d":return 720;default:return}}function wd({open:s,onClose:t,companionName:n,onImport:a}){const[r,i]=l.useState(()=>new Set(Ue.map(R=>R.value))),[o,u]=l.useState("all"),[c,g]=l.useState(""),[d,x]=l.useState(!1),[f,h]=l.useState(null),[m,j]=l.useState(s);s!==m&&(j(s),s&&(i(new Set(Ue.map(R=>R.value))),u("all"),g(""),x(!1),h(null)));const w=r.size===Ue.length;function y(R){i(v=>{const _=new Set(v);return _.has(R)?_.delete(R):_.add(R),_})}function E(){i(w?new Set:new Set(Ue.map(R=>R.value)))}const I=l.useCallback(async()=>{if(!(r.size===0||d)){x(!0),h(null);try{const R={types:[...r],hours:Nd(o)},v=parseInt(c,10);v>0&&(R.limit=v);const _=await a(R);h(_)}finally{x(!1)}}},[r,o,c,d,a]);return e.jsxs(we,{open:s,onClose:t,size:"sm",children:[e.jsx(Ee,{title:"Import repeater contacts",onClose:t}),e.jsx(ke,{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(Rs,{checked:w,indeterminate:r.size>0&&!w,onChange:E,label:"All types",size:"sm"}),e.jsx("div",{className:"ml-6 space-y-1.5",children:Ue.map(R=>e.jsx(Rs,{checked:r.has(R.value),onChange:()=>y(R.value),label:R.label,size:"sm"},R.value))})]})]}),e.jsx(lo,{label:"Recency",value:o,onChange:u,options:jd,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(me,{type:"number",min:1,value:c,onChange:R=>g(R.target.value),placeholder:"No limit",className:"mt-1"}),e.jsx(Ce,{children:"Leave empty for no cap."})]}),f&&e.jsxs("p",{className:"text-sm text-sys-green font-medium",children:["Imported ",f.added," new contact",f.added!==1?"s":""," (",f.total," total)"]})]})}),e.jsxs(Pe,{children:[e.jsx(U,{plain:!0,onClick:t,children:"Cancel"}),e.jsx(U,{color:"primary",onClick:I,disabled:d||r.size===0,children:d?e.jsxs(e.Fragment,{children:[e.jsx(ce,{"data-slot":"icon",className:"animate-spin"}),"Importing…"]}):"Import"})]})]})}const kd=["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"],Cd=new Set(kd);function Sd(){return crypto.getRandomValues(new Uint8Array(16))}function dn(s){return Array.from(s).map(t=>t.toString(16).padStart(2,"0")).join("")}function It(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 Id(s){const n=`#${Nn(s)}`,a=new TextEncoder().encode(n);return(await Kr(a)).slice(0,16)}const un=[{key:"create-private",label:"Create Private",icon:Fl,desc:"Generate a new private channel with a random key"},{key:"join-private",label:"Join Private",icon:Ui,desc:"Join an existing private channel using a shared key"},{key:"join-hashtag",label:"Join Hashtag",icon:Le,desc:"Join a public hashtag channel (key derived from name)"}];function _d({open:s,onClose:t,channels:n,onAddChannel:a}){var S;const[r,i]=l.useState("join-hashtag"),[o,u]=l.useState(""),[c,g]=l.useState(""),[d,x]=l.useState(null),[f,h]=l.useState(!1),[m,j]=l.useState(""),[w,y]=l.useState(!1),[E,I]=l.useState(s);s!==E&&(I(s),s&&(i("join-hashtag"),u(""),g(""),x(null),h(!1),j(""),y(!1)));const R=l.useMemo(()=>n.length===0?0:Math.max(...n.map(N=>N.index))+1,[n]),v=l.useMemo(()=>r!=="join-hashtag"?"":Nn(o),[r,o]),_=l.useMemo(()=>{if(!o.trim())return null;const N=r==="join-hashtag"&&v?`#${v}`:o.trim();return n.find(F=>F.name===N)??null},[o,r,v,n]),$=l.useMemo(()=>r==="join-hashtag"&&v?Cd.has(v):!1,[r,v]),k=l.useMemo(()=>{if(!o.trim()||_)return!1;switch(r){case"create-private":return o.trim().length>0&&o.trim().length<=32;case"join-private":return o.trim().length>0&&It(c)!==null;case"join-hashtag":return v.length>0;default:return!1}},[r,o,c,v,_]),p=l.useCallback(async()=>{d&&(await navigator.clipboard.writeText(dn(d)),y(!0),setTimeout(()=>y(!1),2e3))},[d]),b=l.useCallback(async()=>{if(!(!k||f)){h(!0),j("");try{let N,F;switch(r){case"create-private":{N=Sd(),F=o.trim();break}case"join-private":{const L=It(c);if(!L){j("Invalid hex key (must be 32 hex chars = 16 bytes)");return}N=L,F=o.trim();break}case"join-hashtag":{N=await Id(o),F=`#${v}`;break}default:return}if(await a(R,F,N)){if(r==="create-private"){x(N);return}t()}else j("Failed to add channel — device may be unreachable")}catch(N){j(N instanceof Error?N.message:"Unknown error")}finally{h(!1)}}},[k,f,r,o,c,v,R,a,t]);return e.jsxs(we,{open:s,onClose:t,size:"sm",children:[e.jsx(Ee,{title:"Add Channel",onClose:t}),e.jsx(ke,{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:un.map(N=>{const F=N.icon,C=r===N.key;return e.jsxs("button",{onClick:()=>{i(N.key),j(""),x(null)},className:M("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(F,{className:"w-3.5 h-3.5"}),N.label]},N.key)})}),e.jsx("p",{className:"text-xs text-fg-muted",children:(S=un.find(N=>N.key===r))==null?void 0:S.desc}),d&&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:dn(d)}),e.jsx("button",{onClick:p,className:"p-1.5 rounded hover:bg-subtle-fill transition-colors flex-shrink-0",title:"Copy key",children:w?e.jsx(be,{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(me,{type:"text",value:o,onChange:N=>u(N.target.value),placeholder:r==="join-hashtag"?"e.g. south-bay":"e.g. My Channel",maxLength:32,className:"mt-1",disabled:!!d}),r==="join-hashtag"&&v&&v!==o&&e.jsxs(Ce,{className:"mt-1",children:["Will be registered as ",e.jsxs("code",{className:"text-fg-primary font-mono text-[11px]",children:["#",v]})]}),r==="join-hashtag"&&$&&e.jsx(Ce,{className:"mt-1 text-sys-green",children:"Known region channel"})]}),_&&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:_.name})," already exists at slot ",_.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(me,{type:"text",value:c,onChange:N=>g(N.target.value),placeholder:"e.g. a1b2c3d4e5f6...",maxLength:32,className:"mt-1 font-mono text-xs"}),c&&!It(c)&&e.jsx(Ce,{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(Pe,{children:[e.jsx(U,{plain:!0,onClick:t,children:d?"Done":"Cancel"}),!d&&e.jsx(U,{color:"primary",onClick:b,disabled:!k||f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"}),"Adding…"]}):r==="create-private"?"Create Channel":"Join Channel"})]})]})}const Rd=202,Md=/^[0-9a-fA-F]+$/;function Ed(s){const t=s.replace(/\s/g,"");return t.length>=Rd&&t.length%2===0&&Md.test(t)}const Pd=l.memo(function({open:t,onClose:n,contacts:a,exportPubKey:r,onExport:i,onImport:o}){const[u,c]=l.useState(r?"export":"import"),[g,d]=l.useState(r??""),[x,f]=l.useState(""),[h,m]=l.useState(""),[j,w]=l.useState(!1),[y,E]=l.useState(!1),[I,R]=l.useState(!1),[v,_]=l.useState(null),[$,k]=l.useState(!1),p=l.useRef(null);l.useEffect(()=>{t&&(c(r?"export":"import"),d(r??""),f(""),m(""),w(!1),E(!1),R(!1),_(null),k(!1))},[t,r]);const b=l.useCallback(()=>{n()},[n]),S=l.useCallback(async()=>{if(!g)return;w(!0),_(null),f("");const C=await i(g);w(!1),C?f(C):_("Failed to export contact advert")},[g,i]),N=l.useCallback(async()=>{if(x)try{await navigator.clipboard.writeText(x),R(!0),setTimeout(()=>R(!1),2e3)}catch{_("Failed to copy to clipboard")}},[x]),F=l.useCallback(async()=>{const C=h.replace(/\s/g,"");if(!Ed(C)){_("Invalid hex — must be at least 202 hex characters (101 bytes)");return}E(!0),_(null);const L=await o(C);E(!1),L?(k(!0),m(""),setTimeout(()=>b(),1500)):_("Import failed — check the hex string and try again")},[h,o,b]);return e.jsxs(we,{open:t,onClose:b,children:[e.jsx(qr,{children:"Contact Import / Export"}),e.jsxs(ke,{children:[e.jsxs("div",{className:"flex gap-1 p-0.5 rounded-lg bg-subtle-fill mb-4",children:[e.jsxs("button",{onClick:()=>{c("export"),_(null)},className:M("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(Lt,{className:"w-3.5 h-3.5"}),"Export"]}),e.jsxs("button",{onClick:()=>{c("import"),_(null)},className:M("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:g,onChange:C=>{d(C.target.value),f(""),_(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:!g||j,onClick:S,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:N,children:[I?e.jsx(be,{"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:h,onChange:C=>{m(C.target.value),_(null),k(!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"})]}),$&&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(be,{className:"w-3.5 h-3.5"}),"Contact imported successfully"]}),e.jsx(U,{color:"primary",outline:!0,className:"w-full justify-center",disabled:!h.trim()||y,onClick:F,children:y?"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(kn,{className:"w-3.5 h-3.5 flex-shrink-0"}),v]})]}),e.jsx(Pe,{children:e.jsx(U,{plain:!0,onClick:b,children:"Close"})})]})});function yu(){var gs,ys,bs,vs,js,Ns;const s=Vr(),t=vn(),n=Jr(),a=Qr(),r=Xr(),i=Yr(),o=ft(),u=Zr(),c=el(),g=tl(),d=yn(),x=sl(),f=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]),h=l.useMemo(()=>{const P=new Map;if(!(x!=null&&x.neighbors))return P;const B=[];for(const[V,de]of Object.entries(x.neighbors))de.zero_hop&&de.rssi!=null&&de.snr!=null&&de.rssi!==0&&B.push({hash:(V.startsWith("0x")?V.slice(2):V).toLowerCase(),rssi:de.rssi,snr:de.snr,advertCount:de.advert_count??1});if(B.length===0)return P;for(const V of f){const de=V.public_key.toLowerCase();for(const fe of B)if(de===fe.hash||de.startsWith(fe.hash)){P.set(V.public_key,{rssi:fe.rssi,snr:fe.snr,advertCount:fe.advertCount});break}}return P},[x==null?void 0:x.neighbors,f]),m=nl(),j=al(),w=jn(),y=rl(),E=ll(t),I=il(),R=ol(),v=cl(),_=dl(),$=ul(),[k,p]=ml(),[b,S]=l.useState(!1),[N,F]=l.useState(!1),[C,L]=l.useState(!1),[q,T]=l.useState(!1),[O,G]=l.useState(null),[H,A]=l.useState(!1),[D,z]=l.useState(!1),[W,J]=l.useState(!0),ve="pymc_companion_contacts_micro",Te="pymc_companion_split",[ze,ga]=l.useState(()=>{try{return localStorage.getItem(ve)==="1"}catch{return!1}}),Vt=25,Jt=75,[Nt,Qt]=l.useState(()=>{try{const P=Number(localStorage.getItem(Te));return P>=Vt&&P<=Jt?P:50}catch{return 50}}),et=l.useRef(null),He=l.useRef(null),Xt=l.useRef(null),tt=l.useRef(!1),Be=l.useRef(Nt);Be.current=Nt;const ya=l.useCallback(P=>{P.preventDefault(),P.target.setPointerCapture(P.pointerId),tt.current=!0},[]),ba=l.useCallback(P=>{if(!tt.current||!et.current)return;const B=et.current.getBoundingClientRect(),V=Math.round(Math.min(Jt,Math.max(Vt,(P.clientX-B.left)/B.width*100)));Be.current=V,He.current&&(He.current.style.width=`${V}%`)},[]),Yt=l.useCallback(()=>{if(!tt.current)return;tt.current=!1;const P=Be.current;Qt(P);try{localStorage.setItem(Te,String(P))}catch{}},[]),va=l.useCallback(()=>{Be.current=50,He.current&<(He.current,{width:"50%"},re.layoutResize),Qt(50);try{localStorage.setItem(Te,String(50))}catch{}},[]),ja=l.useCallback(P=>{if(ga(P),typeof window<"u"&&window.innerWidth<768)return;const B=et.current,V=Xt.current;if(!B)return;const de=B.getBoundingClientRect().width;B.style.width=P?"var(--companion-side-micro)":"var(--companion-side)";const fe=B.getBoundingClientRect().width;if(B.style.width=`${de}px`,V){const Ua=P?56:Be.current/100*fe,Ga=V.offsetWidth,Ka=Math.max(0,fe-Ua-12);V.style.flex="none",V.style.width=`${Ga}px`,lt(V,{width:`${Ka}px`},{...re.layoutResize,onComplete(){V.style.flex="",V.style.width=""}})}lt(B,{width:`${fe}px`},{...re.layoutResize,onComplete(){B.style.width=P?"var(--companion-side-micro)":"var(--companion-side)"}})},[]),{selectCompanion:Na,selectConversation:je,sendMessage:Zt,sendChannelMessage:es,retryMessage:wa,retryMessageAsFlood:ka,resetPath:wt,shareContact:Ca,removeContact:Sa,addChannel:Ia,requestStatus:ts,requestTelemetry:ss,loginToRepeater:kt,logoutFromRepeater:ns,getNeighbours:as,traceContactPath:rs,discoverPath:ls,pingContact:_a,markAsRead:is,fetchCompanions:os,seedFromRepeater:Ra,exportContactAdvert:Ma,importContactAdvert:Ea,setContactPath:cs,deleteChannel:Pa,loadOlderMessages:Ta}=se.getState(),$a=l.useCallback(P=>{je(P),window.innerWidth>=1280?A(!0):z(!0)},[je]),ds=se(P=>P.messages),us=se(P=>P.unreadMap);l.useEffect(()=>{is()},[m,is]),l.useEffect(()=>{const P=k.get("dm");P&&f.length>0&&f.find(V=>V.public_key===P)&&(je({type:"contact",id:P}),p({},{replace:!0}))},[k,f,je,p]);const Aa=l.useMemo(()=>{const P=new Set;for(const B of f)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,V)=>B.localeCompare(V))},[f,j]),ms=l.useMemo(()=>{const P=new Map;for(const B of f)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 V=B.sender_name.toLowerCase();P.has(V)||P.set(V,B.sender_key)}return P},[f,j]),Fa=l.useCallback(P=>{const B=ms.get(P.toLowerCase());B&&(je({type:"contact",id:B}),A(!0))},[ms,je]),Oa=l.useCallback(async P=>m?m.type==="channel"?es(Number(m.id),P):Zt(m.id,P):!1,[m,Zt,es]),Da=w&&!I,ps=v!=null&&(v.adv_type&15)===3,xs=Ot(ps?v.public_key:null),La=ps&&xs!=="success",hs=pl(),[ue,$e]=l.useState("idle"),za=l.useCallback(async()=>{$e("flood-sending");const P=await se.getState().sendFloodAdvert();$e(P?"flood-done":"idle"),P&&setTimeout(()=>$e(B=>B==="flood-done"?"idle":B),2e3)},[]),Ha=l.useCallback(async()=>{$e("zero-sending");const P=await se.getState().sendZeroHopAdvert();$e(P?"zero-done":"idle"),P&&setTimeout(()=>$e(B=>B==="zero-done"?"idle":B),2e3)},[]),Ba=e.jsxs("div",{className:"flex items-center gap-2",children:[w&&n&&e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsxs("button",{onClick:za,disabled:ue!=="idle"&&ue!=="zero-done",className:M("inline-flex items-center gap-1.5 sm:gap-2 px-2.5 sm:px-3.5 py-1.5 sm: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",ue==="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:[ue==="flood-sending"?e.jsx(ce,{className:"w-4 h-4 animate-spin"}):e.jsx(Yi,{className:"w-4 h-4"}),ue==="flood-done"?e.jsx("span",{children:"Sent!"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline",children:"Flood Advert"}),e.jsx("span",{className:"sm:hidden",children:"Flood"})]})]}),e.jsxs("button",{onClick:Ha,disabled:ue!=="idle"&&ue!=="flood-done",className:M("inline-flex items-center gap-1.5 sm:gap-2 px-2.5 sm:px-3.5 py-1.5 sm: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",ue==="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:[ue==="zero-sending"?e.jsx(ce,{className:"w-4 h-4 animate-spin"}):e.jsx(On,{className:"w-4 h-4"}),ue==="zero-done"?e.jsx("span",{children:"Sent!"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline",children:"Local Advert"}),e.jsx("span",{className:"sm:hidden",children:"Local"})]})]})]}),e.jsx("button",{onClick:()=>xl.getState().toggleFocusMode(),className:"hidden lg:flex p-1.5 hover:bg-subtle-fill rounded transition-colors",title:hs?"Collapse view":"Expand view",children:hs?e.jsx(Gl,{className:"w-4 h-4 text-fg-muted"}):e.jsx(Kl,{className:"w-4 h-4 text-fg-muted"})})]}),Wa=e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[e.jsx(ge,{children:g.length>0&&e.jsx(le.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:re.fade,className:"flex items-center gap-1 overflow-hidden",children:g.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(Ge,{className:"w-2.5 h-2.5"}),P.name]},P.pubHex))},"advert-notifs")}),e.jsx(ge,{children:y?e.jsxs(le.span,{initial:{opacity:0,scale:.9,width:0},animate:{opacity:1,scale:1,width:"auto"},exit:{opacity:0,scale:.9,width:0},transition:re.fade,className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-sys-blue/10 text-[11px] text-sys-blue font-medium whitespace-nowrap overflow-hidden",title:E!=null&&E.clientIp?`Another client (${E.clientIp}) is attached to this companion. Connecting would evict them.`:"Another client is attached to this companion. Connecting would evict them.",children:[e.jsx("span",{className:"relative flex h-1.5 w-1.5 flex-shrink-0",children:e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-sys-blue"})}),"Another client connected",e.jsx("button",{onClick:()=>se.getState().forceConnect(),className:"ml-1 px-1.5 py-0.5 rounded-full bg-sys-blue/20 hover:bg-sys-blue/30 transition-colors text-[10px] font-semibold",title:"Evict the other client and connect now",children:"Connect anyway"})]},"external-client"):w?null:e.jsxs(le.span,{initial:{opacity:0,scale:.9,width:0},animate:{opacity:1,scale:1,width:"auto"},exit:{opacity:0,scale:.9,width:0},transition:re.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:()=>F(!0),disabled:u,className:"data-box flex items-center gap-1 cursor-pointer hover:bg-subtle-fill-strong transition-colors disabled:opacity-50",title:c>0?`${c} 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(so,{className:"w-3.5 h-3.5 text-sys-blue"}),c>0&&e.jsxs("span",{className:"text-sys-blue",children:["+",c]})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${f.length} contacts${c>0?` (${c} from repeater)`:""}`,children:[e.jsx(Rt,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:f.length})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${n.channels_count} channels`,children:[e.jsx(Le,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:n.channels_count})]})]}),e.jsx(vd,{companions:s,selected:t,onSelect:Na}),e.jsx(U,{plain:!0,onClick:()=>S(!0),title:"Companion configuration",children:e.jsx(hl,{"data-slot":"icon"})})]});if(s.length===0&&!I)return e.jsxs(Ms,{children:[e.jsx(Es,{title:"Companion",icon:e.jsx(ye,{}),controls:e.jsxs(U,{color:"primary",outline:!0,onClick:()=>S(!0),children:[e.jsx(Xe,{"data-slot":"icon"}),"Add Companion"]})}),e.jsx(Ps,{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(ye,{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:()=>S(!0),children:[e.jsx(Xe,{"data-slot":"icon"}),"Add Companion"]})]})}),e.jsx(cn,{open:b,onClose:()=>S(!1),onRefresh:os})]});const fs=m?m.type==="channel"?((gs=i.find(P=>String(P.index)===m.id))==null?void 0:gs.name)??"Channel":((ys=f.find(P=>P.public_key===m.id))==null?void 0:ys.name)??m.id.slice(0,8):null;return e.jsxs(Ms,{children:[e.jsx(Es,{title:(o==null?void 0:o.node_name)||"Companion",icon:e.jsx(ye,{}),leading:Ba,controls:Wa}),e.jsx(Ps,{children:e.jsxs("div",{className:"companion-layout flex gap-4",style:{height:"calc(100vh - 11rem)",minHeight:400},children:[e.jsxs("div",{ref:et,"data-micro":ze?"true":void 0,className:M("companion-side-card flex-shrink-0 flex h-full overflow-hidden radius-inner bg-surface/80 backdrop-blur-lg depth-raised",W?"flex":"hidden md:flex"),children:[e.jsx(Wo,{ref:He,contacts:f,selectedConversation:m,unreadMap:us,messages:ds,onSelect:P=>{je(P),window.innerWidth<768&&J(!1)},onShowDetails:$a,onShareContact:Ca,onResetPath:wt,onRemoveContact:Sa,onPingContact:_a,repeaterSignalMap:h,isLoading:I,splitPercent:Nt,onMicroChange:ja}),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:ya,onPointerMove:ba,onPointerUp:Yt,onPointerCancel:Yt,onDoubleClick:va,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(Vo,{ref:Xt,channels:i,selectedConversation:m,unreadMap:us,messages:ds,onSelect:P=>{je(P),window.innerWidth<768&&J(!1)},onAddChannel:()=>L(!0),onDeleteChannel:Pa})]}),e.jsxs(Ts,{noPadding:!0,radius:"sm",className:M("flex-1 flex-col min-w-0 overflow-hidden relative",W?"hidden md:flex":"flex"),children:[e.jsx(ge,{children:R&&e.jsxs(le.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:re.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:R})]},"error-banner")}),!W&&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:()=>J(!0),className:"p-1 hover:bg-subtle-fill rounded transition-colors",children:e.jsx($i,{className:"w-4 h-4 text-fg-secondary"})}),e.jsx("span",{className:"text-sm text-fg-primary font-medium truncate flex-1",children:fs}),m&&e.jsx("button",{onClick:()=>z(!0),className:"p-1 hover:bg-subtle-fill rounded transition-colors",title:"Details",children:e.jsx(Ke,{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:fs??"Select a conversation"}),e.jsx(ge,{children:m&&e.jsx(le.button,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:re.fade,onClick:()=>{window.innerWidth>=1280?A(P=>!P):z(!0)},className:"p-1 hover:bg-subtle-fill rounded transition-colors",title:H?"Hide detail panel":"Show details",children:H&&window.innerWidth>=1280?e.jsx(Hs,{className:"w-4 h-4 text-fg-muted"}):e.jsx(Ke,{className:"w-4 h-4 text-fg-muted"})},"ctx-toggle")})]}),La&&v?e.jsx(Zc,{contact:v,loginStatus:xs,onLogin:kt}):e.jsxs(e.Fragment,{children:[e.jsx(Vc,{messages:j,contacts:f,className:"flex-1 min-h-0",conversationKey:m?m.type==="channel"?`ch:${m.id}`:m.id:void 0,onRetry:wa,onRetryAsFlood:ka,onMentionClick:Fa,isLoading:d,historyLoading:_,historyExhausted:m?$.get(m.type==="channel"?`ch:${m.id}`:m.id)??!1:!0,onLoadOlder:m?()=>Ta(m.type==="channel"?`ch:${m.id}`:m.id):void 0,channelName:(m==null?void 0:m.type)==="channel"?(bs=i.find(P=>String(P.index)===m.id))==null?void 0:bs.name:void 0,contactPubKey:(m==null?void 0:m.type)==="contact"?m.id:void 0}),m&&e.jsx(Qc,{onSend:Oa,disabled:!Da,mentionNames:Aa,placeholder:m.type==="channel"?`Message ${((vs=i.find(P=>String(P.index)===m.id))==null?void 0:vs.name)??"channel"}`:`Message ${((js=f.find(P=>P.public_key===m.id))==null?void 0:js.name)??"contact"}`})]})]}),e.jsx(le.div,{initial:!1,animate:{width:H&&m?"var(--companion-context)":"0px",opacity:H&&m?1:0},transition:re.layoutResize,className:"hidden xl:block flex-shrink-0 overflow-hidden",style:{pointerEvents:H&&m?"auto":"none"},children:m&&e.jsxs(Ts,{neomorphic:!0,noPadding:!0,radius:"sm",className:"h-full relative",children:[e.jsx(ge,{children:H&&e.jsx(le.button,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:re.fade,onClick:()=>A(!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(Hs,{className:"w-4 h-4 text-fg-muted"})},"ctx-close")}),e.jsx(sn,{contact:m.type==="contact"?v:null,channel:m.type==="channel"?i.find(P=>String(P.index)===m.id)??null:null,contacts:f,selfPubKey:(o==null?void 0:o.public_key)??null,onResetPath:wt,onRequestStatus:ts,onRequestTelemetry:ss,onLoginToRepeater:kt,onLogoutFromRepeater:ns,onGetNeighbours:as,onTraceContactPath:rs,onDiscoverPath:ls,onExportContact:P=>{G(P),T(!0)},onSetContactPath:cs})]})})]})}),e.jsx(cn,{open:b,onClose:()=>S(!1),onRefresh:os}),e.jsx(wd,{open:N,onClose:()=>F(!1),companionName:t??"companion",onImport:Ra}),e.jsx(Pd,{open:q,onClose:()=>{T(!1),G(null)},contacts:f,exportPubKey:O,onExport:Ma,onImport:Ea}),e.jsx(_d,{open:C,onClose:()=>L(!1),channels:i,onAddChannel:Ia}),e.jsxs(we,{open:D,onClose:()=>z(!1),size:"md",children:[e.jsx(Ee,{icon:(m==null?void 0:m.type)==="channel"?e.jsx(Le,{className:"w-5 h-5"}):v&&(v.adv_type&15)===2?e.jsx(Ge,{className:"w-5 h-5"}):e.jsx(ye,{className:"w-5 h-5"}),title:(m==null?void 0:m.type)==="channel"?((Ns=i.find(P=>String(P.index)===m.id))==null?void 0:Ns.name)??"Channel":(v==null?void 0:v.name)||"Contact Details",onClose:()=>z(!1)}),e.jsx(ke,{className:"max-h-[70vh] overflow-y-auto",children:e.jsx(sn,{embedded:!0,contact:(m==null?void 0:m.type)==="contact"?v:null,channel:(m==null?void 0:m.type)==="channel"?i.find(P=>String(P.index)===m.id)??null:null,contacts:f,selfPubKey:(o==null?void 0:o.public_key)??null,onResetPath:wt,onRequestStatus:ts,onRequestTelemetry:ss,onLoginToRepeater:kt,onLogoutFromRepeater:ns,onGetNeighbours:as,onTraceContactPath:rs,onDiscoverPath:ls,onExportContact:P=>{G(P),T(!0)},onSetContactPath:cs})})]})]})}export{yu as default}; diff --git a/frontend/dist/assets/Companion-CJJQvP9m.js b/frontend/dist/assets/Companion-CJJQvP9m.js new file mode 100644 index 00000000..7119a498 --- /dev/null +++ b/frontend/dist/assets/Companion-CJJQvP9m.js @@ -0,0 +1,81 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CompanionPathMap-BjSrbG5W.js","assets/index-Ch85h29t.js","assets/BasemapLayer-DEvncc0Q.js","assets/layer-Xsjnvj9G.js","assets/usePipelineStore-BfPa6Qak.js","assets/node-types-CUHPebtj.js","assets/useReplayTick-DnxaulGE.js","assets/payload-detail-CX4NrBt7.js","assets/car-DIm4EGM2.js","assets/map-pin-off-D_9hye06.js","assets/monitor-smartphone-CTx9MPdz.js","assets/index-6Dqm8vG_.css","assets/BasemapLayer-B1CfjdFi.css","assets/CompanionEchoMap-DGz3ueVV.js"])))=>i.map(i=>d[i]); +import{aZ as Ra,fM as cs,a$ as Xs,b0 as Ea,a_ as Ys,b1 as Pa,r as l,b2 as Ta,b3 as Se,b6 as rt,aV as ie,ba as Z,b7 as pe,bk as Aa,bb as vt,bf as $a,bg as Fa,bl as Da,bh as lt,bi as Zs,bm as Oa,bj as _e,bn as ds,bo as La,bp as za,bq as st,br as Ba,bs as Ha,bt as Wa,aY as Ua,b8 as Ka,fO as qa,dh as us,fQ as en,bv as Ga,bw as ke,bx as Va,bE as Ja,dv as Qa,dw as Xa,bG as Ya,fR as Za,bu as Ye,bF as tn,bz as er,fS as tr,bI as ms,e as se,j as e,c as A,a7 as ge,fT as sr,w as nr,d2 as ne,cy as it,R as Be,bO as ot,fd as Ie,fe as Me,ff as Re,d as he,fU as ar,fV as rr,fW as te,m as ae,fX as lr,cY as He,aB as ve,aL as Ee,aD as We,aC as Ne,a9 as oe,b_ as Ue,eU as Pe,B as H,fY as sn,fZ as ct,ax as ir,$ as or,z as Ct,f_ as ps,aA as cr,aF as dr,_ as nn,ce as ur,a2 as $e,f$ as St,cL as mr,N as xs,g0 as pr,dQ as xr,g1 as _t,g2 as hr,g3 as fr,bK as Nt,g4 as gr,g5 as yr,g6 as br,dB as jr,dF as vr,eN as Nr,d9 as wr,a8 as It,eq as kr,g7 as Cr,g8 as Sr,g9 as an,ga as _r,ae as Ir,gb as Mr,gc as rn,fB as Rr,gd as Er,ge as Pr,I as me,C as hs,gf as ln,gg as Tr,gh as Ar,gi as $r,gj as Fr,gk as Dr,gl as Or,gm as Lr,gn as zr,go as Br,gp as Hr,ad as Wr,gq as Ur,gr as Kr,gs as qr,gt as Gr,gu as Vr,gv as Jr,gw as Qr,gx as Xr,gy as Yr,gz as Zr,gA as el,gB as tl,eP as sl}from"./index-Ch85h29t.js";import{P as fs,a as gs,B as ys,C as bs}from"./PageLayout-BB80XCAa.js";import{e as dt,g as ut,a as mt,f as nl,b as al}from"./chat-utils-CSGjqJAH.js";import{c as js,S as rl,a as ll}from"./SignalIndicator-ouvwsHYL.js";import{b as il,F as ol,y as cl,R as dl,T as ul,w as ml,A as pl}from"./floating-wXUaY1-5.js";import{p as xl,a as Ze,c as J,f as Qe,b as hl,L as fl,S as Xe,s as gl,u as yl}from"./element-movement-CCLCtDhK.js";import{s as bl}from"./use-text-value-CQ3ua4o5.js";import{F as jl}from"./use-tree-walker-CT3tHYMm.js";import{a as et}from"./index-Ds7D6791.js";import{M as fe}from"./monitor-smartphone-CTx9MPdz.js";import{S as vs}from"./search-Dp7kJbPL.js";import{S as vl}from"./share-2-xeKwph2s.js";import{R as Ke,L as Nl}from"./route-P3Lngy7n.js";import{R as on}from"./rotate-ccw-Bkw4kxED.js";import{T as qe}from"./trash-2-D_NWmP0i.js";import{H as Fe}from"./hash-0CI2pLT2.js";import{C as wl}from"./check-check-ai3mrJDi.js";import{P as Ge}from"./plus-C7tLXNBe.js";import{S as kl,C as Cl}from"./ChatBubble-CL_NnCFm.js";import{p as Sl}from"./payload-detail-CX4NrBt7.js";import{A as _l}from"./arrow-down-BSET2HFf.js";import{C as Il}from"./WorkspaceNav-ZTG5UTjF.js";import{C as cn}from"./circle-alert-BYJOlPMS.js";import{f as Ml,c as Rl,a as El,M as Pl}from"./variants-DSc9sq6e.js";import{M as dn}from"./map-pin-c0Hi1adb.js";import{C as un}from"./clock-BDyTFNOi.js";import{A as mn}from"./activity-Uf5hjDsb.js";import{T as pn}from"./thermometer-B01w9TEg.js";import{U as Mt}from"./upload-BOBY87np.js";import{S as Tl}from"./shield-check-DF8MawhL.js";import{W as Ns}from"./wand-sparkles-Br5G9OBm.js";import{S as Al}from"./save-Ci6Me-tl.js";import{C as $l}from"./compass-D1WTkLry.js";import{G as ws}from"./git-branch-B0JLmrv3.js";import{F as re,L as le,D as Ce}from"./fieldset-C4AcLahj.js";import{C as xn}from"./ConfirmModal-DdfUdqSh.js";import{K as hn}from"./key-round-DLgdhdTl.js";import{F as fn,R as Fl}from"./radio-group-elwRJEn2.js";import{P as Dl}from"./pencil-BZOxTwpZ.js";import"./use-by-comparator-DeUfymOv.js";var Ol=Object.defineProperty,Ll=(s,t,n)=>t in s?Ol(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n,ks=(s,t,n)=>(Ll(s,typeof t!="symbol"?t+"":t,n),n),ee=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(ee||{}),nt=(s=>(s[s.Pointer=0]="Pointer",s[s.Other=1]="Other",s))(nt||{}),U=(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))(U||{});function Cs(s,t=n=>n){let n=s.activeItemIndex!==null?s.items[s.activeItemIndex]:null,a=Pa(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 zl={1(s){if(s.menuState===1)return s;let t=s.buttonElement?Ze.Tracked(hl(s.buttonElement)):s.buttonPositionState;return{...s,activeItemIndex:null,pendingFocus:{focus:J.Nothing},menuState:1,buttonPositionState:t}},0(s,t){return s.menuState===0?s:{...s,__demoMode:!1,pendingFocus:t.focus,menuState:0,buttonPositionState:Ze.Idle}},2:(s,t)=>{var n,a,r,i,o;if(s.menuState===1)return s;let m={...s,searchQuery:"",activationTrigger:(n=t.trigger)!=null?n:1,__demoMode:!1};if(t.focus===J.Nothing)return{...m,activeItemIndex:null};if(t.focus===J.Specific)return{...m,activeItemIndex:s.items.findIndex(d=>d.id===t.id)};if(t.focus===J.Previous){let d=s.activeItemIndex;if(d!==null){let x=s.items[d].dataRef.current.domRef,g=Qe(t,{resolveItems:()=>s.items,resolveActiveIndex:()=>s.activeItemIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(g!==null){let h=s.items[g].dataRef.current.domRef;if(((a=x.current)==null?void 0:a.previousElementSibling)===h.current||((r=h.current)==null?void 0:r.previousElementSibling)===null)return{...m,activeItemIndex:g}}}}else if(t.focus===J.Next){let d=s.activeItemIndex;if(d!==null){let x=s.items[d].dataRef.current.domRef,g=Qe(t,{resolveItems:()=>s.items,resolveActiveIndex:()=>s.activeItemIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(g!==null){let h=s.items[g].dataRef.current.domRef;if(((i=x.current)==null?void 0:i.nextElementSibling)===h.current||((o=h.current)==null?void 0:o.nextElementSibling)===null)return{...m,activeItemIndex:g}}}}let c=Cs(s),f=Qe(t,{resolveItems:()=>c.items,resolveActiveIndex:()=>c.activeItemIndex,resolveId:d=>d.id,resolveDisabled:d=>d.dataRef.current.disabled});return{...m,...c,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 m;return((m=o.dataRef.current.textValue)==null?void 0:m.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!==J.Nothing&&(a=Qe(s.pendingFocus,{resolveItems:()=>n,resolveActiveIndex:()=>s.activeItemIndex,resolveId:r=>r.id,resolveDisabled:r=>r.dataRef.current.disabled})),{...s,items:n,activeItemIndex:a,pendingFocus:{focus:J.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,...Cs(s),pendingShouldSort:!1}:s,10(s){return s.buttonPositionState.kind!=="Tracked"?s:{...s,buttonPositionState:Ze.Moved}}};class Rt extends Ra{constructor(t){super(t),ks(this,"actions",{registerItem:cs(()=>{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:cs(()=>{let n=[];return[a=>n.push(a),()=>this.send({type:6,items:n.splice(0)})]})}),ks(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=Xs.get(null);this.disposables.add(a.on(Ea.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(xl(a.buttonElement,a.buttonPositionState,()=>{this.send({type:10})})))})})}static new({id:t,__demoMode:n=!1}){return new Rt({id:t,__demoMode:n,menuState:n?0:1,buttonElement:null,itemsElement:null,items:[],searchQuery:"",activeItemIndex:null,activationTrigger:1,pendingShouldSort:!1,pendingFocus:{focus:J.Nothing},buttonPositionState:Ze.Idle})}reduce(t,n){return Ys(n.type,zl,t,n)}}const gn=l.createContext(null);function Et(s){let t=l.useContext(gn);if(t===null){let n=new Error(`<${s} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,yn),n}return t}function yn({id:s,__demoMode:t=!1}){let n=l.useMemo(()=>Rt.new({id:s,__demoMode:t}),[]);return Ta(()=>n.dispose()),n}let Bl=l.Fragment;function Hl(s,t){let n=l.useId(),{__demoMode:a=!1,...r}=s,i=yn({id:n,__demoMode:a}),[o,m,c]=pe(i,S=>[S.menuState,S.itemsElement,S.buttonElement]),f=rt(t),d=Xs.get(null),x=pe(d,l.useCallback(S=>d.selectors.isTop(S,n),[d,n]));Ja(x,[c,m],(S,b)=>{var E;i.send({type:U.CloseMenu}),Qa(b,Xa.Loose)||(S.preventDefault(),(E=i.state.buttonElement)==null||E.focus())});let g=ie(()=>{i.send({type:U.CloseMenu})}),h=lt({open:o===ee.Open,close:g}),u={ref:f},v=_e();return ke.createElement(pl,null,ke.createElement(gn.Provider,{value:i},ke.createElement(Ya,{value:Ys(o,{[ee.Open]:st.Open,[ee.Closed]:st.Closed})},v({ourProps:u,theirProps:r,slot:h,defaultTag:Bl,name:"Menu"}))))}let Wl="button";function Ul(s,t){let n=Et("Menu.Button"),a=l.useId(),{id:r=`headlessui-menu-button-${a}`,disabled:i=!1,autoFocus:o=!1,...m}=s,c=l.useRef(null),f=il(),d=rt(t,c,ol(),ie(j=>n.send({type:U.SetButtonElement,element:j}))),x=ie(j=>{switch(j.key){case Z.Space:case Z.Enter:case Z.ArrowDown:j.preventDefault(),j.stopPropagation(),n.send({type:U.OpenMenu,focus:{focus:J.First}});break;case Z.ArrowUp:j.preventDefault(),j.stopPropagation(),n.send({type:U.OpenMenu,focus:{focus:J.Last}});break}}),g=ie(j=>{switch(j.key){case Z.Space:j.preventDefault();break}}),[h,u,v]=pe(n,j=>[j.menuState,j.buttonElement,j.itemsElement]),S=h===ee.Open;fl(S,{trigger:u,action:l.useCallback(j=>{if(u!=null&&u.contains(j.target))return Xe.Ignore;let C=j.target.closest('[role="menuitem"]:not([data-disabled])');return Aa(C)?Xe.Select(C):v!=null&&v.contains(j.target)?Xe.Ignore:Xe.Close},[u,v]),close:l.useCallback(()=>n.send({type:U.CloseMenu}),[]),select:l.useCallback(j=>j.click(),[])});let b=gl(j=>{var C;i||(h===ee.Open?(vt.flushSync(()=>n.send({type:U.CloseMenu})),(C=c.current)==null||C.focus({preventScroll:!0})):(j.preventDefault(),n.send({type:U.OpenMenu,focus:{focus:J.Nothing},trigger:nt.Pointer})))}),{isFocusVisible:E,focusProps:I}=$a({autoFocus:o}),{isHovered:_,hoverProps:y}=Fa({isDisabled:i}),{pressed:M,pressProps:$}=Da({disabled:i}),R=lt({open:h===ee.Open,active:M||h===ee.Open,disabled:i,hover:_,focus:E,autofocus:o}),p=Zs(f(),{ref:d,id:r,type:Oa(s,c.current),"aria-haspopup":"menu","aria-controls":v==null?void 0:v.id,"aria-expanded":h===ee.Open,disabled:i||void 0,autoFocus:o,onKeyDown:x,onKeyUp:g},b,I,y,$);return _e()({ourProps:p,theirProps:m,slot:R,defaultTag:Wl,name:"Menu.Button"})}let Kl="div",ql=ms.RenderStrategy|ms.Static;function Gl(s,t){let n=l.useId(),{id:a=`headlessui-menu-items-${n}`,anchor:r,portal:i=!1,modal:o=!0,transition:m=!1,...c}=s,f=cl(r),d=Et("Menu.Items"),[x,g]=dl(f),h=ul(),[u,v]=l.useState(null),S=rt(t,f?x:null,ie(L=>d.send({type:U.SetItemsElement,element:L})),v),[b,E]=pe(d,L=>[L.menuState,L.buttonElement]),I=ds(E),_=ds(u);f&&(i=!0);let y=La(),[M,$]=za(m,u,y!==null?(y&st.Open)===st.Open:b===ee.Open);Ba(M,E,()=>{d.send({type:U.CloseMenu})});let R=pe(d,L=>L.__demoMode),p=R?!1:o&&b===ee.Open;Ha(p,_);let j=R?!1:o&&b===ee.Open;Wa(j,{allowed:l.useCallback(()=>[E,u],[E,u])});let C=pe(d,d.selectors.didButtonMove)?!1:M;l.useEffect(()=>{let L=u;L&&b===ee.Open&&(Ua(L)||L.focus({preventScroll:!0}))},[b,u]),jl(b===ee.Open,{container:u,accept(L){return L.getAttribute("role")==="menuitem"?NodeFilter.FILTER_REJECT:L.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(L){L.setAttribute("role","none")}});let k=Ka(),F=ie(L=>{var G,w,T;switch(k.dispose(),L.key){case Z.Space:if(d.state.searchQuery!=="")return L.preventDefault(),L.stopPropagation(),d.send({type:U.Search,value:L.key});case Z.Enter:if(L.preventDefault(),L.stopPropagation(),d.state.activeItemIndex!==null){let{dataRef:z}=d.state.items[d.state.activeItemIndex];(w=(G=z.current)==null?void 0:G.domRef.current)==null||w.click()}d.send({type:U.CloseMenu}),en(d.state.buttonElement);break;case Z.ArrowDown:return L.preventDefault(),L.stopPropagation(),d.send({type:U.GoToItem,focus:J.Next});case Z.ArrowUp:return L.preventDefault(),L.stopPropagation(),d.send({type:U.GoToItem,focus:J.Previous});case Z.Home:case Z.PageUp:return L.preventDefault(),L.stopPropagation(),d.send({type:U.GoToItem,focus:J.First});case Z.End:case Z.PageDown:return L.preventDefault(),L.stopPropagation(),d.send({type:U.GoToItem,focus:J.Last});case Z.Escape:L.preventDefault(),L.stopPropagation(),vt.flushSync(()=>d.send({type:U.CloseMenu})),(T=d.state.buttonElement)==null||T.focus({preventScroll:!0});break;case Z.Tab:L.preventDefault(),L.stopPropagation(),vt.flushSync(()=>d.send({type:U.CloseMenu})),qa(d.state.buttonElement,L.shiftKey?us.Previous:us.Next);break;default:L.key.length===1&&(d.send({type:U.Search,value:L.key}),k.setTimeout(()=>d.send({type:U.ClearSearch}),350));break}}),N=ie(L=>{switch(L.key){case Z.Space:L.preventDefault();break}}),D=lt({open:b===ee.Open}),q=Zs(f?h():{},{"aria-activedescendant":pe(d,d.selectors.activeDescendantId),"aria-labelledby":pe(d,L=>{var G;return(G=L.buttonElement)==null?void 0:G.id}),id:a,onKeyDown:F,onKeyUp:N,role:"menu",tabIndex:b===ee.Open?0:void 0,ref:S,style:{...c.style,...g,"--button-width":ml(M,E,!0).width},...Ga($)}),X=_e();return ke.createElement(Va,{enabled:i?s.static||M:!1,ownerDocument:I},X({ourProps:q,theirProps:c,slot:D,defaultTag:Kl,features:ql,visible:C,name:"Menu.Items"}))}let Vl=l.Fragment;function Jl(s,t){let n=l.useId(),{id:a=`headlessui-menu-item-${n}`,disabled:r=!1,...i}=s,o=Et("Menu.Item"),m=pe(o,C=>o.selectors.isActive(C,a)),c=l.useRef(null),f=rt(t,c),d=pe(o,C=>o.selectors.shouldScrollIntoView(C,a));Ye(()=>{if(d)return er().requestAnimationFrame(()=>{var C,k;(k=(C=c.current)==null?void 0:C.scrollIntoView)==null||k.call(C,{block:"nearest"})})},[d,c]);let x=bl(c),g=l.useRef({disabled:r,domRef:c,get textValue(){return x()}});Ye(()=>{g.current.disabled=r},[g,r]),Ye(()=>(o.actions.registerItem(a,g),()=>o.actions.unregisterItem(a)),[g,a]);let h=ie(()=>{o.send({type:U.CloseMenu})}),u=ie(C=>{if(r)return C.preventDefault();o.send({type:U.CloseMenu}),en(o.state.buttonElement)}),v=ie(()=>{if(r)return o.send({type:U.GoToItem,focus:J.Nothing});o.send({type:U.GoToItem,focus:J.Specific,id:a})}),S=yl(),b=ie(C=>S.update(C)),E=ie(C=>{S.wasMoved(C)&&(r||m||o.send({type:U.GoToItem,focus:J.Specific,id:a,trigger:nt.Pointer}))}),I=ie(C=>{S.wasMoved(C)&&(r||m&&o.state.activationTrigger===nt.Pointer&&o.send({type:U.GoToItem,focus:J.Nothing}))}),[_,y]=tn(),[M,$]=tr(),R=lt({active:m,focus:m,disabled:r,close:h}),p={id:a,ref:f,role:"menuitem",tabIndex:r===!0?void 0:-1,"aria-disabled":r===!0?!0:void 0,"aria-labelledby":_,"aria-describedby":M,disabled:void 0,onClick:u,onFocus:v,onPointerEnter:b,onMouseEnter:b,onPointerMove:E,onMouseMove:E,onPointerLeave:I,onMouseLeave:I},j=_e();return ke.createElement(y,null,ke.createElement($,null,j({ourProps:p,theirProps:i,slot:R,defaultTag:Vl,name:"Menu.Item"})))}let Ql="div";function Xl(s,t){let[n,a]=tn(),r=s,i={ref:t,"aria-labelledby":n,role:"group"},o=_e();return ke.createElement(a,null,o({ourProps:i,theirProps:r,slot:{},defaultTag:Ql,name:"Menu.Section"}))}let Yl="header";function Zl(s,t){let n=l.useId(),{id:a=`headlessui-menu-heading-${n}`,...r}=s,i=Za();Ye(()=>i.register(a),[a,i.register]);let o={id:a,ref:t,role:"presentation",...i.props};return _e()({ourProps:o,theirProps:r,slot:{},defaultTag:Yl,name:"Menu.Heading"})}let ei="div";function ti(s,t){let n=s,a={ref:t,role:"separator"};return _e()({ourProps:a,theirProps:n,slot:{},defaultTag:ei,name:"Menu.Separator"})}let si=Se(Hl),bn=Se(Ul),jn=Se(Gl),wt=Se(Jl),ni=Se(Xl),ai=Se(Zl),vn=Se(ti),ri=Object.assign(si,{Button:bn,Items:jn,Item:wt,Section:ni,Heading:ai,Separator: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 li=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],ii=se("arrow-left",li);/** + * @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 oi=[["path",{d:"M13.67 8H18a2 2 0 0 1 2 2v4.33",key:"7az073"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}],["path",{d:"M8 8H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 1.414-.586",key:"s09a7a"}],["path",{d:"M9 13v2",key:"rq6x2g"}],["path",{d:"M9.67 4H12v2.33",key:"110xot"}]],ci=se("bot-off",oi);/** + * @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 di=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Ss=se("bot",di);/** + * @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 ui=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Nn=se("circle-dot",ui);/** + * @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 mi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],pi=se("crosshair",mi);/** + * @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 xi=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],hi=se("ellipsis-vertical",xi);/** + * @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 fi=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],gi=se("key",fi);/** + * @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 yi=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],kt=se("log-in",yi);/** + * @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 bi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],ji=se("panel-left-close",bi);/** + * @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 vi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Ni=se("panel-left-open",vi);/** + * @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 wi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],_s=se("panel-right-close",wi);/** + * @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 ki=[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]],Ci=se("radar",ki);/** + * @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 Si=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],_i=se("star",Si);/** + * @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 Ii=[["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:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Mi=se("user-plus",Ii);function je({children:s,className:t,onClick:n,disabled:a=!1,destructive:r=!1,icon:i,trailing:o,href:m,checked:c}){const f=e.jsxs(e.Fragment,{children:[(i||c!==void 0)&&e.jsx("span",{className:A("flex-shrink-0 w-4 h-4 flex items-center justify-center","text-fg-muted",r&&"text-sys-red","group-data-[focus]:text-white"),children:c!==void 0?c?e.jsx(ge,{className:"h-4 w-4 text-sys-blue group-data-[focus]:text-white"}):null:i}),e.jsx("span",{className:"flex-1 truncate",children:s}),o&&e.jsx("span",{className:"flex-shrink-0 text-fg-muted group-data-[focus]:text-white/70 text-xs",children:o})]}),d=A("group flex items-center gap-2 w-full","px-3 py-2 radius-control cursor-default","text-sm text-left","transition-colors","focus:outline-none",a?"opacity-50 cursor-not-allowed":[r?["text-sys-red","data-[focus]:bg-sys-red data-[focus]:text-white"]:["text-fg-primary","data-[focus]:bg-sys-blue data-[focus]:text-white"]],t);return m&&!a?e.jsx(wt,{children:e.jsx("a",{href:m,className:d,children:f})}):e.jsx(wt,{disabled:a,children:e.jsx("button",{type:"button",onClick:n,disabled:a,className:d,children:f})})}function Ri({className:s}){return e.jsx(vn,{className:A("my-1 h-px bg-border-subtle",s)})}const Ei=100,Pi=101,Ti=102,Ai=103,$i=104,Fi=115,Di=116,Oi=117,Li=120,zi=125,Bi=128,Hi=136;function Wi(s){const t=new sr(s),n=[];for(;t.getRemainingBytesCount()>=2;){const a=t.readUInt8(),r=t.readUInt8();if(a===0&&r===0)break;switch(r){case Ei:n.push({channel:a,type:r,value:t.readUInt32BE()});break;case Pi:n.push({channel:a,type:r,value:t.readInt16BE()});break;case Ti:n.push({channel:a,type:r,value:t.readUInt8()});break;case Ai:n.push({channel:a,type:r,value:t.readInt16BE()/10});break;case $i:n.push({channel:a,type:r,value:t.readUInt8()/2});break;case Fi:n.push({channel:a,type:r,value:t.readUInt16BE()/10});break;case Di:n.push({channel:a,type:r,value:t.readInt16BE()/100});break;case Oi:n.push({channel:a,type:r,value:t.readInt16BE()/1e3});break;case Li:n.push({channel:a,type:r,value:t.readUInt8()});break;case zi:n.push({channel:a,type:r,value:t.readUInt16BE()});break;case Bi:n.push({channel:a,type:r,value:t.readUInt16BE()});break;case Hi:n.push({channel:a,type:r,value:{latitude:t.readInt24BE()/1e4,longitude:t.readInt24BE()/1e4,altitude:t.readInt24BE()/100}});break;default:return n}}return n}const pt=new Set(["☀️","🌤","🌤️","⛅","⛅️","☁️","🌫","🌫️","🌦","🌦️","🌧","🌧️","❄️","🌨","🌨️","⛈","⛈️","🌩","🌩️","🌪","🌪️"]),Ui="🌬";function Ki(s){const t=s.trim();if(!t)return null;let n="",a=t;const r=t.match(/^([^:]+):\s*/);r&&(n=r[1].trim(),a=t.slice(r[0].length));let i="";for(const I of pt)if(a.includes(I)){i=I,a=a.replace(I,"").trim();break}if(!i)return null;a=a.replace(Ui,"").replace(/\uFE0F/g,"").trim();const o=a.match(/(-?\d+)\s*°\s*([FC]?)/);if(!o)return null;const m=parseInt(o[1],10),c=o[2]==="C"?"°C":"°F",d=a.slice(0,a.indexOf(o[0])).trim()||"Unknown",x=a.match(/([NSEW]{1,2}\d+)/),g=x==null?void 0:x[1],h=a.match(/(\d+%)\s*RH/i),u=a.match(/💧\s*(-?\d+°)/),v=a.match(/👁️?\s*(\d+\s*mi)/),S=a.match(/📊\s*([\d.]+)/),b=a.match(/H:\s*(-?\d+)°/),E=a.match(/L:\s*(-?\d+)°/);return{label:n||"Now",conditionEmoji:i,condition:d,temp:m,unit:c,wind:g,humidity:h==null?void 0:h[1],dewPoint:u==null?void 0:u[1],visibility:v==null?void 0:v[1],pressure:S==null?void 0:S[1],high:b?parseInt(b[1],10):void 0,low:E?parseInt(E[1],10):void 0}}function wn(s){if(!s.includes("|"))return null;let t=!1;for(const r of pt)if(s.includes(r)){t=!0;break}if(!t||!/\d+\s*°/.test(s))return null;const n=s.split("|").map(r=>r.trim()),a=[];for(const r of n){if(/^H:\s*-?\d+°/.test(r)&&!r.match(/[☀🌤⛅☁🌫🌦🌧❄🌨⛈]/)){const o=r.match(/H:\s*(-?\d+)°/),m=r.match(/L:\s*(-?\d+)°/);a.length>0&&(o&&(a[a.length-1].high=parseInt(o[1],10)),m&&(a[a.length-1].low=parseInt(m[1],10)));continue}const i=Ki(r);i&&a.push(i)}return a.length===0?null:{periods:a,rawSections:n}}function kn(s){if(!s.includes("|"))return null;const t=/SNR:\s*[-+]?[\d.]+/i.test(s),n=/RSSI:\s*[-+]?\d+/i.test(s);if(!t&&!n)return null;const a=/^ack\s/i.test(s.trim()),r=s.split("|").map(y=>y.trim());let i,o;const m=r[0];if(a)i=m.replace(/^ack\s+/i,"").trim()||void 0;else{const y=m.match(/^Rx\s+([^:]+):\s*(.*)/i);y&&(i=y[1].trim(),o=y[2].trim()||void 0)}let c,f,d;for(const y of r){const M=y.match(/\((\d+)\s*hops?\)/i)??y.match(/(\d+)\s*hops?\s*via/i);M&&(d=parseInt(M[1],10));const $=y.match(/([0-9a-f]{2}(?:\s*,\s*[0-9a-f]{2})+)/i);$&&(c=$[1],f=c.split(",").map(R=>R.trim()))}const x=s.match(/SNR:\s*([-+]?[\d.]+)\s*d[Bb]/i),g=x?parseFloat(x[1]):void 0,h=s.match(/RSSI:\s*([-+]?\d+)\s*dBm/i),u=h?parseInt(h[1],10):void 0,v=s.match(/(\d+\.?\d*)\s*(km|mi|miles?|m)\b/i),S=v?`${v[1]} ${v[2]}`:void 0,b=s.match(/Received\s*at:\s*(\S+)/i),E=b==null?void 0:b[1],I=s.match(/elapsed:\s*(\S+)/i),_=I==null?void 0:I[1];return{target:i,isAck:a,pathRaw:c,pathHops:f,hops:d,snr:g,rssi:u,distance:S,receivedAt:E,phrase:o,elapsed:_}}function Cn(s){if(!s.includes("🎲"))return null;const t=[],n=[],a=/(\d+)d(\d+):\s*\[([^\]]+)\]\s*=\s*(\d+)/g;let r;for(;(r=a.exec(s))!==null;){const f=parseInt(r[1],10),d=r[3].split(",").map(x=>parseInt(x.trim(),10));t.push({dieType:`d${r[2]}`,count:f,results:d,total:parseInt(r[4],10)}),n.push([r.index,r.index+r[0].length])}const i=/(\d*)d(\d+):\s*(\d+)/g;let o;for(;(o=i.exec(s))!==null;){if(n.some(([d,x])=>o.index>=d&&o.index=2?{text:t,setup:n[0].trim(),delivery:n.slice(1).join(` +`).trim(),isTwoPart:!0}:{text:t,isTwoPart:!1}}function _n(s){if(!s.includes("🥸"))return null;const t=s.replace(/🥸\s*/,"").trim();if(!t)return null;const n=t.split(/\n\s*\n/);return n.length>=2?{text:t,setup:n[0].trim(),delivery:n.slice(1).join(` +`).trim(),isTwoPart:!0}:{text:t,isTwoPart:!1}}function In(s){return s.includes("🎱")&&s.replace(/🎱\s*/,"").trim()||null}function Mn(s){if(!s.startsWith("⚠️")&&!s.startsWith("⚠"))return null;const t=s.replace(/^⚠️?\s*/,"").trim();if(!t)return null;const n=t.match(/^([A-Z][A-Z\s]+):\s*(.*)/s);return n?{severity:n[1].trim(),headline:n[2].trim()}:{headline:t}}function Rn(s){const t=s.split(` +`).map(a=>a.trim()).filter(Boolean);if(t.length<2)return null;const n=[];for(const a of t){const r=a.match(/^([A-Za-z]{1,3}):\s*/);if(!r)continue;let i=a.slice(r[0].length),o="";for(const x of pt)if(i.includes(x)){o=x,i=i.replace(x,"").trim();break}if(!o)continue;const m=i.match(/H:\s*(-?\d+)°/),c=i.match(/L:\s*(-?\d+)°/),f=i.search(/H:|\d+°/),d=f>0?i.slice(0,f).trim():"";n.push({dayAbbrev:r[1],conditionEmoji:o,condition:d||"Unknown",high:m?parseInt(m[1],10):void 0,low:c?parseInt(c[1],10):void 0})}return n.length>=2?n:null}function En(s){const t=s.split(` +`).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 h of pt)if(i.includes(h)){o=h,i=i.replace(h,"").trim();break}if(!o)continue;let m;const c=i.match(/(\d+)%/);c&&(m=parseInt(c[1],10),i=i.replace(c[0],"").trim());const f=i.match(/(-?\d+)°/);if(!f)continue;const d=parseInt(f[1],10),x=i.indexOf(f[0]),g=x>0?i.slice(0,x).trim():"";n.push({hour:r[1].toUpperCase(),conditionEmoji:o,condition:g||"Unknown",temp:d,precipChance:m})}return n.length>=2?n:null}function Pn(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 m,c=o;c.includes("🎯")?(m="high",c=c.replace("🎯","").trim()):c.includes("📍")?(m="medium",c=c.replace("📍","").trim()):c.includes("❓")&&(m="low",c=c.replace("❓","").trim()),n.push({hex:i,name:c,confidence:m})}}return n.length>=2?{hops:n}:null}const qi=new Set(["🟢","🟡","🟠","🔴","🟣","🟤"]);function Tn(s){let t="";for(const x of qi)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),m=o>2?i.slice(0,o).replace(/:$/,"").trim():void 0,c=[],f=/(PM2\.5|PM10|O3|NO2|CO|SO2):\s*([\d.]+)/gi;let d;for(;(d=f.exec(s))!==null;)c.push({name:d[1].toUpperCase(),value:parseFloat(d[2])});return{location:m,aqi:a,category:r,colorEmoji:t,pollutants:c}}function An(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),m=s.match(/X[- ]?[Rr]ay(?:\s*Flux)?:?\s*([A-Z]\d+\.?\d*)/i)??s.match(/Xray:([A-Z]\d+\.?\d*)/i),c=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:m==null?void 0:m[1],signalNoise:c==null?void 0:c[1]}}function $n(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",m=/(\d+m(?:-\d+m)?)(Good|Fair|Poor|Excellent)/gi;let c;for(;(c=m.exec(i[2]))!==null;)t.push({time:o,name:c[1],condition:c[2]})}return t.length>=2?{bands:t}:null}function Fn(s){var h,u;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),m=s.match(/Remaining:?\s*(\d+)h\s*(\d+)m/i),c=s.match(/Azimuth:?\s*([\d.]+)/i),f=s.match(/Altitude:?\s*(-?[\d.]+)/i),d=s.search(/Sun\s*Rise/i),x=s.search(/Sun\s*Set/i),g=x>=0&&(d<0||xa.trim()).filter(Boolean),n=[];for(const a of t){let r="";for(const c of Vi)if(a.startsWith(c)){r=c;break}if(!r)continue;const i=a.slice(r.length).trim(),o=i.match(/^(.+?)\s+(\d+)\s*[-–]\s*(.+?)\s+(\d+)\s*\((.+)\)$/);if(o){const c=o[5].trim(),f=/final/i.test(c),d=!f&&/\d/.test(c);n.push({sportEmoji:r,away:o[1].trim(),home:o[3].trim(),awayScore:parseInt(o[2],10),homeScore:parseInt(o[4],10),status:c,isLive:d,isFinal:f});continue}const m=i.match(/^(.+?)\s*[-–]\s*(.+?)\s*\((.+)\)$/);m&&n.push({sportEmoji:r,away:m[1].trim(),home:m[2].trim(),status:m[3].trim(),isLive:!1,isFinal:!1})}return n.length>=1?{games:n}:null}function Bn(s){var f,d,x,g;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 h=s.match(/^(.+?)\n/i);return{type:"leaderboard",entries:t,title:(f=h==null?void 0:h[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),m=s.match(/Top\s*User:\s*(.+?)\s*\(/i),c=s.match(/^(.+?)\n/i);return{type:"basic",commands:r?parseInt(r[1],10):void 0,replies:i?parseInt(i[1],10):void 0,topCommand:(d=o==null?void 0:o[1])==null?void 0:d.trim(),topUser:(x=m==null?void 0:m[1])==null?void 0:x.trim(),title:(g=c==null?void 0:c[1])==null?void 0:g.replace(/📊\s*/,"").trim()}}const Ji=new Set(["🐱","🐈","😺","😸","😹","😻","😼","😽","🙀","😿","😾","🐾","👂","🐟","🧶","🥛"]);function Hn(s){if(!/\bcats?\b/i.test(s))return null;const t=s.slice(-4);for(const n of Ji)if(t.includes(n))return s;return null}const Qi=[{type:"dice",test:Cn},{type:"joke",test:Sn},{type:"dadjoke",test:_n},{type:"magic8",test:In},{type:"weather-alert",test:Mn},{type:"satpass",test:On},{type:"aurora",test:Ln},{type:"moon",test:Dn},{type:"sun",test:Fn},{type:"hfcond",test:$n},{type:"solar",test:An},{type:"aqi",test:Tn},{type:"sports",test:zn},{type:"stats",test:Bn},{type:"path",test:Pn},{type:"weather-multiday",test:Rn},{type:"weather-hourly",test:En},{type:"test",test:kn},{type:"weather",test:wn},{type:"catfact",test:Hn}];function Wn(s){for(const{type:t,test:n}of Qi)if(n(s)!=null)return t;return null}function Xi(s,t){switch(t){case"weather":return wn(s);case"weather-multiday":return Rn(s);case"weather-hourly":return En(s);case"weather-alert":return Mn(s);case"test":return kn(s);case"path":return Pn(s);case"aqi":return Tn(s);case"solar":return An(s);case"hfcond":return $n(s);case"sun":return Fn(s);case"moon":return Dn(s);case"satpass":return On(s);case"aurora":return Ln(s);case"dice":return Cn(s);case"joke":return Sn(s);case"dadjoke":return _n(s);case"magic8":return In(s);case"sports":return zn(s);case"stats":return Bn(s);case"catfact":return Hn(s);default:return null}}const Un=/[\u{1F916}\u{1F9BE}\u{1F9BF}]/u;function Yi(s,t,n){if(t==="bot")return!0;if(t==="not-bot")return!1;if(Un.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)Wn(i)!=null&&a++;if(a>=Math.ceil(r.length*.6))return!0}return!1}function Kn(s){return Un.test(s)||/bot\b/i.test(s)}const qn="pymc_howl_bot_overrides";function Zi(){try{const s=localStorage.getItem(qn);if(!s)return new Map;const t=JSON.parse(s);return new Map(t)}catch{return new Map}}function Is(s){try{localStorage.setItem(qn,JSON.stringify([...s]))}catch{}}const Gn=nr(s=>({overrides:Zi(),setOverride:(t,n)=>s(a=>{const r=new Map(a.overrides);return r.set(t,n),Is(r),{overrides:r}}),clearOverride:t=>s(n=>{const a=new Map(n.overrides);return a.delete(t),Is(a),{overrides:a}})}));function Vn(s){return Gn(t=>t.overrides.get(s))}function eo(){return Gn(s=>s.setOverride)}const Jn="pymc_companion_contacts_micro",Qn="pymc_companion_favorites",yt=56;function Ms(){try{return localStorage.getItem(Jn)==="1"}catch{return!1}}function to(s){try{localStorage.setItem(Jn,s?"1":"0")}catch{}}function so(){try{const s=localStorage.getItem(Qn);return s?new Set(JSON.parse(s)):new Set}catch{return new Set}}function no(s){try{localStorage.setItem(Qn,JSON.stringify([...s]))}catch{}}function ao({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",m=a==="sm"?"size-3":"size-3.5";if(i===2){const x=r&&r.rssi!==0,g=x?`RSSI: ${r.rssi} dBm · SNR: ${r.snr.toFixed(1)} dB`:void 0;return e.jsx("div",{className:A(o,"relative rounded-full flex items-center justify-center flex-shrink-0 ring-[1.5px]",x?"ring-transparent":"ring-sys-blue"),title:g,children:x?e.jsx(rl,{rssi:r.rssi,snr:r.snr,compact:!0,showValues:!1}):e.jsx(Be,{className:A(m,"text-sys-blue")})})}if(i===3)return e.jsx("div",{className:A(o,"relative rounded-full flex items-center justify-center flex-shrink-0 ring-[1.5px] ring-sys-pink"),children:e.jsx(it,{className:A(m,"text-sys-pink")})});if(!s)return e.jsx("div",{className:A(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:c}=dt(s),f=ut(s),d=mt(s);return e.jsx("div",{className:A(o,"relative clay-avatar",c?"text-base":"text-white text-[11px] font-bold"),style:{"--avatar-color":f},children:c||d})}const Rs=[{key:"companion",label:"Companions",icon:fe,color:"text-sys-blue"},{key:"room",label:"Room Servers",icon:it,color:"text-sys-pink"},{key:"repeater",label:"Repeaters",icon:Be,color:"text-sys-blue"}];function Xn(s){const t=(s.adv_type??0)&15;return t===3?"room":t===2?"repeater":"companion"}const ro=4e3,lo=5e3,io=2e3,oo=8,co=l.forwardRef(function({contact:t,isActive:n,unread:a,lastMsg:r,isFav:i,microContent:o,onSelect:m,onShowDetails:c,onShareContact:f,onResetPath:d,onRemoveContact:x,onPingContact:g,repeaterSignal:h,toggleFavorite:u},v){const S=ar(t.public_key),b=rr(t.public_key),E=Vn(t.public_key),I=eo(),_=E==="bot"||E==null&&Kn(t.name||""),[y,M]=l.useState(!1),[$,R]=l.useState(!1),p=l.useRef(null),[j,C]=l.useState("idle"),k=l.useRef(!1),F=l.useRef(null),[N,D]=l.useState({w:0,h:0});l.useEffect(()=>{let O=!1,W=null;return S?(k.current=!0,W="idle"):k.current&&(k.current=!1,W=te.getState().pingResults.get(t.public_key)!=null?"success":"failed"),W&&queueMicrotask(()=>{O||C(W)}),()=>{O=!0}},[S,t.public_key]),l.useEffect(()=>{if(j==="idle")return;const W=setTimeout(()=>C("idle"),j==="success"?lo:io);return()=>clearTimeout(W)},[j]);const q=(S||j!=="idle")&&!y;l.useEffect(()=>{if(!q)return;const O=F.current;if(!O)return;const W=()=>{const de=O.offsetWidth,we=O.offsetHeight;D(ye=>ye.w===de&&ye.h===we?ye:{w:de,h:we})};W();const V=new ResizeObserver(W);return V.observe(O),()=>V.disconnect()},[q]);const X=l.useCallback(()=>{M(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>M(!1),ro)},[]),L=l.useCallback(()=>{M(!1),p.current&&clearTimeout(p.current)},[]),G=l.useCallback(async()=>{x&&(p.current&&clearTimeout(p.current),R(!0),await x(t.public_key),R(!1),M(!1))},[x,t.public_key]),w=l.useMemo(()=>h&&h.rssi!==0?{rssi:h.rssi,snr:h.snr}:null,[h]),T=l.useCallback(O=>{F.current=O,typeof v=="function"?v(O):v&&(v.current=O)},[v]),z=y?"":j==="success"?"bg-sys-green/5":j==="failed"?"bg-sys-red/5":S?"bg-sys-blue/5":n?"bg-sys-blue":"hover:bg-elevated";return e.jsxs(ae.div,{ref:T,layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:ne.fade,className:A("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(he,{children:q&&N.w>0&&(j!=="idle"?e.jsx(ae.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{opacity:{duration:.15}},className:A("absolute inset-0 radius-inner ring-2 ring-inset pointer-events-none z-[2]",j==="success"?"ring-sys-green":"ring-sys-red")},`ping-${j}`):e.jsx(lr,{borderRadius:oo,width:N.w,height:N.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:A("flex items-center gap-2.5",y&&!o&&"invisible pointer-events-none"),children:[e.jsxs("button",{onClick:()=>m({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(ao,{name:t.name,pubkey:t.public_key,advType:t.adv_type,signal:w}),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"}),_&&!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(Ss,{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:A("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)+"…"})}),j==="success"&&b?e.jsxs("div",{className:"text-[11px] text-sys-green font-medium truncate tabular-nums",children:[b.snr_db.toFixed(1)," dB SNR · ",b.rtt_ms," ms · ",b.hop_count," ",b.hop_count===1?"hop":"hops"]}):j==="failed"?e.jsx("div",{className:"text-[11px] text-sys-red font-medium truncate",children:"No response"}):r?e.jsx("div",{className:A("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(ri,{as:"div",className:"absolute inset-0",children:({open:O})=>e.jsxs(e.Fragment,{children:[e.jsx(bn,{className:A("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(hi,{className:A("h-3.5 w-3.5 transition-colors",n?"text-white/60 hover:text-white":"text-fg-muted hover:text-sys-blue")})}),e.jsxs(jn,{anchor:"right start",transition:!0,className:A("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(je,{icon:e.jsx(He,{className:"w-4 h-4"}),onClick:()=>{c==null||c({type:"contact",id:t.public_key})},children:"Details"}),f&&e.jsx(je,{icon:e.jsx(vl,{className:"w-4 h-4"}),onClick:()=>f(t.public_key),children:"Share"}),e.jsx(je,{icon:e.jsx(Ke,{className:"w-4 h-4"}),onClick:()=>m({type:"contact",id:t.public_key}),children:"Set Path"}),d&&e.jsx(je,{icon:e.jsx(on,{className:"w-4 h-4"}),onClick:()=>d(t.public_key),children:"Reset Path"}),g&&Xn(t)==="repeater"&&e.jsx(je,{icon:e.jsx(pi,{className:"w-4 h-4"}),onClick:()=>g(t.public_key),disabled:S,children:S?"Pinging…":"Ping"}),x&&e.jsx(je,{icon:e.jsx(qe,{className:"w-4 h-4"}),destructive:!0,onClick:X,children:"Remove Contact"}),e.jsx(Ri,{}),e.jsx(je,{icon:_?e.jsx(ci,{className:"w-4 h-4 text-fg-muted"}):e.jsx(Ss,{className:"w-4 h-4 text-sys-violet"}),onClick:()=>I(t.public_key,_?"not-bot":"bot"),children:_?"Not a Bot":"Mark as HOWL Bot"}),e.jsx(je,{icon:e.jsx(_i,{className:A("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:()=>u(t.public_key),children:i?"Unfavorite":"Favorite"})]})]})})})]}),!o&&e.jsx("div",{className:A("flex items-center gap-1.5 self-center",!y&&"invisible pointer-events-none"),children:$?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:L,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:G,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)}),Es={excellent:4,good:3,fair:2,weak:1,poor:0};function Ps(s,t){const n=t==null?void 0:t.get(s);return n&&n.rssi!==0?n.rssi:null}function uo(s,t,n,a){return[...s].sort((r,i)=>{const o=t.has(r.public_key)?0:1,m=t.has(i.public_key)?0:1;if(o!==m)return o-m;if(n){const c=n.get(r.public_key),f=c&&c.length>0?c[c.length-1].timestamp:0,d=n.get(i.public_key),x=d&&d.length>0?d[d.length-1].timestamp:0;if(f!==x)return x-f}if(a){const c=Ps(r.public_key,a),f=Ps(i.public_key,a);if(c!=null&&f==null)return-1;if(c==null&&f!=null)return 1;if(c!=null&&f!=null){const d=Es[js(c)]??0,x=Es[js(f)]??0;if(d!==x)return x-d}}return(r.name||"").localeCompare(i.name||"")})}const mo=l.memo(l.forwardRef(function({contacts:t,selectedConversation:n,unreadMap:a,messages:r,onSelect:i,onShowDetails:o,onShareContact:m,onResetPath:c,onRemoveContact:f,onPingContact:d,repeaterSignalMap:x,isLoading:g,splitPercent:h=50,onMicroChange:u,className:v},S){const[b,E]=l.useState(Ms),[I,_]=l.useState(Ms),[y,M]=l.useState(""),[$,R]=l.useState(!1),[p,j]=l.useState(so),C=l.useRef(null),k=l.useRef(null),F=l.useCallback(w=>{k.current=w,typeof S=="function"?S(w):S&&(S.current=w)},[S]),N=l.useCallback(()=>{E(w=>{const T=!w;to(T);const z=k.current;if(T&&_(!0),z){let O=0;const W=z.parentElement;if(T)O=(W==null?void 0:W.offsetWidth)??z.offsetWidth;else if(W){const de=W.style.width;W.style.width="var(--companion-side)",O=W.offsetWidth,W.style.width=de}const V=T?yt:Math.round(h/100*O);et(z,{width:`${V}px`},{...ne.layoutResize,onComplete(){z.style.width=T?`${yt}px`:`${h}%`,T||_(!1)}})}return u==null||u(T),T})},[h,u]),D=l.useCallback(w=>{j(T=>{const z=new Set(T);return z.has(w)?z.delete(w):z.add(w),no(z),z})},[]),q=$||y.length>0,X=l.useMemo(()=>{const w=new Set,T=t.filter(O=>w.has(O.public_key)?!1:(w.add(O.public_key),!0));if(!y.trim())return T;const z=y.toLowerCase();return T.filter(O=>{var W;return((W=O.name)==null?void 0:W.toLowerCase().includes(z))||O.public_key.toLowerCase().includes(z)})},[t,y]),L=l.useMemo(()=>{const w=new Map;for(const T of Rs)w.set(T.key,[]);for(const T of X)w.get(Xn(T)).push(T);return Rs.map(T=>({...T,items:uo(w.get(T.key),p,r,T.key==="repeater"?x:void 0)})).filter(T=>T.items.length>0)},[X,p,r,x]),G=(n==null?void 0:n.type)==="contact"?n.id:null;return e.jsxs("div",{ref:F,className:A("flex-shrink-0 overflow-hidden flex flex-col h-full",v),style:{width:b?yt:`${h}%`},children:[e.jsx("div",{className:A("flex items-center border-b border-edge-subtle flex-shrink-0",I?"justify-center p-2":"gap-2 px-3 py-2"),children:I?e.jsx("button",{onClick:N,className:"p-1 hover:bg-subtle-fill rounded transition-colors",title:"Expand contacts",children:e.jsx(Ni,{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:()=>{q?(M(""),R(!1)):(R(!0),setTimeout(()=>{var w;return(w=C.current)==null?void 0:w.focus()},50))},className:A("p-1 rounded transition-colors flex-shrink-0",q?"bg-sys-blue/10 text-sys-blue":"hover:bg-subtle-fill text-fg-muted"),title:q?"Close search":"Search contacts",children:e.jsx(vs,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:N,className:"p-1 hover:bg-subtle-fill rounded transition-colors flex-shrink-0",title:"Collapse contacts",children:e.jsx(ji,{className:"w-3.5 h-3.5 text-fg-muted"})})]})]})}),!I&&q&&e.jsxs("div",{className:"relative px-2.5 py-2 border-b border-edge-subtle/50 flex-shrink-0",children:[e.jsx(vs,{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:C,type:"text",value:y,onChange:w=>M(w.target.value),onFocus:()=>R(!0),onBlur:()=>R(!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:()=>{M(""),R(!1)},className:"absolute right-5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-subtle-fill rounded",children:e.jsx(ot,{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:A("flex-1 overflow-y-auto min-h-0",I?"px-0":"px-1.5"),style:{contain:"layout style paint"},children:[L.map(w=>{const T=w.icon;return e.jsxs(Ie,{defaultOpen:!0,className:"mb-1",children:[e.jsxs(Me,{className:A("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(T,{className:A("w-3.5 h-3.5",w.color)}),!I&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:w.label}),e.jsx("span",{className:"type-data-xs text-fg-muted/50 ml-auto",children:w.items.length})]})]}),e.jsx(Re,{children:e.jsx(he,{initial:!1,mode:"popLayout",children:w.items.map(z=>e.jsx(co,{contact:z,isActive:G===z.public_key,unread:a.get(z.public_key)??0,lastMsg:(()=>{const O=r.get(z.public_key);return O&&O.length>0?O[O.length-1]:void 0})(),isFav:p.has(z.public_key),microContent:I,onSelect:i,onShowDetails:o,onShareContact:m,onResetPath:c,onRemoveContact:f,onPingContact:d,repeaterSignal:x==null?void 0:x.get(z.public_key),toggleFavorite:D},z.public_key))})})]},w.key)}),X.length===0&&e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-sm text-fg-muted",children:y?"No matches":"No contacts yet"})})]})]})}));function po({open:s,onClose:t}){const n=te(p=>p.discoverImportableChannels),a=te(p=>p.getEmptyChannelSlots),r=te(p=>p.importChannel),i=te(p=>p.refreshChannels),[o,m]=l.useState("discover"),[c,f]=l.useState([]),[d,x]=l.useState([]),[g,h]=l.useState(null),u=l.useRef(!1);l.useEffect(()=>{if(!s)return;m("discover"),f([]),x([]),h(null),u.current=!1;let p=!1;return(async()=>{try{const[j,C]=await Promise.all([n(),a()]);if(p)return;if(x(C),j.length===0){h("No channels found in repeater history. Decoded messages may still be loading."),m("select");return}C.length===0&&h("No empty channel slots on device. Delete a channel first to make room."),f(j.map(k=>({name:k.name,alreadyOnDevice:k.alreadyOnDevice,selected:!k.alreadyOnDevice,status:"pending"}))),m("select")}catch(j){p||(h(j instanceof Error?j.message:"Discovery failed"),m("select"))}})(),()=>{p=!0}},[s,n,a]);const v=l.useCallback(p=>{f(j=>j.map(C=>C.name===p&&!C.alreadyOnDevice?{...C,selected:!C.selected}:C))},[]),S=l.useCallback(()=>{f(p=>p.map(j=>j.alreadyOnDevice?j:{...j,selected:!0}))},[]),b=l.useCallback(()=>{f(p=>p.map(j=>j.alreadyOnDevice?j:{...j,selected:!1}))},[]),E=l.useMemo(()=>c.filter(p=>!p.alreadyOnDevice).length,[c]),I=l.useMemo(()=>c.filter(p=>p.selected&&!p.alreadyOnDevice).length,[c]),_=l.useMemo(()=>c.filter(p=>p.status==="done").length,[c]),y=l.useMemo(()=>c.filter(p=>p.status==="failed").length,[c]),M=l.useCallback(async()=>{m("import"),u.current=!1;const p=c.filter(C=>C.selected&&!C.alreadyOnDevice),j=[...d];for(const C of p){if(u.current)break;const k=j.shift();if(k===void 0){f(N=>N.map(D=>D.name===C.name&&D.status==="pending"?{...D,status:"failed"}:D));continue}f(N=>N.map(D=>D.name===C.name?{...D,status:"sending"}:D)),await new Promise(N=>setTimeout(N,150));const F=await r(C.name,k);f(N=>N.map(D=>D.name===C.name?{...D,status:F?"done":"failed"}:D)),F||j.unshift(k),u.current||await new Promise(N=>setTimeout(N,300))}await i(),m("complete")},[c,d,r,i]),$=l.useCallback(()=>{u.current=!0},[]),R=p=>{switch(p){case"pending":return e.jsx(Nn,{className:"w-3.5 h-3.5 text-fg-muted"});case"sending":return e.jsx(oe,{className:"w-3.5 h-3.5 text-sys-blue animate-spin"});case"done":return e.jsx(ge,{className:"w-3.5 h-3.5 text-sys-green"});case"failed":return e.jsx(ot,{className:"w-3.5 h-3.5 text-sys-red"})}};return e.jsxs(ve,{open:s,onClose:o==="import"?()=>{}:t,size:"sm",children:[e.jsx(Ee,{icon:e.jsx(We,{className:"w-5 h-5"}),title:"Import Channels",onClose:o==="import"?void 0:t}),e.jsxs(Ne,{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(oe,{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:[g&&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(Ue,{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:g})]}),c.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:[E," discoverable · ",d.length," slot",d.length!==1?"s":""," free"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:S,className:"text-[11px] text-sys-blue hover:underline",children:"All"}),e.jsx("span",{className:"text-fg-muted/40",children:"·"}),e.jsx("button",{onClick:b,className:"text-[11px] text-sys-blue hover:underline",children:"None"})]})]}),e.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:c.map(p=>e.jsxs("button",{onClick:()=>v(p.name),disabled:p.alreadyOnDevice,className:A("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:A("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(ge,{className:"w-3 h-3 text-white"})}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(Fe,{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:[_+y," / ",c.filter(p=>p.selected&&!p.alreadyOnDevice).length]})]}),e.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:c.filter(p=>p.selected&&!p.alreadyOnDevice).map(p=>e.jsxs("div",{className:A("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:R(p.status)}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(Fe,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:A("text-sm truncate",p.status==="done"?"text-fg-primary":"text-fg-secondary"),children:p.name})]}),e.jsx("span",{className:A("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(Pe,{children:[o==="select"&&e.jsxs(e.Fragment,{children:[e.jsx(H,{plain:!0,onClick:t,children:"Cancel"}),e.jsxs(H,{color:"primary",onClick:M,disabled:I===0||d.length===0,children:[e.jsx(We,{className:"w-4 h-4"}),"Import ",I," ",I===1?"Channel":"Channels"]})]}),o==="import"&&e.jsx(H,{plain:!0,onClick:$,children:"Stop"}),o==="complete"&&e.jsxs(e.Fragment,{children:[y>0&&e.jsxs("span",{className:"text-xs text-sys-red flex items-center gap-1 mr-auto",children:[e.jsx(Ue,{className:"w-3.5 h-3.5"}),y," failed"]}),e.jsxs(H,{color:"primary",onClick:t,children:[e.jsx(wl,{className:"w-4 h-4"}),"Done — ",_," imported"]})]})]})]})}const xo=4e3;function ho(s){const t=s.frequency_hz/1e3,n=s.bandwidth_hz/1e3;return`${t} · SF${s.spreading_factor} · ${n}k`}const fo=l.forwardRef(function({channel:t,isActive:n,unread:a,lastMsg:r,isLoadingMessages:i,selfInfo:o,onSelect:m,onDeleteChannel:c},f){const[d,x]=l.useState(!1),[g,h]=l.useState(!1),u=l.useRef(null),v=l.useCallback(()=>{x(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>x(!1),xo)},[]),S=l.useCallback(()=>{x(!1),u.current&&clearTimeout(u.current)},[]),b=l.useCallback(async()=>{c&&(u.current&&clearTimeout(u.current),h(!0),await c(t.index),h(!1),x(!1))},[c,t.index]),E=t.name.toLowerCase()==="public",I=c&&!E;return e.jsx(ae.div,{ref:f,layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:ne.fade,className:A("group w-full flex items-center gap-2.5 px-2.5 py-1 radius-inner","transition-[background-color] duration-150",d?"":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:A("flex items-center gap-2.5 min-w-0",d&&"invisible pointer-events-none"),children:[e.jsx("button",{onClick:()=>m({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:A("text-sm flex-shrink-0",n?"text-white font-semibold":r?"text-fg-primary font-semibold":"text-fg-secondary font-normal"),children:t.name}),E&&o&&e.jsx("span",{className:A("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:ho(o)})]}),r&&e.jsx("div",{className:A("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:v,className:A("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:A("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:A("flex items-center gap-1.5 self-center",!d&&"invisible pointer-events-none"),children:g?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:S,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:b,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:m,className:c},f){const d=sn(),x=ct(),[g,h]=l.useState(!1),u=l.useMemo(()=>{const S=new Set,b=t.filter(E=>S.has(E.index)?!1:(S.add(E.index),!0));return b.sort((E,I)=>{const _=E.name.toLowerCase()==="public",y=I.name.toLowerCase()==="public";if(_&&!y)return-1;if(!_&&y)return 1;const M=r.get(`ch:${E.index}`),$=M&&M.length>0?M[M.length-1].timestamp:0,R=r.get(`ch:${I.index}`),p=R&&R.length>0?R[R.length-1].timestamp:0;return $!==p?p-$:E.name.localeCompare(I.name)}),b},[t,r]),v=(n==null?void 0:n.type)==="channel"?n.id:null;return e.jsxs("div",{ref:f,className:A("flex-1 min-w-0 overflow-hidden flex flex-col h-full",c),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:()=>h(!0),className:"p-1 rounded hover:bg-subtle-fill transition-colors flex-shrink-0",title:"Import channels from repeater history",children:e.jsx(We,{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(Ge,{className:"w-3.5 h-3.5 text-fg-muted"})})]})]}),e.jsx(po,{open:g,onClose:()=>h(!1)}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 px-1.5 py-1",style:{contain:"layout style paint"},children:u.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(Ge,{className:"w-3.5 h-3.5"}),"Add Channel"]})]}):e.jsx(he,{initial:!1,mode:"popLayout",children:u.map(S=>e.jsx(fo,{channel:S,isActive:v===String(S.index),unread:a.get(`ch:${S.index}`)??0,lastMsg:(()=>{const b=r.get(`ch:${S.index}`);return b&&b.length>0?b[b.length-1]:void 0})(),isLoadingMessages:d,selfInfo:x,onSelect:i,onDeleteChannel:m},S.index))})})]})}));function yo(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,m=Math.floor(o/30),c=`${i.text}:${m}`;n.has(c)||n.set(c,a)}return n}function bo(s){const t=ct(),n=ir(),a=or(),r=t==null?void 0:t.node_name,i=l.useMemo(()=>r?yo(n,r):new Map,[n,r]);return l.useMemo(()=>{const o=new Map;if(!r||i.size===0)return o;const m=new Map;for(const d of s){if(!d.is_outgoing||!d.is_channel)continue;const x=Math.floor(d.timestamp/30);let g=!1;for(const h of[x-1,x,x+1]){const u=i.get(`${d.text}:${h}`);if(u){const v=m.get(u)??[];v.push(d.id),m.set(u,v),g=!0;break}}}if(m.size===0)return o;const c=new Set(m.keys()),f=new Map;for(const d of a)c.has(d.packet_hash)&&f.set(d.packet_hash,(f.get(d.packet_hash)??0)+1);for(const[d,x]of m){const g=f.get(d)??0,h=Math.max(0,g-1);for(const u of x)o.set(u,h)}return o},[s,r,i,a])}const Q=l.memo(function({children:t,className:n,bgClassName:a,hideBadge:r,compact:i}){return e.jsxs("div",{className:A("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]})}),jo=new Set(["☀️","🌤","🌤️"]),vo=new Set(["⛅","⛅️"]),No=new Set(["☁️","🌫","🌫️"]),wo=new Set(["🌧","🌧️","🌦","🌦️","⛈","⛈️","🌩","🌩️"]),ko=new Set(["❄️","🌨","🌨️"]);function Co(s){return jo.has(s)?"bg-gradient-to-br from-[var(--sys-blue)]/20 to-[var(--sys-indigo)]/10":vo.has(s)?"bg-gradient-to-br from-[var(--zinc-800)]/80 to-[var(--sys-blue)]/15":No.has(s)?"bg-gradient-to-br from-[var(--zinc-800)]/80 to-[var(--zinc-700)]/60":wo.has(s)?"bg-gradient-to-br from-[var(--zinc-900)]/80 to-[var(--zinc-700)]/60":ko.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 Le({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 So({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 _o=l.memo(function({data:t}){const n=t.periods[0],a=t.periods.slice(1),r=Co(n.conditionEmoji);return e.jsxs(Q,{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(Le,{label:`💨 ${n.wind}`}),n.humidity&&e.jsx(Le,{label:`💧 ${n.humidity}`}),n.dewPoint&&e.jsx(Le,{label:`💧 ${n.dewPoint}`}),n.visibility&&e.jsx(Le,{label:`👁️ ${n.visibility}`}),n.pressure&&e.jsx(Le,{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(So,{period:i},o))})]})}),Io=l.memo(function({data:t}){return e.jsx(Q,{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))})})}),Mo=l.memo(function({data:t}){return e.jsx(Q,{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:A("text-[9px] tabular-nums font-medium",n.precipChance>=50?"text-sys-blue":"text-sys-blue/60"),children:[n.precipChance,"%"]})]},a))})})});function Ro(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 Eo={red:"border-l-sys-red",amber:"border-l-sys-amber"},Po={red:"text-sys-red",amber:"text-sys-amber"},To=l.memo(function({data:t}){const n=Ro(t.severity);return e.jsx(Q,{compact:!0,hideBadge:!0,children:e.jsxs("div",{className:A("border-l-[3px] pl-2.5 -ml-0.5",Eo[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:A("text-[10px] font-bold uppercase tracking-wider",Po[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})]})})}),Ao={high:"🎯",medium:"📍",low:"❓"};function $o({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:A("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:Ao[s.confidence]})]})]})}const Fo=l.memo(function({data:t}){return e.jsxs(Q,{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($o,{hop:n},a))})]})});function Do(s){return s>=10?5:s>=6?4:s>=3?3:s>=0?2:s>=-5?1:0}function Oo(s){return s>=4?"bg-sys-green":s>=3?"bg-sys-amber":s>=2?"bg-sys-orange":"bg-sys-red"}function Lo({bars:s}){const t=Oo(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:A("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 Bo(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 Ho=l.memo(function({data:t}){const{text:n,bg:a}=Bo(t.aqi);return e.jsxs(Q,{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:A("flex items-center justify-center w-12 h-12 rounded-xl",a),children:e.jsx("span",{className:A("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:A("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 Wo(s){return s<=3?"text-sys-green":s<=4?"text-sys-amber":s<=6?"text-sys-orange":"text-sys-red"}function Ae({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:A("text-sm font-semibold tabular-nums text-fg-primary",n),children:t})]})}const Uo=l.memo(function({data:t}){return e.jsxs(Q,{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(Ae,{label:"A-Index",value:t.aIndex}),t.kIndex!=null&&e.jsx(Ae,{label:"K-Index",value:t.kIndex,className:Wo(t.kIndex)}),t.sunspots!=null&&e.jsx(Ae,{label:"Sunspots",value:t.sunspots}),t.xrayFlux!=null&&e.jsx(Ae,{label:"X-Ray",value:t.xrayFlux}),t.solarFlux!=null&&e.jsx(Ae,{label:"Flux",value:t.solarFlux}),t.signalNoise!=null&&e.jsx(Ae,{label:"Noise",value:t.signalNoise})]})]})});function Ko(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 Ts({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:A("text-[10px] font-semibold px-1.5 py-0.5 rounded",Ko(s.condition)),children:s.condition})]})}const qo=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(Q,{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(Ts,{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(Ts,{band:r},i))]})]})]})});function Go({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 Vo=l.memo(function({data:t}){let n=null;if(t.daylightHours!=null&&t.daylightMinutes!=null&&t.remainingHours!=null&&t.remainingMinutes!=null){const m=t.daylightHours*60+t.daylightMinutes,c=t.remainingHours*60+t.remainingMinutes;m>0&&(n=1-c/m)}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(Q,{compact:!0,children:[e.jsx(Go,{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),"°"]})]})]})}),Jo=l.memo(function({data:t}){return e.jsxs(Q,{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),"°"]})]})]})}),Qo=l.memo(function({data:t}){return e.jsxs(Q,{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 Xo(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 Yo=l.memo(function({data:t}){const n=Xo(t.kpIndex);return e.jsxs(Q,{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})]})]})}),Zo=l.memo(function({data:t}){return e.jsxs(Q,{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})]})]})}),As=l.memo(function({data:t,isDadJoke:n}){const a=n?"🥸":"🎭";return e.jsx(Q,{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})})]})})}),ec=l.memo(function({data:t}){return e.jsx(Q,{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))})})}),tc=l.memo(function({data:t}){var n;return e.jsxs(Q,{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)})})]})}),sc=l.memo(function({data:t}){return e.jsx(Q,{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 nc({text:s}){return e.jsx(Q,{compact:!0,children:e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed tracking-wide whitespace-pre-wrap break-words",children:nl(s)})})}const ac=l.memo(function({text:t,messageType:n}){const a=l.useMemo(()=>n?Xi(t,n):null,[t,n]);if(a)switch(n){case"weather":return e.jsx(_o,{data:a});case"weather-multiday":return e.jsx(Io,{data:a});case"weather-hourly":return e.jsx(Mo,{data:a});case"weather-alert":return e.jsx(To,{data:a});case"path":return e.jsx(Fo,{data:a});case"test":return e.jsx(zo,{data:a});case"aqi":return e.jsx(Ho,{data:a});case"solar":return e.jsx(Uo,{data:a});case"hfcond":return e.jsx(qo,{data:a});case"sun":return e.jsx(Vo,{data:a});case"moon":return e.jsx(Jo,{data:a});case"satpass":return e.jsx(Qo,{data:a});case"aurora":return e.jsx(Yo,{data:a});case"dice":return e.jsx(Zo,{data:a});case"joke":return e.jsx(As,{data:a});case"dadjoke":return e.jsx(As,{data:a,isDadJoke:!0});case"sports":return e.jsx(ec,{data:a});case"stats":return e.jsx(tc,{data:a});case"catfact":return e.jsx(sc,{data:a})}return e.jsx(nc,{text:t})}),rc=l.lazy(()=>nn(()=>import("./CompanionPathMap-BjSrbG5W.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(s=>({default:s.CompanionPathMap}))),lc=l.lazy(()=>nn(()=>import("./CompanionEchoMap-DGz3ueVV.js"),__vite__mapDeps([13,1,2,3,4,5,9,10,11,12])).then(s=>({default:s.CompanionEchoMap}))),$s=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 ic(s,t,n){return dr(new Date(s*1e3),t,n)}function oc(s,t){return cr(new Date(s*1e3),t)}function cc(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 uc(s){if(!s)return[];const t=[];for(let n=0;n64?t&63:t}function pc(s,t){const n=t.find(a=>a.public_key.startsWith(s));return(n==null?void 0:n.name)||null}function Fs(s,t){return s.is_outgoing?"You":s.sender_name?s.sender_name:s.author_prefix?s.author_prefix.slice(0,8):t.get(s.sender_key)??s.sender_key.slice(0,8)}const xc=new Set(["🎭","🥸"]);function hc({senderName:s,timestamp:t,signed:n,preferences:a,children:r}){const{emoji:i,cleanName:o}=dt(s),m=ut(o),c=mt(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:A("clay-avatar w-9 h-9",i?"text-lg":"text-white text-[13px] font-bold tracking-tight"),style:{"--avatar-color":m},children:i||c}),e.jsx("span",{className:"text-xs text-chat-timestamp tabular-nums h-4 leading-4",children:al(t,a)})]}),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:o}),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:r})]})]})}const fc=l.memo(function({msg:t,contact:n,contacts:a,selfInfo:r,echoCount:i,channelName:o,allMessages:m,children:c}){const[f,d]=l.useState(!1),[x,g]=l.useState(!1),[h,u]=l.useState(0),v=l.useRef(null),S=mc(t.path_len),b=!t.is_outgoing,E=b&&S!=null,I=t.is_outgoing&&t.is_channel&&(i??0)>0,_=(o==null?void 0:o.toLowerCase().includes("wardrive"))??!1,y=l.useMemo(()=>_&&b?Sl(t.text):null,[_,b,t.text]),M=E||I,$=l.useMemo(()=>{const N=[];if(t.path_hops&&t.path_hops.length>0)N.push({hops:t.path_hops.slice(0,64),snr:t.path_snr,rssi:t.path_rssi});else if(b&&(n!=null&&n.out_path)){const D=uc(n.out_path);D.length>0&&N.push({hops:D})}if(t.alternate_paths)for(const D of t.alternate_paths)N.push(D);return N},[t.path_hops,t.path_snr,t.path_rssi,t.alternate_paths,b,n]),R=h<$.length?h:0,p=$[R]??$[0],j=$.length>1,C=(p==null?void 0:p.snr)??t.msg_snr,k=()=>{g(!0),d(N=>!N)},F=l.useCallback(N=>{var D;N.propertyName==="grid-template-rows"&&(f?(D=v.current)==null||D.scrollIntoView({block:"nearest",behavior:"smooth"}):g(!1))},[f]);return e.jsxs("div",{ref:v,className:A("rounded-xl px-2 py-1 -mx-2 transition-colors duration-150",M&&"hover:bg-subtle-fill cursor-pointer"),onClick:()=>M&&k(),children:[c,M&&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:F,children:e.jsxs("div",{className:"overflow-hidden",children:[x&&E&&e.jsxs("div",{className:"mt-1.5 ml-13 space-y-1",children:[j&&e.jsx("div",{className:"flex items-center gap-1 flex-wrap",onClick:N=>N.stopPropagation(),children:$.map((N,D)=>e.jsxs("button",{onClick:()=>u(D),className:A("flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] transition-colors",D===R?"bg-sys-blue/15 text-sys-blue font-semibold":"bg-subtle-fill text-fg-muted hover:text-fg-secondary"),children:[e.jsx(Ke,{className:"w-2.5 h-2.5"}),N.hops.length||S,N.snr!=null&&e.jsxs("span",{className:"ml-0.5 opacity-70",children:[N.snr>0?"+":"",N.snr.toFixed(1)]})]},D))}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx(Ke,{className:"w-3 h-3 text-fg-muted flex-shrink-0"}),S===0&&!p?e.jsx("span",{className:"text-[10px] text-fg-muted font-medium",children:"Direct"}):p&&p.hops.length>0?p.hops.map((N,D)=>{const q=pc(N,a);return e.jsxs("span",{className:"contents",children:[D>0&&e.jsx(Il,{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:N}),q&&e.jsxs("span",{className:"text-fg-muted",children:["(",q,")"]})]})]},D)}):e.jsxs("span",{className:"text-[10px] text-fg-muted font-medium",children:[S," hop",S>1?"s":""]}),C!=null&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-fg-muted ml-0.5",children:[e.jsx(ll,{className:"w-2.5 h-2.5"}),C>0?"+":"",C.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:$s,children:e.jsx(rc,{hops:p.hops,contacts:a,selfInfo:r,snr:C,wardriveCoords:y??void 0,wardriveSenderName:t.sender_name,channelMessages:_?m:void 0,messageTimestamp:t.timestamp})})]}),x&&I&&e.jsx("div",{className:"mt-1.5",children:e.jsx(l.Suspense,{fallback:$s,children:e.jsx(lc,{text:t.text,timestamp:t.timestamp,contacts:a})})})]})})]})}),gc=l.memo(function({messages:t,contacts:n,className:a,conversationKey:r,onRetry:i,onRetryAsFlood:o,onMentionClick:m,isLoading:c,historyLoading:f,historyExhausted:d,onLoadOlder:x,channelName:g,contactPubKey:h}){const u=Ct(),v=l.useRef(null),S=l.useRef(null),[b,E]=l.useState(!1),[I,_]=l.useState(()=>new Date),y=l.useRef(t.length),M=l.useRef(0);l.useEffect(()=>{const w=window.setInterval(()=>_(new Date),6e4);return()=>window.clearInterval(w)},[]);const $=l.useRef(r);l.useEffect(()=>{if(r!==$.current){$.current=r,y.current=t.length,M.current=0;const w=requestAnimationFrame(()=>{E(!1);const T=v.current;T&&(T.scrollTop=T.scrollHeight)});return()=>cancelAnimationFrame(w)}},[r,t.length]);const R=l.useMemo(()=>cc(n),[n]),p=l.useMemo(()=>dc(n),[n]),j=ct(),C=bo(t),k=Vn(h??""),F=h?p.get(h):void 0,N=l.useMemo(()=>{if(!F)return!1;const w=t.filter(T=>!T.is_outgoing).slice(-5).map(T=>T.text);return Yi(F.name,k,w)},[F,k,t]),{combinedTexts:D,skipIds:q}=l.useMemo(()=>{const w=new Map,T=new Set;for(let z=0;z3)continue;const V=[...O.text][0];if(!V||!xc.has(V)||[...W.text][0]!==V)continue;const de=W.text.slice(V.length).trimStart();w.set(O.id,O.text+` + +`+de),T.add(W.id),z++}return{combinedTexts:w,skipIds:T}},[t]);l.useEffect(()=>{var T;const w=v.current;if(w){if(t.length>y.current&&M.current>0){const z=w.scrollHeight-M.current;if(z>0&&w.scrollTop<200){w.scrollTop+=z,y.current=t.length,M.current=0;return}}y.current=t.length,b||(T=S.current)==null||T.scrollIntoView({behavior:"smooth"})}},[t.length,b]);const X=l.useCallback(()=>{const w=v.current;if(!w)return;const T=w.scrollHeight-w.scrollTop-w.clientHeight;E(T>100),w.scrollTop<80&&x&&!f&&!d&&(M.current=w.scrollHeight,x())},[x,f,d]),L=l.useCallback(()=>{var w;(w=S.current)==null||w.scrollIntoView({behavior:"smooth"}),E(!1)},[]);let G="";return e.jsxs("div",{className:A("relative flex flex-col",a),children:[e.jsxs("div",{ref:v,onScroll:X,className:"flex-1 overflow-y-auto min-h-0 px-4 py-3",style:{contain:"layout style paint"},children:[f&&e.jsx("div",{className:"flex items-center justify-center py-3",children:e.jsx(oe,{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:c?"Loading messages…":"No messages yet"})}):t.map(w=>{if(q.has(w.id))return null;const T=oc(w.timestamp,u),z=T!==G;G=T;const O=w.unconfirmed&&w.is_channel&&(C.get(w.id)??0)>0,W=w.is_outgoing?w.failed?"failed":w.confirmed||O?"confirmed":w.unconfirmed?"unconfirmed":(w.retryAttempt??0)>0?"retrying":w.sent?"sent":"pending":void 0,V=w.is_channel&&w.channel_idx!=null?`ch:${w.channel_idx}`:w.sender_key;return e.jsxs("div",{children:[z&&e.jsx(kl,{text:ic(w.timestamp,u,I)}),e.jsx(fc,{msg:w,contact:p.get(w.sender_key),contacts:n,selfInfo:j,echoCount:C.get(w.id),channelName:g,allMessages:g!=null&&g.toLowerCase().includes("wardrive")?t:void 0,children:(()=>{if(!w.is_outgoing){const de=Fs(w,R);if(w.is_channel?Kn(de):N){const ye=D.get(w.id)??w.text,xt=Wn(ye);return e.jsx(hc,{senderName:de,timestamp:w.timestamp,signed:w.txt_type===ps.SignedPlain,preferences:u,children:e.jsx(ac,{text:ye,messageType:xt})})}}return e.jsx(Cl,{senderName:Fs(w,R),text:w.text,timestamp:w.timestamp,isOutgoing:w.is_outgoing,status:W,onRetry:i&&w.failed?()=>i(V,w.id):void 0,onRetryAsFlood:o&&w.failed&&!w.is_channel?()=>o(V,w.id):void 0,retryAttempt:w.retryAttempt,maxRetries:w.maxRetries,echoCount:C.get(w.id),signed:!w.is_outgoing&&w.txt_type===ps.SignedPlain,bubbleVariant:"subtle",onMentionClick:m},`${w.id}-${u.timeFormat}-${u.timeZone}`)})()})]},w.id)}),e.jsx("div",{ref:S})]}),e.jsx("button",{onClick:L,className:A("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",b?"opacity-100 translate-y-0":"opacity-0 translate-y-2 pointer-events-none"),children:e.jsx(_l,{className:"w-4 h-4 text-white"})})]})}),yc=6,bc=l.memo(function({onSend:t,disabled:n,placeholder:a="Type a message…",className:r,mentionNames:i=[]}){const[o,m]=l.useState(""),[c,f]=l.useState(!1),d=l.useRef(null),[x,g]=l.useState(null),[h,u]=l.useState(-1),[v,S]=l.useState(0),b=l.useMemo(()=>{if(x==null)return[];const R=x.toLowerCase();return i.filter(p=>p.toLowerCase().includes(R)).slice(0,yc)},[x,i]),E=b.length>0;l.useEffect(()=>{S(0)},[b]);const I=l.useCallback(()=>{g(null),u(-1),S(0)},[]),_=l.useCallback(R=>{var N;if(h<0)return;const p=o.slice(0,h),j=((N=d.current)==null?void 0:N.selectionStart)??o.length,C=o.slice(j),k=`@[${R}] `,F=p+k+C;m(F),I(),requestAnimationFrame(()=>{var q,X;const D=p.length+k.length;(q=d.current)==null||q.setSelectionRange(D,D),(X=d.current)==null||X.focus()})},[o,h,I]),y=l.useCallback(async()=>{var p;const R=o.trim();!R||c||n||(f(!0),I(),m(""),await t(R),f(!1),(p=d.current)==null||p.focus())},[o,c,n,t,I]),M=l.useCallback(R=>{const p=R.target.value;m(p);const j=R.target.selectionStart??p.length,C=p.slice(0,j),k=C.lastIndexOf("@");if(k>=0){const F=k>0?C[k-1]:" ";if(/\s/.test(F)||k===0){const N=C.slice(k+1);if(!N.includes(" ")&&!N.includes("[")){g(N),u(k);return}}}I()},[I]),$=l.useCallback(R=>{if(E){if(R.key==="ArrowDown"){R.preventDefault(),S(p=>(p+1)%b.length);return}if(R.key==="ArrowUp"){R.preventDefault(),S(p=>(p-1+b.length)%b.length);return}if(R.key==="Enter"||R.key==="Tab"){R.preventDefault(),_(b[v]);return}if(R.key==="Escape"){R.preventDefault(),I();return}}R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),y())},[y,E,b,v,_,I]);return e.jsxs("div",{className:A("relative flex items-center gap-2 p-3 border-t border-edge-subtle",r),children:[E&&e.jsx("div",{className:"absolute bottom-full left-3 right-3 mb-1 radius-inset surface-elevated depth-raised overflow-hidden z-50",children:b.map((R,p)=>{const j=ut(R),{emoji:C,cleanName:k}=dt(R),F=mt(R);return e.jsxs("button",{onMouseDown:N=>{N.preventDefault(),_(R)},className:A("w-full flex items-center gap-2.5 px-3 py-1.5 text-left transition-colors",p===v?"bg-sys-blue/10":"hover:bg-subtle-fill"),children:[e.jsx("div",{className:A("clay-avatar w-5 h-5",C?"text-xs":"text-white text-[9px] font-bold"),style:{"--avatar-color":j},children:C||F}),e.jsx("span",{className:"text-sm text-fg-primary truncate",children:k})]},R)})}),e.jsx("input",{ref:d,type:"text",value:o,onChange:M,onKeyDown:$,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:y,disabled:!o.trim()||c||n,className:A("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(ur,{className:"w-4.5 h-4.5 -translate-x-[0.5px] translate-y-[0.5px]",strokeWidth:2.5})})]})}),Pt="pymc_companion_room_pwd_";function jc(s){try{return localStorage.getItem(`${Pt}${s}`)}catch{return null}}function vc(s,t){try{localStorage.setItem(`${Pt}${s}`,t)}catch{}}function Ds(s){try{localStorage.removeItem(`${Pt}${s}`)}catch{}}const Nc=l.memo(function({contact:t,loginStatus:n,onLogin:a,className:r}){const[i,o]=l.useState(""),[m,c]=l.useState(!0),[f,d]=l.useState(null),[x,g]=l.useState(!1),h=l.useRef(null),u=l.useRef(!0),v=t.public_key,S=l.useRef(v);S.current!==v&&(S.current=v,g(!1),d(null),o("")),l.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]),l.useEffect(()=>{if(x||n==="success")return;const _=jc(v);if(!_){g(!0);return}g(!0),(async()=>{const y=await a(v,_);u.current&&(y||(Ds(v),d("Saved password rejected — please re-enter.")))})()},[v,x,n,a]);const b=l.useCallback(async()=>{d(null);const _=await a(v,i);u.current&&(_?m&&i?vc(v,i):Ds(v):d("Login failed — check your password and try again."))},[v,i,m,a]),E=l.useCallback(_=>{_.key==="Enter"&&(_.preventDefault(),b())},[b]),I=n==="pending";return I&&!i?e.jsxs("div",{className:A("flex-1 flex flex-col items-center justify-center gap-3",r),children:[e.jsx(oe,{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(ae.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:A("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(it,{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(cn,{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:h,type:"password",value:i,onChange:_=>o(_.target.value),onKeyDown:E,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:m,onChange:_=>c(_.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(H,{color:"pink",className:"w-full justify-center",disabled:I,onClick:b,children:[I?e.jsx(oe,{"data-slot":"icon",className:"animate-spin"}):e.jsx(kt,{"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 Os(s,t){return[s,t].sort().join("-")}function tt(s){return s.substring(0,2)}function wc(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 kc(s,t,n,a){const{edgeMap:r}=n;if(r.size===0)return null;const i=new Map;for(const[,y]of r){const M=y.fromHash,$=y.toHash;i.has(M)||i.set(M,[]),i.has($)||i.set($,[]),i.get(M).push({neighbor:$,edge:y}),i.get($).push({neighbor:M,edge:y})}const o=new Set(i.keys()),m=Ls(s,o),c=Ls(t,o);if(!m||!c||m===c)return null;const f=new Map,d=new Map,x=new Set,g=[];for(f.set(m,0),d.set(m,null),g.push({node:m,cost:0});g.length>0;){g.sort(($,R)=>$.cost-R.cost);const y=g.shift();if(x.has(y.node))continue;if(x.add(y.node),y.node===c)break;const M=i.get(y.node)??[];for(const{neighbor:$,edge:R}of M){if(x.has($))continue;const p=wc(R),j=y.cost+1/p,C=f.get($)??1/0;j{var F,N;const $=tt(y),R=v.get($);let p=0;const j=h[M],C=Os(j,y),k=r.get(C);return(N=(F=k==null?void 0:k.traceQuality)==null?void 0:F.composite)!=null&&N.mean?p=k.traceQuality.composite.mean:(k==null?void 0:k.avgSnr)!=null&&(p=k.avgSnr),{hash:y,prefix:$,name:(R==null?void 0:R.name)||null,snr:p}});let E=0,I=0;for(let y=0;y0?E/I:0;return{hops:S.map(tt),confidence:_,via:b}}function Ls(s,t){if(t.has(s))return s;const n=tt(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 m=Math.min(s.length,i.length);for(let c=0;cr&&(r=o,a=i)}return a}function zs(s){switch(s&15){case 1:return"Companion";case 2:return"Repeater";case 3:return"Room Server";default:return"Unknown"}}function Bs(s){switch(s&15){case 1:return"blue";case 2:return"green";case 3:return"indigo";default:return"zinc"}}function Cc(s){return(s&15)===2}const Hs=l.memo(function({contact:t,channel:n,contacts:a=[],selfPubKey:r,embedded:i=!1,onResetPath:o,onRequestStatus:m,onRequestTelemetry:c,onLoginToRepeater:f,onLogoutFromRepeater:d,onGetNeighbours:x,onTraceContactPath:g,onDiscoverPath:h,onExportContact:u,onSetContactPath:v,className:S}){const[b,E]=l.useState({}),I=Ct(),_=(t==null?void 0:t.public_key)??null,[y,M]=l.useState(_);if(_!==y&&(M(_),E({})),!t&&!n)return i?null:e.jsx("div",{className:A("flex items-center justify-center h-full",S),children:e.jsx("p",{className:"text-sm text-fg-muted",children:"Select a conversation"})});async function $(C,k){E(N=>({...N,[C]:"loading"}));const F=await k();E(N=>({...N,[C]:F?"done":"error"})),setTimeout(()=>E(N=>({...N,[C]:"idle"})),2e3)}const R=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(Fe,{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($e,{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,p=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(Ec,{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(Us,{pubkey:t.public_key})]}),e.jsx($e,{color:Bs(t.adv_type),children:zs(t.adv_type)})]})]}),i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{color:Bs(t.adv_type),children:zs(t.adv_type)}),e.jsx(Us,{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(Ke,{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>=0?(()=>{const C=St(t.out_path_len);return C.hopCount>0?`${C.hopCount} hop${C.hopCount===1?"":"s"} · ${C.hashSize}B`:"direct"})():"unknown"})]}),(t.gps_lat!==0||t.gps_lon!==0)&&e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx(dn,{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(un,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted",children:"Last Heard"}),e.jsxs("span",{className:"text-fg-primary ml-auto",children:[mr(new Date((t.lastmod||t.last_advert_timestamp)*1e3),I,{month:"short",day:"numeric"})," ",xs(new Date((t.lastmod||t.last_advert_timestamp)*1e3),I)]})]}),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:xs(new Date(t.last_advert_timestamp*1e3),I)})]})]}),e.jsx(Tc,{contact:t,contacts:a,selfPubKey:r,onSetContactPath:v,onDiscoverPath:h,actionState:b,setActionState:E,runAction:$}),e.jsxs("div",{className:"space-y-2 pt-2 border-t border-edge-subtle",children:[e.jsxs(H,{color:b.reset==="done"?"success":b.reset==="error"?"danger":"primary",outline:!0,className:"w-full justify-center",disabled:b.reset==="loading",onClick:()=>$("reset",()=>o(t.public_key)),children:[e.jsx(on,{"data-slot":"icon"}),b.reset==="loading"?"Resetting…":b.reset==="done"?"Reset!":"Reset Path"]}),e.jsxs(H,{color:b.status==="done"?"success":b.status==="error"?"danger":"primary",outline:!0,className:"w-full justify-center",disabled:b.status==="loading",onClick:()=>$("status",()=>m(t.public_key)),children:[e.jsx(mn,{"data-slot":"icon"}),b.status==="loading"?"Requesting…":"Request Status"]}),e.jsxs(H,{color:b.telemetry==="done"?"success":b.telemetry==="error"?"danger":"primary",outline:!0,className:"w-full justify-center",disabled:b.telemetry==="loading",onClick:()=>$("telemetry",()=>c(t.public_key)),children:[e.jsx(pn,{"data-slot":"icon"}),b.telemetry==="loading"?"Requesting…":"Request Telemetry"]})]}),u&&e.jsxs(H,{color:"primary",outline:!0,className:"w-full justify-center",onClick:()=>u(t.public_key),children:[e.jsx(Mt,{"data-slot":"icon"}),"Export Contact"]}),Cc(t.adv_type)&&e.jsxs(e.Fragment,{children:[e.jsx(Ac,{pubkey:t.public_key,onLogin:f,onLogout:d,actionState:b,runAction:$}),e.jsx($c,{pubkey:t.public_key,onGetNeighbours:x,actionState:b,runAction:$}),e.jsx(Fc,{pubkey:t.public_key,contact:t,onTrace:g,actionState:b,runAction:$})]}),e.jsx(Sc,{pubkey:t.public_key}),e.jsx(Rc,{pubkey:t.public_key})]}):null,j=R??p;return i?e.jsx("div",{className:S,children:j}):e.jsx("div",{className:A("flex flex-col h-full overflow-y-auto",S),children:e.jsx(he,{mode:"wait",children:n?e.jsx(ae.div,{variants:Ml,initial:"hidden",animate:"visible",exit:"exit",className:"p-4",children:R},`ch-${n.index}`):t?e.jsx(ae.div,{variants:Rl,initial:"hidden",animate:"visible",exit:"exit",className:"p-4",children:p},`contact-${t.public_key}`):null})})});function Ws(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 Sc({pubkey:s}){const t=yr(s);return t?e.jsxs(Ie,{defaultOpen:!0,className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Me,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(mn,{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(Re,{children:e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsx(Y,{label:"Battery",value:`${(t.battMilliVolts/1e3).toFixed(2)}V`}),e.jsx(Y,{label:"Noise Floor",value:`${t.noiseFloor} dBm`}),e.jsx(Y,{label:"Last RSSI",value:`${t.lastRssi} dBm`}),e.jsx(Y,{label:"Last SNR",value:`${(t.lastSnr/4).toFixed(1)} dB`}),e.jsx(Y,{label:"Uptime",value:Ws(t.totalUpTimeSecs)}),e.jsx(Y,{label:"Air Time",value:Ws(t.totalAirTimeSecs)}),e.jsx(Y,{label:"TX Queue",value:String(t.currTxQueueLen)}),e.jsx(Y,{label:"Packets Rx",value:String(t.nPacketsRecv)}),e.jsx(Y,{label:"Packets Tx",value:String(t.nPacketsSent)}),e.jsx(Y,{label:"Flood Rx/Tx",value:`${t.nRecvFlood}/${t.nSentFlood}`}),e.jsx(Y,{label:"Direct Rx/Tx",value:`${t.nRecvDirect}/${t.nSentDirect}`}),e.jsx(Y,{label:"Dups (D/F)",value:`${t.nDirectDups}/${t.nFloodDups}`}),t.errEvents>0&&e.jsx(Y,{label:"Errors",value:String(t.errEvents)})]})})]}):null}function Y({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 _c(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 Ic(s){switch(s){case 104:return"%";case 116:return"V";case 117:return"A";case 120:return"%";case 125:return" ppm";case 128:return"W";default:return""}}function Mc(s,t,n){return s===103?vr(t,n,{minimumFractionDigits:2,maximumFractionDigits:2}):s===115?Nr(t,n):`${t.toFixed(s===116?2:0)}${Ic(s)}`}function Rc({pubkey:s}){const t=br(s),n=Ct();if(!t)return null;const a=Wi(t.lppSensorData);return a.length===0?null:e.jsxs(Ie,{defaultOpen:!0,className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Me,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(pn,{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(Re,{children:e.jsx("div",{className:"space-y-1.5 py-1",children:a.map((r,i)=>typeof r.value=="object"?e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Y,{label:`Ch${r.channel} GPS Lat`,value:r.value.latitude.toFixed(5)}),e.jsx(Y,{label:`Ch${r.channel} GPS Lon`,value:r.value.longitude.toFixed(5)}),e.jsx(Y,{label:`Ch${r.channel} GPS Alt`,value:jr(r.value.altitude,n)})]},i):e.jsx(Y,{label:`Ch${r.channel} ${_c(r.type)}`,value:typeof r.value=="number"?Mc(r.type,r.value,n):String(r.value)},i))})})]})}function Ec({contact:s}){const{emoji:t}=dt(s.name||""),n=ut(s.name||s.public_key),a=s.name?mt(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(Be,{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(it,{className:"size-7 text-sys-pink"})}):e.jsx("div",{className:A("w-14 h-14 clay-avatar",t?"text-2xl":"text-white text-lg font-bold"),style:{"--avatar-color":n},children:t||a})}function Us({pubkey:s}){return pr().get(s)!==!0?null:e.jsx("span",{title:"Ed25519 verified identity",children:e.jsx(Tl,{className:"w-4 h-4 text-sys-green flex-shrink-0"})})}const bt=64;function Pc(s,t=1){if(!s)return[];const n=[],a=t*2;for(let r=0;r=0?St(s.out_path_len):null,_=(I==null?void 0:I.hopCount)??0,y=_>0,M=Pc(s.out_path,I==null?void 0:I.hashSize),$=l.useCallback(async()=>{if(!a)return;const j=d.split(",").map(F=>F.trim()).filter(Boolean);if(j.length===0){h("Enter at least one hop");return}if(j.length>bt){h(`Max ${bt} hops`);return}if(!j.every(F=>/^[0-9a-fA-F]{1,2}$/.test(F))){h("Each hop must be 1-2 hex characters");return}h(null),o(F=>({...F,path:"loading"}));const k=await a(s.public_key,j);o(F=>({...F,path:k?"done":"error"})),k&&f(!1),setTimeout(()=>o(F=>({...F,path:"idle"})),2e3)},[a,d,s.public_key,o]),R=l.useCallback(()=>{if(!n){b("Self identity not available");return}const j=kc(n,s.public_key,E,t);j?(v(j),b(null)):(v(null),b("No route found in topology"))},[n,s.public_key,E,t]),p=l.useCallback(async()=>{if(!a||!u)return;o(C=>({...C,path:"loading"}));const j=await a(s.public_key,u.hops);o(C=>({...C,path:j?"done":"error"})),j&&(v(null),b(null)),setTimeout(()=>o(C=>({...C,path:"idle"})),2e3)},[a,u,s.public_key,o]);return e.jsxs(Ie,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Me,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(Ke,{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:y?`${_} hop${_>1?"s":""}`:"direct"})]}),e.jsx(Re,{children:e.jsxs("div",{className:"space-y-2 py-1",children:[M.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"}),M.map((j,C)=>e.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill font-mono text-[10px] text-fg-primary",children:j},C))]}),u&&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(Ns,{className:"w-3 h-3"}),e.jsxs("span",{children:["Auto-route (",u.via.length," hop",u.via.length!==1?"s":"",", ",Math.round(u.confidence*100),"% confidence)"]})]}),e.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:u.via.map((j,C)=>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:j.prefix}),j.name&&e.jsxs("span",{className:"text-fg-muted",children:["(",j.name,")"]}),j.snr!==0&&e.jsx("span",{className:A("font-mono",at(j.snr)),children:j.snr.toFixed(1)})]},C))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(H,{color:i.path==="done"?"success":"primary",outline:!0,className:"flex-1 justify-center text-xs",disabled:i.path==="loading",onClick:p,children:[e.jsx(ge,{"data-slot":"icon"}),i.path==="loading"?"Saving…":"Accept"]}),e.jsxs(H,{plain:!0,className:"text-xs",onClick:()=>{v(null),b(null)},children:[e.jsx(ot,{"data-slot":"icon"}),"Dismiss"]})]})]}),S&&!u&&e.jsx("p",{className:"text-[9px] text-sys-amber",children:S}),a&&!u&&e.jsx("div",{className:"flex items-center gap-2",children:c?e.jsxs("div",{className:"space-y-1.5 flex-1",children:[e.jsx("input",{type:"text",value:d,onChange:j=>{x(j.target.value),h(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 ",bt,")"]}),g&&e.jsx("p",{className:"text-[9px] text-sys-red",children:g}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(H,{color:i.path==="done"?"success":i.path==="error"?"danger":"primary",outline:!0,className:"flex-1 justify-center text-xs",disabled:i.path==="loading"||!d.trim(),onClick:$,children:[e.jsx(Al,{"data-slot":"icon"}),i.path==="loading"?"Saving…":"Save"]}),e.jsx(H,{plain:!0,className:"text-xs",onClick:()=>{f(!1),h(null)},children:"Cancel"})]})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{f(!0),x(M.length>0?M.join(", "):""),h(null)},className:"text-[10px] text-sys-blue hover:text-sys-blue/80 transition-colors",children:"Edit path…"}),n&&E.edgeMap.size>0&&e.jsxs("button",{onClick:R,className:"inline-flex items-center gap-0.5 text-[10px] text-sys-indigo hover:text-sys-indigo/80 transition-colors",children:[e.jsx(Ns,{className:"w-3 h-3"}),"Auto-route"]}),r&&e.jsxs("button",{onClick:()=>m("discover",()=>r(s.public_key)),disabled:i.discover==="loading",className:A("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($l,{className:"w-3 h-3"}),i.discover==="loading"?"Discovering…":i.discover==="done"?"Discovered!":i.discover==="error"?"Failed":"Discover"]})]})})]})})]})}function Ac({pubkey:s,onLogin:t,onLogout:n,actionState:a,runAction:r}){const[i,o]=l.useState(""),m=_t(s);return t?e.jsxs(Ie,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Me,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(kt,{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"}),m!=="idle"&&e.jsx($e,{color:m==="success"?"green":m==="failed"?"red":"amber",className:"ml-auto text-[9px]",children:m})]}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-1.5 py-1",children:m==="success"&&n?e.jsxs(H,{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(hr,{"data-slot":"icon"}),a.logout==="loading"?"Disconnecting…":"Disconnect"]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"password",value:i,onChange:c=>o(c.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(H,{color:m==="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(kt,{"data-slot":"icon"}),a.login==="loading"?"Logging in…":"Login"]})]})})})]}):null}function $c({pubkey:s,onGetNeighbours:t,actionState:n,runAction:a}){const r=fr(s),i=_t(s);return t?e.jsxs(Ie,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Me,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(Nt,{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(Re,{children:e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsxs(H,{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(Nt,{"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,m)=>m.snr-o.snr).map((o,m)=>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:Oc(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:A("h-full rounded-full",Dc(o.snr)),style:{width:`${Math.min(100,Math.max(5,(o.snr+20)/35*100))}%`}})}),e.jsx("span",{className:A("font-mono text-[9px] w-8 text-right",at(o.snr)),children:o.snr.toFixed(1)})]})]},m))})]})})]}):null}function Fc({pubkey:s,contact:t,onTrace:n,actionState:a,runAction:r}){const i=gr(s);if(!n)return null;const o=t.out_path_len>=0&&St(t.out_path_len).hopCount>0;return e.jsxs(Ie,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Me,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(ws,{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.hopCount," hops"]})]}),e.jsx(Re,{children:e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsxs(H,{color:"primary",outline:!0,className:"w-full justify-center text-xs",disabled:a.trace==="loading"||!o,onClick:()=>r("trace",()=>n(s)),children:[e.jsx(ws,{"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((m,c)=>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:c+1}),e.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill font-mono text-[10px] text-fg-primary",children:m.hash}),m.name&&e.jsx("span",{className:"text-fg-muted text-[10px] truncate",children:m.name}),e.jsxs("span",{className:A("font-mono text-[10px] ml-auto",at(m.snr)),children:[m.snr.toFixed(1)," dB"]})]},c)),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:A("font-mono text-[10px]",at(i.lastSnr)),children:[i.lastSnr.toFixed(1)," dB"]})]})]})]})})]})}function at(s){return s>5?"text-sys-green":s>0?"text-sys-amber":"text-sys-red"}function Dc(s){return s>5?"bg-sys-green":s>0?"bg-sys-amber":"bg-sys-red"}function Oc(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 Ks=128,qs=/^[0-9a-fA-F]+$/;function Lc({open:s,onClose:t}){const n=te(N=>N.exportPrivateKey),a=te(N=>N.importPrivateKey),[r,i]=l.useState("export"),[o,m]=l.useState(null),[c,f]=l.useState(!1),[d,x]=l.useState(!1),[g,h]=l.useState(""),[u,v]=l.useState(!1),[S,b]=l.useState(!1),[E,I]=l.useState(!1),[_,y]=l.useState(!1),[M,$]=l.useState(null),[R,p]=l.useState(!1);s!==R&&(p(s),s&&(i("export"),m(null),f(!1),x(!1),h(""),v(!1),b(!1),I(!1),y(!1),$(null)));const j=l.useCallback(async()=>{f(!0),$(null),y(!1);try{const N=await n();N==="disabled"?y(!0):m(N.hex)}catch(N){$(N instanceof Error?N.message:"Export failed")}finally{f(!1)}},[n]),C=l.useCallback(async()=>{if(o)try{await navigator.clipboard.writeText(o),x(!0),setTimeout(()=>x(!1),2e3)}catch{$("Failed to copy to clipboard")}},[o]),k=g.length===Ks&&qs.test(g),F=l.useCallback(async()=>{b(!1),v(!0),$(null),y(!1);try{await a(g)==="disabled"?y(!0):I(!0)}catch(N){$(N instanceof Error?N.message:"Import failed")}finally{v(!1)}},[a,g]);return e.jsxs(e.Fragment,{children:[e.jsxs(ve,{open:s,onClose:t,size:"md",solid:!0,children:[e.jsx(Ee,{icon:e.jsx(hn,{className:"w-5 h-5"}),title:"Key Management",onClose:t}),e.jsxs(Ne,{children:[_&&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(wr,{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(N=>e.jsxs("button",{onClick:()=>{i(N),$(null)},className:A("flex-1 flex items-center justify-center gap-1.5 py-1.5 px-3 rounded-md text-sm font-medium transition-colors",r===N?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:[N==="export"?e.jsx(We,{className:"w-3.5 h-3.5"}):e.jsx(Mt,{className:"w-3.5 h-3.5"}),N==="export"?"Export":"Import"]},N))}),r==="export"&&e.jsx("div",{className:"space-y-4",children:o?e.jsxs(re,{children:[e.jsx(le,{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:C,className:"absolute top-2 right-2 p-1.5 rounded-md hover:bg-subtle-fill-strong transition-colors",title:"Copy to clipboard",children:d?e.jsx(ge,{className:"w-3.5 h-3.5 text-sys-green"}):e.jsx(It,{className:"w-3.5 h-3.5 text-fg-muted"})})]}),e.jsx(Ce,{children:e.jsxs("span",{className:"flex items-start gap-1.5 mt-1",children:[e.jsx(Ue,{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(H,{color:"primary",onClick:j,disabled:c||_,children:c?"Exporting…":"Export Private Key"})]})}),r==="import"&&e.jsx("div",{className:"space-y-4",children:E?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(ge,{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(re,{children:[e.jsx(le,{children:"Private Key (128 hex characters)"}),e.jsx("textarea",{value:g,onChange:N=>h(N.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(Ce,{children:[g.length>0&&!k&&e.jsx("span",{className:"text-sys-red",children:qs.test(g)?`${g.length}/${Ks} characters`:"Invalid characters — hex only (0-9, a-f)"}),g.length>0&&k&&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(Ue,{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."]})]})]})}),M&&e.jsx("p",{className:"type-data-xs text-sys-red mt-3",children:M})]}),e.jsxs(Pe,{children:[e.jsx(H,{plain:!0,onClick:t,children:"Close"}),r==="import"&&!E&&e.jsx(H,{color:"danger",onClick:()=>b(!0),disabled:!k||u||_,children:u?"Importing…":"Import Key"})]})]}),e.jsx(xn,{isOpen:S,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:F,onCancel:()=>b(!1)})]})}function Yn(s){return s.settings??{}}const Zn="pymc_companion_recent_regions",Tt=8;function ea(){try{const s=localStorage.getItem(Zn);return s?JSON.parse(s).slice(0,Tt):[]}catch{return[]}}function zc(s){try{localStorage.setItem(Zn,JSON.stringify(s.slice(0,Tt)))}catch{}}function Bc(s){const t=ea().filter(a=>a!==s);t.unshift(s);const n=t.slice(0,Tt);return zc(n),n}function Gs(s){return s.toLowerCase().replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Hc({open:s,onClose:t,mode:n,identity:a,onSave:r}){const i=n==="edit"&&a,[o,m]=l.useState(""),[c,f]=l.useState(""),[d,x]=l.useState(""),[g,h]=l.useState(!1),[u,v]=l.useState(""),[S,b]=l.useState(5e3),[E,I]=l.useState("0.0.0.0"),[_,y]=l.useState(!1),[M,$]=l.useState(null),[R,p]=l.useState(""),j=`${s}-${(a==null?void 0:a.name)??""}-${n}`;if(j!==R)if(p(j),$(null),y(!1),h(!1),i){const k=Yn(a);m(a.name),f(""),x(a.identity_key??""),v(k.node_name??a.name),b(k.tcp_port??5e3),I(k.bind_address??"0.0.0.0")}else m(""),f(""),x(""),v(""),b(5e3),I("0.0.0.0");const C=l.useCallback(async()=>{var k,F;if(!i&&!o.trim()){$("Name is required");return}y(!0),$(null);try{if(i){const N={name:a.name,new_name:c,identity_key:d,type:"companion",settings:{node_name:u,tcp_port:S,bind_address:E}},D=await Er(N);if(!D.success&&!((k=D.data)!=null&&k.message))throw new Error(D.error||"Failed")}else{const N={name:o.trim(),identity_key:d,type:"companion",settings:{node_name:u||o.trim(),tcp_port:S??5e3,bind_address:E||"0.0.0.0"}},D=await Pr(N);if(!D.success&&!((F=D.data)!=null&&F.message))throw new Error(D.error||"Failed")}await r(),t()}catch(N){$(N instanceof Error?N.message:"Operation failed")}finally{y(!1)}},[i,a,o,c,d,u,S,E,r,t]);return e.jsxs(ve,{open:s,onClose:t,size:"md",solid:!0,children:[e.jsx(Ee,{icon:i?void 0:e.jsx(fe,{className:"w-5 h-5"}),title:i?"Edit Companion":"Add Companion",onClose:t}),e.jsx(Ne,{children:e.jsxs("div",{className:"space-y-5",children:[i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{color:a.registered?"green":"red",children:a.registered?"Configured":"Not registered"}),a.hash&&e.jsx("span",{className:"type-data-xs text-fg-muted",children:a.hash})]}),i?e.jsxs(e.Fragment,{children:[e.jsxs(re,{children:[e.jsx(le,{children:"Current Name"}),e.jsx(me,{value:a.name,disabled:!0})]}),e.jsxs(re,{children:[e.jsxs(le,{children:["New Name ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(me,{value:c,onChange:k=>f(k.target.value),placeholder:"Leave empty to keep current name"})]})]}):e.jsxs(re,{children:[e.jsx(le,{children:"Name"}),e.jsx(me,{value:o,onChange:k=>m(k.target.value),placeholder:"e.g., TestCompanion",autoFocus:!0})]}),e.jsxs(re,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(le,{children:["Identity Key ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx("button",{type:"button",onClick:()=>h(k=>!k),className:"type-data-xs text-fg-muted underline hover:text-fg-secondary",children:g?"Hide":"Show"})]}),g&&e.jsxs(e.Fragment,{children:[e.jsx(me,{value:d,onChange:k=>x(k.target.value),placeholder:i?"Leave empty to keep current key":"Leave empty to auto-generate",className:"font-mono"}),e.jsx(Ce,{children:"32 or 64 bytes hex."})]})]}),e.jsxs(re,{children:[e.jsx(le,{children:"Node Name"}),e.jsx(me,{value:u,onChange:k=>v(k.target.value),placeholder:"Display name"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(re,{children:[e.jsx(le,{children:"TCP Port"}),e.jsx(me,{type:"number",min:1,max:65535,value:S,onChange:k=>b(parseInt(k.target.value,10)||5e3)})]}),e.jsxs(re,{children:[e.jsx(le,{children:"Bind Address"}),e.jsx(me,{value:E,onChange:k=>I(k.target.value),placeholder:"0.0.0.0"})]})]}),M&&e.jsx("p",{className:"type-data-xs text-sys-red",children:M})]})}),e.jsxs(Pe,{children:[e.jsx(H,{plain:!0,onClick:t,children:"Cancel"}),e.jsx(H,{color:"primary",onClick:C,disabled:_,children:_?"Saving…":i?"Save":"Create"})]})]})}function Wc(){const s=Mr(),t=rn(),{setFloodScope:n,clearFloodScope:a}=te.getState(),[r,i]=l.useState(""),[o,m]=l.useState(!1),[c,f]=l.useState(ea),[d,x]=l.useState(null),g=l.useRef(null),h=r.trim()?Gs(r.trim()):"",u=l.useCallback(async b=>{const E=Gs(b);if(!E)return;m(!0),x(null),i(""),f(Bc(E)),await n(E)||x("Failed to set transport key on device"),m(!1)},[n]),v=l.useCallback(async()=>{m(!0),x(null),await a()||x("Failed to clear transport key on device"),m(!1)},[a]),S=l.useCallback(b=>{b.key==="Enter"&&h&&(b.preventDefault(),u(h))},[h,u]);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(He,{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(fn,{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(dn,{className:"w-3.5 h-3.5"}),"#",s]}),e.jsx("button",{onClick:v,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(oe,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsx(ot,{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(Rr,{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:g,type:"text",value:r,onChange:b=>i(b.target.value),onKeyDown:S,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(H,{color:"primary",onClick:()=>u(h),disabled:!h||o||!t,children:[o?e.jsx(oe,{"data-slot":"icon",className:"animate-spin"}):null,"Set"]})]}),h&&h!==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:["#",h]})]})]}),c.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(un,{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:c.map(b=>e.jsx("button",{onClick:()=>u(b),disabled:o||!t,className:A("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",b===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:["#",b]})},b))})]}),!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."}),d&&e.jsx("p",{className:"type-data-xs text-sys-red",children:d})]})}function Vs({open:s,onClose:t,onRefresh:n}){const[a,r]=l.useState("companions"),[i,o]=l.useState(null),[m,c]=l.useState(!0),[f,d]=l.useState(!1),[x,g]=l.useState("create"),[h,u]=l.useState(null),[v,S]=l.useState(null),[b,E]=l.useState(!1),[I,_]=l.useState(!1),y=l.useRef(!0);l.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]);const[M,$]=l.useState(!1);s!==M&&($(s),s&&r("companions"));const R=l.useCallback(async()=>{c(!0);try{const T=await kr();y.current&&T.success&&T.data&&o(T.data)}catch{}finally{y.current&&c(!1)}},[]);l.useEffect(()=>{s&&R()},[s,R]);const p=(i==null?void 0:i.configured_companions)??[],j=l.useCallback(async()=>{await R(),n==null||n()},[R,n]),C=l.useCallback(async()=>{if(v){E(!0);try{await Cr(v.name,"companion"),await j()}catch{}finally{y.current&&(E(!1),S(null))}}},[v,j]),k=Sr(),F=an(),{setCompanionPaused:N}=te.getState(),[D,q]=l.useState({});l.useEffect(()=>{if(!(i!=null&&i.configured_companions))return;const T={};for(const z of i.configured_companions)T[z.name]=_r(z.name);q(T)},[i]);const X=l.useCallback(T=>T===F?k:D[T]??!1,[F,k,D]),[L,G]=l.useState(null),w=l.useCallback(async(T,z)=>{G(T);try{await N(T,!z),q(O=>({...O,[T]:!z}))}finally{y.current&&G(null)}},[N]);return e.jsxs(e.Fragment,{children:[e.jsxs(ve,{open:s,onClose:t,size:"md",solid:!0,children:[e.jsx(Ee,{icon:e.jsx(fe,{className:"w-5 h-5"}),title:"Companion Configuration",onClose:t}),e.jsxs(Ne,{children:[e.jsx("div",{className:"flex gap-1 mb-4 p-0.5 rounded-lg bg-subtle-fill",children:[["companions","Companions",fe],["transport","Transport Key",fn]].map(([T,z,O])=>e.jsxs("button",{onClick:()=>r(T),className:A("flex-1 flex items-center justify-center gap-1.5 py-1.5 px-3 rounded-md text-sm font-medium transition-colors",a===T?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:[e.jsx(O,{className:"w-3.5 h-3.5"}),z]},T))}),a==="companions"&&e.jsx(e.Fragment,{children:m?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(oe,{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.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 rounded-lg border border-sys-blue/10 bg-sys-blue/5 p-3",children:[e.jsx(He,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-sys-blue"}),e.jsx("p",{className:"type-data-xs text-fg-muted",children:"This switch only controls openHop Console's browser companion session. Turning it off releases the browser frame connection so external apps can connect; it does not stop the companion identity or companion service from working in the repeater."})]}),p.map(T=>{const z=Yn(T),O=X(T.name),W=L===T.name;return e.jsxs("div",{className:A("bg-subtle-fill radius-inner p-3 hover:bg-subtle-fill-strong transition-base",O&&"opacity-60"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:A("h-2 w-2 rounded-full flex-shrink-0",O?"bg-fg-muted":"bg-sys-blue")}),e.jsx("h3",{className:"type-body-sm text-fg-primary font-medium truncate flex-1",children:T.name}),e.jsx($e,{color:O?"zinc":"blue",children:O?"Browser off":"Browser on"}),e.jsx(H,{color:"primary",plain:!0,onClick:()=>{u(T),g("edit"),d(!0)},children:e.jsx(Dl,{"data-slot":"icon"})}),e.jsx(Ir,{enabled:!O,onChange:V=>w(T.name,V),size:"sm",disabled:W,status:W?"loading":"idle",tooltip:O?"Allow Console to connect in this browser":"Release Console browser connection for external apps",dangerOff:!0}),e.jsx(H,{color:"danger",plain:!0,onClick:()=>S(T),children:e.jsx(qe,{"data-slot":"icon"})})]}),e.jsxs("div",{className:"mt-1.5 type-data-xs text-fg-muted pl-5",children:[z.node_name||T.name," · Port ",z.tcp_port??5e3," · ",z.bind_address||"0.0.0.0"," · ",O?"external apps can connect":"external apps cannot use this companion while Browser on"]})]},T.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(fe,{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(Wc,{})]}),e.jsxs(Pe,{children:[a==="companions"&&e.jsx(H,{plain:!0,onClick:()=>_(!0),title:"Key Management",children:e.jsx(hn,{"data-slot":"icon"})}),e.jsx("div",{className:"flex-1"}),e.jsx(H,{plain:!0,onClick:t,children:"Close"}),a==="companions"&&e.jsxs(H,{color:"primary",onClick:()=>{u(null),g("create"),d(!0)},children:[e.jsx(Ge,{"data-slot":"icon"})," Add Companion"]})]})]}),e.jsx(Hc,{open:f,onClose:()=>d(!1),mode:x,identity:h,onSave:j}),e.jsx(xn,{isOpen:!!v,title:"Delete Companion",message:`Delete '${v==null?void 0:v.name}'? A service restart is required.`,confirmLabel:b?"Deleting…":"Delete",cancelLabel:"Cancel",variant:"danger",onConfirm:C,onCancel:()=>S(null)}),e.jsx(Lc,{open:I,onClose:()=>_(!1)})]})}const Uc=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))})}),ze=[{value:"Chat Node",label:"Companions"},{value:"Room Server",label:"Room Servers"},{value:"Repeater",label:"Repeaters"}],Kc=[{value:"all",label:"All time"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function qc(s){switch(s){case"24h":return 24;case"7d":return 168;case"30d":return 720;default:return}}function Gc({open:s,onClose:t,companionName:n,onImport:a}){const[r,i]=l.useState(()=>new Set(ze.map(_=>_.value))),[o,m]=l.useState("all"),[c,f]=l.useState(""),[d,x]=l.useState(!1),[g,h]=l.useState(null),[u,v]=l.useState(s);s!==u&&(v(s),s&&(i(new Set(ze.map(_=>_.value))),m("all"),f(""),x(!1),h(null)));const S=r.size===ze.length;function b(_){i(y=>{const M=new Set(y);return M.has(_)?M.delete(_):M.add(_),M})}function E(){i(S?new Set:new Set(ze.map(_=>_.value)))}const I=l.useCallback(async()=>{if(!(r.size===0||d)){x(!0),h(null);try{const _={types:[...r],hours:qc(o)},y=parseInt(c,10);y>0&&(_.limit=y);const M=await a(_);h(M)}finally{x(!1)}}},[r,o,c,d,a]);return e.jsxs(ve,{open:s,onClose:t,size:"sm",children:[e.jsx(Ee,{title:"Import repeater contacts",onClose:t}),e.jsx(Ne,{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(re,{children:[e.jsx(le,{children:"Contact types"}),e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsx(hs,{checked:S,indeterminate:r.size>0&&!S,onChange:E,label:"All types",size:"sm"}),e.jsx("div",{className:"ml-6 space-y-1.5",children:ze.map(_=>e.jsx(hs,{checked:r.has(_.value),onChange:()=>b(_.value),label:_.label,size:"sm"},_.value))})]})]}),e.jsx(Fl,{label:"Recency",value:o,onChange:m,options:Kc,orientation:"horizontal",size:"sm"}),e.jsxs(re,{children:[e.jsxs(le,{children:["Import at most ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(optional)"})]}),e.jsx(me,{type:"number",min:1,value:c,onChange:_=>f(_.target.value),placeholder:"No limit",className:"mt-1"}),e.jsx(Ce,{children:"Leave empty for no cap."})]}),g&&e.jsxs("p",{className:"text-sm text-sys-green font-medium",children:["Imported ",g.added," new contact",g.added!==1?"s":""," (",g.total," total)"]})]})}),e.jsxs(Pe,{children:[e.jsx(H,{plain:!0,onClick:t,children:"Cancel"}),e.jsx(H,{color:"primary",onClick:I,disabled:d||r.size===0,children:d?e.jsxs(e.Fragment,{children:[e.jsx(oe,{"data-slot":"icon",className:"animate-spin"}),"Importing…"]}):"Import"})]})]})}const Vc=["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"],Jc=new Set(Vc);function Qc(){return crypto.getRandomValues(new Uint8Array(16))}function Js(s){return Array.from(s).map(t=>t.toString(16).padStart(2,"0")).join("")}function jt(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 Xc(s){const n=`#${ln(s)}`,a=new TextEncoder().encode(n);return(await Tr(a)).slice(0,16)}const Qs=[{key:"create-private",label:"Create Private",icon:Nl,desc:"Generate a new private channel with a random key"},{key:"join-private",label:"Join Private",icon:gi,desc:"Join an existing private channel using a shared key"},{key:"join-hashtag",label:"Join Hashtag",icon:Fe,desc:"Join a public hashtag channel (key derived from name)"}];function Yc({open:s,onClose:t,channels:n,onAddChannel:a}){var C;const[r,i]=l.useState("join-hashtag"),[o,m]=l.useState(""),[c,f]=l.useState(""),[d,x]=l.useState(null),[g,h]=l.useState(!1),[u,v]=l.useState(""),[S,b]=l.useState(!1),[E,I]=l.useState(s);s!==E&&(I(s),s&&(i("join-hashtag"),m(""),f(""),x(null),h(!1),v(""),b(!1)));const _=l.useMemo(()=>n.length===0?0:Math.max(...n.map(k=>k.index))+1,[n]),y=l.useMemo(()=>r!=="join-hashtag"?"":ln(o),[r,o]),M=l.useMemo(()=>{if(!o.trim())return null;const k=r==="join-hashtag"&&y?`#${y}`:o.trim();return n.find(F=>F.name===k)??null},[o,r,y,n]),$=l.useMemo(()=>r==="join-hashtag"&&y?Jc.has(y):!1,[r,y]),R=l.useMemo(()=>{if(!o.trim()||M)return!1;switch(r){case"create-private":return o.trim().length>0&&o.trim().length<=32;case"join-private":return o.trim().length>0&&jt(c)!==null;case"join-hashtag":return y.length>0;default:return!1}},[r,o,c,y,M]),p=l.useCallback(async()=>{d&&(await navigator.clipboard.writeText(Js(d)),b(!0),setTimeout(()=>b(!1),2e3))},[d]),j=l.useCallback(async()=>{if(!(!R||g)){h(!0),v("");try{let k,F;switch(r){case"create-private":{k=Qc(),F=o.trim();break}case"join-private":{const D=jt(c);if(!D){v("Invalid hex key (must be 32 hex chars = 16 bytes)");return}k=D,F=o.trim();break}case"join-hashtag":{k=await Xc(o),F=`#${y}`;break}default:return}if(await a(_,F,k)){if(r==="create-private"){x(k);return}t()}else v("Failed to add channel — device may be unreachable")}catch(k){v(k instanceof Error?k.message:"Unknown error")}finally{h(!1)}}},[R,g,r,o,c,y,_,a,t]);return e.jsxs(ve,{open:s,onClose:t,size:"sm",children:[e.jsx(Ee,{title:"Add Channel",onClose:t}),e.jsx(Ne,{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:Qs.map(k=>{const F=k.icon,N=r===k.key;return e.jsxs("button",{onClick:()=>{i(k.key),v(""),x(null)},className:A("flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors",N?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:[e.jsx(F,{className:"w-3.5 h-3.5"}),k.label]},k.key)})}),e.jsx("p",{className:"text-xs text-fg-muted",children:(C=Qs.find(k=>k.key===r))==null?void 0:C.desc}),d&&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:Js(d)}),e.jsx("button",{onClick:p,className:"p-1.5 rounded hover:bg-subtle-fill transition-colors flex-shrink-0",title:"Copy key",children:S?e.jsx(ge,{className:"w-3.5 h-3.5 text-sys-green"}):e.jsx(It,{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(re,{children:[e.jsx(le,{children:r==="join-hashtag"?"Hashtag name":"Channel name"}),e.jsx(me,{type:"text",value:o,onChange:k=>m(k.target.value),placeholder:r==="join-hashtag"?"e.g. south-bay":"e.g. My Channel",maxLength:32,className:"mt-1",disabled:!!d}),r==="join-hashtag"&&y&&y!==o&&e.jsxs(Ce,{className:"mt-1",children:["Will be registered as ",e.jsxs("code",{className:"text-fg-primary font-mono text-[11px]",children:["#",y]})]}),r==="join-hashtag"&&$&&e.jsx(Ce,{className:"mt-1 text-sys-green",children:"Known region channel"})]}),M&&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(Ue,{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:M.name})," already exists at slot ",M.index,". Remove it first to re-add."]})]}),r==="join-private"&&e.jsxs(re,{children:[e.jsxs(le,{children:["Channel key ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(32 hex chars)"})]}),e.jsx(me,{type:"text",value:c,onChange:k=>f(k.target.value),placeholder:"e.g. a1b2c3d4e5f6...",maxLength:32,className:"mt-1 font-mono text-xs"}),c&&!jt(c)&&e.jsx(Ce,{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:_})]}),u&&e.jsx("p",{className:"text-xs text-sys-red font-medium",children:u})]})}),e.jsxs(Pe,{children:[e.jsx(H,{plain:!0,onClick:t,children:d?"Done":"Cancel"}),!d&&e.jsx(H,{color:"primary",onClick:j,disabled:!R||g,children:g?e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"w-4 h-4 animate-spin"}),"Adding…"]}):r==="create-private"?"Create Channel":"Join Channel"})]})]})}const Zc=202,ed=/^[0-9a-fA-F]+$/;function td(s){const t=s.replace(/\s/g,"");return t.length>=Zc&&t.length%2===0&&ed.test(t)}const sd=l.memo(function({open:t,onClose:n,contacts:a,exportPubKey:r,onExport:i,onImport:o}){const[m,c]=l.useState(r?"export":"import"),[f,d]=l.useState(r??""),[x,g]=l.useState(""),[h,u]=l.useState(""),[v,S]=l.useState(!1),[b,E]=l.useState(!1),[I,_]=l.useState(!1),[y,M]=l.useState(null),[$,R]=l.useState(!1),p=l.useRef(null);l.useEffect(()=>{t&&(c(r?"export":"import"),d(r??""),g(""),u(""),S(!1),E(!1),_(!1),M(null),R(!1))},[t,r]);const j=l.useCallback(()=>{n()},[n]),C=l.useCallback(async()=>{if(!f)return;S(!0),M(null),g("");const N=await i(f);S(!1),N?g(N):M("Failed to export contact advert")},[f,i]),k=l.useCallback(async()=>{if(x)try{await navigator.clipboard.writeText(x),_(!0),setTimeout(()=>_(!1),2e3)}catch{M("Failed to copy to clipboard")}},[x]),F=l.useCallback(async()=>{const N=h.replace(/\s/g,"");if(!td(N)){M("Invalid hex — must be at least 202 hex characters (101 bytes)");return}E(!0),M(null);const D=await o(N);E(!1),D?(R(!0),u(""),setTimeout(()=>j(),1500)):M("Import failed — check the hex string and try again")},[h,o,j]);return e.jsxs(ve,{open:t,onClose:j,children:[e.jsx(Ar,{children:"Contact Import / Export"}),e.jsxs(Ne,{children:[e.jsxs("div",{className:"flex gap-1 p-0.5 rounded-lg bg-subtle-fill mb-4",children:[e.jsxs("button",{onClick:()=>{c("export"),M(null)},className:A("flex-1 flex items-center justify-center gap-1.5 py-1.5 rounded-md text-xs font-medium transition-colors",m==="export"?"bg-surface shadow-sm text-fg-primary":"text-fg-muted hover:text-fg-secondary"),children:[e.jsx(Mt,{className:"w-3.5 h-3.5"}),"Export"]}),e.jsxs("button",{onClick:()=>{c("import"),M(null)},className:A("flex-1 flex items-center justify-center gap-1.5 py-1.5 rounded-md text-xs font-medium transition-colors",m==="import"?"bg-surface shadow-sm text-fg-primary":"text-fg-muted hover:text-fg-secondary"),children:[e.jsx(We,{className:"w-3.5 h-3.5"}),"Import"]})]}),m==="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:N=>{d(N.target.value),g(""),M(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(N=>e.jsx("option",{value:N.public_key,children:N.name||N.public_key.slice(0,12)},N.public_key))]})]}),e.jsx(H,{color:"primary",outline:!0,className:"w-full justify-center",disabled:!f||v,onClick:C,children:v?"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(H,{color:I?"success":"primary",outline:!0,className:"w-full justify-center",onClick:k,children:[I?e.jsx(ge,{"data-slot":"icon"}):e.jsx(It,{"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:h,onChange:N=>{u(N.target.value),M(null),R(!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"})]}),$&&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(ge,{className:"w-3.5 h-3.5"}),"Contact imported successfully"]}),e.jsx(H,{color:"primary",outline:!0,className:"w-full justify-center",disabled:!h.trim()||b,onClick:F,children:b?"Importing…":"Import Contact"})]}),y&&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(cn,{className:"w-3.5 h-3.5 flex-shrink-0"}),y]})]}),e.jsx(Pe,{children:e.jsx(H,{plain:!0,onClick:j,children:"Close"})})]})});function Wd(){var ns,as,rs,ls,is,os;const s=$r(),t=an(),n=Fr(),a=Dr(),r=Or(),i=Lr(),o=ct(),m=zr(),c=Br(),f=Hr(),d=sn(),x=Wr(),g=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]),h=l.useMemo(()=>{const P=new Map;if(!(x!=null&&x.neighbors))return P;const B=[];for(const[K,ce]of Object.entries(x.neighbors))ce.zero_hop&&ce.rssi!=null&&ce.snr!=null&&ce.rssi!==0&&B.push({hash:(K.startsWith("0x")?K.slice(2):K).toLowerCase(),rssi:ce.rssi,snr:ce.snr,advertCount:ce.advert_count??1});if(B.length===0)return P;for(const K of g){const ce=K.public_key.toLowerCase();for(const xe of B)if(ce===xe.hash||ce.startsWith(xe.hash)){P.set(K.public_key,{rssi:xe.rssi,snr:xe.snr,advertCount:xe.advertCount});break}}return P},[x==null?void 0:x.neighbors,g]),u=Ur(),v=Kr(),S=rn(),b=qr(),E=Gr(t),I=Vr(),_=Jr(),y=Qr(),M=Xr(),$=Yr(),[R,p]=Zr(),[j,C]=l.useState(!1),[k,F]=l.useState(!1),[N,D]=l.useState(!1),[q,X]=l.useState(!1),[L,G]=l.useState(null),[w,T]=l.useState(!1),[z,O]=l.useState(!1),[W,V]=l.useState(!0),de="pymc_companion_contacts_micro",we="pymc_companion_split",[ye,xt]=l.useState(()=>{try{return localStorage.getItem(de)==="1"}catch{return!1}}),At=25,$t=75,[ht,Ft]=l.useState(()=>{try{const P=Number(localStorage.getItem(we));return P>=At&&P<=$t?P:50}catch{return 50}}),Ve=l.useRef(null),De=l.useRef(null),Dt=l.useRef(null),Je=l.useRef(!1),Oe=l.useRef(ht);Oe.current=ht;const ta=l.useCallback(P=>{P.preventDefault(),P.target.setPointerCapture(P.pointerId),Je.current=!0},[]),sa=l.useCallback(P=>{if(!Je.current||!Ve.current)return;const B=Ve.current.getBoundingClientRect(),K=Math.round(Math.min($t,Math.max(At,(P.clientX-B.left)/B.width*100)));Oe.current=K,De.current&&(De.current.style.width=`${K}%`)},[]),Ot=l.useCallback(()=>{if(!Je.current)return;Je.current=!1;const P=Oe.current;Ft(P);try{localStorage.setItem(we,String(P))}catch{}},[]),na=l.useCallback(()=>{Oe.current=50,De.current&&et(De.current,{width:"50%"},ne.layoutResize),Ft(50);try{localStorage.setItem(we,String(50))}catch{}},[]),aa=l.useCallback(P=>{if(xt(P),typeof window<"u"&&window.innerWidth<768)return;const B=Ve.current,K=Dt.current;if(!B)return;const ce=B.getBoundingClientRect().width;B.style.width=P?"var(--companion-side-micro)":"var(--companion-side)";const xe=B.getBoundingClientRect().width;if(B.style.width=`${ce}px`,K){const _a=P?56:Oe.current/100*xe,Ia=K.offsetWidth,Ma=Math.max(0,xe-_a-12);K.style.flex="none",K.style.width=`${Ia}px`,et(K,{width:`${Ma}px`},{...ne.layoutResize,onComplete(){K.style.flex="",K.style.width=""}})}et(B,{width:`${xe}px`},{...ne.layoutResize,onComplete(){B.style.width=P?"var(--companion-side-micro)":"var(--companion-side)"}})},[]),{selectCompanion:ra,selectConversation:be,sendMessage:Lt,sendChannelMessage:zt,retryMessage:la,retryMessageAsFlood:ia,resetPath:ft,shareContact:oa,removeContact:ca,addChannel:da,requestStatus:Bt,requestTelemetry:Ht,loginToRepeater:gt,logoutFromRepeater:Wt,getNeighbours:Ut,traceContactPath:Kt,discoverPath:qt,pingContact:ua,markAsRead:Gt,fetchCompanions:Vt,seedFromRepeater:ma,exportContactAdvert:pa,importContactAdvert:xa,setContactPath:Jt,deleteChannel:ha,loadOlderMessages:fa}=te.getState(),ga=l.useCallback(P=>{be(P),window.innerWidth>=1280?T(!0):O(!0)},[be]),Qt=te(P=>P.messages),Xt=te(P=>P.unreadMap);l.useEffect(()=>{Gt()},[u,Gt]),l.useEffect(()=>{const P=R.get("dm");P&&g.length>0&&g.find(K=>K.public_key===P)&&(be({type:"contact",id:P}),p({},{replace:!0}))},[R,g,be,p]);const ya=l.useMemo(()=>{const P=new Set;for(const B of g)B.name&&P.add(B.name);for(const B of v)B.sender_name&&!B.is_outgoing&&P.add(B.sender_name);return[...P].sort((B,K)=>B.localeCompare(K))},[g,v]),Yt=l.useMemo(()=>{const P=new Map;for(const B of g)B.name&&P.set(B.name.toLowerCase(),B.public_key);for(const B of v)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},[g,v]),ba=l.useCallback(P=>{const B=Yt.get(P.toLowerCase());B&&(be({type:"contact",id:B}),T(!0))},[Yt,be]),ja=l.useCallback(async P=>u?u.type==="channel"?zt(Number(u.id),P):Lt(u.id,P):!1,[u,Lt,zt]),va=S&&!I,Zt=y!=null&&(y.adv_type&15)===3,es=_t(Zt?y.public_key:null),Na=Zt&&es!=="success",ts=el(),[ue,Te]=l.useState("idle"),wa=l.useCallback(async()=>{Te("flood-sending");const P=await te.getState().sendFloodAdvert();Te(P?"flood-done":"idle"),P&&setTimeout(()=>Te(B=>B==="flood-done"?"idle":B),2e3)},[]),ka=l.useCallback(async()=>{Te("zero-sending");const P=await te.getState().sendZeroHopAdvert();Te(P?"zero-done":"idle"),P&&setTimeout(()=>Te(B=>B==="zero-done"?"idle":B),2e3)},[]),Ca=e.jsxs("div",{className:"flex items-center gap-2",children:[S&&n&&e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsxs("button",{onClick:wa,disabled:ue!=="idle"&&ue!=="zero-done",className:A("inline-flex items-center gap-1.5 sm:gap-2 px-2.5 sm:px-3.5 py-1.5 sm: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",ue==="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:[ue==="flood-sending"?e.jsx(oe,{className:"w-4 h-4 animate-spin"}):e.jsx(Ci,{className:"w-4 h-4"}),ue==="flood-done"?e.jsx("span",{children:"Sent!"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline",children:"Flood Advert"}),e.jsx("span",{className:"sm:hidden",children:"Flood"})]})]}),e.jsxs("button",{onClick:ka,disabled:ue!=="idle"&&ue!=="flood-done",className:A("inline-flex items-center gap-1.5 sm:gap-2 px-2.5 sm:px-3.5 py-1.5 sm: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",ue==="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:[ue==="zero-sending"?e.jsx(oe,{className:"w-4 h-4 animate-spin"}):e.jsx(Nn,{className:"w-4 h-4"}),ue==="zero-done"?e.jsx("span",{children:"Sent!"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline",children:"Local Advert"}),e.jsx("span",{className:"sm:hidden",children:"Local"})]})]})]}),e.jsx("button",{onClick:()=>tl.getState().toggleFocusMode(),className:"hidden lg:flex p-1.5 hover:bg-subtle-fill rounded transition-colors",title:ts?"Collapse view":"Expand view",children:ts?e.jsx(El,{className:"w-4 h-4 text-fg-muted"}):e.jsx(Pl,{className:"w-4 h-4 text-fg-muted"})})]}),Sa=e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[e.jsx(he,{children:f.length>0&&e.jsx(ae.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:ne.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(Be,{className:"w-2.5 h-2.5"}),P.name]},P.pubHex))},"advert-notifs")}),e.jsx(he,{children:b?e.jsxs(ae.span,{initial:{opacity:0,scale:.9,width:0},animate:{opacity:1,scale:1,width:"auto"},exit:{opacity:0,scale:.9,width:0},transition:ne.fade,className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-sys-blue/10 text-[11px] text-sys-blue font-medium whitespace-nowrap overflow-hidden",title:E!=null&&E.clientIp?`Another client (${E.clientIp}) is attached to this companion. Connecting would evict them.`:"Another client is attached to this companion. Connecting would evict them.",children:[e.jsx("span",{className:"relative flex h-1.5 w-1.5 flex-shrink-0",children:e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-sys-blue"})}),"Another client connected",e.jsx("button",{onClick:()=>te.getState().forceConnect(),className:"ml-1 px-1.5 py-0.5 rounded-full bg-sys-blue/20 hover:bg-sys-blue/30 transition-colors text-[10px] font-semibold",title:"Evict the other client and connect now",children:"Connect anyway"})]},"external-client"):S?null:e.jsxs(ae.span,{initial:{opacity:0,scale:.9,width:0},animate:{opacity:1,scale:1,width:"auto"},exit:{opacity:0,scale:.9,width:0},transition:ne.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:()=>F(!0),disabled:m,className:"data-box flex items-center gap-1 cursor-pointer hover:bg-subtle-fill-strong transition-colors disabled:opacity-50",title:c>0?`${c} contacts seeded from repeater — click to refresh`:"Seed contacts from repeater adverts",children:[m?e.jsx(oe,{className:"w-3.5 h-3.5 text-sys-blue animate-spin"}):e.jsx(Mi,{className:"w-3.5 h-3.5 text-sys-blue"}),c>0&&e.jsxs("span",{className:"text-sys-blue",children:["+",c]})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${g.length} contacts${c>0?` (${c} from repeater)`:""}`,children:[e.jsx(Nt,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:g.length})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${n.channels_count} channels`,children:[e.jsx(Fe,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:n.channels_count})]})]}),e.jsx(Uc,{companions:s,selected:t,onSelect:ra}),e.jsx(H,{plain:!0,onClick:()=>C(!0),title:"Companion configuration",children:e.jsx(sl,{"data-slot":"icon"})})]});if(s.length===0&&!I)return e.jsxs(fs,{children:[e.jsx(gs,{title:"Companion",icon:e.jsx(fe,{}),controls:e.jsxs(H,{color:"primary",outline:!0,onClick:()=>C(!0),children:[e.jsx(Ge,{"data-slot":"icon"}),"Add Companion"]})}),e.jsx(ys,{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(fe,{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(H,{color:"primary",outline:!0,onClick:()=>C(!0),children:[e.jsx(Ge,{"data-slot":"icon"}),"Add Companion"]})]})}),e.jsx(Vs,{open:j,onClose:()=>C(!1),onRefresh:Vt})]});const ss=u?u.type==="channel"?((ns=i.find(P=>String(P.index)===u.id))==null?void 0:ns.name)??"Channel":((as=g.find(P=>P.public_key===u.id))==null?void 0:as.name)??u.id.slice(0,8):null;return e.jsxs(fs,{children:[e.jsx(gs,{title:(o==null?void 0:o.node_name)||"Companion",icon:e.jsx(fe,{}),leading:Ca,controls:Sa}),e.jsx(ys,{children:e.jsxs("div",{className:"companion-layout flex gap-4",style:{height:"calc(100vh - 11rem)",minHeight:400},children:[e.jsxs("div",{ref:Ve,"data-micro":ye?"true":void 0,className:A("companion-side-card flex-shrink-0 flex h-full overflow-hidden radius-inner bg-surface/80 backdrop-blur-lg depth-raised",W?"flex":"hidden md:flex"),children:[e.jsx(mo,{ref:De,contacts:g,selectedConversation:u,unreadMap:Xt,messages:Qt,onSelect:P=>{be(P),window.innerWidth<768&&V(!1)},onShowDetails:ga,onShareContact:oa,onResetPath:ft,onRemoveContact:ca,onPingContact:ua,repeaterSignalMap:h,isLoading:I,splitPercent:ht,onMicroChange:aa}),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:ta,onPointerMove:sa,onPointerUp:Ot,onPointerCancel:Ot,onDoubleClick:na,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:Dt,channels:i,selectedConversation:u,unreadMap:Xt,messages:Qt,onSelect:P=>{be(P),window.innerWidth<768&&V(!1)},onAddChannel:()=>D(!0),onDeleteChannel:ha})]}),e.jsxs(bs,{noPadding:!0,radius:"sm",className:A("flex-1 flex-col min-w-0 overflow-hidden relative",W?"hidden md:flex":"flex"),children:[e.jsx(he,{children:_&&e.jsxs(ae.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:ne.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:_})]},"error-banner")}),!W&&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:()=>V(!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:ss}),u&&e.jsx("button",{onClick:()=>O(!0),className:"p-1 hover:bg-subtle-fill rounded transition-colors",title:"Details",children:e.jsx(He,{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:ss??"Select a conversation"}),e.jsx(he,{children:u&&e.jsx(ae.button,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:ne.fade,onClick:()=>{window.innerWidth>=1280?T(P=>!P):O(!0)},className:"p-1 hover:bg-subtle-fill rounded transition-colors",title:w?"Hide detail panel":"Show details",children:w&&window.innerWidth>=1280?e.jsx(_s,{className:"w-4 h-4 text-fg-muted"}):e.jsx(He,{className:"w-4 h-4 text-fg-muted"})},"ctx-toggle")})]}),Na&&y?e.jsx(Nc,{contact:y,loginStatus:es,onLogin:gt}):e.jsxs(e.Fragment,{children:[e.jsx(gc,{messages:v,contacts:g,className:"flex-1 min-h-0",conversationKey:u?u.type==="channel"?`ch:${u.id}`:u.id:void 0,onRetry:la,onRetryAsFlood:ia,onMentionClick:ba,isLoading:d,historyLoading:M,historyExhausted:u?$.get(u.type==="channel"?`ch:${u.id}`:u.id)??!1:!0,onLoadOlder:u?()=>fa(u.type==="channel"?`ch:${u.id}`:u.id):void 0,channelName:(u==null?void 0:u.type)==="channel"?(rs=i.find(P=>String(P.index)===u.id))==null?void 0:rs.name:void 0,contactPubKey:(u==null?void 0:u.type)==="contact"?u.id:void 0}),u&&e.jsx(bc,{onSend:ja,disabled:!va,mentionNames:ya,placeholder:u.type==="channel"?`Message ${((ls=i.find(P=>String(P.index)===u.id))==null?void 0:ls.name)??"channel"}`:`Message ${((is=g.find(P=>P.public_key===u.id))==null?void 0:is.name)??"contact"}`})]})]}),e.jsx(ae.div,{initial:!1,animate:{width:w&&u?"var(--companion-context)":"0px",opacity:w&&u?1:0},transition:ne.layoutResize,className:"hidden xl:block flex-shrink-0 overflow-hidden",style:{pointerEvents:w&&u?"auto":"none"},children:u&&e.jsxs(bs,{neomorphic:!0,noPadding:!0,radius:"sm",className:"h-full relative",children:[e.jsx(he,{children:w&&e.jsx(ae.button,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:ne.fade,onClick:()=>T(!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(_s,{className:"w-4 h-4 text-fg-muted"})},"ctx-close")}),e.jsx(Hs,{contact:u.type==="contact"?y:null,channel:u.type==="channel"?i.find(P=>String(P.index)===u.id)??null:null,contacts:g,selfPubKey:(o==null?void 0:o.public_key)??null,onResetPath:ft,onRequestStatus:Bt,onRequestTelemetry:Ht,onLoginToRepeater:gt,onLogoutFromRepeater:Wt,onGetNeighbours:Ut,onTraceContactPath:Kt,onDiscoverPath:qt,onExportContact:P=>{G(P),X(!0)},onSetContactPath:Jt})]})})]})}),e.jsx(Vs,{open:j,onClose:()=>C(!1),onRefresh:Vt}),e.jsx(Gc,{open:k,onClose:()=>F(!1),companionName:t??"companion",onImport:ma}),e.jsx(sd,{open:q,onClose:()=>{X(!1),G(null)},contacts:g,exportPubKey:L,onExport:pa,onImport:xa}),e.jsx(Yc,{open:N,onClose:()=>D(!1),channels:i,onAddChannel:da}),e.jsxs(ve,{open:z,onClose:()=>O(!1),size:"md",children:[e.jsx(Ee,{icon:(u==null?void 0:u.type)==="channel"?e.jsx(Fe,{className:"w-5 h-5"}):y&&(y.adv_type&15)===2?e.jsx(Be,{className:"w-5 h-5"}):e.jsx(fe,{className:"w-5 h-5"}),title:(u==null?void 0:u.type)==="channel"?((os=i.find(P=>String(P.index)===u.id))==null?void 0:os.name)??"Channel":(y==null?void 0:y.name)||"Contact Details",onClose:()=>O(!1)}),e.jsx(Ne,{className:"max-h-[70vh] overflow-y-auto",children:e.jsx(Hs,{embedded:!0,contact:(u==null?void 0:u.type)==="contact"?y:null,channel:(u==null?void 0:u.type)==="channel"?i.find(P=>String(P.index)===u.id)??null:null,contacts:g,selfPubKey:(o==null?void 0:o.public_key)??null,onResetPath:ft,onRequestStatus:Bt,onRequestTelemetry:Ht,onLoginToRepeater:gt,onLogoutFromRepeater:Wt,onGetNeighbours:Ut,onTraceContactPath:Kt,onDiscoverPath:qt,onExportContact:P=>{G(P),X(!0)},onSetContactPath:Jt})})]})]})}export{Wd as default}; diff --git a/frontend/dist/assets/CompanionEchoMap-CwrYV0II.js b/frontend/dist/assets/CompanionEchoMap-CwrYV0II.js deleted file mode 100644 index 0ebf5baa..00000000 --- a/frontend/dist/assets/CompanionEchoMap-CwrYV0II.js +++ /dev/null @@ -1 +0,0 @@ -import{r as i,cW as J,aa as K,W as O,fJ as T,au as D,cA as I,g3 as q,Z as Q,V as X,j as a,c as V,$ as k}from"./index-BdFZD4tW.js";import{M as ee,B as te,a as A}from"./BasemapLayer-BQjI_o60.js";import{S as ne,L as se}from"./layer-Cmi1sSNL.js";import{useSrcHashResolverMap as ae,useDiscoveredNodes as oe}from"./usePipelineStore-BbC5u-iu.js";import{M as re}from"./map-pin-off-pPPXHu6z.js";import{M as le}from"./monitor-smartphone-B-al2jiR.js";import"./node-types-BqQm1p4f.js";const ie={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},R=X.amber,W=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(le,{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 ce(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 ue(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 de(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 Me({text:p,timestamp:c,contacts:o,className:f}){const n=i.useRef(null),r=J(),u=K(),l=O(),[t,v]=i.useState(!1),m=T(),C=D(),z=u==null?void 0:u.neighbors,E=ae(),B=oe(),y=I(),h=q(),w=(m==null?void 0:m.node_name)??(h==null?void 0:h.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)||(h==null?void 0:h.node_name)||(h==null?void 0:h.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}:y&&N(y.latitude,y.longitude)?{prefix:"",name:e,lat:y.latitude,lng:y.longitude}:null},[m,h,y]),L=i.useMemo(()=>w?ue(p,c,C,w):null,[p,c,C,w]),G=i.useMemo(()=>L?de(L,l):[],[L,l]),j=i.useMemo(()=>G.map(e=>{const s=ce(e.prefix,o,F);return{prefix:e.prefix,snr:e.snr,...s}}),[G,o,F]),M=i.useMemo(()=>j.filter(e=>e.hasGps),[j]),P=i.useMemo(()=>j.filter(e=>!e.hasGps),[j]),_=i.useMemo(()=>{if(!d||M.length===0)return[];const e=[d.lng,d.lat];return M.map(s=>{const g=[s.lng,s.lat];return{from:e,to:g,midpoint:[(e[0]+g[0])/2,(e[1]+g[1])/2]}})},[d,M]),Z=i.useMemo(()=>_.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[_]),$=i.useMemo(()=>{if(typeof document>"u")return{amber:R,zinc:W};const e=getComputedStyle(document.documentElement),s=e.getPropertyValue("--sys-amber").trim(),g=e.getPropertyValue("--zinc-400").trim();return{amber:s.startsWith("#")?s:R,zinc:g.startsWith("#")?g:W}},[]),x=i.useMemo(()=>{if(!d||M.length===0)return null;let e=d.lat,s=d.lat,g=d.lng,S=d.lng;for(const b of M)b.lats&&(s=b.lat),b.lngS&&(S=b.lng);return[[g,e],[S,s]]},[d,M]),Y=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 H=[(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(ee,{ref:n,initialViewState:{longitude:H[0],latitude:H[1],zoom:10},onLoad:Y,style:{height:"100%",width:"100%"},mapStyle:ie,attributionControl:!1,interactive:!1,children:[a.jsx(te,{mode:r}),_.map((e,s)=>a.jsx(ne,{id:`cecho-${s}`,type:"geojson",data:Z[s],lineMetrics:!0,children:a.jsx(se,{id:`cecho-line-${s}`,type:"line",paint:{"line-width":2,"line-gradient":["interpolate",["linear"],["line-progress"],0,$.amber,1,$.zinc]},layout:{"line-cap":"round","line-join":"round"}})},`cecho-${s}`)),a.jsx(A,{longitude:d.lng,latitude:d.lat,anchor:"center",children:a.jsx(U,{prefix:d.prefix,name:d.name,isLocal:!0,color:"amber"})}),M.map((e,s)=>a.jsx(A,{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}`))]})}),P.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:P.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{Me as CompanionEchoMap}; diff --git a/frontend/dist/assets/CompanionEchoMap-DGz3ueVV.js b/frontend/dist/assets/CompanionEchoMap-DGz3ueVV.js new file mode 100644 index 00000000..1d00d870 --- /dev/null +++ b/frontend/dist/assets/CompanionEchoMap-DGz3ueVV.js @@ -0,0 +1 @@ +import{r as i,d4 as I,ad as K,$ as O,fZ as T,ax as D,cI as J,gj as q,Z as Q,Y as X,j as a,c as W,a2 as k}from"./index-Ch85h29t.js";import{M as ee,B as te,a as R}from"./BasemapLayer-DEvncc0Q.js";import{S as ne,L as se}from"./layer-Xsjnvj9G.js";import{useSrcHashResolverMap as ae,useDiscoveredNodes as oe}from"./usePipelineStore-BfPa6Qak.js";import{M as re}from"./map-pin-off-D_9hye06.js";import{M as le}from"./monitor-smartphone-CTx9MPdz.js";import"./node-types-CUHPebtj.js";const ie={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},A=X.amber,U=Q[400],Z=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:W("type-data-xs shadow-lg border border-current/30 transition-all duration-150 cursor-default",r&&"relative z-50"),children:[f&&a.jsx(le,{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 ce(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 ue(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 de(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 Me({text:p,timestamp:c,contacts:o,className:f}){const n=i.useRef(null),r=I(),u=K(),l=O(),[t,v]=i.useState(!1),m=T(),C=D(),z=u==null?void 0:u.neighbors,E=ae(),B=oe(),y=J(),h=q(),w=(m==null?void 0:m.node_name)??(h==null?void 0:h.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)||(h==null?void 0:h.node_name)||(h==null?void 0:h.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}:y&&N(y.latitude,y.longitude)?{prefix:"",name:e,lat:y.latitude,lng:y.longitude}:null},[m,h,y]),L=i.useMemo(()=>w?ue(p,c,C,w):null,[p,c,C,w]),G=i.useMemo(()=>L?de(L,l):[],[L,l]),j=i.useMemo(()=>G.map(e=>{const s=ce(e.prefix,o,F);return{prefix:e.prefix,snr:e.snr,...s}}),[G,o,F]),M=i.useMemo(()=>j.filter(e=>e.hasGps),[j]),P=i.useMemo(()=>j.filter(e=>!e.hasGps),[j]),_=i.useMemo(()=>{if(!d||M.length===0)return[];const e=[d.lng,d.lat];return M.map(s=>{const g=[s.lng,s.lat];return{from:e,to:g,midpoint:[(e[0]+g[0])/2,(e[1]+g[1])/2]}})},[d,M]),Y=i.useMemo(()=>_.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[_]),$=i.useMemo(()=>{if(typeof document>"u")return{amber:A,zinc:U};const e=getComputedStyle(document.documentElement),s=e.getPropertyValue("--sys-amber").trim(),g=e.getPropertyValue("--zinc-400").trim();return{amber:s.startsWith("#")?s:A,zinc:g.startsWith("#")?g:U}},[]),x=i.useMemo(()=>{if(!d||M.length===0)return null;let e=d.lat,s=d.lat,g=d.lng,S=d.lng;for(const b of M)b.lats&&(s=b.lat),b.lngS&&(S=b.lng);return[[g,e],[S,s]]},[d,M]),V=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 H=[(x[0][0]+x[1][0])/2,(x[0][1]+x[1][1])/2];return a.jsxs("div",{className:W("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(ee,{ref:n,initialViewState:{longitude:H[0],latitude:H[1],zoom:10},onLoad:V,style:{height:"100%",width:"100%"},mapStyle:ie,attributionControl:!1,interactive:!1,children:[a.jsx(te,{mode:r}),_.map((e,s)=>a.jsx(ne,{id:`cecho-${s}`,type:"geojson",data:Y[s],lineMetrics:!0,children:a.jsx(se,{id:`cecho-line-${s}`,type:"line",paint:{"line-width":2,"line-gradient":["interpolate",["linear"],["line-progress"],0,$.amber,1,$.zinc]},layout:{"line-cap":"round","line-join":"round"}})},`cecho-${s}`)),a.jsx(R,{longitude:d.lng,latitude:d.lat,anchor:"center",children:a.jsx(Z,{prefix:d.prefix,name:d.name,isLocal:!0,color:"amber"})}),M.map((e,s)=>a.jsx(R,{longitude:e.lng,latitude:e.lat,anchor:"center",children:a.jsx(Z,{prefix:e.prefix,name:e.name,isLocal:!1,color:"zinc"})},`cecho-node-${e.prefix}-${s}`))]})}),P.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:P.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{Me as CompanionEchoMap}; diff --git a/frontend/dist/assets/CompanionPathMap-BXnFAxbT.js b/frontend/dist/assets/CompanionPathMap-BXnFAxbT.js deleted file mode 100644 index a25c1da6..00000000 --- a/frontend/dist/assets/CompanionPathMap-BXnFAxbT.js +++ /dev/null @@ -1 +0,0 @@ -import{r as a,cW as Le,aa as Re,cA as Ce,g3 as ke,Z as me,V as U,j as t,c as V,bJ as Ee,dL as Pe,dt as Fe,$ as Y}from"./index-BdFZD4tW.js";import{M as _e,B as Ge,a as W}from"./BasemapLayer-BQjI_o60.js";import{S as G,L as A}from"./layer-Cmi1sSNL.js";import{useSrcHashResolverMap as Ae,useDiscoveredNodes as He}from"./usePipelineStore-BbC5u-iu.js";import{g as Oe,u as ze,l as We,a as $e,m as Be,c as De,j as Ie,k as Je,p as Ke,r as Te,e as E,R as Ve}from"./useReplayTick-XUa2wZbr.js";import{C as ue}from"./car-a6j4OITc.js";import{M as Ye}from"./map-pin-off-pPPXHu6z.js";import{M as Ue}from"./monitor-smartphone-B-al2jiR.js";import"./node-types-BqQm1p4f.js";import"./payload-detail--84fg8Ib.js";const Ze={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},Xe=me[500],de=U.orange,pe=U.green,$=U.blue,T={type:"FeatureCollection",features:[]},qe=a.memo(function({prefix:s,name:r,isLocal:p,color:f}){const[c,h]=a.useState(!1);return t.jsx("div",{onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{pointerEvents:"auto"},children:t.jsxs(Y,{color:f,filled:!0,className:V("type-data-xs shadow-lg border border-current/30 transition-all duration-150 cursor-default",c&&"relative z-50"),children:[p&&t.jsx(Ue,{className:"w-2.5 h-2.5 mr-0.5"}),s&&t.jsx("span",{className:"font-mono",children:s}),c&&r&&t.jsx("span",{className:s?"ml-0.5 opacity-75":"",children:r})]})})});function R(l,s){return Number.isFinite(s)&&Number.isFinite(l)&&s>=-90&&s<=90&&l>=-180&&l<=180}function P(l,s){return l==null||s==null?!1:R(s,l)&&(l!==0||s!==0)}function Qe(l,s,r){var f;const p=[];for(const c of l){const h=c.toUpperCase(),d=s.find(m=>m.public_key.toUpperCase().startsWith(h));if(d&&P(d.gps_lat,d.gps_lon)){p.push({prefix:c,name:d.name||null,lat:d.gps_lat,lng:d.gps_lon,isLocal:!1,hasGps:!0});continue}if(r.neighbors){const m=Object.entries(r.neighbors).find(([i])=>i.toUpperCase().startsWith(h));if(m){const[,i]=m;if(P(i.latitude,i.longitude)){p.push({prefix:c,name:i.node_name||i.name||null,lat:i.latitude,lng:i.longitude,isLocal:!1,hasGps:!0});continue}}}const N=r.srcHashMap.get(h);if(N){const m=r.discoveredNodes.get(N);if(m&&P(m.latitude,m.longitude)){p.push({prefix:c,name:m.name||null,lat:m.latitude,lng:m.longitude,isLocal:!1,hasGps:!0});continue}if(r.neighbors){const i=r.neighbors[N];if(i&&P(i.latitude,i.longitude)){p.push({prefix:c,name:i.node_name||i.name||null,lat:i.latitude,lng:i.longitude,isLocal:!1,hasGps:!0});continue}}}p.push({prefix:c,name:(d==null?void 0:d.name)||(N?((f=r.discoveredNodes.get(N))==null?void 0:f.name)??null:null),lat:0,lng:0,isLocal:!1,hasGps:!1})}return p}function et(l,s,r,p){const f=(s==null?void 0:s.node_name)||p||(r==null?void 0:r.name)||"Me";if(s&&P(s.latitude,s.longitude)){const c=s.public_key.slice(0,2).toUpperCase();return[...l,{prefix:c,name:f,lat:s.latitude,lng:s.longitude,isLocal:!0,hasGps:!0}]}return r&&P(r.latitude,r.longitude)?[...l,{prefix:"",name:f,lat:r.latitude,lng:r.longitude,isLocal:!0,hasGps:!0}]:l}function dt({hops:l,contacts:s,selfInfo:r,snr:p,wardriveCoords:f,wardriveSenderName:c,channelMessages:h,messageTimestamp:d,className:N}){const m=a.useRef(null),i=Le(),B=Re(),[Z,ge]=a.useState(!1),X=B==null?void 0:B.neighbors,q=Ae(),Q=He(),ee=Ce(),C=ke(),te=a.useMemo(()=>({neighbors:X,srcHashMap:q,discoveredNodes:Q}),[X,q,Q]),F=a.useMemo(()=>{if(!(h!=null&&h.length)||!c||!d)return[];const e=Oe(h),n=d-86400;return e.filter(o=>o.senderName===c&&o.timestampS>=n&&o.timestampS<=d)},[h,c,d]),D=F.length>=2,_=a.useMemo(()=>`${c??"x"}-${d??0}`,[c,d]),fe=ze(),he=We(),ne=$e(),v=Be(),ye=De(),y=Ie();Je();const g=fe&&he===_,I=g&&y.length>0?Math.round(Math.max(0,Math.min(y.length-1,v))):-1,se=a.useMemo(()=>{var e;return I>=0?((e=y[I])==null?void 0:e.pathHops)??l:l},[I,y,l]),oe=(C==null?void 0:C.node_name)??(C==null?void 0:C.companion_name)??null,j=a.useMemo(()=>{const e=Qe(se,s,te);return et(e,r,ee,oe)},[se,s,te,r,ee,oe]),x=a.useMemo(()=>j.filter(e=>e.hasGps),[j]),ae=a.useMemo(()=>j.filter(e=>!e.hasGps),[j]),b=a.useMemo(()=>f&&R(f.lon,f.lat)?f:null,[f]),H=a.useMemo(()=>{const e=[];if(x.length<2)return e;const n=[];for(let o=0;oH.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[H]),re=a.useMemo(()=>{if(typeof document>"u")return Xe;const e=getComputedStyle(document.documentElement).getPropertyValue("--zinc-400").trim();return e.startsWith("#")?e:me[400]},[]),O=a.useMemo(()=>{if(!b||x.length===0)return null;const e=[b.lon,b.lat],n=x[0];return{from:e,to:[n.lng,n.lat]}},[b,x]),le=a.useMemo(()=>O?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[O.from,O.to]}}]}:null,[O]),ie=a.useMemo(()=>{if(typeof document>"u")return{orange:de,green:pe};const e=getComputedStyle(document.documentElement),n=e.getPropertyValue("--sys-orange").trim(),o=e.getPropertyValue("--sys-green").trim();return{orange:n.startsWith("#")?n:de,green:o.startsWith("#")?o:pe}},[]),k=a.useMemo(()=>{if(!g)return null;const e=Ke(y,v);return e&&R(e.lon,e.lat)?e:null},[g,y,v]),be=a.useMemo(()=>{if(!g)return T;const e=Te(y,v).filter(([n,o])=>R(n,o));return e.length<2?T:{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}}]}},[g,y,v]),je=a.useMemo(()=>!g||y.length===0?T:{type:"FeatureCollection",features:y.filter(e=>R(e.lon,e.lat)).map((e,n)=>({type:"Feature",properties:{index:n},geometry:{type:"Point",coordinates:[e.lon,e.lat]}}))},[g,y]);a.useEffect(()=>()=>{const e=E.getState();e.ownerKey===_&&e.stopRewind()},[_]);const we=y.length,z=Math.max(0,we-1),Ne=z>0?v/z:1,ve=Math.round(z-v),w=a.useMemo(()=>{const e=[];for(const u of x)R(u.lng,u.lat)&&e.push([u.lng,u.lat]);b&&e.push([b.lon,b.lat]);for(const u of F)R(u.lon,u.lat)&&e.push([u.lon,u.lat]);if(e.length<2)return null;let n=1/0,o=-1/0,S=1/0,M=-1/0;for(const[u,L]of e)Lo&&(o=L),uM&&(M=u);return[[S,n],[M,o]]},[x,b,F]),Se=a.useCallback(()=>{E.getState().stopRewind()},[]),Me=a.useCallback(()=>{var e;try{const n=(e=m.current)==null?void 0:e.getMap();n&&w&&n.fitBounds(w,{padding:{top:40,bottom:D?52:44,left:56,right:56},maxZoom:14,duration:0})}catch(n){console.warn("[CompanionPathMap] Failed to fit wardrive/path bounds:",n)}finally{ge(!0)}D&&E.getState().startRewind(F,_)},[w,D,F,_]);if(!w)return null;const ce=[(w[0][0]+w[1][0])/2,(w[0][1]+w[1][1])/2];return t.jsxs("div",{className:V("relative rounded-lg overflow-hidden",N),style:{aspectRatio:"16 / 10"},children:[!Z&&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:Z?1:0},children:t.jsxs(_e,{ref:m,initialViewState:{longitude:ce[0],latitude:ce[1],zoom:10},onLoad:Me,style:{height:"100%",width:"100%"},mapStyle:Ze,attributionControl:!1,interactive:g,children:[t.jsx(Ge,{mode:i}),le&&!g&&t.jsx(G,{id:"cwd-edge",type:"geojson",data:le,lineMetrics:!0,children:t.jsx(A,{id:"cwd-edge-line",type:"line",paint:{"line-width":2,"line-gradient":["interpolate",["linear"],["line-progress"],0,ie.orange,1,ie.green]},layout:{"line-cap":"round","line-join":"round"}})}),b&&!g&&t.jsx(W,{longitude:b.lon,latitude:b.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(ue,{className:"w-4 h-4",strokeWidth:2.5})})})}),H.map((e,n)=>t.jsx(G,{id:`cedge-${n}`,type:"geojson",data:xe[n],children:t.jsx(A,{id:`cedge-line-${n}`,type:"line",paint:{"line-color":re,"line-width":2,"line-opacity":.85},layout:{"line-cap":"round","line-join":"round"}})},`cedge-${n}`)),H.map((e,n)=>t.jsx(W,{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:re,color:"#fff",fontSize:"10px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:e.hopNumber})},`chop-${n}`)),x.map((e,n)=>{const o=n===0,S=n===x.length-1,M=e.isLocal?"amber":o?"green":S?"amber":"zinc";return t.jsx(W,{longitude:e.lng,latitude:e.lat,anchor:"center",children:t.jsx(qe,{prefix:e.prefix,name:e.name,isLocal:e.isLocal,color:M})},`cnode-${e.prefix}-${n}`)}),g&&t.jsxs(t.Fragment,{children:[t.jsx(G,{id:"replay-dots",type:"geojson",data:je,children:t.jsx(A,{id:"replay-dots-circle",type:"circle",paint:{"circle-radius":3,"circle-color":$,"circle-opacity":.35,"circle-stroke-width":1,"circle-stroke-color":$,"circle-stroke-opacity":.15}})}),t.jsx(G,{id:"replay-trail",type:"geojson",data:be,children:t.jsx(A,{id:"replay-trail-line",type:"line",paint:{"line-color":$,"line-width":3,"line-opacity":.7},layout:{"line-cap":"round","line-join":"round"}})}),k&&x.length>0&&t.jsx(G,{id:"replay-path-link",type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[[k.lon,k.lat],[x[0].lng,x[0].lat]]}}]},children:t.jsx(A,{id:"replay-path-link-line",type:"line",paint:{"line-color":$,"line-width":1.5,"line-opacity":.5,"line-dasharray":[3,2]},layout:{"line-cap":"round"}})}),k&&t.jsx(W,{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(ue,{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(Ee,{className:"w-3 h-3"})}),t.jsx("button",{onClick:()=>E.getState().togglePlay(),className:"p-1 rounded-full bg-sys-blue/20 text-sys-blue hover:bg-sys-blue/30 transition-colors shrink-0",title:ne?"Pause":"Rewind",children:ne?t.jsx(Pe,{className:"w-3 h-3"}):t.jsx(Fe,{className:"w-3 h-3"})}),t.jsx("input",{type:"range",min:0,max:100,step:.1,value:Ne*100,onChange:e=>{const n=parseFloat(e.target.value)/100;E.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:[ve,"/",z," pkts"]}),t.jsx("div",{className:"flex items-center gap-px shrink-0",children:Ve.map(e=>t.jsxs("button",{onClick:()=>E.getState().setSpeed(e),className:V("px-1 py-0.5 rounded text-[9px] font-medium transition-colors",e===ye?"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary"),children:[e,"×"]},e))})]})}),!g&&ae.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:ae.map((e,n)=>t.jsxs(Y,{color:"zinc",className:"type-data-xs shadow-sm opacity-70",children:[t.jsx(Ye,{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(Y,{color:"zinc",className:"type-data-xs shadow-sm",children:[p>0?"+":"",p.toFixed(1)," dB"]})})]})}export{dt as CompanionPathMap}; diff --git a/frontend/dist/assets/CompanionPathMap-BjSrbG5W.js b/frontend/dist/assets/CompanionPathMap-BjSrbG5W.js new file mode 100644 index 00000000..e36605b4 --- /dev/null +++ b/frontend/dist/assets/CompanionPathMap-BjSrbG5W.js @@ -0,0 +1 @@ +import{r as a,d4 as Le,ad as Re,cI as Ce,gj as ke,Z as me,Y as U,j as t,c as J,bO as Ee,dY as Pe,dG as Fe,a2 as V}from"./index-Ch85h29t.js";import{M as Ge,B as _e,a as B}from"./BasemapLayer-DEvncc0Q.js";import{S as _,L as H}from"./layer-Xsjnvj9G.js";import{useSrcHashResolverMap as He,useDiscoveredNodes as Oe}from"./usePipelineStore-BfPa6Qak.js";import{g as Ae,u as ze,l as Be,a as We,m as $e,c as Ie,j as Ye,k as De,p as Ke,r as Te,e as E,R as Je}from"./useReplayTick-DnxaulGE.js";import{C as ue}from"./car-DIm4EGM2.js";import{M as Ve}from"./map-pin-off-D_9hye06.js";import{M as Ue}from"./monitor-smartphone-CTx9MPdz.js";import"./node-types-CUHPebtj.js";import"./payload-detail-CX4NrBt7.js";const Ze={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},Xe=me[500],de=U.orange,pe=U.green,W=U.blue,T={type:"FeatureCollection",features:[]},qe=a.memo(function({prefix:s,name:r,isLocal:p,color:f}){const[c,h]=a.useState(!1);return t.jsx("div",{onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{pointerEvents:"auto"},children:t.jsxs(V,{color:f,filled:!0,className:J("type-data-xs shadow-lg border border-current/30 transition-all duration-150 cursor-default",c&&"relative z-50"),children:[p&&t.jsx(Ue,{className:"w-2.5 h-2.5 mr-0.5"}),s&&t.jsx("span",{className:"font-mono",children:s}),c&&r&&t.jsx("span",{className:s?"ml-0.5 opacity-75":"",children:r})]})})});function R(l,s){return Number.isFinite(s)&&Number.isFinite(l)&&s>=-90&&s<=90&&l>=-180&&l<=180}function P(l,s){return l==null||s==null?!1:R(s,l)&&(l!==0||s!==0)}function Qe(l,s,r){var f;const p=[];for(const c of l){const h=c.toUpperCase(),d=s.find(m=>m.public_key.toUpperCase().startsWith(h));if(d&&P(d.gps_lat,d.gps_lon)){p.push({prefix:c,name:d.name||null,lat:d.gps_lat,lng:d.gps_lon,isLocal:!1,hasGps:!0});continue}if(r.neighbors){const m=Object.entries(r.neighbors).find(([i])=>i.toUpperCase().startsWith(h));if(m){const[,i]=m;if(P(i.latitude,i.longitude)){p.push({prefix:c,name:i.node_name||i.name||null,lat:i.latitude,lng:i.longitude,isLocal:!1,hasGps:!0});continue}}}const N=r.srcHashMap.get(h);if(N){const m=r.discoveredNodes.get(N);if(m&&P(m.latitude,m.longitude)){p.push({prefix:c,name:m.name||null,lat:m.latitude,lng:m.longitude,isLocal:!1,hasGps:!0});continue}if(r.neighbors){const i=r.neighbors[N];if(i&&P(i.latitude,i.longitude)){p.push({prefix:c,name:i.node_name||i.name||null,lat:i.latitude,lng:i.longitude,isLocal:!1,hasGps:!0});continue}}}p.push({prefix:c,name:(d==null?void 0:d.name)||(N?((f=r.discoveredNodes.get(N))==null?void 0:f.name)??null:null),lat:0,lng:0,isLocal:!1,hasGps:!1})}return p}function et(l,s,r,p){const f=(s==null?void 0:s.node_name)||p||(r==null?void 0:r.name)||"Me";if(s&&P(s.latitude,s.longitude)){const c=s.public_key.slice(0,2).toUpperCase();return[...l,{prefix:c,name:f,lat:s.latitude,lng:s.longitude,isLocal:!0,hasGps:!0}]}return r&&P(r.latitude,r.longitude)?[...l,{prefix:"",name:f,lat:r.latitude,lng:r.longitude,isLocal:!0,hasGps:!0}]:l}function dt({hops:l,contacts:s,selfInfo:r,snr:p,wardriveCoords:f,wardriveSenderName:c,channelMessages:h,messageTimestamp:d,className:N}){const m=a.useRef(null),i=Le(),$=Re(),[Z,ge]=a.useState(!1),X=$==null?void 0:$.neighbors,q=He(),Q=Oe(),ee=Ce(),C=ke(),te=a.useMemo(()=>({neighbors:X,srcHashMap:q,discoveredNodes:Q}),[X,q,Q]),F=a.useMemo(()=>{if(!(h!=null&&h.length)||!c||!d)return[];const e=Ae(h),n=d-86400;return e.filter(o=>o.senderName===c&&o.timestampS>=n&&o.timestampS<=d)},[h,c,d]),I=F.length>=2,G=a.useMemo(()=>`${c??"x"}-${d??0}`,[c,d]),fe=ze(),he=Be(),ne=We(),v=$e(),ye=Ie(),y=Ye();De();const g=fe&&he===G,Y=g&&y.length>0?Math.round(Math.max(0,Math.min(y.length-1,v))):-1,se=a.useMemo(()=>{var e;return Y>=0?((e=y[Y])==null?void 0:e.pathHops)??l:l},[Y,y,l]),oe=(C==null?void 0:C.node_name)??(C==null?void 0:C.companion_name)??null,j=a.useMemo(()=>{const e=Qe(se,s,te);return et(e,r,ee,oe)},[se,s,te,r,ee,oe]),x=a.useMemo(()=>j.filter(e=>e.hasGps),[j]),ae=a.useMemo(()=>j.filter(e=>!e.hasGps),[j]),b=a.useMemo(()=>f&&R(f.lon,f.lat)?f:null,[f]),O=a.useMemo(()=>{const e=[];if(x.length<2)return e;const n=[];for(let o=0;oO.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[O]),re=a.useMemo(()=>{if(typeof document>"u")return Xe;const e=getComputedStyle(document.documentElement).getPropertyValue("--zinc-400").trim();return e.startsWith("#")?e:me[400]},[]),A=a.useMemo(()=>{if(!b||x.length===0)return null;const e=[b.lon,b.lat],n=x[0];return{from:e,to:[n.lng,n.lat]}},[b,x]),le=a.useMemo(()=>A?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[A.from,A.to]}}]}:null,[A]),ie=a.useMemo(()=>{if(typeof document>"u")return{orange:de,green:pe};const e=getComputedStyle(document.documentElement),n=e.getPropertyValue("--sys-orange").trim(),o=e.getPropertyValue("--sys-green").trim();return{orange:n.startsWith("#")?n:de,green:o.startsWith("#")?o:pe}},[]),k=a.useMemo(()=>{if(!g)return null;const e=Ke(y,v);return e&&R(e.lon,e.lat)?e:null},[g,y,v]),be=a.useMemo(()=>{if(!g)return T;const e=Te(y,v).filter(([n,o])=>R(n,o));return e.length<2?T:{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}}]}},[g,y,v]),je=a.useMemo(()=>!g||y.length===0?T:{type:"FeatureCollection",features:y.filter(e=>R(e.lon,e.lat)).map((e,n)=>({type:"Feature",properties:{index:n},geometry:{type:"Point",coordinates:[e.lon,e.lat]}}))},[g,y]);a.useEffect(()=>()=>{const e=E.getState();e.ownerKey===G&&e.stopRewind()},[G]);const we=y.length,z=Math.max(0,we-1),Ne=z>0?v/z:1,ve=Math.round(z-v),w=a.useMemo(()=>{const e=[];for(const u of x)R(u.lng,u.lat)&&e.push([u.lng,u.lat]);b&&e.push([b.lon,b.lat]);for(const u of F)R(u.lon,u.lat)&&e.push([u.lon,u.lat]);if(e.length<2)return null;let n=1/0,o=-1/0,S=1/0,M=-1/0;for(const[u,L]of e)Lo&&(o=L),uM&&(M=u);return[[S,n],[M,o]]},[x,b,F]),Se=a.useCallback(()=>{E.getState().stopRewind()},[]),Me=a.useCallback(()=>{var e;try{const n=(e=m.current)==null?void 0:e.getMap();n&&w&&n.fitBounds(w,{padding:{top:40,bottom:I?52:44,left:56,right:56},maxZoom:14,duration:0})}catch(n){console.warn("[CompanionPathMap] Failed to fit wardrive/path bounds:",n)}finally{ge(!0)}I&&E.getState().startRewind(F,G)},[w,I,F,G]);if(!w)return null;const ce=[(w[0][0]+w[1][0])/2,(w[0][1]+w[1][1])/2];return t.jsxs("div",{className:J("relative rounded-lg overflow-hidden",N),style:{aspectRatio:"16 / 10"},children:[!Z&&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:Z?1:0},children:t.jsxs(Ge,{ref:m,initialViewState:{longitude:ce[0],latitude:ce[1],zoom:10},onLoad:Me,style:{height:"100%",width:"100%"},mapStyle:Ze,attributionControl:!1,interactive:g,children:[t.jsx(_e,{mode:i}),le&&!g&&t.jsx(_,{id:"cwd-edge",type:"geojson",data:le,lineMetrics:!0,children:t.jsx(H,{id:"cwd-edge-line",type:"line",paint:{"line-width":2,"line-gradient":["interpolate",["linear"],["line-progress"],0,ie.orange,1,ie.green]},layout:{"line-cap":"round","line-join":"round"}})}),b&&!g&&t.jsx(B,{longitude:b.lon,latitude:b.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(ue,{className:"w-4 h-4",strokeWidth:2.5})})})}),O.map((e,n)=>t.jsx(_,{id:`cedge-${n}`,type:"geojson",data:xe[n],children:t.jsx(H,{id:`cedge-line-${n}`,type:"line",paint:{"line-color":re,"line-width":2,"line-opacity":.85},layout:{"line-cap":"round","line-join":"round"}})},`cedge-${n}`)),O.map((e,n)=>t.jsx(B,{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:re,color:"#fff",fontSize:"10px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:e.hopNumber})},`chop-${n}`)),x.map((e,n)=>{const o=n===0,S=n===x.length-1,M=e.isLocal?"amber":o?"green":S?"amber":"zinc";return t.jsx(B,{longitude:e.lng,latitude:e.lat,anchor:"center",children:t.jsx(qe,{prefix:e.prefix,name:e.name,isLocal:e.isLocal,color:M})},`cnode-${e.prefix}-${n}`)}),g&&t.jsxs(t.Fragment,{children:[t.jsx(_,{id:"replay-dots",type:"geojson",data:je,children:t.jsx(H,{id:"replay-dots-circle",type:"circle",paint:{"circle-radius":3,"circle-color":W,"circle-opacity":.35,"circle-stroke-width":1,"circle-stroke-color":W,"circle-stroke-opacity":.15}})}),t.jsx(_,{id:"replay-trail",type:"geojson",data:be,children:t.jsx(H,{id:"replay-trail-line",type:"line",paint:{"line-color":W,"line-width":3,"line-opacity":.7},layout:{"line-cap":"round","line-join":"round"}})}),k&&x.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],[x[0].lng,x[0].lat]]}}]},children:t.jsx(H,{id:"replay-path-link-line",type:"line",paint:{"line-color":W,"line-width":1.5,"line-opacity":.5,"line-dasharray":[3,2]},layout:{"line-cap":"round"}})}),k&&t.jsx(B,{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(ue,{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(Ee,{className:"w-3 h-3"})}),t.jsx("button",{onClick:()=>E.getState().togglePlay(),className:"p-1 rounded-full bg-sys-blue/20 text-sys-blue hover:bg-sys-blue/30 transition-colors shrink-0",title:ne?"Pause":"Rewind",children:ne?t.jsx(Pe,{className:"w-3 h-3"}):t.jsx(Fe,{className:"w-3 h-3"})}),t.jsx("input",{type:"range",min:0,max:100,step:.1,value:Ne*100,onChange:e=>{const n=parseFloat(e.target.value)/100;E.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:[ve,"/",z," pkts"]}),t.jsx("div",{className:"flex items-center gap-px shrink-0",children:Je.map(e=>t.jsxs("button",{onClick:()=>E.getState().setSpeed(e),className:J("px-1 py-0.5 rounded text-[9px] font-medium transition-colors",e===ye?"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary"),children:[e,"×"]},e))})]})}),!g&&ae.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:ae.map((e,n)=>t.jsxs(V,{color:"zinc",className:"type-data-xs shadow-sm opacity-70",children:[t.jsx(Ve,{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(V,{color:"zinc",className:"type-data-xs shadow-sm",children:[p>0?"+":"",p.toFixed(1)," dB"]})})]})}export{dt as CompanionPathMap}; diff --git a/frontend/dist/assets/Configuration-4fw93R2m.js b/frontend/dist/assets/Configuration-4fw93R2m.js deleted file mode 100644 index 089b656b..00000000 --- a/frontend/dist/assets/Configuration-4fw93R2m.js +++ /dev/null @@ -1,27 +0,0 @@ -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 _e,dn as ze,dp as _t,dq as kt,r as a,er as is,es as ls,j as e,c as b,_ as Ae,ab as fe,G as St,S as Ct,et as Tt,f as q,bJ as Oe,a6 as Y,a4 as Ne,cO as we,ct as cs,eu as Ft,B as F,$ as rs,ev as Vs,aA as Ws,bV as Le,a1 as Ys,ew as Et,aa as Rt,az as Hs,c3 as Pt,c6 as os,ds as Qs,ex as At,ey as $s,ez as Mt,eA as Dt,eB as Lt,R as It,eC as de,I as Ot,a5 as zt,a7 as Kt}from"./index-BdFZD4tW.js";import{g as Vt,a as Ht,s as $t,c as Ut,u as qt,d as Bt}from"./transport-50jRpUgK.js";import{c as Gt,r as Jt}from"./system-DPP-2Czb.js";import{C as Xt}from"./ConfirmModal-N7ejcMF0.js";import{S as Wt,A as Yt,a as Qt,N as Zt}from"./AutoConfigureDialog-C3FQqWjM.js";import{S,a as Me}from"./setting-field-B3HlOVfd.js";import{i as ea,g as sa,s as ta,a as aa,k as na}from"./keycap-sfx-ByZp-njj.js";import{C as B,P as la,a as ra,B as oa}from"./PageLayout-CIUNh3-q.js";import{T as Zs}from"./trash-2-B1G94Z60.js";import{P as ia}from"./pencil-CsCVD6uI.js";import{R as ca}from"./rotate-ccw-3--rrl0z.js";import{W as da}from"./wand-sparkles-DJklHh-3.js";import{S as ua}from"./shield-Jo4379LI.js";import{R as ma}from"./repeat-D_z9MmTf.js";import{G as fa}from"./git-branch-CjkWLr6F.js";import{C as xa}from"./clock-B5Mz4CYE.js";import{C as et}from"./WorkspaceNav-DR8N-VVk.js";import{R as W,C as ue}from"./Grid-BkuFQpqe.js";import{A as pa}from"./antenna-CLTumJYG.js";import{F as Us}from"./folder-lock-zGoUhhVc.js";import{P as qs}from"./plus-J10T9_Ph.js";import{K as Ze}from"./key-round-Ca3f2GE6.js";import"./monitor-smartphone-B-al2jiR.js";import"./arrow-right-DWDq16dR.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 ha=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],st=_e("external-link",ha);/** - * @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 ya=[["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2",key:"3hgo9p"}],["path",{d:"m22 14-4.5 4.5",key:"1ef6z8"}],["path",{d:"m21 15 1 1",key:"1ejcpy"}]],ga=_e("folder-key",ya);/** - * @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 ba=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],ja=_e("git-commit-horizontal",ba);/** - * @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 va=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Na=_e("monitor",va);/** - * @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 wa=[["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"}]],_a=_e("triangle-dashed",wa);async function ka(){try{return await ze("/api/auth/tokens")}catch{return{tokens:[]}}}async function Sa(t){return ze("/api/auth/tokens",{method:"POST",body:JSON.stringify({name:t})})}async function Ca(t){return ze(`/api/auth/tokens/${t}`,{method:"DELETE"})}async function Ta(t,l){const n=_t();if(!n)return{success:!1,error:"Not authenticated"};try{const c=await fetch(`${kt}/auth/change_password`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({current_password:t,new_password:l})}),r=c.headers.get("content-type"),o=r!=null&&r.includes("application/json")?await c.json():null;return!c.ok||!(o!=null&&o.success)?{success:!1,error:(o==null?void 0:o.error)||`Password change failed: ${c.status} ${c.statusText}`}:o}catch(c){return{success:!1,error:c instanceof Error?c.message:"Failed to change password"}}}async function Bs(t){return ze("/api/update_web_config",{method:"POST",body:JSON.stringify(t)})}a.memo(function(){const{theme:l}=is(),{themeId:n}=l,c=ls.find(r=>r.meta.id===n)??ls[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 es=a.memo(function({compact:l=!1}){const{theme:n,setTheme:c}=is(),{themeId:r}=n;return e.jsx("div",{className:b("grid grid-cols-2 gap-2",l?"w-full min-w-0 self-stretch":"w-full"),children:[...ls].reverse().map(o=>{const y=r===o.meta.id,p=o.meta.isDark;return e.jsxs("button",{type:"button",title:o.meta.name,className:b("flex flex-row items-stretch radius-inner transition-all duration-200 ease-out overflow-hidden cursor-pointer",l&&"h-6",y?"ring-2 ring-sys-blue scale-[1.02]":"opacity-70 hover:opacity-100"),onClick:()=>c(o.meta.id),children:[e.jsx("div",{className:b("flex-1 h-full",p?"bg-[#18181b]":"bg-[#EFF0F1]")}),e.jsx("div",{className:"flex flex-col h-full",children:o.display.palette.map((h,u)=>e.jsx("div",{className:"flex flex-1",children:h.map((i,j)=>e.jsx("div",{className:"w-2 h-full",style:{backgroundColor:i}},j))},u))})]},o.meta.id)})})});let Gs=!1,De=null;async function Fa(){if(!Gs)return De||(De=(async()=>{try{await Promise.all([Ae(()=>Promise.resolve({}),__vite__mapDeps([0])),Ae(()=>Promise.resolve({}),__vite__mapDeps([1])),Ae(()=>Promise.resolve({}),__vite__mapDeps([2])),Ae(()=>Promise.resolve({}),__vite__mapDeps([3]))]),Gs=!0}catch(t){console.warn("Failed to load theme fonts:",t)}})(),De)}const ss=a.memo(function(){const{theme:l,setTheme:n}=is(),{themeId:c}=l,r=c==="breeze dark",o=a.useCallback(y=>{n(y?"breeze dark":"breeze light")},[n]);return e.jsx(fe,{enabled:r,onChange:o,label:e.jsxs(e.Fragment,{children:["Dark Mode: ",r?e.jsx(St,{className:"w-3.5 h-3.5 text-sys-blue inline"}):e.jsx(Ct,{className:"w-3.5 h-3.5 text-[#e8a517] inline"})]}),tooltip:"Switch between dark and light mode",size:"md"})}),Ea=a.memo(function({layout:l="horizontal"}){return a.useEffect(()=>{Fa()},[]),l==="toggle-only"?e.jsx(ss,{}):l==="thumbnails-only"?e.jsx(es,{}):l==="vertical"?e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx(ss,{}),e.jsx(es,{})]}):e.jsxs("div",{className:"flex items-stretch gap-4",children:[e.jsx("div",{className:"flex-shrink-0 flex items-start",children:e.jsx(ss,{})}),e.jsx(es,{compact:!0})]})}),Ra=1e4,ts=2e3;function as(t,l,n){const[c,r]=a.useState("idle"),[o,y]=a.useState(null),p=a.useRef(!0),h=a.useRef(null),u=a.useRef(null),i=a.useRef(!1),j=a.useRef("idle"),D=a.useRef(t),v=a.useRef(l),E=a.useRef(n);j.current=c,D.current=t,v.current=l,E.current=n,a.useEffect(()=>(p.current=!0,()=>{p.current=!1,h.current&&clearTimeout(h.current),u.current&&clearTimeout(u.current)}),[]);const C=a.useCallback(async m=>{if(j.current==="loading")return;const g=D.current;h.current&&clearTimeout(h.current),u.current&&clearTimeout(u.current),i.current=!1,y(m),r("loading"),h.current=setTimeout(()=>{i.current||!p.current||(y(g),r("error"),u.current=setTimeout(()=>{p.current&&(r("idle"),y(null))},ts))},Ra);try{if(await v.current(m),i.current=!0,h.current&&clearTimeout(h.current),!p.current)return;r("success"),u.current=setTimeout(()=>{var k;p.current&&(r("idle"),y(null),(k=E.current)==null||k.call(E))},ts)}catch{if(i.current=!0,h.current&&clearTimeout(h.current),!p.current)return;y(g),r("error"),u.current=setTimeout(()=>{p.current&&(r("idle"),y(null))},ts)}},[]);return{enabled:o!==null?o:t,status:c,toggle:C}}function Pa(){const{latitude:t,longitude:l,enabled:n,setLocation:c,enable:r,disable:o,clear:y}=Tt(),[p,h]=a.useState(!1),[u,i]=a.useState(""),[j,D]=a.useState(""),[v,E]=a.useState("idle"),[C,N]=a.useState(null),m=a.useRef(null),g=a.useRef(null),k=a.useRef(!0);a.useEffect(()=>(k.current=!0,()=>{k.current=!1,g.current&&clearTimeout(g.current)}),[]);const R=()=>{i((t==null?void 0:t.toFixed(6))??""),D((l==null?void 0:l.toFixed(6))??""),N(null),h(!0)},J=()=>{h(!1),N(null)};a.useEffect(()=>{if(!p)return;const P=z=>{v!=="loading"&&m.current&&!m.current.contains(z.target)&&J()};return document.addEventListener("mouseup",P),()=>document.removeEventListener("mouseup",P)},[p,v]);const V=(P,z)=>{const H=parseFloat(P),U=parseFloat(z);return isNaN(H)||isNaN(U)?"Please enter valid numbers":H<-90||H>90?"Latitude must be between -90 and 90":U<-180||U>180?"Longitude must be between -180 and 180":H===0&&U===0?"Coordinates (0, 0) are invalid":null},w=()=>{if(v==="loading")return;g.current&&clearTimeout(g.current);const P=V(u,j);if(P){N(P);return}E("loading"),N(null);const z=parseFloat(u),H=parseFloat(j);c(z,H),n||r(),E("success"),g.current=setTimeout(()=>{k.current&&(E("idle"),h(!1))},1e3)},T=()=>{n?o():r()},f=()=>{y(),h(!1)},O=t!==null&&l!==null;return e.jsx(B,{children:e.jsxs("div",{ref:m,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(q,{icon:e.jsx(_a,{}),title:"Stealth"}),e.jsxs("div",{className:"flex items-center gap-1",children:[O&&!p&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:T,className:b("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:b("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(Zs,{className:"w-4 h-4"})})]}),p?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:J,disabled:v==="loading",className:b("p-2 rounded-lg transition-colors",v==="loading"?"text-fg-muted cursor-not-allowed":"text-fg-muted hover:text-sys-red hover:bg-sys-red/10"),title:"Cancel",children:e.jsx(Oe,{className:"w-4 h-4"})}),e.jsx("button",{onClick:w,disabled:v==="loading",className:b("p-2 rounded-lg transition-colors",v==="loading"?"text-sys-blue cursor-wait":v==="success"?"text-sys-green":v==="error"?"text-sys-red":"text-sys-green hover:bg-sys-green/10"),title:"Save",children:v==="loading"?e.jsx(Y,{className:"w-4 h-4 animate-spin"}):v==="success"?e.jsx(Ne,{className:"w-4 h-4"}):v==="error"?e.jsx(Oe,{className:"w-4 h-4"}):e.jsx(Ne,{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:O?"Edit stealth location":"Set stealth location",children:e.jsx(ia,{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(we,{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"}),"."]})]})}),C&&e.jsx("div",{className:"text-xs mb-3 px-2 py-1.5 rounded-md text-sys-red bg-sys-red/10",children:C}),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:p?"Latitude (°)":"Latitude"}),e.jsx("div",{className:b("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:p?e.jsx("input",{type:"number",value:u,onChange:P=>i(P.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:b("type-data",O&&n?"text-fg-primary":"text-fg-muted"),children:O?t.toFixed(6):"Not set"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:p?"Longitude (°)":"Longitude"}),e.jsx("div",{className:b("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:p?e.jsx("input",{type:"number",value:j,onChange:P=>D(P.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:b("type-data",O&&n?"text-fg-primary":"text-fg-muted"),children:O?l.toFixed(6):"Not set"})})]})]}),O&&!p&&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:b("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),r=t%60;return r>0?`${c}m ${r}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 ns({title:t,defaultOpen:l=!1,children:n}){const[c,r]=a.useState(l);return e.jsxs("div",{className:"bg-subtle-fill radius-inner overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>r(!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(Ws,{className:b("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 Ie={off:{label:"Off",description:"All rate limiting disabled. Every advert is forwarded unconditionally.",color:"text-fg-muted",config:Wt},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}}},tt=["off","light","standard","strict"];function Aa(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 r of tt){if(r==="off")continue;const o=Ie[r].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 r}return null}function Ma(){var P,z,H,U,se,Q;const{stats:t,fetchStats:l}=cs(),n=a.useRef(!0),[c,r]=a.useState(!0),[o,y]=a.useState(!1),[p,h]=a.useState(null),[u,i]=a.useState("idle"),j=a.useRef(null),[D,v]=a.useState(!1),[E,C]=a.useState(new Set);a.useEffect(()=>(n.current=!0,()=>{n.current=!1,j.current&&clearTimeout(j.current)}),[]);const N=a.useCallback(async()=>{var d;try{const A=await Ft();if(!n.current)return;A.success&&A.data&&((d=A.data.adaptive)!=null&&d.current_tier)?r(!0):r(!1)}catch{n.current&&r(!1)}},[]);a.useEffect(()=>{N();const d=setInterval(N,3e4);return()=>clearInterval(d)},[N]);const m=(z=(P=t==null?void 0:t.config)==null?void 0:P.repeater)==null?void 0:z.advert_rate_limit,g=(U=(H=t==null?void 0:t.config)==null?void 0:H.repeater)==null?void 0:U.advert_penalty_box,k=(Q=(se=t==null?void 0:t.config)==null?void 0:se.repeater)==null?void 0:Q.advert_adaptive;if(!c&&!m&&!g&&!k)return null;const R=d=>E.has(d),J=d=>{C(A=>{if(!A.has(d))return A;const G=new Set(A);return G.delete(d),G})},V=Aa(m,g,k),w=V?Ie[V]:null,T=async(d,A)=>{J(d),y(!0),h(null),j.current&&clearTimeout(j.current);try{const G=await Vs({[d]:A});if(!n.current)return;G.success?(i("success"),await Promise.all([l({force:!0}).catch(()=>{}),N()])):(i("error"),h(G.error||"Failed to save"))}catch{n.current&&(i("error"),h("Failed to save"))}finally{n.current&&(y(!1),j.current=setTimeout(()=>{n.current&&(i("idle"),h(null))},1500))}},f=async d=>{if(!(d===V||o)){y(!0),h(null),C(new Set),j.current&&clearTimeout(j.current);try{const A=await Vs(Ie[d].config);if(!n.current)return;A.success?(i("success"),await Promise.all([l({force:!0}).catch(()=>{}),N()])):(i("error"),h(A.error||"Failed to save"))}catch{n.current&&(i("error"),h("Failed to save"))}finally{n.current&&(y(!1),j.current=setTimeout(()=>{n.current&&i("idle")},1500))}}},O=()=>f("off");return e.jsxs(B,{neomorphic:!0,children:[e.jsx(q,{icon:e.jsx(ua,{}),title:"Advert Rate Limiting",actions:e.jsxs("div",{className:"flex items-center gap-3",children:[u!=="idle"&&e.jsxs("span",{className:"flex items-center",children:[u==="success"&&e.jsx(Ne,{className:"w-4 h-4 text-sys-green"}),u==="error"&&e.jsx(Oe,{className:"w-4 h-4 text-sys-red"})]}),e.jsxs(F,{plain:!0,onClick:O,className:"flex items-center gap-1.5 text-zinc-500 hover:text-zinc-400 transition-colors",children:[e.jsx(ca,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-body-xs font-medium hidden sm:inline",children:"Reset"})]}),e.jsxs(F,{plain:!0,onClick:()=>v(!0),className:"flex items-center gap-1.5 text-sys-blue hover:text-sys-blue/80 transition-colors",children:[e.jsx(da,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-body-xs font-medium",children:"Auto"})]})]})}),p&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:p}),e.jsx("div",{className:"toggle-group w-full mb-4",children:tt.map(d=>{const A=Ie[d],G=d===V;return e.jsx("button",{onClick:()=>f(d),disabled:o,className:b("toggle-group-item flex-1",G&&"active",G&&A.color),children:A.label},d)})}),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(we,{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:b("type-data-xs font-medium uppercase tracking-wide",(w==null?void 0:w.color)??"text-fg-muted"),children:(w==null?void 0:w.label)??"Custom"}),(w==null?void 0:w.recommended)&&e.jsx(rs,{color:"green",children:"Recommended"}),!V&&e.jsx(rs,{color:"zinc",children:"Custom"})]}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:(w==null?void 0:w.description)??"Settings have been manually tuned and don’t match any preset."})]})]})}),e.jsxs("div",{className:b("space-y-3",V==="off"&&"opacity-40 pointer-events-none"),children:[e.jsx(ns,{title:"Token Rules",children:m?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(S,{label:"Bucket Capacity",value:String(m.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 d=>T("bucket_capacity",parseInt(d,10))}),e.jsx(S,{label:"Refill Tokens",value:String(m.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 d=>T("refill_tokens",parseInt(d,10))}),e.jsx(S,{label:"Refill Interval",value:me(m.refill_interval_seconds),editValue:String(parseFloat((m.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 d=>T("refill_interval_seconds",Math.round(parseFloat(d)*3600))}),e.jsx(S,{label:"Min Interval",value:me(m.min_interval_seconds),editValue:String(m.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 d=>T("min_interval_seconds",parseInt(d,10))})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})}),e.jsx(ns,{title:"Jail Settings",children:g?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(S,{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 d=>T("violation_threshold",parseInt(d,10))}),e.jsx(S,{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 d=>T("base_penalty_seconds",Math.round(parseFloat(d)*3600))}),e.jsx(S,{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 d=>T("penalty_multiplier",parseFloat(d))}),e.jsx(S,{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 d=>T("max_penalty_seconds",Math.round(parseFloat(d)*3600))}),e.jsx(S,{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 d=>T("violation_decay_seconds",Math.round(parseFloat(d)*3600))})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})}),e.jsx(ns,{title:"Traffic Tiers",children:k?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(S,{label:"EWMA α",value:String(k.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 d=>T("ewma_alpha",parseFloat(d))}),e.jsx(S,{label:"Hysteresis",value:me(k.hysteresis_seconds),editValue:String(parseFloat((k.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 d=>T("hysteresis_seconds",Math.round(parseFloat(d)*60))}),e.jsx(S,{label:"Quiet Max",value:String(k.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 d=>T("quiet_max",parseFloat(d))}),e.jsx(S,{label:"Normal Max",value:String(k.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 d=>T("normal_max",parseFloat(d))}),e.jsx(S,{label:"Busy Max",value:String(k.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 d=>T("busy_max",parseFloat(d))})]}):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(we,{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(Yt,{open:D,onClose:()=>v(!1),currentConfig:{tokenBucket:m,penaltyBox:g,adaptive:k},onApplied:async()=>{C(new Set(Qt)),await Promise.all([l({force:!0}).catch(()=>{}),N()])}})]})}const Js={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"}},Da=["off","minimal","moderate","strict"];function La(){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,r=!!c,o=(c==null?void 0:c.loop_detect)??"off",y=Js[o],p=t==null?void 0:t.local_hash,[h,u]=a.useState(!1),[i,j]=a.useState(null),[D,v]=a.useState("idle"),E=a.useRef(null);if(a.useEffect(()=>(n.current=!0,()=>{n.current=!1,E.current&&clearTimeout(E.current)}),[]),a.useEffect(()=>{if(!i)return;const m=setTimeout(()=>{n.current&&j(null)},4e3);return()=>clearTimeout(m)},[i]),!t)return null;const C=async m=>{if(!(!r||m===o||h)){u(!0),j(null),E.current&&clearTimeout(E.current);try{const g=await Ys({loop_detect:m});if(!n.current)return;g.success?(v("success"),await l({force:!0}).catch(()=>{})):(v("error"),j(g.error||"Failed to save"))}catch{n.current&&(v("error"),j("Failed to save"))}finally{n.current&&(u(!1),E.current=setTimeout(()=>{n.current&&v("idle")},1500))}}};return e.jsxs(B,{neomorphic:!0,children:[e.jsx(q,{icon:e.jsx(ma,{}),title:"Flood Loop Detection",actions:D!=="idle"?e.jsxs("span",{className:"flex items-center",children:[D==="success"&&e.jsx(Ne,{className:"w-4 h-4 text-sys-green"}),D==="error"&&e.jsx(Oe,{className:"w-4 h-4 text-sys-red"})]}):void 0}),!r&&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(Le,{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 openHop 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."]})]}),i&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:i}),e.jsx("div",{className:b("toggle-group w-full mb-4",!r&&"opacity-50 pointer-events-none"),children:Da.map(m=>{const g=Js[m],k=m===o;return e.jsx("button",{onClick:()=>C(m),disabled:h||!r,className:b("toggle-group-item flex-1",k&&"active",k&&g.color),children:g.label},m)})}),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(we,{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:b("type-data-xs font-medium uppercase tracking-wide",y.color),children:y.label}),y.threshold!==null&&e.jsxs("span",{className:"data-box data-box-compact text-fg-secondary tabular-nums",children:["≥",y.threshold,"× → drop"]}),y.recommended&&e.jsx(rs,{color:"green",children:"Recommended"})]}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:y.description}),p&&o!=="off"&&e.jsxs("p",{className:"type-data-xs text-fg-muted/60 mt-2 font-mono",children:["Local hash: ",p]})]})]})})]})}function Ia(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 Oa(){const{status:t,updateAvailable:l,isChecking:n,channels:c,changelog:r,error:o,available:y,checkForUpdate:p,fetchChannels:h,fetchChangelog:u,setChannel:i,openModal:j}=Et(),D=Rt(),[v,E]=a.useState(!1),[C,N]=a.useState(!1);if(a.useEffect(()=>{h(),u()},[h,u]),!y)return null;const m=f=>f.split("+")[0],g=f=>f!=null&&f.includes("+")?f.split("+")[1]:null,k=(t==null?void 0:t.current_version)??(D==null?void 0:D.version)??null,R=(t==null?void 0:t.latest_version)??null,J=k?m(k):null,V=R?m(R):null,w=g(k),T=(t==null?void 0:t.channel)??"main";return e.jsxs(B,{neomorphic:!0,children:[e.jsx(q,{icon:e.jsx(Hs,{}),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:J?`v${J}`:"—"}),w&&e.jsx(Pt,{copy:!0,copyValue:w,title:`Build: ${w}`,children:w})]})]}),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(fa,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-sys-indigo truncate",children:T})]})]}),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(xa,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:Ia((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||C||(N(!0),await i(f.name),N(!1))},disabled:f.active||C,className:b("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",C&&!f.active&&"opacity-50 cursor-not-allowed"),children:[f.name,f.active&&e.jsx(os,{className:"w-3 h-3 ml-1.5 inline-block"})]},f.name))})]}),r.length>0&&e.jsxs("div",{className:"bg-subtle-fill radius-inner mb-4",children:[e.jsxs("button",{onClick:()=>E(!v),className:"w-full flex items-center gap-2 px-4 py-3 text-left hover:bg-subtle-fill-hover transition-colors radius-inner",children:[v?e.jsx(Ws,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}):e.jsx(et,{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:[r.length," commit",r.length!==1?"s":""]})]}),v&&e.jsx("div",{className:"px-4 pb-3 space-y-1 max-h-[300px] overflow-y-auto",children:r.map(f=>e.jsxs("div",{className:"flex items-start gap-2 py-1.5 group",children:[e.jsx(ja,{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(st,{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(F,{color:"danger",onClick:j,children:[e.jsx(Hs,{"data-slot":"icon"}),"Update to v",V]}),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(os,{className:"w-3.5 h-3.5"}),"Up to date"]}),e.jsx(F,{color:"primary",outline:!0,onClick:()=>p(!0),disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(Y,{"data-slot":"icon",className:"animate-spin"}),"Checking..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Qs,{"data-slot":"icon"}),"Check for Updates"]})})]})]})}const za=[{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"}],Ka=[5,6,7,8,9,10,11,12],Va=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],Ha=[{value:0,label:"1-byte — 0x00"},{value:1,label:"2-byte — 0x0000"},{value:2,label:"3-byte — 0x000000"}],Xs={RADIO_CONFIG:"radioConfig"};function $a(t){if(!t)return"Never";const n=Date.now()-t*1e3,c=Math.floor(n/6e4),r=Math.floor(n/36e5),o=Math.floor(n/864e5);return c<1?"Just now":c<60?`${c}m ago`:r<24?`${r}h ago`:o<365?`${o}d ago`:`${Math.floor(o/365)}y ago`}function at({node:t,level:l,expandedKeys:n,selectedKeyId:c,onSelect:r,onToggle:o}){const y=n.has(t.id),p=c===t.id,h=t.children&&t.children.length>0;return e.jsxs("div",{children:[e.jsxs("div",{className:b("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",p?"bg-sys-blue/15":"hover:bg-subtle-fill"),style:{marginLeft:`${l*16}px`},onClick:()=>r(t.id),children:[h?e.jsx("button",{onClick:u=>{u.stopPropagation(),o(t.id)},className:"p-1 hover:bg-subtle-fill-hover rounded-full transition-colors",children:e.jsx(et,{className:b("w-3.5 h-3.5 text-fg-muted transition-transform",y&&"rotate-90")})}):e.jsx("span",{className:"w-5"}),e.jsx(ga,{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:$a(t.last_used)}),e.jsx("span",{className:b("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"})]}),h&&y&&e.jsx("div",{children:t.children.map(u=>e.jsx(at,{node:u,level:l+1,expandedKeys:n,selectedKeyId:c,onSelect:r,onToggle:o},u.id))})]})}function Ua(){const[t,l]=a.useState(ea),[n,c]=a.useState(sa),[r,o]=a.useState(!1),y=a.useCallback(u=>{l(u),ta(u)},[]),p=a.useCallback(u=>{const i=parseFloat(u.target.value);c(i),aa(i)},[]),h=a.useCallback(async()=>{r||(o(!0),await na(),o(!1))},[r]);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:y,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(F,{color:"primary",outline:!0,onClick:h,disabled:!t||r,className:"w-16 justify-center",children:r?"…":"Test"})]}),e.jsxs("div",{className:b("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:p,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 hn(){var Rs,Ps,As,Ms,Ds,Ls,Is,Os,zs,Ks;const{stats:t,setMode:l,clearModeMutation:n,setDutyCycleConfig:c,clearDutyCycleMutation:r,fetchStats:o,startMutation:y,clearMutation:p}=cs(),h=At(),u=(Rs=t==null?void 0:t.config)==null?void 0:Rs.radio,i=(Ps=t==null?void 0:t.config)==null?void 0:Ps.repeater,j=(As=t==null?void 0:t.config)==null?void 0:As.duty_cycle,D=(t==null?void 0:t.node_name)||((Ms=t==null?void 0:t.config)==null?void 0:Ms.node_name)||"Unknown Node",v=(i==null?void 0:i.mode)??"forward",E=(j==null?void 0:j.enforcement_enabled)??!1,C=(Ds=t==null?void 0:t.config)==null?void 0:Ds.delays,N=a.useRef(!0);a.useEffect(()=>(N.current=!0,()=>{N.current=!1}),[]);const m=(Ls=t==null?void 0:t.config)==null?void 0:Ls.web,[g,k]=a.useState([]),[R,J]=a.useState(!1),[V,w]=a.useState(null),[T,f]=a.useState(!1),[O,P]=a.useState(""),[z,H]=a.useState(null),[U,se]=a.useState(!1),[Q,d]=a.useState(null),[A,G]=a.useState(!1),[ds,us]=a.useState(!1),[ms,fs]=a.useState(!1),[Ke,xs]=a.useState(""),[xe,ps]=a.useState(""),[Ve,hs]=a.useState(""),[te,pe]=a.useState("idle"),[ys,ae]=a.useState(null),[Z,nt]=a.useState([]),[lt,gs]=a.useState(!1),[bs,L]=a.useState(null),[He,rt]=a.useState(()=>localStorage.getItem("pymc:unscopedFloodPolicy")==="allow"?"allow":"deny"),js=a.useCallback(s=>{rt(s),localStorage.setItem("pymc:unscopedFloodPolicy",s)},[]),[vs,Ns]=a.useState(!1),[K,$e]=a.useState(null),[ot,it]=a.useState(new Set),[ke,he]=a.useState(!1),[Se,oe]=a.useState(!1),[Ce,ie]=a.useState(!1),[I,ee]=a.useState(null),[ne,ye]=a.useState(null),[Te,Fe]=a.useState(""),[Ue,ge]=a.useState("allow"),[X,ce]=a.useState(!1),[Ee,ws]=a.useState(!0),[be,qe]=a.useState(!1),[ct,_s]=a.useState(!0),[je,le]=a.useState("idle"),[dt,Be]=a.useState(!1),[Ge,ut]=a.useState(!1),ks=a.useCallback(()=>{const s=C==null?void 0:C.tx_delay_factor;return s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??1:typeof s=="number"?s:1},[C]),Ss=a.useCallback(()=>{const s=C==null?void 0:C.direct_tx_delay_factor;return typeof s=="number"?s:.5},[C]),Je=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]),Xe=as(v==="forward",async s=>{await l(s?"forward":"monitor")},n),We=as(E,async s=>{await c({max_airtime_percent:Je(),enforcement_enabled:s})},r),Ye=as((m==null?void 0:m.cors_enabled)??!1,async s=>{var _;const x=await Bs({web:{cors_enabled:s}});if(!x.success&&!((_=x.data)!=null&&_.persisted))throw new Error("CORS update failed");await o()}),$=a.useCallback(async s=>{y(Xs.RADIO_CONFIG);try{const x=await Ys(s);if(!x.success)throw new Error(x.error||"Failed to save");await o({force:!0}).catch(()=>{})}finally{p(Xs.RADIO_CONFIG)}},[y,p,o]);a.useEffect(()=>{(async()=>{_s(!0);try{const x=await Gt();x.success&&x.data?qe(x.data.exists):qe(!1);const _=m==null?void 0:m.web_path;ws(!_||_==="")}catch{qe(!1)}finally{_s(!1)}})()},[m==null?void 0:m.web_path]);const Cs=async s=>{var x;if(je!=="loading"){le("loading");try{const _=await Bs({web:{web_path:s?null:"/opt/pymc_console/web/html"}});if(!N.current)return;_.success||(x=_.data)!=null&&x.persisted?(ws(s),le("success"),Be(!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)}}},mt=async()=>{if(!Ge){ut(!0);try{await Jt(),Be(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{Be(!1),setTimeout(()=>{window.location.reload()},3e3)}}},Re=a.useCallback(async()=>{J(!0),w(null);try{const s=await ka();k(s.tokens||[])}catch(s){w(s instanceof Error?s.message:"Failed to fetch tokens")}finally{J(!1)}},[]);a.useEffect(()=>{Re()},[Re]);const Ts=async()=>{if(!O.trim()){w("Token name is required");return}G(!0),w(null);try{const s=await Sa(O.trim());H(s.token||null),f(!1),se(!0),P(""),await Re()}catch(s){w(s instanceof Error?s.message:"Failed to create token")}finally{G(!1)}},ft=async()=>{if(Q){us(!0),w(null);try{await Ca(Q.id),await Re(),d(null)}catch(s){w(s instanceof Error?s.message:"Failed to revoke token")}finally{us(!1)}}},xt=async()=>{z&&(await Kt(z),fs(!0),setTimeout(()=>fs(!1),2e3))},pt=s=>s?new Date(s*1e3).toLocaleString():"Never",ht=async s=>{if(s==null||s.preventDefault(),te!=="loading"){if(pe("error"),!Ke||!xe||!Ve){ae("Enter your current password, new password, and confirmation.");return}if(xe.length<8){ae("New password must be at least 8 characters long.");return}if(xe!==Ve){ae("New password and confirmation do not match.");return}pe("loading"),ae(null);try{const x=await Ta(Ke,xe);if(!N.current)return;x.success?(xs(""),ps(""),hs(""),pe("success"),ae(x.message||"Password changed successfully. Use the new password next time you log in.")):(pe("error"),ae(x.error||"Failed to change password."))}catch(x){if(!N.current)return;pe("error"),ae(x instanceof Error?x.message:"Failed to change password.")}}},Fs=a.useCallback(s=>{const x=new Map,_=[];return s.forEach(M=>{const Pe={id:M.id,name:M.name,floodPolicy:M.flood_policy,transport_key:M.transport_key,last_used:M.last_used,parent_id:M.parent_id,children:[]};x.set(M.id,Pe)}),x.forEach(M=>{M.parent_id&&x.has(M.parent_id)?x.get(M.parent_id).children.push(M):_.push(M)}),_},[]),ve=a.useCallback(async()=>{gs(!0),L(null);try{const s=await Vt();if(s.success&&s.data){const x=Fs(s.data);nt(x),$e(_=>{if(_===null)return null;const M=Pe=>{for(const Qe of Pe)if(Qe.id===_||Qe.children&&M(Qe.children))return!0;return!1};return M(x)?_:null})}else L(s.error||"Failed to load transport keys")}catch(s){L(s instanceof Error?s.message:"Unknown error occurred")}finally{gs(!1)}},[Fs]);a.useEffect(()=>{ve(),Ht().then(s=>{s.success&&s.data&&js(s.data.unscoped_flood_allow?"allow":"deny")}).catch(()=>{})},[ve]);const re=a.useCallback((s,x)=>{for(const _ of s){if(_.id===x)return _;if(_.children){const M=re(_.children,x);if(M)return M}}return null},[]),yt=a.useCallback(()=>{if(!K)return;const s=re(Z,K);return s==null?void 0:s.name},[K,Z,re]),gt=a.useCallback(s=>{it(x=>{const _=new Set(x);return _.has(s)?_.delete(s):_.add(s),_})},[]),bt=async s=>{Ns(!0),L(null);try{const x=await $t(s==="allow");x.success?js(s):L(x.error||"Failed to update unscoped flood policy")}catch(x){L(x instanceof Error?x.message:"Failed to update unscoped flood policy")}finally{Ns(!1)}},Es=async()=>{if(!Te.trim()){L("Key name is required");return}ce(!0),L(null);try{const s=await Ut({name:Te.trim(),flood_policy:Ue,parent_id:K??void 0});s.success?(await ve(),he(!1),Fe(""),ge("allow")):L(s.error||"Failed to add transport key")}catch(s){L(s instanceof Error?s.message:"Failed to add transport key")}finally{ce(!1)}},jt=async()=>{if(I){ce(!0),L(null);try{const s=await qt(I.id,{name:I.name,flood_policy:I.floodPolicy});s.success?(await ve(),oe(!1),ee(null)):L(s.error||"Failed to update transport key")}catch(s){L(s instanceof Error?s.message:"Failed to update transport key")}finally{ce(!1)}}},vt=async()=>{if(ne){ce(!0),L(null);try{const s=await Bt(ne.id);s.success?(await ve(),ie(!1),ye(null),$e(null)):L(s.error||"Failed to delete transport key")}catch(s){L(s instanceof Error?s.message:"Failed to delete transport key")}finally{ce(!1)}}},Nt=a.useCallback(()=>{if(!K)return;const s=re(Z,K);s&&(ee({...s}),oe(!0))},[K,Z,re]);a.useEffect(()=>{const s=_=>{_.key==="Escape"&&(ke&&(he(!1),Fe(""),ge("allow")),Se&&(oe(!1),ee(null)),Ce&&(ie(!1),ye(null)),T&&(f(!1),P("")),U&&(se(!1),H(null)))};if(ke||Se||Ce||T||U)return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[ke,Se,Ce,T,U]);const wt=a.useCallback(()=>{if(!K)return;const s=re(Z,K);s&&(ye(s),ie(!0))},[K,Z,re]);return e.jsxs(la,{children:[e.jsx(ra,{title:"Configuration",icon:e.jsx($s,{})}),e.jsxs(oa,{ready:h,children:[e.jsxs(W,{template:"standard",children:[e.jsx(ue,{span:12,md:6,children:e.jsxs(B,{neomorphic:!0,children:[e.jsx(q,{icon:e.jsx(Mt,{}),title:"Repeater Settings"}),i?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(S,{label:"Node Name",value:D,onSave:async s=>$({node_name:s}),placeholder:"Enter node name",maxLength:50})}),e.jsx(S,{label:"Latitude",value:i.latitude!==0?i.latitude.toFixed(6):"Not set",editValue:String(i.latitude),type:"number",suffix:"°",step:1e-6,min:-90,max:90,onSave:async s=>$({latitude:parseFloat(s)})}),e.jsx(S,{label:"Longitude",value:i.longitude!==0?i.longitude.toFixed(6):"Not set",editValue:String(i.longitude),type:"number",suffix:"°",step:1e-6,min:-180,max:180,onSave:async s=>$({longitude:parseFloat(s)})}),e.jsx(S,{label:"Advert Interval",value:i.send_advert_interval_hours>0?`${i.send_advert_interval_hours}h`:"Disabled",editValue:String(i.send_advert_interval_hours),type:"number",suffix:"hours",min:0,max:48,description:"0 = disabled, 3-48 hours",onSave:async s=>$({flood_advert_interval_hours:parseInt(s,10)})}),e.jsx(S,{label:"Score-based TX",value:i.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(B,{neomorphic:!0,children:[e.jsx(q,{icon:e.jsx(pa,{}),title:"Radio Configuration"}),u?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(S,{label:"Frequency",value:Dt(u.frequency),editValue:(u.frequency/1e6).toFixed(3),type:"number",suffix:"MHz",step:.001,min:400,max:930,onSave:async s=>$({frequency_mhz:parseFloat(s)})}),e.jsx(S,{label:"TX Power",value:`${u.tx_power} dBm`,editValue:String(u.tx_power),type:"number",suffix:"dBm",min:2,max:30,onSave:async s=>$({tx_power:parseInt(s,10)})}),e.jsx(Me,{label:"Bandwidth",value:Lt(u.bandwidth),editValue:u.bandwidth/1e3,options:za,onSave:async s=>$({bandwidth_khz:parseFloat(s)})}),e.jsx(Me,{label:"Spreading Factor",value:`SF${u.spreading_factor}`,editValue:u.spreading_factor,options:Ka.map(s=>({value:s,label:`SF${s}`})),onSave:async s=>$({spreading_factor:parseInt(s,10)})}),e.jsx(Me,{label:"Coding Rate",value:`4/${u.coding_rate}`,editValue:u.coding_rate,options:Va,onSave:async s=>$({coding_rate:parseInt(s,10)})}),e.jsx(S,{label:"Preamble",value:`${u.preamble_length} symbols`,readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading radio configuration..."})]})})]}),e.jsxs(W,{template:"standard",children:[e.jsx(ue,{span:12,md:6,children:e.jsxs(B,{neomorphic:!0,children:[e.jsx(q,{icon:e.jsx(It,{}),title:"Operating Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(fe,{enabled:Xe.enabled,onChange:Xe.toggle,label:"Repeat",tooltip:"Toggles repeater or monitor mode. In monitor mode, the repeater will not repeat packets from the mesh.",status:Xe.status,size:"md"}),e.jsx(fe,{enabled:We.enabled,onChange:We.toggle,label:"Duty Cycle",tooltip:"Limit transmission time to comply with airtime utilization regulations",status:We.status,size:"md"}),e.jsx(S,{label:"Max Airtime",value:`${Je().toFixed(1)}%`,editValue:String(Je()),type:"number",suffix:"%",step:.5,min:.1,max:100,onSave:async s=>{await c({max_airtime_percent:parseFloat(s),enforcement_enabled:E}),r()}}),e.jsx(S,{label:"Flood TX Delay",value:`${ks().toFixed(2)}x`,editValue:String(ks()),type:"number",suffix:"x",step:.1,min:0,max:5,onSave:async s=>$({tx_delay_factor:parseFloat(s)})}),e.jsx(S,{label:"Direct TX Delay",value:`${Ss().toFixed(2)}x`,editValue:String(Ss()),type:"number",suffix:"x",description:"MeshCore TX delay factor, not seconds",step:.1,min:0,max:5,onSave:async s=>$({direct_tx_delay_factor:parseFloat(s)})}),e.jsx(S,{label:"Max Flood Hops",value:String((i==null?void 0:i.max_flood_hops)??3),type:"number",min:0,max:64,description:"0–64 hops",onSave:async s=>$({max_flood_hops:parseInt(s,10)})})]}),e.jsx("div",{className:"mt-4",children:e.jsx(Me,{label:"Path Hash Size",value:`${(((Os=(Is=t==null?void 0:t.config)==null?void 0:Is.mesh)==null?void 0:Os.path_hash_mode)??0)+1}-byte`,editValue:((Ks=(zs=t==null?void 0:t.config)==null?void 0:zs.mesh)==null?void 0:Ks.path_hash_mode)??0,options:Ha,onSave:async s=>$({path_hash_mode:parseInt(s,10)})})})]})}),e.jsx(ue,{span:12,md:6,children:e.jsxs(B,{neomorphic:!0,children:[e.jsx(q,{icon:e.jsx($s,{}),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:Ye.enabled,onChange:Ye.toggle,label:"Enable CORS",tooltip:"Allow cross-origin API access",status:Ye.status,size:"md"}),e.jsx("div",{children:e.jsx(Ea,{})}),e.jsx(Ua,{})]})]})})]}),e.jsx(W,{template:"auto",children:e.jsx(Ma,{})}),e.jsx(W,{template:"auto",children:e.jsxs(B,{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(q,{icon:e.jsx(Us,{}),title:"Region Configuration"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(F,{color:"primary",outline:!0,onClick:()=>he(!0),children:[e.jsx(qs,{"data-slot":"icon"}),"Add"]}),e.jsx(F,{color:"primary",outline:!0,onClick:Nt,disabled:!K,children:"Edit"}),e.jsx(F,{color:"danger",outline:!0,onClick:wt,disabled:!K,children:"Delete"})]})]}),e.jsxs("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:[e.jsx("p",{className:"type-body-sm text-fg-muted mb-3",children:"Region configuration controls where flood packets are allowed to travel. Add named regions, nest child regions under parents, and set the flood policy for each branch of the region tree."}),e.jsx(fe,{enabled:He==="allow",onChange:s=>bt(s?"allow":"deny"),label:e.jsxs(e.Fragment,{children:["Unscoped Flood: ",e.jsx("span",{className:He==="allow"?"text-sys-green":"text-sys-red",children:He==="allow"?"Allow":"Deny"})]}),tooltip:"Forward flood packets that have no region transport key. This is independent of region scope configuration.",status:vs?"loading":"idle",disabled:vs,dangerOff:!0,size:"md",className:"flex-row-reverse justify-between w-full"})]}),bs&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:bs}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 min-h-[120px]",children:lt?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx(Y,{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..."})]}):Z.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(Us,{className:"w-6 h-6 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No regions configured"}),e.jsx("p",{className:"type-body-sm text-fg-muted/70 mt-1",children:"Add your first region to start configuring flood scope."})]}):e.jsx("div",{className:"space-y-1",children:Z.map(s=>e.jsx(at,{node:s,level:0,expandedKeys:ot,selectedKeyId:K,onSelect:$e,onToggle:gt},s.id))})})]})}),e.jsxs(W,{template:"standard",children:[e.jsx(ue,{span:12,md:6,children:e.jsx(La,{})}),e.jsx(ue,{span:12,md:6,children:e.jsxs(B,{neomorphic:!0,className:"h-full flex flex-col",children:[e.jsx(q,{icon:e.jsx(Ze,{}),title:"API Tokens"}),V&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:V}),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(Y,{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: ",pt(s.last_used)]})]}),e.jsx("button",{type:"button",onClick:()=>d({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(Zs,{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(Ze,{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(F,{color:"primary",outline:!0,onClick:()=>f(!0),className:"w-full justify-center mt-auto",children:[e.jsx(qs,{"data-slot":"icon"}),"Create Token"]})]})})]}),e.jsx(W,{template:"auto",children:e.jsxs(B,{neomorphic:!0,children:[e.jsx(q,{icon:e.jsx(Na,{}),title:"Web Frontend"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:b("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Ee?"border-sys-blue bg-sys-blue/5":"border-transparent hover:border-sys-blue/30",je==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:Ee,onChange:()=>Cs(!0),disabled:je==="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/openhop-dev/openhop_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 openHop Repeater web interface"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/openhop_repeater/repeater/web/html"})]})]}),e.jsxs("label",{className:b("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Ee?"border-transparent hover:border-sys-blue/30":"border-sys-blue bg-sys-blue/5",je==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:!Ee,onChange:()=>Cs(!1),disabled:je==="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:"openHop 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 openHop Repeater"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_console/web/html"})]})]})]}),!ct&&e.jsx("div",{className:b("bg-subtle-fill radius-card p-4",be?"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:b("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",be?"bg-sys-green/20":"bg-sys-cyan/20"),children:be?e.jsx(os,{className:"w-4 h-4 text-sys-green"}):e.jsx(we,{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:be?"openHop Console has been detected":"openHop Console Not Installed"}),be?e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1",children:["openHop 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:["openHop 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(F,{color:"primary",outline:!0,href:"https://github.com/dmduran12/pymc_console-dist",children:[e.jsx(st,{"data-slot":"icon"}),"openHop Console Install Instructions"]})]})]})]})}),dt&&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(Le,{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 openhop-repeater service."})]})]}),e.jsx(F,{color:"warning",outline:!0,onClick:mt,disabled:Ge,children:Ge?e.jsxs(e.Fragment,{children:[e.jsx(Y,{"data-slot":"icon",className:"animate-spin"}),"Restarting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Qs,{"data-slot":"icon"}),"Restart Now"]})})]})})]})]})}),e.jsx(W,{template:"auto",children:e.jsx(Oa,{})}),t&&e.jsx(W,{template:"auto",children:e.jsx(Zt,{nodeName:D,publicKey:t.public_key})}),t&&((i==null?void 0:i.latitude)===0||!(i!=null&&i.latitude))&&((i==null?void 0:i.longitude)===0||!(i!=null&&i.longitude))&&e.jsx(W,{template:"auto",children:e.jsx(Pa,{})}),e.jsx(W,{template:"auto",children:e.jsxs(B,{neomorphic:!0,children:[e.jsx(q,{icon:e.jsx(Ze,{}),title:"Change Password"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Update the admin password used to sign in to this repeater. The new password must be at least 8 characters long."}),e.jsxs("form",{onSubmit:ht,className:"space-y-4",children:[ys&&e.jsx("div",{className:b("type-body-sm px-3 py-2 rounded-full",te==="success"?"text-sys-green bg-sys-green/10":"text-sys-red bg-sys-red/10"),children:ys}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(de,{label:"Current Password",type:"password",value:Ke,onChange:s=>xs(s.target.value),autoComplete:"current-password",disabled:te==="loading",required:!0}),e.jsx(de,{label:"New Password",type:"password",value:xe,onChange:s=>ps(s.target.value),autoComplete:"new-password",minLength:8,disabled:te==="loading",required:!0}),e.jsx(de,{label:"Confirm New Password",type:"password",value:Ve,onChange:s=>hs(s.target.value),autoComplete:"new-password",minLength:8,disabled:te==="loading",required:!0})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(F,{type:"submit",color:"primary",disabled:te==="loading",children:te==="loading"?e.jsxs(e.Fragment,{children:[e.jsx(Y,{"data-slot":"icon",className:"animate-spin"}),"Changing..."]}):"Change Password"})})]})]})})]}),T&&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(de,{label:"Token Name",type:"text",value:O,onChange:s=>P(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"&&Ts(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{f(!1),P(""),w(null)},disabled:A,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:Ts,disabled:A||!O.trim(),children:A?e.jsxs(e.Fragment,{children:[e.jsx(Y,{"data-slot":"icon",className:"animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),U&&z&&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&&se(!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(Le,{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(Ot,{value:z,readOnly:!0,className:"flex-1 font-mono"}),e.jsxs(F,{color:"primary",outline:!0,onClick:xt,children:[ms?e.jsx(Ne,{"data-slot":"icon",className:"text-sys-green"}):e.jsx(zt,{"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: ',z.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),e.jsx("div",{className:"flex justify-end mt-6",children:e.jsx(F,{color:"primary",onClick:()=>{se(!1),H(null)},children:"Done"})})]})]})}),e.jsx(Xt,{isOpen:!!Q,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${Q==null?void 0:Q.name}'? This action cannot be undone.`,confirmLabel:ds?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:ft,onCancel:()=>d(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&&he(!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 Region"}),e.jsxs("div",{className:"space-y-4",children:[K&&e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3 text-sm text-fg-secondary",children:["Adding region as child of: ",e.jsx("strong",{className:"text-fg-primary",children:yt()})]}),e.jsx(de,{label:"Region Name",type:"text",value:Te,onChange:s=>Fe(s.target.value),placeholder:"e.g., uk, au, us",onKeyDown:s=>s.key==="Enter"&&Es(),autoFocus:!0}),e.jsx("p",{className:"type-data-xs text-fg-muted -mt-2",children:"The # prefix is added automatically for regions."}),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:()=>ge("deny"),className:b("toggle-group-item flex-1",Ue==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>ge("allow"),className:b("toggle-group-item flex-1",Ue==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{he(!1),Fe(""),ge("allow")},disabled:X,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:Es,disabled:X||!Te.trim(),children:X?e.jsxs(e.Fragment,{children:[e.jsx(Y,{"data-slot":"icon",className:"animate-spin"}),"Adding..."]}):"Add Region"})]})]})]})}),Se&&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&&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 Region"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(de,{label:"Region Name",type:"text",value:I.name,onChange:s=>ee({...I,name:s.target.value}),autoFocus:!0}),e.jsx("p",{className:"type-data-xs text-fg-muted -mt-2",children:"The # prefix is added automatically for regions."}),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:()=>ee({...I,floodPolicy:"deny"}),className:b("toggle-group-item flex-1",I.floodPolicy==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>ee({...I,floodPolicy:"allow"}),className:b("toggle-group-item flex-1",I.floodPolicy==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),I.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:I.transport_key})]}),e.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[e.jsx(F,{color:"danger",outline:!0,onClick:()=>{oe(!1),ye(I),ie(!0),ee(null)},disabled:X,children:"Delete"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{oe(!1),ee(null)},disabled:X,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:jt,disabled:X||!I.name.trim(),children:X?e.jsxs(e.Fragment,{children:[e.jsx(Y,{"data-slot":"icon",className:"animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),Ce&&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&&ie(!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 Region"}),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(Le,{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 region has ",ne.children.length," child region(s). Deleting will also remove all children."]})]})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{ie(!1),ye(null)},disabled:X,children:"Cancel"}),e.jsx(F,{color:"danger",onClick:vt,disabled:X,children:X?e.jsxs(e.Fragment,{children:[e.jsx(Y,{"data-slot":"icon",className:"animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{hn as default}; diff --git a/frontend/dist/assets/Configuration-DoXqskWq.js b/frontend/dist/assets/Configuration-DoXqskWq.js new file mode 100644 index 00000000..f7a2d23d --- /dev/null +++ b/frontend/dist/assets/Configuration-DoXqskWq.js @@ -0,0 +1,32 @@ +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 xe,dy as Ve,dz as Dt,dA as Mt,r as a,eF as fs,eG as cs,j as e,c as N,_ as Me,ae as pe,H as At,S as It,eH as Lt,f as B,bO as Ke,a9 as X,a7 as _e,cY as ke,cB as ps,eI as Ot,B as E,a2 as ds,eJ as Gs,aE as nt,b_ as Oe,a4 as lt,eK as zt,ad as Kt,z as xs,aD as Js,c8 as Vt,cb as us,cL as rt,dD as ot,eL as Z,eM as Ae,cz as Ht,dB as $t,dE as Ut,dF as Bt,eN as qt,N as Ws,eO as Gt,cA as Jt,eP as Xs,eQ as Wt,eR as Xt,eS as Yt,R as Zt,eT as me,I as Qt,a8 as ea,aa as sa}from"./index-Ch85h29t.js";import{g as ta,a as aa,s as na,c as la,u as ra,d as oa}from"./transport-DFlFRyLO.js";import{c as ia,r as ca}from"./system-D8kFotbu.js";import{C as da}from"./ConfirmModal-DdfUdqSh.js";import{S as ua,A as ma,a as fa,N as pa}from"./AutoConfigureDialog-yPaPohCI.js";import{S as k,a as Ie}from"./setting-field-C4EiJNDk.js";import{i as xa,g as ha,s as ya,a as ga,k as ba}from"./keycap-sfx-ByZp-njj.js";import{C as q,P as ja,a as va,B as Na}from"./PageLayout-BB80XCAa.js";import{T as it}from"./trash-2-D_NWmP0i.js";import{P as wa}from"./pencil-BZOxTwpZ.js";import{R as ct}from"./rotate-ccw-Bkw4kxED.js";import{W as _a}from"./wand-sparkles-Br5G9OBm.js";import{S as ka}from"./shield-651xYu1q.js";import{R as Sa}from"./repeat-DVY-bBc4.js";import{G as Ca}from"./git-branch-B0JLmrv3.js";import{C as Ta}from"./clock-BDyTFNOi.js";import{C as dt}from"./WorkspaceNav-ZTG5UTjF.js";import{R as ms,F as Ys}from"./radio-group-elwRJEn2.js";import{R as W,C as se}from"./Grid-DKZX3hrI.js";import{A as Fa}from"./antenna-DGc7zBO5.js";import{P as Zs}from"./plus-C7tLXNBe.js";import{K as as}from"./key-round-DLgdhdTl.js";import"./monitor-smartphone-CTx9MPdz.js";import"./arrow-right-CKd6FEys.js";import"./use-by-comparator-DeUfymOv.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 Ea=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ut=xe("external-link",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 Ra=[["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2",key:"3hgo9p"}],["path",{d:"m22 14-4.5 4.5",key:"1ef6z8"}],["path",{d:"m21 15 1 1",key:"1ejcpy"}]],Pa=xe("folder-key",Ra);/** + * @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 Da=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],Ma=xe("git-commit-horizontal",Da);/** + * @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=[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m14.305 7.53.923-.382",key:"1mlnsw"}],["path",{d:"m15.228 4.852-.923-.383",key:"82mpwg"}],["path",{d:"m16.852 3.228-.383-.924",key:"ln4sir"}],["path",{d:"m16.852 8.772-.383.923",key:"1dejw0"}],["path",{d:"m19.148 3.228.383-.924",key:"192kgf"}],["path",{d:"m19.53 9.696-.382-.924",key:"fiavlr"}],["path",{d:"m20.772 4.852.924-.383",key:"1j8mgp"}],["path",{d:"m20.772 7.148.924.383",key:"zix9be"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]],Ia=xe("monitor-cog",Aa);/** + * @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 La=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Oa=xe("monitor",La);/** + * @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 za=[["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"}]],Ka=xe("triangle-dashed",za);async function Va(){try{return await Ve("/api/auth/tokens")}catch{return{tokens:[]}}}async function Ha(t){return Ve("/api/auth/tokens",{method:"POST",body:JSON.stringify({name:t})})}async function $a(t){return Ve(`/api/auth/tokens/${t}`,{method:"DELETE"})}async function Ua(t,l){const n=Dt();if(!n)return{success:!1,error:"Not authenticated"};try{const c=await fetch(`${Mt}/auth/change_password`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({current_password:t,new_password:l})}),o=c.headers.get("content-type"),i=o!=null&&o.includes("application/json")?await c.json():null;return!c.ok||!(i!=null&&i.success)?{success:!1,error:(i==null?void 0:i.error)||`Password change failed: ${c.status} ${c.statusText}`}:i}catch(c){return{success:!1,error:c instanceof Error?c.message:"Failed to change password"}}}async function Qs(t){return Ve("/api/update_web_config",{method:"POST",body:JSON.stringify(t)})}a.memo(function(){const{theme:l}=fs(),{themeId:n}=l,c=cs.find(o=>o.meta.id===n)??cs[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 ns=a.memo(function({compact:l=!1}){const{theme:n,setTheme:c}=fs(),{themeId:o}=n;return e.jsx("div",{className:N("grid grid-cols-2 gap-2",l?"w-full min-w-0 self-stretch":"w-full"),children:[...cs].reverse().map(i=>{const j=o===i.meta.id,x=i.meta.isDark;return e.jsxs("button",{type:"button",title:i.meta.name,className:N("flex flex-row items-stretch radius-inner transition-all duration-200 ease-out overflow-hidden cursor-pointer",l&&"h-6",j?"ring-2 ring-sys-blue scale-[1.02]":"opacity-70 hover:opacity-100"),onClick:()=>c(i.meta.id),children:[e.jsx("div",{className:N("flex-1 h-full",x?"bg-[#18181b]":"bg-[#EFF0F1]")}),e.jsx("div",{className:"flex flex-col h-full",children:i.display.palette.map((b,f)=>e.jsx("div",{className:"flex flex-1",children:b.map((h,y)=>e.jsx("div",{className:"w-2 h-full",style:{backgroundColor:h}},y))},f))})]},i.meta.id)})})});let et=!1,Le=null;async function Ba(){if(!et)return Le||(Le=(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]))]),et=!0}catch(t){console.warn("Failed to load theme fonts:",t)}})(),Le)}const ls=a.memo(function(){const{theme:l,setTheme:n}=fs(),{themeId:c}=l,o=c==="breeze dark",i=a.useCallback(j=>{n(j?"breeze dark":"breeze light")},[n]);return e.jsx(pe,{enabled:o,onChange:i,label:e.jsxs(e.Fragment,{children:["Dark Mode: ",o?e.jsx(At,{className:"w-3.5 h-3.5 text-sys-blue inline"}):e.jsx(It,{className:"w-3.5 h-3.5 text-[#e8a517] inline"})]}),tooltip:"Switch between dark and light mode",size:"md"})}),qa=a.memo(function({layout:l="horizontal"}){return a.useEffect(()=>{Ba()},[]),l==="toggle-only"?e.jsx(ls,{}):l==="thumbnails-only"?e.jsx(ns,{}):l==="vertical"?e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx(ls,{}),e.jsx(ns,{})]}):e.jsxs("div",{className:"flex items-stretch gap-4",children:[e.jsx("div",{className:"flex-shrink-0 flex items-start",children:e.jsx(ls,{})}),e.jsx(ns,{compact:!0})]})}),Ga=1e4,rs=2e3;function os(t,l,n){const[c,o]=a.useState("idle"),[i,j]=a.useState(null),x=a.useRef(!0),b=a.useRef(null),f=a.useRef(null),h=a.useRef(!1),y=a.useRef("idle"),u=a.useRef(t),v=a.useRef(l),S=a.useRef(n);y.current=c,u.current=t,v.current=l,S.current=n,a.useEffect(()=>(x.current=!0,()=>{x.current=!1,b.current&&clearTimeout(b.current),f.current&&clearTimeout(f.current)}),[]);const A=a.useCallback(async r=>{if(y.current==="loading")return;const p=u.current;b.current&&clearTimeout(b.current),f.current&&clearTimeout(f.current),h.current=!1,j(r),o("loading"),b.current=setTimeout(()=>{h.current||!x.current||(j(p),o("error"),f.current=setTimeout(()=>{x.current&&(o("idle"),j(null))},rs))},Ga);try{if(await v.current(r),h.current=!0,b.current&&clearTimeout(b.current),!x.current)return;o("success"),f.current=setTimeout(()=>{var w;x.current&&(o("idle"),j(null),(w=S.current)==null||w.call(S))},rs)}catch{if(h.current=!0,b.current&&clearTimeout(b.current),!x.current)return;j(p),o("error"),f.current=setTimeout(()=>{x.current&&(o("idle"),j(null))},rs)}},[]);return{enabled:i!==null?i:t,status:c,toggle:A}}function Ja(){const{latitude:t,longitude:l,enabled:n,setLocation:c,enable:o,disable:i,clear:j}=Lt(),[x,b]=a.useState(!1),[f,h]=a.useState(""),[y,u]=a.useState(""),[v,S]=a.useState("idle"),[A,C]=a.useState(null),r=a.useRef(null),p=a.useRef(null),w=a.useRef(!0);a.useEffect(()=>(w.current=!0,()=>{w.current=!1,p.current&&clearTimeout(p.current)}),[]);const T=()=>{h((t==null?void 0:t.toFixed(6))??""),u((l==null?void 0:l.toFixed(6))??""),C(null),b(!0)},Y=()=>{b(!1),C(null)};a.useEffect(()=>{if(!x)return;const P=H=>{v!=="loading"&&r.current&&!r.current.contains(H.target)&&Y()};return document.addEventListener("mouseup",P),()=>document.removeEventListener("mouseup",P)},[x,v]);const V=(P,H)=>{const z=parseFloat(P),$=parseFloat(H);return isNaN(z)||isNaN($)?"Please enter valid numbers":z<-90||z>90?"Latitude must be between -90 and 90":$<-180||$>180?"Longitude must be between -180 and 180":z===0&&$===0?"Coordinates (0, 0) are invalid":null},D=()=>{if(v==="loading")return;p.current&&clearTimeout(p.current);const P=V(f,y);if(P){C(P);return}S("loading"),C(null);const H=parseFloat(f),z=parseFloat(y);c(H,z),n||o(),S("success"),p.current=setTimeout(()=>{w.current&&(S("idle"),b(!1))},1e3)},F=()=>{n?i():o()},L=()=>{j(),b(!1)},m=t!==null&&l!==null;return e.jsx(q,{children:e.jsxs("div",{ref:r,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(B,{icon:e.jsx(Ka,{}),title:"Stealth"}),e.jsxs("div",{className:"flex items-center gap-1",children:[m&&!x&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:F,className:N("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:N("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:L,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(it,{className:"w-4 h-4"})})]}),x?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:Y,disabled:v==="loading",className:N("p-2 rounded-lg transition-colors",v==="loading"?"text-fg-muted cursor-not-allowed":"text-fg-muted hover:text-sys-red hover:bg-sys-red/10"),title:"Cancel",children:e.jsx(Ke,{className:"w-4 h-4"})}),e.jsx("button",{onClick:D,disabled:v==="loading",className:N("p-2 rounded-lg transition-colors",v==="loading"?"text-sys-blue cursor-wait":v==="success"?"text-sys-green":v==="error"?"text-sys-red":"text-sys-green hover:bg-sys-green/10"),title:"Save",children:v==="loading"?e.jsx(X,{className:"w-4 h-4 animate-spin"}):v==="success"?e.jsx(_e,{className:"w-4 h-4"}):v==="error"?e.jsx(Ke,{className:"w-4 h-4"}):e.jsx(_e,{className:"w-4 h-4"})})]}):e.jsx("button",{onClick:T,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-fg-primary hover:bg-subtle",title:m?"Edit stealth location":"Set stealth location",children:e.jsx(wa,{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(ke,{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"}),"."]})]})}),A&&e.jsx("div",{className:"text-xs mb-3 px-2 py-1.5 rounded-md text-sys-red bg-sys-red/10",children:A}),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:x?"Latitude (°)":"Latitude"}),e.jsx("div",{className:N("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:x?e.jsx("input",{type:"number",value:f,onChange:P=>h(P.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:N("type-data",m&&n?"text-fg-primary":"text-fg-muted"),children:m?t.toFixed(6):"Not set"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:x?"Longitude (°)":"Longitude"}),e.jsx("div",{className:N("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:x?e.jsx("input",{type:"number",value:y,onChange:P=>u(P.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:N("type-data",m&&n?"text-fg-primary":"text-fg-muted"),children:m?l.toFixed(6):"Not set"})})]})]}),m&&!x&&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:N("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 fe(t){if(t<60)return`${t}s`;if(t<3600){const c=Math.floor(t/60),o=t%60;return o>0?`${c}m ${o}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 is({title:t,defaultOpen:l=!1,children:n}){const[c,o]=a.useState(l);return e.jsxs("div",{className:"bg-subtle-fill radius-inner overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>o(!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(nt,{className:N("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 ze={off:{label:"Off",description:"All rate limiting disabled. Every advert is forwarded unconditionally.",color:"text-fg-muted",config:ua},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}}},mt=["off","light","standard","strict"];function Wa(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 o of mt){if(o==="off")continue;const i=ze[o].config;if((t==null?void 0:t.bucket_capacity)===i.bucket_capacity&&(t==null?void 0:t.refill_tokens)===i.refill_tokens&&(t==null?void 0:t.refill_interval_seconds)===i.refill_interval_seconds&&(t==null?void 0:t.min_interval_seconds)===i.min_interval_seconds&&(l==null?void 0:l.violation_threshold)===i.violation_threshold&&(l==null?void 0:l.base_penalty_seconds)===i.base_penalty_seconds&&(l==null?void 0:l.penalty_multiplier)===i.penalty_multiplier&&(l==null?void 0:l.max_penalty_seconds)===i.max_penalty_seconds&&(l==null?void 0:l.violation_decay_seconds)===i.violation_decay_seconds&&(n==null?void 0:n.ewma_alpha)===i.ewma_alpha&&(n==null?void 0:n.hysteresis_seconds)===i.hysteresis_seconds)return o}return null}function Xa(){var P,H,z,$,ie,te;const{stats:t,fetchStats:l}=ps(),n=a.useRef(!0),[c,o]=a.useState(!0),[i,j]=a.useState(!1),[x,b]=a.useState(null),[f,h]=a.useState("idle"),y=a.useRef(null),[u,v]=a.useState(!1),[S,A]=a.useState(new Set);a.useEffect(()=>(n.current=!0,()=>{n.current=!1,y.current&&clearTimeout(y.current)}),[]);const C=a.useCallback(async()=>{var d;try{const R=await Ot();if(!n.current)return;R.success&&R.data&&((d=R.data.adaptive)!=null&&d.current_tier)?o(!0):o(!1)}catch{n.current&&o(!1)}},[]);a.useEffect(()=>{C();const d=setInterval(C,3e4);return()=>clearInterval(d)},[C]);const r=(H=(P=t==null?void 0:t.config)==null?void 0:P.repeater)==null?void 0:H.advert_rate_limit,p=($=(z=t==null?void 0:t.config)==null?void 0:z.repeater)==null?void 0:$.advert_penalty_box,w=(te=(ie=t==null?void 0:t.config)==null?void 0:ie.repeater)==null?void 0:te.advert_adaptive;if(!c&&!r&&!p&&!w)return null;const T=d=>S.has(d),Y=d=>{A(R=>{if(!R.has(d))return R;const G=new Set(R);return G.delete(d),G})},V=Wa(r,p,w),D=V?ze[V]:null,F=async(d,R)=>{Y(d),j(!0),b(null),y.current&&clearTimeout(y.current);try{const G=await Gs({[d]:R});if(!n.current)return;G.success?(h("success"),await Promise.all([l({force:!0}).catch(()=>{}),C()])):(h("error"),b(G.error||"Failed to save"))}catch{n.current&&(h("error"),b("Failed to save"))}finally{n.current&&(j(!1),y.current=setTimeout(()=>{n.current&&(h("idle"),b(null))},1500))}},L=async d=>{if(!(d===V||i)){j(!0),b(null),A(new Set),y.current&&clearTimeout(y.current);try{const R=await Gs(ze[d].config);if(!n.current)return;R.success?(h("success"),await Promise.all([l({force:!0}).catch(()=>{}),C()])):(h("error"),b(R.error||"Failed to save"))}catch{n.current&&(h("error"),b("Failed to save"))}finally{n.current&&(j(!1),y.current=setTimeout(()=>{n.current&&h("idle")},1500))}}},m=()=>L("off");return e.jsxs(q,{neomorphic:!0,children:[e.jsx(B,{icon:e.jsx(ka,{}),title:"Advert Rate Limiting",actions:e.jsxs("div",{className:"flex items-center gap-3",children:[f!=="idle"&&e.jsxs("span",{className:"flex items-center",children:[f==="success"&&e.jsx(_e,{className:"w-4 h-4 text-sys-green"}),f==="error"&&e.jsx(Ke,{className:"w-4 h-4 text-sys-red"})]}),e.jsxs(E,{plain:!0,onClick:m,className:"flex items-center gap-1.5 text-zinc-500 hover:text-zinc-400 transition-colors",children:[e.jsx(ct,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-body-xs font-medium hidden sm:inline",children:"Reset"})]}),e.jsxs(E,{plain:!0,onClick:()=>v(!0),className:"flex items-center gap-1.5 text-sys-blue hover:text-sys-blue/80 transition-colors",children:[e.jsx(_a,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-body-xs font-medium",children:"Auto"})]})]})}),x&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:x}),e.jsx("div",{className:"toggle-group w-full mb-4",children:mt.map(d=>{const R=ze[d],G=d===V;return e.jsx("button",{onClick:()=>L(d),disabled:i,className:N("toggle-group-item flex-1",G&&"active",G&&R.color),children:R.label},d)})}),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(ke,{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:N("type-data-xs font-medium uppercase tracking-wide",(D==null?void 0:D.color)??"text-fg-muted"),children:(D==null?void 0:D.label)??"Custom"}),(D==null?void 0:D.recommended)&&e.jsx(ds,{color:"green",children:"Recommended"}),!V&&e.jsx(ds,{color:"zinc",children:"Custom"})]}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:(D==null?void 0:D.description)??"Settings have been manually tuned and don’t match any preset."})]})]})}),e.jsxs("div",{className:N("space-y-3",V==="off"&&"opacity-40 pointer-events-none"),children:[e.jsx(is,{title:"Token Rules",children:r?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(k,{label:"Bucket Capacity",value:String(r.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:T("bucket_capacity"),onSave:async d=>F("bucket_capacity",parseInt(d,10))}),e.jsx(k,{label:"Refill Tokens",value:String(r.refill_tokens),type:"number",suffix:"tokens",min:1,max:50,tooltip:"Tokens added back each refill cycle. Higher = more forgiving over time.",autoConfigured:T("refill_tokens"),onSave:async d=>F("refill_tokens",parseInt(d,10))}),e.jsx(k,{label:"Refill Interval",value:fe(r.refill_interval_seconds),editValue:String(parseFloat((r.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:T("refill_interval_seconds"),onSave:async d=>F("refill_interval_seconds",Math.round(parseFloat(d)*3600))}),e.jsx(k,{label:"Min Interval",value:fe(r.min_interval_seconds),editValue:String(r.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:T("min_interval_seconds"),onSave:async d=>F("min_interval_seconds",parseInt(d,10))})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})}),e.jsx(is,{title:"Jail Settings",children:p?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(k,{label:"Violation Threshold",value:String(p.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:T("violation_threshold"),onSave:async d=>F("violation_threshold",parseInt(d,10))}),e.jsx(k,{label:"Base Penalty",value:fe(p.base_penalty_seconds),editValue:String(parseFloat((p.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:T("base_penalty_seconds"),onSave:async d=>F("base_penalty_seconds",Math.round(parseFloat(d)*3600))}),e.jsx(k,{label:"Multiplier",value:`${p.penalty_multiplier}x`,editValue:String(p.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:T("penalty_multiplier"),onSave:async d=>F("penalty_multiplier",parseFloat(d))}),e.jsx(k,{label:"Max Penalty",value:fe(p.max_penalty_seconds),editValue:String(parseFloat((p.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:T("max_penalty_seconds"),onSave:async d=>F("max_penalty_seconds",Math.round(parseFloat(d)*3600))}),e.jsx(k,{label:"Violation Decay",value:fe(p.violation_decay_seconds),editValue:String(parseFloat((p.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:T("violation_decay_seconds"),onSave:async d=>F("violation_decay_seconds",Math.round(parseFloat(d)*3600))})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})}),e.jsx(is,{title:"Traffic Tiers",children:w?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(k,{label:"EWMA α",value:String(w.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:T("ewma_alpha"),onSave:async d=>F("ewma_alpha",parseFloat(d))}),e.jsx(k,{label:"Hysteresis",value:fe(w.hysteresis_seconds),editValue:String(parseFloat((w.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:T("hysteresis_seconds"),onSave:async d=>F("hysteresis_seconds",Math.round(parseFloat(d)*60))}),e.jsx(k,{label:"Quiet Max",value:String(w.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:T("quiet_max"),onSave:async d=>F("quiet_max",parseFloat(d))}),e.jsx(k,{label:"Normal Max",value:String(w.thresholds.normal_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic below this = normal activity. Standard rate limits apply.",autoConfigured:T("normal_max"),onSave:async d=>F("normal_max",parseFloat(d))}),e.jsx(k,{label:"Busy Max",value:String(w.thresholds.busy_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic above this = congested mesh. Strictest rate limits kick in.",autoConfigured:T("busy_max"),onSave:async d=>F("busy_max",parseFloat(d))})]}):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(ke,{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(ma,{open:u,onClose:()=>v(!1),currentConfig:{tokenBucket:r,penaltyBox:p,adaptive:w},onApplied:async()=>{A(new Set(fa)),await Promise.all([l({force:!0}).catch(()=>{}),C()])}})]})}const st={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"}},Ya=["off","minimal","moderate","strict"];function Za(){var C;const{stats:t,fetchStats:l}=ps(),n=a.useRef(!0),c=(C=t==null?void 0:t.config)==null?void 0:C.mesh,o=!!c,i=(c==null?void 0:c.loop_detect)??"off",j=st[i],x=t==null?void 0:t.local_hash,[b,f]=a.useState(!1),[h,y]=a.useState(null),[u,v]=a.useState("idle"),S=a.useRef(null);if(a.useEffect(()=>(n.current=!0,()=>{n.current=!1,S.current&&clearTimeout(S.current)}),[]),a.useEffect(()=>{if(!h)return;const r=setTimeout(()=>{n.current&&y(null)},4e3);return()=>clearTimeout(r)},[h]),!t)return null;const A=async r=>{if(!(!o||r===i||b)){f(!0),y(null),S.current&&clearTimeout(S.current);try{const p=await lt({loop_detect:r});if(!n.current)return;p.success?(v("success"),await l({force:!0}).catch(()=>{})):(v("error"),y(p.error||"Failed to save"))}catch{n.current&&(v("error"),y("Failed to save"))}finally{n.current&&(f(!1),S.current=setTimeout(()=>{n.current&&v("idle")},1500))}}};return e.jsxs(q,{neomorphic:!0,children:[e.jsx(B,{icon:e.jsx(Sa,{}),title:"Flood Loop Detection",actions:u!=="idle"?e.jsxs("span",{className:"flex items-center",children:[u==="success"&&e.jsx(_e,{className:"w-4 h-4 text-sys-green"}),u==="error"&&e.jsx(Ke,{className:"w-4 h-4 text-sys-red"})]}):void 0}),!o&&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(Oe,{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 openHop 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."]})]}),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:N("toggle-group w-full mb-4",!o&&"opacity-50 pointer-events-none"),children:Ya.map(r=>{const p=st[r],w=r===i;return e.jsx("button",{onClick:()=>A(r),disabled:b||!o,className:N("toggle-group-item flex-1",w&&"active",w&&p.color),children:p.label},r)})}),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(ke,{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:N("type-data-xs font-medium uppercase tracking-wide",j.color),children:j.label}),j.threshold!==null&&e.jsxs("span",{className:"data-box data-box-compact text-fg-secondary tabular-nums",children:["≥",j.threshold,"× → drop"]}),j.recommended&&e.jsx(ds,{color:"green",children:"Recommended"})]}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:j.description}),x&&i!=="off"&&e.jsxs("p",{className:"type-data-xs text-fg-muted/60 mt-2 font-mono",children:["Local hash: ",x]})]})]})})]})}function Qa(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 en(){const{status:t,updateAvailable:l,isChecking:n,channels:c,changelog:o,error:i,available:j,checkForUpdate:x,fetchChannels:b,fetchChangelog:f,setChannel:h,openModal:y}=zt(),u=Kt(),v=xs(),[S,A]=a.useState(!1),[C,r]=a.useState(!1);if(a.useEffect(()=>{b(),f()},[b,f]),!j)return null;const p=m=>m.split("+")[0],w=m=>m!=null&&m.includes("+")?m.split("+")[1]:null,T=(t==null?void 0:t.current_version)??(u==null?void 0:u.version)??null,Y=(t==null?void 0:t.latest_version)??null,V=T?p(T):null,D=Y?p(Y):null,F=w(T),L=(t==null?void 0:t.channel)??"main";return e.jsxs(q,{neomorphic:!0,children:[e.jsx(B,{icon:e.jsx(Js,{}),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:V?`v${V}`:"—"}),F&&e.jsx(Vt,{copy:!0,copyValue:F,title:`Build: ${F}`,children:F})]})]}),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(Ca,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-sys-indigo truncate",children:L})]})]}),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(Ta,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:Qa((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(m=>e.jsxs("button",{onClick:async()=>{m.active||C||(r(!0),await h(m.name),r(!1))},disabled:m.active||C,className:N("px-3 py-1.5 radius-inner type-data-xs font-medium transition-colors",m.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",C&&!m.active&&"opacity-50 cursor-not-allowed"),children:[m.name,m.active&&e.jsx(us,{className:"w-3 h-3 ml-1.5 inline-block"})]},m.name))})]}),o.length>0&&e.jsxs("div",{className:"bg-subtle-fill radius-inner mb-4",children:[e.jsxs("button",{onClick:()=>A(!S),className:"w-full flex items-center gap-2 px-4 py-3 text-left hover:bg-subtle-fill-hover transition-colors radius-inner",children:[S?e.jsx(nt,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}):e.jsx(dt,{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:[o.length," commit",o.length!==1?"s":""]})]}),S&&e.jsx("div",{className:"px-4 pb-3 space-y-1 max-h-[300px] overflow-y-auto",children:o.map(m=>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:[m.url?e.jsx("a",{href:m.url,target:"_blank",rel:"noopener noreferrer",className:"type-data-xs text-fg-primary truncate hover:text-sys-blue transition-colors",children:m.title}):e.jsx("p",{className:"type-data-xs text-fg-primary truncate",children:m.title}),m.url&&e.jsx("a",{href:m.url,target:"_blank",rel:"noopener noreferrer",className:"opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:e.jsx(ut,{className:"w-3 h-3 text-fg-muted"})})]}),m.body&&e.jsx("p",{className:"type-data-xs text-fg-muted mt-0.5 line-clamp-2 whitespace-pre-line",children:m.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:m.short_sha}),e.jsx("span",{className:"text-fg-muted/30",children:"·"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:m.author}),e.jsx("span",{className:"text-fg-muted/30",children:"·"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:m.date?rt(new Date(m.date),v):""})]})]})]},m.sha))})]}),i&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:i}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l&&e.jsxs(E,{color:"danger",onClick:y,children:[e.jsx(Js,{"data-slot":"icon"}),"Update to v",D]}),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(us,{className:"w-3.5 h-3.5"}),"Up to date"]}),e.jsx(E,{color:"primary",outline:!0,onClick:()=>x(!0),disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(X,{"data-slot":"icon",className:"animate-spin"}),"Checking..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ot,{"data-slot":"icon"}),"Check for Updates"]})})]})]})}const sn=[{value:"auto",label:"Auto"},{value:"metric",label:"Metric"},{value:"imperial",label:"Imperial"}],tn=[{value:"auto",label:"Auto"},{value:"iso",label:"ISO"}],an=[{value:"auto",label:"Auto"},{value:"24h",label:"24h"},{value:"12h",label:"12h"}],nn=[{value:"local",label:"Local"},{value:"utc",label:"UTC"}];function tt({label:t,options:l,value:n,onChange:c,preview:o,className:i=""}){return e.jsxs("section",{className:`min-w-0 px-2.5 py-2.5 sm:px-3 sm:py-3 ${i}`,children:[e.jsxs("div",{className:"mb-2 min-w-0",children:[e.jsx("h3",{className:"type-micro text-fg-muted",children:t}),e.jsx("span",{className:"mt-0.5 block min-w-0 truncate type-data-sm font-medium text-fg-primary",title:o,children:o})]}),e.jsx(ms,{label:e.jsx("span",{className:"sr-only",children:t}),options:l,value:n,onChange:c,variant:"segmented",size:"sm",className:"flex min-w-0 max-w-full flex-col items-end !space-y-0"})]})}function ln(){const t=Z(r=>r.measurementSystem),l=Z(r=>r.dateFormat),n=Z(r=>r.timeFormat),c=Z(r=>r.timeZone),o=Z(r=>r.setMeasurementSystem),i=Z(r=>r.setDateFormat),j=Z(r=>r.setTimeFormat),x=Z(r=>r.setTimeZone),b=Z(r=>r.reset),f=xs(),[h,y]=a.useState(()=>new Date);a.useEffect(()=>{const r=window.setInterval(()=>y(new Date),1e3);return()=>window.clearInterval(r)},[]);const u=t===Ae.measurementSystem&&l===Ae.dateFormat&&n===Ae.timeFormat&&c===Ae.timeZone,v=[{label:"Distance",value:Ht(12345,f,{compact:!0})},{label:"Altitude",value:$t(123,f,{compact:!0,maximumFractionDigits:0})},{label:"Speed",value:Ut(88,f,{compact:!0,maximumFractionDigits:0})},{label:"Temp",value:Bt(21.5,f,{minimumFractionDigits:0,maximumFractionDigits:0})},{label:"Pressure",value:qt(980,f,{compact:!0,maximumFractionDigits:0})}],S=rt(h,f),A=Ws(h,f,!0),C=Ws(h,f);return e.jsxs(q,{neomorphic:!0,isLoaded:!0,children:[e.jsx(B,{icon:e.jsx(Ia,{}),title:"Unit Display",actions:e.jsxs(E,{type:"button",color:"muted",outline:!0,"aria-label":"Reset unit display preferences",title:"Reset unit display preferences",onClick:b,disabled:u,children:[e.jsx(ct,{"data-slot":"icon"}),e.jsx("span",{className:"hidden sm:inline",children:"Reset"})]})}),e.jsxs("div",{className:"overflow-hidden bg-subtle-fill radius-inner",children:[e.jsxs("section",{className:"grid min-w-0 grid-cols-12 items-center",children:[e.jsx("div",{className:"col-span-3 px-3 py-2.5",children:e.jsx("h3",{className:"type-micro text-fg-muted",title:"Auto follows your browser region. Radio and protocol units remain canonical.",children:"Units"})}),e.jsx("div",{className:"col-span-9 flex justify-end px-3 py-2.5",children:e.jsx(ms,{label:e.jsx("span",{className:"sr-only",children:"Measurement units"}),options:sn,value:t,onChange:o,variant:"segmented",size:"sm",className:"flex min-w-0 max-w-full flex-col items-end !space-y-0"})}),e.jsx("div",{className:"col-span-12 grid grid-cols-5 divide-x divide-edge-subtle border-t border-edge-subtle","aria-label":"Unit examples",children:v.map(r=>e.jsx("span",{className:"min-w-0 truncate px-0.5 py-2 text-center type-data-sm font-medium text-fg-primary","aria-label":`${r.label}: ${r.value}`,title:`${r.label}: ${r.value}`,children:r.value},r.label))})]}),e.jsxs("div",{className:"grid grid-cols-2 border-t border-edge-subtle",children:[e.jsx(tt,{label:"Date",options:tn,value:l,onChange:i,preview:S,className:"border-r border-edge-subtle"}),e.jsx(tt,{label:"Time",options:an,value:n,onChange:j,preview:A})]}),e.jsxs("section",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-3 border-t border-edge-subtle px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"type-micro text-fg-muted",children:"Time zone"}),e.jsx("span",{className:"mt-0.5 block min-w-0 truncate type-data-sm font-medium text-fg-primary",title:C,children:C})]}),e.jsx(ms,{label:e.jsx("span",{className:"sr-only",children:"Time zone"}),options:nn,value:c,onChange:x,variant:"segmented",size:"sm",className:"flex min-w-0 max-w-full flex-col items-end !space-y-0"})]})]})]})}const rn=[{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"}],on=[5,6,7,8,9,10,11,12],cn=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],dn=[{value:0,label:"1-byte — 0x00"},{value:1,label:"2-byte — 0x0000"},{value:2,label:"3-byte — 0x000000"}],at={RADIO_CONFIG:"radioConfig"};function un(t){if(!t)return"Never";const n=Date.now()-t*1e3,c=Math.floor(n/6e4),o=Math.floor(n/36e5),i=Math.floor(n/864e5);return c<1?"Just now":c<60?`${c}m ago`:o<24?`${o}h ago`:i<365?`${i}d ago`:`${Math.floor(i/365)}y ago`}function ft({node:t,level:l,expandedKeys:n,selectedKeyId:c,onSelect:o,onToggle:i,formatTimestamp:j}){const x=n.has(t.id),b=c===t.id,f=t.children&&t.children.length>0;return e.jsxs("div",{children:[e.jsxs("div",{className:N("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",b?"bg-sys-blue/15":"hover:bg-subtle-fill"),style:{marginLeft:`${l*16}px`},onClick:()=>o(t.id),children:[f?e.jsx("button",{onClick:h=>{h.stopPropagation(),i(t.id)},className:"p-1 hover:bg-subtle-fill-hover rounded-full transition-colors",children:e.jsx(dt,{className:N("w-3.5 h-3.5 text-fg-muted transition-transform",x&&"rotate-90")})}):e.jsx("span",{className:"w-5"}),e.jsx(Pa,{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?j(t.last_used):void 0,children:un(t.last_used)}),e.jsx("span",{className:N("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"})]}),f&&x&&e.jsx("div",{children:t.children.map(h=>e.jsx(ft,{node:h,level:l+1,expandedKeys:n,selectedKeyId:c,onSelect:o,onToggle:i,formatTimestamp:j},h.id))})]})}function mn(){const[t,l]=a.useState(xa),[n,c]=a.useState(ha),[o,i]=a.useState(!1),j=a.useCallback(f=>{l(f),ya(f)},[]),x=a.useCallback(f=>{const h=parseFloat(f.target.value);c(h),ga(h)},[]),b=a.useCallback(async()=>{o||(i(!0),await ba(),i(!1))},[o]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(pe,{enabled:t,onChange:j,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(E,{color:"primary",outline:!0,onClick:b,disabled:!t||o,className:"w-16 justify-center",children:o?"…":"Test"})]}),e.jsxs("div",{className:N("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:x,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 On(){var Ls,Os,zs,Ks,Vs,Hs,$s,Us,Bs,qs;const{stats:t,setMode:l,clearModeMutation:n,setDutyCycleConfig:c,clearDutyCycleMutation:o,fetchStats:i,startMutation:j,clearMutation:x}=ps(),b=Gt(),f=xs(),h=a.useCallback(s=>s?Jt(new Date(s*1e3),f):"Never",[f]),y=(Ls=t==null?void 0:t.config)==null?void 0:Ls.radio,u=(Os=t==null?void 0:t.config)==null?void 0:Os.repeater,v=(zs=t==null?void 0:t.config)==null?void 0:zs.duty_cycle,S=(t==null?void 0:t.node_name)||((Ks=t==null?void 0:t.config)==null?void 0:Ks.node_name)||"Unknown Node",A=(u==null?void 0:u.mode)??"forward",C=(v==null?void 0:v.enforcement_enabled)??!1,r=(Vs=t==null?void 0:t.config)==null?void 0:Vs.delays,p=a.useRef(!0);a.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]);const w=(Hs=t==null?void 0:t.config)==null?void 0:Hs.web,[T,Y]=a.useState([]),[V,D]=a.useState(!1),[F,L]=a.useState(null),[m,P]=a.useState(!1),[H,z]=a.useState(""),[$,ie]=a.useState(null),[te,d]=a.useState(!1),[R,G]=a.useState(null),[He,hs]=a.useState(!1),[ys,gs]=a.useState(!1),[bs,js]=a.useState(!1),[$e,vs]=a.useState(""),[he,Ns]=a.useState(""),[Ue,ws]=a.useState(""),[ae,ye]=a.useState("idle"),[_s,ne]=a.useState(null),[Q,pt]=a.useState([]),[xt,ks]=a.useState(!1),[Ss,I]=a.useState(null),[Be,ht]=a.useState(()=>localStorage.getItem("pymc:unscopedFloodPolicy")==="allow"?"allow":"deny"),qe=a.useCallback(s=>{ht(s),localStorage.setItem("pymc:unscopedFloodPolicy",s)},[]),[Cs,Ts]=a.useState(!1),[K,Ge]=a.useState(null),[yt,gt]=a.useState(new Set),[Se,ge]=a.useState(!1),[Ce,ce]=a.useState(!1),[Te,de]=a.useState(!1),[O,ee]=a.useState(null),[le,be]=a.useState(null),[Fe,Ee]=a.useState(""),[Je,je]=a.useState("allow"),[J,ue]=a.useState(!1),[Re,Fs]=a.useState(!0),[ve,We]=a.useState(!1),[bt,Es]=a.useState(!0),[Ne,re]=a.useState("idle"),[jt,Xe]=a.useState(!1),[Ye,vt]=a.useState(!1),Rs=a.useCallback(()=>{const s=r==null?void 0:r.tx_delay_factor;return s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??1:typeof s=="number"?s:1},[r]),Ps=a.useCallback(()=>{const s=r==null?void 0:r.direct_tx_delay_factor;return typeof s=="number"?s:.5},[r]),Ze=a.useCallback(()=>{const s=v==null?void 0:v.max_airtime_percent;return typeof s=="number"?s:s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??6:6},[v]),Qe=os(A==="forward",async s=>{await l(s?"forward":"monitor")},n),es=os(C,async s=>{await c({max_airtime_percent:Ze(),enforcement_enabled:s})},o),ss=os((w==null?void 0:w.cors_enabled)??!1,async s=>{var _;const g=await Qs({web:{cors_enabled:s}});if(!g.success&&!((_=g.data)!=null&&_.persisted))throw new Error("CORS update failed");await i()}),U=a.useCallback(async s=>{j(at.RADIO_CONFIG);try{const g=await lt(s);if(!g.success)throw new Error(g.error||"Failed to save");await i({force:!0}).catch(()=>{})}finally{x(at.RADIO_CONFIG)}},[j,x,i]);a.useEffect(()=>{(async()=>{Es(!0);try{const g=await ia();g.success&&g.data?We(g.data.exists):We(!1);const _=w==null?void 0:w.web_path;Fs(!_||_==="")}catch{We(!1)}finally{Es(!1)}})()},[w==null?void 0:w.web_path]);const Ds=async s=>{var g;if(Ne!=="loading"){re("loading");try{const _=await Qs({web:{web_path:s?null:"/opt/pymc_console/web/html"}});if(!p.current)return;_.success||(g=_.data)!=null&&g.persisted?(Fs(s),re("success"),Xe(!0),setTimeout(()=>{p.current&&re("idle")},2e3)):(re("error"),setTimeout(()=>{p.current&&re("idle")},2e3))}catch{if(!p.current)return;re("error"),setTimeout(()=>{p.current&&re("idle")},2e3)}}},Nt=async()=>{if(!Ye){vt(!0);try{await ca(),Xe(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{Xe(!1),setTimeout(()=>{window.location.reload()},3e3)}}},Pe=a.useCallback(async()=>{D(!0),L(null);try{const s=await Va();Y(s.tokens||[])}catch(s){L(s instanceof Error?s.message:"Failed to fetch tokens")}finally{D(!1)}},[]);a.useEffect(()=>{Pe()},[Pe]);const Ms=async()=>{if(!H.trim()){L("Token name is required");return}hs(!0),L(null);try{const s=await Ha(H.trim());ie(s.token||null),P(!1),d(!0),z(""),await Pe()}catch(s){L(s instanceof Error?s.message:"Failed to create token")}finally{hs(!1)}},wt=async()=>{if(R){gs(!0),L(null);try{await $a(R.id),await Pe(),G(null)}catch(s){L(s instanceof Error?s.message:"Failed to revoke token")}finally{gs(!1)}}},_t=async()=>{$&&(await sa($),js(!0),setTimeout(()=>js(!1),2e3))},kt=async s=>{if(s==null||s.preventDefault(),ae!=="loading"){if(ye("error"),!$e||!he||!Ue){ne("Enter your current password, new password, and confirmation.");return}if(he.length<8){ne("New password must be at least 8 characters long.");return}if(he!==Ue){ne("New password and confirmation do not match.");return}ye("loading"),ne(null);try{const g=await Ua($e,he);if(!p.current)return;g.success?(vs(""),Ns(""),ws(""),ye("success"),ne(g.message||"Password changed successfully. Use the new password next time you log in.")):(ye("error"),ne(g.error||"Failed to change password."))}catch(g){if(!p.current)return;ye("error"),ne(g instanceof Error?g.message:"Failed to change password.")}}},As=a.useCallback(s=>{const g=new Map,_=[];return s.forEach(M=>{const De={id:M.id,name:M.name,floodPolicy:M.flood_policy,transport_key:M.transport_key,last_used:M.last_used,parent_id:M.parent_id,children:[]};g.set(M.id,De)}),g.forEach(M=>{M.parent_id&&g.has(M.parent_id)?g.get(M.parent_id).children.push(M):_.push(M)}),_},[]),we=a.useCallback(async()=>{ks(!0),I(null);try{const s=await ta();if(s.success&&s.data){const g=As(s.data);pt(g),Ge(_=>{if(_===null)return null;const M=De=>{for(const ts of De)if(ts.id===_||ts.children&&M(ts.children))return!0;return!1};return M(g)?_:null})}else I(s.error||"Failed to load transport keys")}catch(s){I(s instanceof Error?s.message:"Unknown error occurred")}finally{ks(!1)}},[As]);a.useEffect(()=>{we(),aa().then(s=>{s.success&&s.data&&qe(s.data.unscoped_flood_allow?"allow":"deny")}).catch(()=>{})},[we,qe]);const oe=a.useCallback((s,g)=>{for(const _ of s){if(_.id===g)return _;if(_.children){const M=oe(_.children,g);if(M)return M}}return null},[]),St=a.useCallback(()=>{if(!K)return;const s=oe(Q,K);return s==null?void 0:s.name},[K,Q,oe]),Ct=a.useCallback(s=>{gt(g=>{const _=new Set(g);return _.has(s)?_.delete(s):_.add(s),_})},[]),Tt=async s=>{Ts(!0),I(null);try{const g=await na(s==="allow");g.success?qe(s):I(g.error||"Failed to update unscoped flood policy")}catch(g){I(g instanceof Error?g.message:"Failed to update unscoped flood policy")}finally{Ts(!1)}},Is=async()=>{if(!Fe.trim()){I("Key name is required");return}ue(!0),I(null);try{const s=await la({name:Fe.trim(),flood_policy:Je,parent_id:K??void 0});s.success?(await we(),ge(!1),Ee(""),je("allow")):I(s.error||"Failed to add transport key")}catch(s){I(s instanceof Error?s.message:"Failed to add transport key")}finally{ue(!1)}},Ft=async()=>{if(O){ue(!0),I(null);try{const s=await ra(O.id,{name:O.name,flood_policy:O.floodPolicy});s.success?(await we(),ce(!1),ee(null)):I(s.error||"Failed to update transport key")}catch(s){I(s instanceof Error?s.message:"Failed to update transport key")}finally{ue(!1)}}},Et=async()=>{if(le){ue(!0),I(null);try{const s=await oa(le.id);s.success?(await we(),de(!1),be(null),Ge(null)):I(s.error||"Failed to delete transport key")}catch(s){I(s instanceof Error?s.message:"Failed to delete transport key")}finally{ue(!1)}}},Rt=a.useCallback(()=>{if(!K)return;const s=oe(Q,K);s&&(ee({...s}),ce(!0))},[K,Q,oe]);a.useEffect(()=>{const s=_=>{_.key==="Escape"&&(Se&&(ge(!1),Ee(""),je("allow")),Ce&&(ce(!1),ee(null)),Te&&(de(!1),be(null)),m&&(P(!1),z("")),te&&(d(!1),ie(null)))};if(Se||Ce||Te||m||te)return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[Se,Ce,Te,m,te]);const Pt=a.useCallback(()=>{if(!K)return;const s=oe(Q,K);s&&(be(s),de(!0))},[K,Q,oe]);return e.jsxs(ja,{children:[e.jsx(va,{title:"Configuration",icon:e.jsx(Xs,{})}),e.jsxs(Na,{ready:b,children:[e.jsxs(W,{template:"standard",children:[e.jsx(se,{span:12,md:6,children:e.jsxs(q,{neomorphic:!0,children:[e.jsx(B,{icon:e.jsx(Wt,{}),title:"Repeater Settings"}),u?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(k,{label:"Node Name",value:S,onSave:async s=>U({node_name:s}),placeholder:"Enter node name",maxLength:50})}),e.jsx(k,{label:"Latitude",value:u.latitude!==0?u.latitude.toFixed(6):"Not set",editValue:String(u.latitude),type:"number",suffix:"°",step:1e-6,min:-90,max:90,onSave:async s=>U({latitude:parseFloat(s)})}),e.jsx(k,{label:"Longitude",value:u.longitude!==0?u.longitude.toFixed(6):"Not set",editValue:String(u.longitude),type:"number",suffix:"°",step:1e-6,min:-180,max:180,onSave:async s=>U({longitude:parseFloat(s)})}),e.jsx(k,{label:"Advert Interval",value:u.send_advert_interval_hours>0?`${u.send_advert_interval_hours}h`:"Disabled",editValue:String(u.send_advert_interval_hours),type:"number",suffix:"hours",min:0,max:168,description:"0 = disabled, 3-168 hours",onSave:async s=>U({flood_advert_interval_hours:parseInt(s,10)})}),e.jsx(k,{label:"Score-based TX",value:u.use_score_for_tx?"Enabled":"Disabled",readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading repeater settings..."})]})}),e.jsx(se,{span:12,md:6,children:e.jsxs(q,{neomorphic:!0,children:[e.jsx(B,{icon:e.jsx(Fa,{}),title:"Radio Configuration"}),y?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(k,{label:"Frequency",value:Xt(y.frequency),editValue:(y.frequency/1e6).toFixed(3),type:"number",suffix:"MHz",step:.001,min:400,max:930,onSave:async s=>U({frequency_mhz:parseFloat(s)})}),e.jsx(k,{label:"TX Power",value:`${y.tx_power} dBm`,editValue:String(y.tx_power),type:"number",suffix:"dBm",min:2,max:30,onSave:async s=>U({tx_power:parseInt(s,10)})}),e.jsx(Ie,{label:"Bandwidth",value:Yt(y.bandwidth),editValue:y.bandwidth/1e3,options:rn,onSave:async s=>U({bandwidth_khz:parseFloat(s)})}),e.jsx(Ie,{label:"Spreading Factor",value:`SF${y.spreading_factor}`,editValue:y.spreading_factor,options:on.map(s=>({value:s,label:`SF${s}`})),onSave:async s=>U({spreading_factor:parseInt(s,10)})}),e.jsx(Ie,{label:"Coding Rate",value:`4/${y.coding_rate}`,editValue:y.coding_rate,options:cn,onSave:async s=>U({coding_rate:parseInt(s,10)})}),e.jsx(k,{label:"Preamble",value:`${y.preamble_length} symbols`,readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading radio configuration..."})]})})]}),e.jsxs(W,{template:"auto",children:[e.jsx(se,{span:12,md:6,children:e.jsxs(q,{neomorphic:!0,children:[e.jsx(B,{icon:e.jsx(Zt,{}),title:"Operating Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(pe,{enabled:Qe.enabled,onChange:Qe.toggle,label:"Repeat",tooltip:"Toggles repeater or monitor mode. In monitor mode, the repeater will not repeat packets from the mesh.",status:Qe.status,size:"md"}),e.jsx(pe,{enabled:es.enabled,onChange:es.toggle,label:"Duty Cycle",tooltip:"Limit transmission time to comply with airtime utilization regulations",status:es.status,size:"md"}),e.jsx(k,{label:"Max Airtime",value:`${Ze().toFixed(1)}%`,editValue:String(Ze()),type:"number",suffix:"%",step:.5,min:.1,max:100,onSave:async s=>{await c({max_airtime_percent:parseFloat(s),enforcement_enabled:C}),o()}}),e.jsx(k,{label:"Flood TX Delay",value:`${Rs().toFixed(2)}x`,editValue:String(Rs()),type:"number",suffix:"x",step:.1,min:0,max:5,onSave:async s=>U({tx_delay_factor:parseFloat(s)})}),e.jsx(k,{label:"Direct TX Delay",value:`${Ps().toFixed(2)}x`,editValue:String(Ps()),type:"number",suffix:"x",description:"MeshCore TX delay factor, not seconds",step:.1,min:0,max:5,onSave:async s=>U({direct_tx_delay_factor:parseFloat(s)})}),e.jsx(k,{label:"Max Flood Hops",value:String((u==null?void 0:u.max_flood_hops)??3),type:"number",min:0,max:64,description:"0–64 hops",onSave:async s=>U({max_flood_hops:parseInt(s,10)})})]}),e.jsx("div",{className:"mt-4",children:e.jsx(Ie,{label:"Path Hash Size",value:`${(((Us=($s=t==null?void 0:t.config)==null?void 0:$s.mesh)==null?void 0:Us.path_hash_mode)??0)+1}-byte`,editValue:((qs=(Bs=t==null?void 0:t.config)==null?void 0:Bs.mesh)==null?void 0:qs.path_hash_mode)??0,options:dn,onSave:async s=>U({path_hash_mode:parseInt(s,10)})})})]})}),e.jsx(se,{span:12,md:6,children:e.jsxs(q,{neomorphic:!0,children:[e.jsx(B,{icon:e.jsx(Xs,{}),title:"App Settings"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Personalize this browser's appearance and interface feedback."}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{children:e.jsx(qa,{})}),e.jsx(mn,{}),e.jsxs("section",{className:"border-t border-edge-subtle pt-4","aria-labelledby":"web-server-access-heading",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{id:"web-server-access-heading",className:"type-body-sm text-fg-primary font-medium",children:"Web/server access"}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-1",children:"Control whether other web applications may call this repeater's API."})]}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-3",children:e.jsx(pe,{enabled:ss.enabled,onChange:ss.toggle,label:"Enable CORS",tooltip:"Allow cross-origin API access",status:ss.status,size:"md"})})]})]})]})})]}),e.jsxs(W,{template:"auto",children:[e.jsx(se,{span:12,md:6,children:e.jsx(ln,{})}),e.jsx(se,{span:12,md:6,children:e.jsxs(q,{neomorphic:!0,children:[e.jsxs("div",{className:"mb-3 flex flex-col gap-3 xl:flex-row xl:items-center xl:justify-between",children:[e.jsx(B,{icon:e.jsx(Ys,{}),title:"Region Configuration"}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsxs(E,{color:"primary",outline:!0,onClick:()=>ge(!0),children:[e.jsx(Zs,{"data-slot":"icon"}),"Add"]}),e.jsx(E,{color:"primary",outline:!0,onClick:Rt,disabled:!K,children:"Edit"}),e.jsx(E,{color:"danger",outline:!0,onClick:Pt,disabled:!K,children:"Delete"})]})]}),e.jsxs("div",{className:"mb-3 bg-subtle-fill p-3 radius-inner",children:[e.jsx("p",{className:"mb-2 type-body-sm text-fg-muted",children:"Define where flood packets may travel. Add or nest regions, then set each branch's policy."}),e.jsx(pe,{enabled:Be==="allow",onChange:s=>Tt(s?"allow":"deny"),label:e.jsxs(e.Fragment,{children:["Unscoped Flood: ",e.jsx("span",{className:Be==="allow"?"text-sys-green":"text-sys-red",children:Be==="allow"?"Allow":"Deny"})]}),tooltip:"Forward flood packets that have no region transport key. This is independent of region scope configuration.",status:Cs?"loading":"idle",disabled:Cs,dangerOff:!0,size:"md",className:"flex-row-reverse justify-between w-full"})]}),Ss&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:Ss}),e.jsx("div",{className:"min-h-[104px] bg-subtle-fill p-3 radius-inner",children:xt?e.jsxs("div",{className:"flex items-center justify-center py-4",children:[e.jsx(X,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading regions..."})]}):Q.length===0?e.jsxs("div",{className:"py-4 text-center",children:[e.jsx("div",{className:"mx-auto mb-2 flex h-10 w-10 items-center justify-center rounded-full bg-subtle-fill",children:e.jsx(Ys,{className:"h-5 w-5 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No regions configured"}),e.jsx("p",{className:"mt-1 type-body-sm text-fg-muted/70",children:"Add a region to define flood scope."})]}):e.jsx("div",{className:"space-y-1",children:Q.map(s=>e.jsx(ft,{node:s,level:0,expandedKeys:yt,selectedKeyId:K,onSelect:Ge,onToggle:Ct,formatTimestamp:h},s.id))})})]})})]}),e.jsx(W,{template:"auto",children:e.jsx(Xa,{})}),e.jsxs(W,{template:"standard",children:[e.jsx(se,{span:12,md:6,children:e.jsx(Za,{})}),e.jsx(se,{span:12,md:6,children:e.jsxs(q,{neomorphic:!0,className:"h-full flex flex-col",children:[e.jsx(B,{icon:e.jsx(as,{}),title:"API Tokens"}),F&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:F}),e.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:V&&T.length===0?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(X,{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..."})]}):T.length>0?e.jsx("div",{className:"space-y-1.5 flex-1 overflow-y-auto mb-3",children:T.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: ",h(s.last_used)]})]}),e.jsx("button",{type:"button",onClick:()=>G({id:s.id,name:s.name}),disabled:ys,className:"text-sys-red/70 hover:text-sys-red transition-colors flex-shrink-0 p-1",title:"Revoke token",children:e.jsx(it,{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(as,{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(E,{color:"primary",outline:!0,onClick:()=>P(!0),className:"w-full justify-center mt-auto",children:[e.jsx(Zs,{"data-slot":"icon"}),"Create Token"]})]})})]}),e.jsx(W,{template:"auto",children:e.jsxs(q,{neomorphic:!0,children:[e.jsx(B,{icon:e.jsx(Oa,{}),title:"Web Frontend"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:N("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Re?"border-sys-blue bg-sys-blue/5":"border-transparent hover:border-sys-blue/30",Ne==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:Re,onChange:()=>Ds(!0),disabled:Ne==="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/openhop-dev/openhop_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 openHop Repeater web interface"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/openhop_repeater/repeater/web/html"})]})]}),e.jsxs("label",{className:N("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Re?"border-transparent hover:border-sys-blue/30":"border-sys-blue bg-sys-blue/5",Ne==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:!Re,onChange:()=>Ds(!1),disabled:Ne==="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:"openHop 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 openHop Repeater"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_console/web/html"})]})]})]}),!bt&&e.jsx("div",{className:N("bg-subtle-fill radius-card p-4",ve?"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:N("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",ve?"bg-sys-green/20":"bg-sys-cyan/20"),children:ve?e.jsx(us,{className:"w-4 h-4 text-sys-green"}):e.jsx(ke,{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:ve?"openHop Console has been detected":"openHop Console Not Installed"}),ve?e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1",children:["openHop 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:["openHop 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(E,{color:"primary",outline:!0,href:"https://github.com/dmduran12/pymc_console-dist",children:[e.jsx(ut,{"data-slot":"icon"}),"openHop Console Install Instructions"]})]})]})]})}),jt&&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(Oe,{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 openhop-repeater service."})]})]}),e.jsx(E,{color:"warning",outline:!0,onClick:Nt,disabled:Ye,children:Ye?e.jsxs(e.Fragment,{children:[e.jsx(X,{"data-slot":"icon",className:"animate-spin"}),"Restarting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ot,{"data-slot":"icon"}),"Restart Now"]})})]})})]})]})}),e.jsx(W,{template:"auto",children:e.jsx(en,{})}),t&&e.jsx(W,{template:"auto",children:e.jsx(pa,{nodeName:S,publicKey:t.public_key})}),t&&((u==null?void 0:u.latitude)===0||!(u!=null&&u.latitude))&&((u==null?void 0:u.longitude)===0||!(u!=null&&u.longitude))&&e.jsx(W,{template:"auto",children:e.jsx(Ja,{})}),e.jsx(W,{template:"auto",children:e.jsxs(q,{neomorphic:!0,children:[e.jsx(B,{icon:e.jsx(as,{}),title:"Change Password"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Update the admin password used to sign in to this repeater. The new password must be at least 8 characters long."}),e.jsxs("form",{onSubmit:kt,className:"space-y-4",children:[_s&&e.jsx("div",{className:N("type-body-sm px-3 py-2 rounded-full",ae==="success"?"text-sys-green bg-sys-green/10":"text-sys-red bg-sys-red/10"),children:_s}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(me,{label:"Current Password",type:"password",value:$e,onChange:s=>vs(s.target.value),autoComplete:"current-password",disabled:ae==="loading",required:!0}),e.jsx(me,{label:"New Password",type:"password",value:he,onChange:s=>Ns(s.target.value),autoComplete:"new-password",minLength:8,disabled:ae==="loading",required:!0}),e.jsx(me,{label:"Confirm New Password",type:"password",value:Ue,onChange:s=>ws(s.target.value),autoComplete:"new-password",minLength:8,disabled:ae==="loading",required:!0})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(E,{type:"submit",color:"primary",disabled:ae==="loading",children:ae==="loading"?e.jsxs(e.Fragment,{children:[e.jsx(X,{"data-slot":"icon",className:"animate-spin"}),"Changing..."]}):"Change Password"})})]})]})})]}),m&&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&&P(!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(me,{label:"Token Name",type:"text",value:H,onChange:s=>z(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"&&Ms(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(E,{color:"muted",outline:!0,onClick:()=>{P(!1),z(""),L(null)},disabled:He,children:"Cancel"}),e.jsx(E,{color:"primary",onClick:Ms,disabled:He||!H.trim(),children:He?e.jsxs(e.Fragment,{children:[e.jsx(X,{"data-slot":"icon",className:"animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),te&&$&&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&&d(!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(Oe,{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(Qt,{value:$,readOnly:!0,className:"flex-1 font-mono"}),e.jsxs(E,{color:"primary",outline:!0,onClick:_t,children:[bs?e.jsx(_e,{"data-slot":"icon",className:"text-sys-green"}):e.jsx(ea,{"data-slot":"icon"}),bs?"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: ',$.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),e.jsx("div",{className:"flex justify-end mt-6",children:e.jsx(E,{color:"primary",onClick:()=>{d(!1),ie(null)},children:"Done"})})]})]})}),e.jsx(da,{isOpen:!!R,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${R==null?void 0:R.name}'? This action cannot be undone.`,confirmLabel:ys?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:wt,onCancel:()=>G(null)}),Se&&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&&ge(!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 Region"}),e.jsxs("div",{className:"space-y-4",children:[K&&e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3 text-sm text-fg-secondary",children:["Adding region as child of: ",e.jsx("strong",{className:"text-fg-primary",children:St()})]}),e.jsx(me,{label:"Region Name",type:"text",value:Fe,onChange:s=>Ee(s.target.value),placeholder:"e.g., uk, au, us",onKeyDown:s=>s.key==="Enter"&&Is(),autoFocus:!0}),e.jsx("p",{className:"type-data-xs text-fg-muted -mt-2",children:"The # prefix is added automatically for regions."}),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:()=>je("deny"),className:N("toggle-group-item flex-1",Je==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>je("allow"),className:N("toggle-group-item flex-1",Je==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(E,{color:"muted",outline:!0,onClick:()=>{ge(!1),Ee(""),je("allow")},disabled:J,children:"Cancel"}),e.jsx(E,{color:"primary",onClick:Is,disabled:J||!Fe.trim(),children:J?e.jsxs(e.Fragment,{children:[e.jsx(X,{"data-slot":"icon",className:"animate-spin"}),"Adding..."]}):"Add Region"})]})]})]})}),Ce&&O&&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":"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 Region"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(me,{label:"Region Name",type:"text",value:O.name,onChange:s=>ee({...O,name:s.target.value}),autoFocus:!0}),e.jsx("p",{className:"type-data-xs text-fg-muted -mt-2",children:"The # prefix is added automatically for regions."}),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:()=>ee({...O,floodPolicy:"deny"}),className:N("toggle-group-item flex-1",O.floodPolicy==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>ee({...O,floodPolicy:"allow"}),className:N("toggle-group-item flex-1",O.floodPolicy==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),O.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:O.transport_key})]}),e.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[e.jsx(E,{color:"danger",outline:!0,onClick:()=>{ce(!1),be(O),de(!0),ee(null)},disabled:J,children:"Delete"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(E,{color:"muted",outline:!0,onClick:()=>{ce(!1),ee(null)},disabled:J,children:"Cancel"}),e.jsx(E,{color:"primary",onClick:Ft,disabled:J||!O.name.trim(),children:J?e.jsxs(e.Fragment,{children:[e.jsx(X,{"data-slot":"icon",className:"animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),Te&&le&&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&&de(!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 Region"}),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:["'",le.name,"'"]}),"?"]}),le.children&&le.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(Oe,{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 region has ",le.children.length," child region(s). Deleting will also remove all children."]})]})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(E,{color:"muted",outline:!0,onClick:()=>{de(!1),be(null)},disabled:J,children:"Cancel"}),e.jsx(E,{color:"danger",onClick:Et,disabled:J,children:J?e.jsxs(e.Fragment,{children:[e.jsx(X,{"data-slot":"icon",className:"animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{On as default}; diff --git a/frontend/dist/assets/ConfirmModal-N7ejcMF0.js b/frontend/dist/assets/ConfirmModal-DdfUdqSh.js similarity index 50% rename from frontend/dist/assets/ConfirmModal-N7ejcMF0.js rename to frontend/dist/assets/ConfirmModal-DdfUdqSh.js index 6418bc47..a8114e9a 100644 --- a/frontend/dist/assets/ConfirmModal-N7ejcMF0.js +++ b/frontend/dist/assets/ConfirmModal-DdfUdqSh.js @@ -1 +1 @@ -import{r as x,j as s,ax as d,aG as m,bV as g,c as f,ay as C,eD as j,B as o}from"./index-BdFZD4tW.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(d,{open:n,onClose:e,size:"sm",children:[s.jsx(m,{icon:s.jsx(g,{className:f("w-5 h-5",u[a])}),title:r,onClose:e}),s.jsx(C,{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=x.memo(N);export{y as C}; +import{r as d,j as s,aB as x,aL as m,b_ as g,c as C,aC as f,eU as j,B as o}from"./index-Ch85h29t.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-B7pOt7vw.js b/frontend/dist/assets/Contacts-B7pOt7vw.js deleted file mode 100644 index 5413f683..00000000 --- a/frontend/dist/assets/Contacts-B7pOt7vw.js +++ /dev/null @@ -1,23 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-uomeHQBw.js","assets/index-BdFZD4tW.js","assets/BasemapLayer-BQjI_o60.js","assets/consumer-registry-CtGZ8uUk.js","assets/link-scoring-B9O-D6Nl.js","assets/ConfirmModal-N7ejcMF0.js","assets/variants-FYWzMom7.js","assets/git-branch-CjkWLr6F.js","assets/database-CmaQi6im.js","assets/useMapViewStore-Cx-3a39J.js","assets/index-CP2gQEIq.js","assets/index-BmiOWPPt.js","assets/eye-BFnCwXMu.js","assets/max-E5sjxGXN.js","assets/funnel-DYG0Qmvo.js","assets/plus-J10T9_Ph.js","assets/compass-BgtU0bsV.js","assets/zap-CpJxzJYo.js","assets/trash-2-B1G94Z60.js","assets/wifi-off-NXSZOryN.js","assets/wifi-BYutYmlw.js","assets/circle-alert-ChQ9pkTw.js","assets/clock-B5Mz4CYE.js","assets/WorkspaceNav-DR8N-VVk.js","assets/useReplayTick-XUa2wZbr.js","assets/payload-detail--84fg8Ib.js","assets/LightSparkline-C-2jB_F1.js","assets/badge-colors-Dl76Mz8m.js","assets/map-pin-tb6dvUSl.js","assets/wrench-wNCT0Kep.js","assets/layer-Cmi1sSNL.js","assets/node-types-BqQm1p4f.js","assets/easing-t1ilSJHb.js","assets/usePipelineStore-BbC5u-iu.js","assets/ping-BDEGZvTB.js","assets/PageLayout-CIUNh3-q.js","assets/listbox-CXq_NRiz.js","assets/element-movement-BoSGi6nG.js","assets/floating-CZl1NkX5.js","assets/use-text-value-DuhO7-HX.js","assets/frozen-QwMVzSxT.js","assets/TimeRangeStepper-DKEoUoXy.js","assets/MqttModeBadge-B4hQyJL0.js","assets/chat-utils-cUFDkDW9.js","assets/SignalIndicator-CxssCk5q.js","assets/CollisionExplorerModal-CXE65Kgs.js","assets/share-2-KLAGGeDO.js","assets/monitor-smartphone-B-al2jiR.js","assets/circle-question-mark-_koL3DDj.js","assets/map-pin-off-pPPXHu6z.js","assets/activity-BkgN42Nd.js","assets/target-B6gSZQdg.js","assets/search-83w2lV8z.js","assets/index-GZXSFQwe.css","assets/BasemapLayer-B1CfjdFi.css","assets/ContactsMapMapLibre-BwWOEply.css"])))=>i.map(i=>d[i]); -import{e as xe,at as ls,j as e,r as n,_ as ds,cp as Oe,cq as Ie,aq as W,a4 as Ce,cr as ms,cs as me,R as de,c3 as xs,av as ze,a6 as De,ct as us,ae as ps,cu as hs,cv as fs,cw as gs,ad as js,cx as bs,cy as ys,af as Ns,aw as vs,ag as ye,cz as ws,cA as Cs,bG as ks,bF as se,a2 as Ms,I as Ss,bJ as Ps,c as we}from"./index-BdFZD4tW.js";import{useDiscoveredNodes as Rs}from"./usePipelineStore-BbC5u-iu.js";import{h as Ne,p as _s}from"./ping-BDEGZvTB.js";import{c as ke}from"./node-types-BqQm1p4f.js";import{P as Ls,a as Ts,B as $s}from"./PageLayout-CIUNh3-q.js";import{L as Fs,a as le}from"./listbox-CXq_NRiz.js";import{T as Fe}from"./TimeRangeStepper-DKEoUoXy.js";import{M as Es}from"./MqttModeBadge-B4hQyJL0.js";import{u as Hs,e as Os,f as Is,r as zs}from"./consumer-registry-CtGZ8uUk.js";import{e as Ds,g as Bs,a as As}from"./chat-utils-cUFDkDW9.js";import{b as qs}from"./SignalIndicator-CxssCk5q.js";import{C as Vs}from"./CollisionExplorerModal-CXE65Kgs.js";import{E as Us}from"./eye-BFnCwXMu.js";import{S as Ws}from"./share-2-KLAGGeDO.js";import{C as Be}from"./circle-question-mark-_koL3DDj.js";import{M as Gs}from"./map-pin-off-pPPXHu6z.js";import{A as Ae}from"./activity-BkgN42Nd.js";import{T as Qs}from"./target-B6gSZQdg.js";import{T as Js}from"./trash-2-B1G94Z60.js";import{C as Xs}from"./ConfirmModal-N7ejcMF0.js";import{M as Ee}from"./monitor-smartphone-B-al2jiR.js";import{M as Zs}from"./map-pin-tb6dvUSl.js";import{S as Ks}from"./search-83w2lV8z.js";import{C as Ys}from"./clock-B5Mz4CYE.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 et=[["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"}]],st=xe("arrow-up-down",et);/** - * @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 tt=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],at=xe("file-digit",tt);/** - * @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 nt=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],rt=xe("list-filter",nt);/** - * @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 ot=[["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"}]],qe=xe("ruler",ot);class ct 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 it=n.lazy(()=>ds(()=>import("./ContactsMapMapLibre-uomeHQBw.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,49,50,51,52,53,54,55]))),He=()=>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 lt({neighbors:o,localNode:l,localHash:m,onRemoveNode:h,selectedNodeHash:b,onNodeSelected:y,highlightedEdgeKey:d,highlightedGhost:P}){return ls()===!1?e.jsx(He,{}):e.jsx(ct,{children:e.jsx(n.Suspense,{fallback:e.jsx(He,{}),children:e.jsx(it,{neighbors:o,localNode:l,localHash:m,onRemoveNode:h,selectedNodeHash:b,onNodeSelected:y,highlightedEdgeKey:d,highlightedGhost:P})})})}function dt({hash:o,className:l="",size:m="sm",collisionInfo:h,isViterbiResolved:b}){const y=Oe(),d=Ie(),[P,w]=n.useState(!1),R=n.useMemo(()=>W(o),[o]),u=n.useMemo(()=>h!==void 0?h:R?y.find(H=>H.prefix===R)??null:null,[R,y,h]),C=b??(d.totalPaths>0&&d.avgPathConfidence>=.7),A=n.useCallback(H=>{H.preventDefault(),H.stopPropagation(),w(!0)},[]),I=n.useCallback(()=>{w(!1)},[]);if(!u)return null;const z=m==="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",G=C?`Prefix conflict resolved by Viterbi HMM (${(d.avgPathConfidence*100).toFixed(0)}% confidence)`:`Prefix conflict: ${u.candidateCount} nodes share prefix "${R}"`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:A,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:G,"aria-label":`View prefix conflict for ${R}${C?" (Viterbi resolved)":""}`,children:C?e.jsxs("span",{className:"relative",children:[e.jsx(Us,{className:z}),e.jsx(Ce,{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 text-sys-green"})]}):e.jsx(at,{className:z})}),P&&e.jsx(Vs,{isOpen:!0,prefix:u.prefix,candidateHashes:u.candidateHashes,onClose:I})]})}const mt=n.memo(dt),Ve=[{target:"Contacts",fn:"name",minStage:1,when:Os},{target:"Contacts",fn:"traceLinks.directed",minStage:2,when:Is}];zs(Ve);function xt(o){return o<1e3?`${Math.round(o)}m`:`${(o/1e3).toFixed(1)}km`}function ut({hash:o,contact:l,isHub:m,isNeighbor:h,distance:b,centrality:y,neighborSignal:d,collisionInfo:P,isViterbiResolved:w,pingingHash:R,pingResult:u,pingError:C,isMobile:A,metaSummary:I,metaTooltip:z,onRowClick:q,onPing:G,onRemove:H}){Hs(Ve);const T=l.latitude&&l.longitude&&l.latitude!==0&&l.longitude!==0,_=l.node_name||l.name||"Unknown",k=h&&d,ue=ke(l),{isRepeater:O,isCompanion:Q,isRoomServer:N,isClient:J,label:$}=ue,te=h?`${$} — Direct RF contact (zero-hop neighbor)`:`${$} — Flood routing (multi-hop via mesh)`,v=n.useCallback(()=>q(o),[q,o]);return e.jsxs("div",{className:`contacts-grid-row ${m?"bg-sys-amber/5 border-l-2 border-l-sys-amber":""} ${T?"cursor-pointer":""}`,onClick:v,children:[e.jsxs("div",{className:"contacts-col-node flex items-center gap-2 min-w-0",children:[k&&(d==null?void 0:d.avgSnr)!==null?e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 self-center ${ms(d.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(N&&O)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(Ws,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-sys-teal"})]});if(N)return e.jsx(me,{className:"w-5 h-5 text-sys-pink"});if(O)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((Q||J)&&_!=="Unknown"){const{emoji:F,cleanName:ae}=Ds(_);return e.jsx("div",{className:"w-6 h-6 clay-avatar",style:{"--avatar-color":Bs(ae)},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:As(_)})})}return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center bg-zinc-500/20",children:e.jsx(Be,{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:_,children:_}),h&&e.jsx("span",{className:"contact-tag contact-tag--nbr",children:"NBR"}),m&&e.jsx("span",{className:"contact-tag contact-tag--hub",children:"HUB"}),O&&e.jsx("span",{className:"contact-tag contact-tag--rpt",children:"RPT"}),N&&e.jsx("span",{className:"contact-tag contact-tag--room",children:"ROOM"}),Q&&e.jsx("span",{className:"contact-tag contact-tag--comp",children:"COMP"}),J&&e.jsx("span",{className:"contact-tag contact-tag--client",children:"CLIENT"}),A&&e.jsx("span",{className:"contact-tag contact-tag--mobile",children:"MOB"}),!T&&e.jsx(Gs,{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(xs,{copy:!0,size:"compact",truncate:[8,6],children:o}),e.jsx(mt,{hash:o,collisionInfo:P,isViterbiResolved:w}),I&&e.jsx("span",{className:"contact-meta",title:z,children:I})]})]})]}),e.jsxs("div",{className:"contacts-col-signal flex items-center justify-end gap-2",children:[k&&(d==null?void 0:d.avgRssi)!==null&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(qs,{rssi:d.avgRssi,className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Math.round(d.avgRssi)})]}),k&&(d==null?void 0:d.avgSnr)!==null&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[d.avgSnr.toFixed(1)," dB"]})]}),e.jsx("div",{className:"contacts-col-distance flex items-center justify-end gap-1 text-fg-muted",children:b!=null&&e.jsxs(e.Fragment,{children:[e.jsx(qe,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs",children:xt(b)})]})}),e.jsx("div",{className:"contacts-col-centrality flex items-center justify-end gap-1",children:y>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ae,{className:"w-3 h-3 text-sys-indigo"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[(y*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?ze(l.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[h&&e.jsx(e.Fragment,{children:u?e.jsxs("div",{className:`flex items-center gap-1 ${Ne(u)?"text-sys-green":"text-fg-muted"}`,title:`RTT: ${u.rtt_ms.toFixed(0)}ms${Ne(u)?` · SNR: ${u.snr_db.toFixed(1)}dB · RSSI: ${u.rssi}dBm`:""}`,children:[e.jsx(Ce,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs hidden sm:inline",children:Ne(u)?`${u.snr_db.toFixed(1)}dB`:`${(u.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=>G(o,F),disabled:R!==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:R===o?e.jsx(De,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(Qs,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})}),e.jsx("button",{onClick:F=>{F.stopPropagation(),H(o,_)},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(Js,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]})}const pt=n.memo(ut),ht=6371e3,ft=[{field:"lastHeard",icon:Ys,label:"Recent"},{field:"distance",icon:qe,label:"Distance"},{field:"centrality",icon:Ae,label:"Centrality"}];function gt(o){switch(o){case"room_server":return"room";case"repeater":return"repeater";case"companion":return"companion";case"unknown":return"companion"}}function jt(o){const l=ke(o);return gt(l.type)}function ve(o,l){const{color:m="primary",border:h=!1}=l??{};return we("flex items-center gap-1.5 px-2 py-1.5 text-sm radius-inner transition-base",o?m==="success"?"bg-sys-green/20 text-sys-green":"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary hover-bg",h&&(o?m==="success"?"border border-sys-green/30":"border border-sys-blue/30":"border border-transparent"))}function bt(o,l,m,h){const b=(m-o)*Math.PI/180,y=(h-l)*Math.PI/180,d=Math.sin(b/2)*Math.sin(b/2)+Math.cos(o*Math.PI/180)*Math.cos(m*Math.PI/180)*Math.sin(y/2)*Math.sin(y/2),P=2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d));return ht*P}function yt({view:o="combined",title:l="Contacts"}){var Te,$e;const{stats:m}=us(),h=ps(),b=hs(),y=fs(),d=gs(),P=js(),w=bs(),R=ys(),u=Ns(),C=vs(),A=ye[u],I=Oe(),z=Ie(),q=ws(),G=z.totalPaths>0&&z.avgPathConfidence>=.7,H=n.useMemo(()=>{const s=new Map;for(const a of I)s.set(a.prefix,a);return s},[I]),[T,_]=n.useState(null),[k,ue]=n.useState("lastHeard"),[O,Q]=n.useState("desc"),[N,J]=n.useState(""),[$,te]=n.useState(!1),[v,F]=n.useState(new Set),[ae,Me]=n.useState(!1),[Ue,Se]=n.useState(null),[pe,Pe]=n.useState(null),[We,he]=n.useState(new Map),[Ge,X]=n.useState(new Map),[M,Qe]=n.useState(25),[V,ne]=n.useState(25),fe=n.useRef(null),Z=n.useMemo(()=>(m==null?void 0:m.neighbors)??{},[m==null?void 0:m.neighbors]),ge=Rs(),re=n.useMemo(()=>{if(ge.size===0)return Z;const s=new Set;for(const t of Object.keys(Z))s.add((t.startsWith("0x")?t.slice(2):t).toLowerCase());let a=null;for(const[t,r]of ge){const c=(t.startsWith("0x")?t.slice(2):t).toLowerCase();s.has(c)||(a||(a={...Z}),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??Z},[Z,ge]),D=n.useMemo(()=>{const a=Date.now()/1e3-A.minutes*60;return Object.fromEntries(Object.entries(re).filter(([t,r])=>h.has(t)?!1:(r.last_seen??0)>=a))},[re,h,A.minutes]),L=Cs(),B=m==null?void 0:m.local_hash,Je=n.useMemo(()=>{const s=new Map;if(!B||w.size===0)return s;for(const[a,t]of w)if(a.endsWith(`→${B}`)&&t.hops.length>1){const r=a.split("→")[0],c=t.hops[t.hops.length-1];s.set(r,c)}return s},[w,B]),Xe=n.useMemo(()=>{const s=new Map;if(!B||w.size===0)return s;const a=new Map;for(const[t,r]of Object.entries(re)){const c=(t.startsWith("0x")?t.slice(2):t).toLowerCase();a.set(c,r)}for(const[t,r]of w){if(!t.endsWith(`→${B}`)||r.hops.length===0)continue;const c=t.split("→")[0],i=r.hops[0];let f=null;for(const[g,j]of a)if(g.startsWith(i.toLowerCase())){f=j.node_name??j.name??null;break}s.set(c,{prefix:i,name:f,hopCount:r.hopCount})}return s},[w,B,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(D))t.latitude&&t.longitude&&t.latitude!==0&&t.longitude!==0?s.set(a,bt(L.latitude,L.longitude,t.latitude,t.longitude)):s.set(a,null);return s},[D,L]),{neighborHashSet:ce,neighborSignalMap:Ze}=n.useMemo(()=>{const s=new Set,a=new Map;for(const t of P)s.add(t.hash),a.set(t.hash,{avgRssi:t.avgRssi,avgSnr:t.avgSnr});return{neighborHashSet:s,neighborSignalMap:a}},[P]),Re=n.useMemo(()=>{const s=N.toLowerCase().trim(),a=s==="neighbor"||s==="neighbors",t=$||a,r=v.size>0;return Object.fromEntries(Object.entries(D).filter(([c,i])=>{if(r){const j=jt(i);if(!v.has(j))return!1}if(t&&!ce.has(c))return!1;if(a||!s)return!0;const f=(i.node_name||i.name||"").toLowerCase(),g=W(c).toLowerCase();return f.includes(s)||g.includes(s)||c.toLowerCase().includes(s)}))},[D,N,$,ce,v]),p=n.useMemo(()=>{const s=Object.entries(Re),a=N.toLowerCase().trim(),t=/^[0-9a-f]{2}(?:[0-9a-f]{2}){0,2}$/i.test(a);return s.sort(([r,c],[i,f])=>{if(t){const j=W(r).toLowerCase(),E=W(i).toLowerCase(),S=j===a,U=E===a;if(S&&!U)return-1;if(U&&!S)return 1}let g=0;switch(k){case"lastHeard":g=(c.last_seen||0)-(f.last_seen||0);break;case"distance":{const j=oe.get(r)??null,E=oe.get(i)??null;j===null&&E===null?g=0:j===null?g=1:E===null?g=-1:g=j-E;break}case"centrality":{const j=d.get(r)||0,E=d.get(i)||0;g=j-E;break}}return O==="desc"?-g:g})},[Re,k,O,oe,d,N]),x=n.useMemo(()=>{let s=0,a=0,t=0,r=0,c=0;for(const[,i]of p){const f=ke(i),g=i.latitude&&i.longitude&&i.latitude!==0&&i.longitude!==0;switch(f.type){case"room_server":t++;break;case"repeater":a++;break;case"companion":s++;break;case"unknown":c++;break}g&&r++}return{companions:s,repeaters:a,roomServers:t,total:p.length,withLocation:r,unknown:c}},[p]),Ke=n.useMemo(()=>new Set(y),[y]),_e=n.useMemo(()=>M===0?p:p.slice(0,V),[p,V,M]);n.useEffect(()=>{ne(M||p.length)},[k,O,N,$,v,M,p.length]),n.useEffect(()=>{const s=a=>{a.target.closest("[data-dropdown]")||Me(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[]),n.useEffect(()=>{if(M===0)return;const s=new IntersectionObserver(a=>{a[0].isIntersecting&&VMath.min(t+M,p.length))},{threshold:.1,rootMargin:"100px"});return fe.current&&s.observe(fe.current),()=>s.disconnect()},[M,V,p.length]);const Ye=n.useCallback(s=>{Qe(s),ne(s||p.length)},[p.length]),es=n.useCallback(s=>{k===s?Q(a=>a==="desc"?"asc":"desc"):(ue(s),Q("desc"))},[k]),ss=n.useCallback(s=>{const a=D[s];a!=null&&a.latitude&&(a!=null&&a.longitude)&&a.latitude!==0&&a.longitude!==0&&Se(s)},[D]),ts=n.useCallback(()=>{Se(null)},[]),as=n.useCallback((s,a)=>{_({hash:s,name:a})},[]),Le=ks(($e=(Te=m==null?void 0:m.config)==null?void 0:Te.mesh)==null?void 0:$e.path_hash_mode),ns=n.useCallback(async(s,a)=>{if(a.stopPropagation(),!pe){Pe(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,Le)}`,c=await _s(r,30);c.success&&c.data?(he(i=>new Map(i).set(s,c.data)),setTimeout(()=>{he(i=>{const f=new Map(i);return f.delete(s),f})},1e4)):(X(i=>new Map(i).set(s,c.error||"Ping failed")),setTimeout(()=>{X(i=>{const f=new Map(i);return f.delete(s),f})},5e3))}catch(t){const r=t instanceof Error?t.message:"Ping failed";X(c=>new Map(c).set(s,r)),setTimeout(()=>{X(c=>{const i=new Map(c);return i.delete(s),i})},5e3)}finally{Pe(null)}}},[pe,Le]);return e.jsxs(Ls,{children:[e.jsx(Ts,{title:l,icon:e.jsx(se,{}),subtitle:e.jsx(Es,{}),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:`${x.total} discovered node${x.total!==1?"s":""} on the mesh network`,children:[e.jsx(se,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:x.total})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Types:"}),x.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:x.repeaters})]}),x.companions>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Companions",children:[e.jsx(Ee,{className:"w-3.5 h-3.5 text-fg-muted"}),e.jsx("span",{children:x.companions})]}),x.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:x.roomServers})]}),x.withLocation>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"With GPS location",children:[e.jsx(Zs,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{children:x.withLocation})]}),x.unknown>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Unknown type",children:[e.jsx(Be,{className:"w-3.5 h-3.5 text-sys-amber"}),e.jsx("span",{children:x.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(se,{className:"w-3 h-3 text-fg-secondary"}),e.jsx("span",{children:x.total})]}),x.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:x.repeaters})]}),x.companions>0&&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-muted"}),e.jsx("span",{children:x.companions})]}),x.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:x.roomServers})]}),e.jsx(Fe,{ranges:ye,selectedIndex:u,onSelect:C,size:"sm"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(Fe,{ranges:ye,selectedIndex:u,onSelect:C})})]})}),e.jsxs($s,{children:[o!=="list"&&e.jsx(lt,{neighbors:D,localNode:L??void 0,localHash:B,onRemoveNode:b,selectedNodeHash:Ue,onNodeSelected:ts}),o!=="map"&&e.jsxs(Ms,{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(se,{})}),e.jsx("span",{className:"type-micro flex-shrink-0 mr-auto hidden sm:block",children:"Discovered Contacts"}),e.jsx(Ss,{type:"search",size:"sm",value:N,onChange:s=>J(s.target.value),placeholder:"Search...",leadingIcon:e.jsx(Ks,{className:"w-3.5 h-3.5"}),trailingIcon:N?e.jsx("button",{onClick:()=>{J(""),(N.toLowerCase().trim()==="neighbor"||N.toLowerCase().trim()==="neighbors")&&te(!1)},className:"text-fg-muted hover:text-fg-secondary",children:e.jsx(Ps,{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:()=>Me(!ae),className:ve(v.size>0,{border:!0}),title:"Filter by contact type",children:[e.jsx(rt,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Filter"}),v.size>0&&e.jsx("span",{className:"tabular-nums text-xs bg-sys-blue/30 px-1 rounded",children:v.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:()=>{F(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",v.has(s)?"bg-sys-blue border-sys-blue text-white":"border-edge-subtle"),children:v.has(s)&&e.jsx(Ce,{className:"w-3 h-3"})}),e.jsx("span",{className:v.has(s)?"text-fg-primary":"text-fg-secondary",children:a})]},s)),v.size>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-edge-subtle my-1"}),e.jsx("button",{onClick:()=>F(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:()=>te(!$),className:ve($,{color:"success",border:!0}),title:$?"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:[ft.map(({field:s,icon:a,label:t})=>e.jsxs("button",{onClick:()=>es(s),className:ve(k===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}),k===s&&e.jsx(st,{className:we("w-3 h-3",O==="asc"&&"rotate-180")})]},s)),e.jsx("div",{className:"h-4 w-px bg-border-subtle"}),e.jsxs(Fs,{value:M,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"})]})]})]}),p.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=Ke.has(s),c=ce.has(s),i=oe.get(s)??null,f=d.get(s)||0,g=c?Ze.get(s):void 0,j=t?H.get(t)??null:null,E=R.has(s),S=c?null:Xe.get(s)??null,U=Je.get(s)??null,je=q.get(s);let K=null;if(je&&je.length>0){const ie=je.reduce((cs,is)=>cs+is.count,0);ie>0&&(K=ie/24)}const be=a.first_seen?ze(a.first_seen).replace(/ ago$/i,""):null,Y=[],ee=[];if(S){const ie=S.name??S.prefix;Y.push(`→${ie} +${S.hopCount}`),ee.push(`Gateway: ${S.name??S.prefix} (${S.hopCount} hop${S.hopCount!==1?"s":""})`)}U&&(Y.push(`↙${U}`),ee.push(`Last forwarder: ${U}`)),K!==null&&(Y.push(`${K<1?"<1":Math.round(K)}/hr`),ee.push(`Packet rate: ${K.toFixed(1)}/hr`)),be&&(Y.push(be),ee.push(`First seen: ${be} ago`));const rs=Y.join(" · "),os=ee.join(` -`);return e.jsx(pt,{hash:s,contact:a,isHub:r,isNeighbor:c,distance:i,centrality:f,neighborSignal:g,collisionInfo:j,isViterbiResolved:G,pingingHash:pe,pingResult:We.get(s),pingError:Ge.get(s),isMobile:E,metaSummary:rs,metaTooltip:os,onRowClick:ss,onPing:ns,onRemove:as},s)})}),M>0&&V0&&Vne(s=>Math.min(s+M,p.length)),className:"text-sys-blue hover:text-sys-blue/80 transition-base",children:"Load more"})]})]}):e.jsxs("div",{className:"roster-empty",children:[e.jsx(se,{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(Xs,{isOpen:!!T,title:"Remove Contact",message:`Remove ${(T==null?void 0:T.name)||"this contact"} from the contacts list? The node will reappear if it advertises again.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{T&&b(T.hash),_(null)},onCancel:()=>_(null)})]})}const Ut=Object.freeze(Object.defineProperty({__proto__:null,default:yt},Symbol.toStringTag,{value:"Module"}));export{Ut as C,mt as P,qe as R}; diff --git a/frontend/dist/assets/Contacts-BgIs_Jxv.js b/frontend/dist/assets/Contacts-BgIs_Jxv.js new file mode 100644 index 00000000..3dbd3369 --- /dev/null +++ b/frontend/dist/assets/Contacts-BgIs_Jxv.js @@ -0,0 +1,23 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-B7iu4Wrl.js","assets/index-Ch85h29t.js","assets/BasemapLayer-DEvncc0Q.js","assets/consumer-registry-CcmnLgp9.js","assets/link-scoring-CktBMF1N.js","assets/ConfirmModal-DdfUdqSh.js","assets/variants-DSc9sq6e.js","assets/git-branch-B0JLmrv3.js","assets/database-DdztsIWz.js","assets/useMapViewStore-CaKi0BBI.js","assets/index-DT64AA0T.js","assets/index-Ds7D6791.js","assets/eye-CrxD2Rly.js","assets/max-BLfoWvHq.js","assets/funnel-CubiYDNe.js","assets/plus-C7tLXNBe.js","assets/compass-D1WTkLry.js","assets/zap-B2tEMCsA.js","assets/trash-2-D_NWmP0i.js","assets/wifi-off-8456H55-.js","assets/wifi-N54J6ORS.js","assets/circle-alert-BYJOlPMS.js","assets/clock-BDyTFNOi.js","assets/WorkspaceNav-ZTG5UTjF.js","assets/useReplayTick-DnxaulGE.js","assets/payload-detail-CX4NrBt7.js","assets/LightSparkline-D_Ijf43d.js","assets/badge-colors-Dl76Mz8m.js","assets/map-pin-c0Hi1adb.js","assets/wrench-CwAAn8Ca.js","assets/layer-Xsjnvj9G.js","assets/node-types-CUHPebtj.js","assets/easing-CZi_Z9ob.js","assets/usePipelineStore-BfPa6Qak.js","assets/ping-RnwmT7Gq.js","assets/PageLayout-BB80XCAa.js","assets/listbox-BSlt6lH8.js","assets/use-by-comparator-DeUfymOv.js","assets/floating-wXUaY1-5.js","assets/element-movement-CCLCtDhK.js","assets/use-text-value-CQ3ua4o5.js","assets/frozen-DKHgF7-0.js","assets/TimeRangeStepper-DpFgHm1c.js","assets/MqttModeBadge-Bi4reIK5.js","assets/chat-utils-CSGjqJAH.js","assets/SignalIndicator-ouvwsHYL.js","assets/CollisionExplorerModal-BPdmq3zY.js","assets/share-2-xeKwph2s.js","assets/monitor-smartphone-CTx9MPdz.js","assets/circle-question-mark-BCu1neoJ.js","assets/map-pin-off-D_9hye06.js","assets/activity-Uf5hjDsb.js","assets/target-ISEIkLpl.js","assets/search-Dp7kJbPL.js","assets/index-6Dqm8vG_.css","assets/BasemapLayer-B1CfjdFi.css","assets/ContactsMapMapLibre-BwWOEply.css"])))=>i.map(i=>d[i]); +import{e as pe,aw as ls,j as e,r as n,_ as ds,cv as Oe,cw as Ie,at as W,a7 as Me,z as ms,cx as xs,cy as ue,R as xe,c8 as us,cz as ps,ay as ze,cA as hs,a9 as Be,cB as fs,ah as gs,cC as js,cD as bs,cE as ys,ag as Ns,cF as vs,cG as ws,ai as Cs,az as ks,aj as ve,cH as Ms,cI as Ss,bL as Ps,bK as se,a5 as _s,I as Rs,bO as Ls,c as ke}from"./index-Ch85h29t.js";import{useDiscoveredNodes as Ts}from"./usePipelineStore-BfPa6Qak.js";import{h as we,p as $s}from"./ping-RnwmT7Gq.js";import{c as Se}from"./node-types-CUHPebtj.js";import{P as Fs,a as Ds,B as Es}from"./PageLayout-BB80XCAa.js";import{L as Hs,a as me}from"./listbox-BSlt6lH8.js";import{T as De}from"./TimeRangeStepper-DpFgHm1c.js";import{M as Os}from"./MqttModeBadge-Bi4reIK5.js";import{u as Is,e as zs,f as Bs,r as As}from"./consumer-registry-CcmnLgp9.js";import{e as Vs,g as qs,a as Us}from"./chat-utils-CSGjqJAH.js";import{b as Ws}from"./SignalIndicator-ouvwsHYL.js";import{C as Gs}from"./CollisionExplorerModal-BPdmq3zY.js";import{E as Qs}from"./eye-CrxD2Rly.js";import{S as Ks}from"./share-2-xeKwph2s.js";import{C as Ae}from"./circle-question-mark-BCu1neoJ.js";import{M as Xs}from"./map-pin-off-D_9hye06.js";import{A as Ve}from"./activity-Uf5hjDsb.js";import{T as Zs}from"./target-ISEIkLpl.js";import{T as Js}from"./trash-2-D_NWmP0i.js";import{C as Ys}from"./ConfirmModal-DdfUdqSh.js";import{M as Ee}from"./monitor-smartphone-CTx9MPdz.js";import{M as et}from"./map-pin-c0Hi1adb.js";import{S as st}from"./search-Dp7kJbPL.js";import{C as tt}from"./clock-BDyTFNOi.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 at=[["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"}]],nt=pe("arrow-up-down",at);/** + * @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 rt=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],ot=pe("file-digit",rt);/** + * @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 ct=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],it=pe("list-filter",ct);/** + * @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 lt=[["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"}]],qe=pe("ruler",lt);class dt extends n.Component{constructor(o){super(o),this.state={hasError:!1}}static getDerivedStateFromError(o){return{hasError:!0,error:o}}render(){var o;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:((o=this.state.error)==null?void 0:o.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 mt=n.lazy(()=>ds(()=>import("./ContactsMapMapLibre-B7iu4Wrl.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,49,50,51,52,53,54,55,56]))),He=()=>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 xt({neighbors:d,localNode:o,localHash:m,onRemoveNode:h,selectedNodeHash:N,onNodeSelected:v,highlightedEdgeKey:l,highlightedGhost:P}){return ls()===!1?e.jsx(He,{}):e.jsx(dt,{children:e.jsx(n.Suspense,{fallback:e.jsx(He,{}),children:e.jsx(mt,{neighbors:d,localNode:o,localHash:m,onRemoveNode:h,selectedNodeHash:N,onNodeSelected:v,highlightedEdgeKey:l,highlightedGhost:P})})})}function ut({hash:d,className:o="",size:m="sm",collisionInfo:h,isViterbiResolved:N}){const v=Oe(),l=Ie(),[P,C]=n.useState(!1),_=n.useMemo(()=>W(d),[d]),u=n.useMemo(()=>h!==void 0?h:_?v.find(D=>D.prefix===_)??null:null,[_,v,h]),k=N??(l.totalPaths>0&&l.avgPathConfidence>=.7),B=n.useCallback(D=>{D.preventDefault(),D.stopPropagation(),C(!0)},[]),H=n.useCallback(()=>{C(!1)},[]);if(!u)return null;const O=m==="sm"?"w-3.5 h-3.5":"w-4 h-4",A=k?"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",G=k?`Prefix conflict resolved by Viterbi HMM (${(l.avgPathConfidence*100).toFixed(0)}% confidence)`:`Prefix conflict: ${u.candidateCount} nodes share prefix "${_}"`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:B,className:`inline-flex items-center justify-center p-0.5 rounded focus:outline-none focus:ring-2 transition-colors cursor-pointer touch-manipulation ${A} ${o}`,title:G,"aria-label":`View prefix conflict for ${_}${k?" (Viterbi resolved)":""}`,children:k?e.jsxs("span",{className:"relative",children:[e.jsx(Qs,{className:O}),e.jsx(Me,{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 text-sys-green"})]}):e.jsx(ot,{className:O})}),P&&e.jsx(Gs,{isOpen:!0,prefix:u.prefix,candidateHashes:u.candidateHashes,onClose:H})]})}const pt=n.memo(ut),Ue=[{target:"Contacts",fn:"name",minStage:1,when:zs},{target:"Contacts",fn:"traceLinks.directed",minStage:2,when:Bs}];As(Ue);function ht({hash:d,contact:o,isHub:m,isNeighbor:h,distance:N,centrality:v,neighborSignal:l,collisionInfo:P,isViterbiResolved:C,pingingHash:_,pingResult:u,pingError:k,isMobile:B,metaSummary:H,metaTooltip:O,onRowClick:A,onPing:G,onRemove:D}){Is(Ue);const T=ms(),V=o.latitude&&o.longitude&&o.latitude!==0&&o.longitude!==0,j=o.node_name||o.name||"Unknown",te=o.last_seen?new Date(o.last_seen*1e3):null,E=h&&l,ae=Se(o),{isRepeater:w,isCompanion:Q,isRoomServer:R,isClient:K,label:b}=ae,ne=h?`${b} — Direct RF contact (zero-hop neighbor)`:`${b} — Flood routing (multi-hop via mesh)`,re=n.useCallback(()=>A(d),[A,d]);return e.jsxs("div",{className:`contacts-grid-row ${m?"bg-sys-amber/5 border-l-2 border-l-sys-amber":""} ${V?"cursor-pointer":""}`,onClick:re,children:[e.jsxs("div",{className:"contacts-col-node flex items-center gap-2 min-w-0",children:[E&&(l==null?void 0:l.avgSnr)!==null?e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 self-center ${xs(l.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:ne,children:(()=>{if(R&&w)return e.jsxs("div",{className:"relative w-5 h-5",children:[e.jsx(ue,{className:"w-5 h-5 absolute inset-0 text-sys-pink"}),e.jsx(Ks,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-sys-teal"})]});if(R)return e.jsx(ue,{className:"w-5 h-5 text-sys-pink"});if(w)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(xe,{className:"w-3.5 h-3.5 text-sys-blue"})});if((Q||K)&&j!=="Unknown"){const{emoji:$,cleanName:he}=Vs(j);return e.jsx("div",{className:"w-6 h-6 clay-avatar",style:{"--avatar-color":qs(he)},children:$?e.jsx("span",{className:"text-sm leading-none",children:$}):e.jsx("span",{className:"text-white text-[9px] font-bold tracking-tighter",children:Us(j)})})}return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center bg-zinc-500/20",children:e.jsx(Ae,{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:j,children:j}),h&&e.jsx("span",{className:"contact-tag contact-tag--nbr",children:"NBR"}),m&&e.jsx("span",{className:"contact-tag contact-tag--hub",children:"HUB"}),w&&e.jsx("span",{className:"contact-tag contact-tag--rpt",children:"RPT"}),R&&e.jsx("span",{className:"contact-tag contact-tag--room",children:"ROOM"}),Q&&e.jsx("span",{className:"contact-tag contact-tag--comp",children:"COMP"}),K&&e.jsx("span",{className:"contact-tag contact-tag--client",children:"CLIENT"}),B&&e.jsx("span",{className:"contact-tag contact-tag--mobile",children:"MOB"}),!V&&e.jsx(Xs,{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(us,{copy:!0,size:"compact",truncate:[8,6],children:d}),e.jsx(pt,{hash:d,collisionInfo:P,isViterbiResolved:C}),H&&e.jsx("span",{className:"contact-meta",title:O,children:H})]})]})]}),e.jsxs("div",{className:"contacts-col-signal flex items-center justify-end gap-2",children:[E&&(l==null?void 0:l.avgRssi)!==null&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ws,{rssi:l.avgRssi,className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Math.round(l.avgRssi)})]}),E&&(l==null?void 0:l.avgSnr)!==null&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[l.avgSnr.toFixed(1)," dB"]})]}),e.jsx("div",{className:"contacts-col-distance flex items-center justify-end gap-1 text-fg-muted",children:N!=null&&e.jsxs(e.Fragment,{children:[e.jsx(qe,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs",children:ps(N,T,{compact:!0})})]})}),e.jsx("div",{className:"contacts-col-centrality flex items-center justify-end gap-1",children:v>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"w-3 h-3 text-sys-indigo"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[(v*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",title:te?`Last seen: ${hs(te,T,!1)}`:void 0,children:o.last_seen?ze(o.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[h&&e.jsx(e.Fragment,{children:u?e.jsxs("div",{className:`flex items-center gap-1 ${we(u)?"text-sys-green":"text-fg-muted"}`,title:`RTT: ${u.rtt_ms.toFixed(0)}ms${we(u)?` · SNR: ${u.snr_db.toFixed(1)}dB · RSSI: ${u.rssi}dBm`:""}`,children:[e.jsx(Me,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs hidden sm:inline",children:we(u)?`${u.snr_db.toFixed(1)}dB`:`${(u.rtt_ms/1e3).toFixed(1)}s`})]}):k?e.jsxs("span",{className:"text-sys-red text-xs font-medium",title:k,children:[e.jsx("span",{className:"hidden sm:inline",children:k}),e.jsx("span",{className:"sm:hidden",children:"✗"})]}):e.jsx("button",{onClick:$=>G(d,$),disabled:_!==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:_===d?e.jsx(Be,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(Zs,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})}),e.jsx("button",{onClick:$=>{$.stopPropagation(),D(d,j)},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(Js,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]})}const ft=n.memo(ht),gt=6371e3,jt=[{field:"lastHeard",icon:tt,label:"Recent"},{field:"distance",icon:qe,label:"Distance"},{field:"centrality",icon:Ve,label:"Centrality"}];function bt(d){switch(d){case"room_server":return"room";case"repeater":return"repeater";case"companion":return"companion";case"unknown":return"companion"}}function yt(d){const o=Se(d);return bt(o.type)}function Ce(d,o){const{color:m="primary",border:h=!1}=o??{};return ke("flex items-center gap-1.5 px-2 py-1.5 text-sm radius-inner transition-base",d?m==="success"?"bg-sys-green/20 text-sys-green":"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary hover-bg",h&&(d?m==="success"?"border border-sys-green/30":"border border-sys-blue/30":"border border-transparent"))}function Nt(d,o,m,h){const N=(m-d)*Math.PI/180,v=(h-o)*Math.PI/180,l=Math.sin(N/2)*Math.sin(N/2)+Math.cos(d*Math.PI/180)*Math.cos(m*Math.PI/180)*Math.sin(v/2)*Math.sin(v/2),P=2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l));return gt*P}function vt({view:d="combined",title:o="Contacts"}){var $e,Fe;const{stats:m}=fs(),h=gs(),N=js(),v=bs(),l=ys(),P=Ns(),C=vs(),_=ws(),u=Cs(),k=ks(),B=ve[u],H=Oe(),O=Ie(),A=Ms(),G=O.totalPaths>0&&O.avgPathConfidence>=.7,D=n.useMemo(()=>{const s=new Map;for(const a of H)s.set(a.prefix,a);return s},[H]),[T,V]=n.useState(null),[j,te]=n.useState("lastHeard"),[E,ae]=n.useState("desc"),[w,Q]=n.useState(""),[R,K]=n.useState(!1),[b,ne]=n.useState(new Set),[re,$]=n.useState(!1),[he,Pe]=n.useState(null),[fe,_e]=n.useState(null),[We,ge]=n.useState(new Map),[Ge,X]=n.useState(new Map),[M,Qe]=n.useState(25),[q,oe]=n.useState(25),je=n.useRef(null),Z=n.useMemo(()=>(m==null?void 0:m.neighbors)??{},[m==null?void 0:m.neighbors]),be=Ts(),ce=n.useMemo(()=>{if(be.size===0)return Z;const s=new Set;for(const t of Object.keys(Z))s.add((t.startsWith("0x")?t.slice(2):t).toLowerCase());let a=null;for(const[t,r]of be){const c=(t.startsWith("0x")?t.slice(2):t).toLowerCase();s.has(c)||(a||(a={...Z}),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??Z},[Z,be]),I=n.useMemo(()=>{const a=Date.now()/1e3-B.minutes*60;return Object.fromEntries(Object.entries(ce).filter(([t,r])=>h.has(t)?!1:(r.last_seen??0)>=a))},[ce,h,B.minutes]),L=Ss(),z=m==null?void 0:m.local_hash,Ke=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],c=t.hops[t.hops.length-1];s.set(r,c)}return s},[C,z]),Xe=n.useMemo(()=>{const s=new Map;if(!z||C.size===0)return s;const a=new Map;for(const[t,r]of Object.entries(ce)){const c=(t.startsWith("0x")?t.slice(2):t).toLowerCase();a.set(c,r)}for(const[t,r]of C){if(!t.endsWith(`→${z}`)||r.hops.length===0)continue;const c=t.split("→")[0],i=r.hops[0];let f=null;for(const[g,y]of a)if(g.startsWith(i.toLowerCase())){f=y.node_name??y.name??null;break}s.set(c,{prefix:i,name:f,hopCount:r.hopCount})}return s},[C,z,ce]),ie=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,Nt(L.latitude,L.longitude,t.latitude,t.longitude)):s.set(a,null);return s},[I,L]),{neighborHashSet:le,neighborSignalMap:Ze}=n.useMemo(()=>{const s=new Set,a=new Map;for(const t of P)s.add(t.hash),a.set(t.hash,{avgRssi:t.avgRssi,avgSnr:t.avgSnr});return{neighborHashSet:s,neighborSignalMap:a}},[P]),Re=n.useMemo(()=>{const s=w.toLowerCase().trim(),a=s==="neighbor"||s==="neighbors",t=R||a,r=b.size>0;return Object.fromEntries(Object.entries(I).filter(([c,i])=>{if(r){const y=yt(i);if(!b.has(y))return!1}if(t&&!le.has(c))return!1;if(a||!s)return!0;const f=(i.node_name||i.name||"").toLowerCase(),g=W(c).toLowerCase();return f.includes(s)||g.includes(s)||c.toLowerCase().includes(s)}))},[I,w,R,le,b]),p=n.useMemo(()=>{const s=Object.entries(Re),a=w.toLowerCase().trim(),t=/^[0-9a-f]{2}(?:[0-9a-f]{2}){0,2}$/i.test(a);return s.sort(([r,c],[i,f])=>{if(t){const y=W(r).toLowerCase(),F=W(i).toLowerCase(),S=y===a,U=F===a;if(S&&!U)return-1;if(U&&!S)return 1}let g=0;switch(j){case"lastHeard":g=(c.last_seen||0)-(f.last_seen||0);break;case"distance":{const y=ie.get(r)??null,F=ie.get(i)??null;y===null&&F===null?g=0:y===null?g=1:F===null?g=-1:g=y-F;break}case"centrality":{const y=l.get(r)||0,F=l.get(i)||0;g=y-F;break}}return E==="desc"?-g:g})},[Re,j,E,ie,l,w]),x=n.useMemo(()=>{let s=0,a=0,t=0,r=0,c=0;for(const[,i]of p){const f=Se(i),g=i.latitude&&i.longitude&&i.latitude!==0&&i.longitude!==0;switch(f.type){case"room_server":t++;break;case"repeater":a++;break;case"companion":s++;break;case"unknown":c++;break}g&&r++}return{companions:s,repeaters:a,roomServers:t,total:p.length,withLocation:r,unknown:c}},[p]),Je=n.useMemo(()=>new Set(v),[v]),Le=n.useMemo(()=>M===0?p:p.slice(0,q),[p,q,M]);n.useEffect(()=>{oe(M||p.length)},[j,E,w,R,b,M,p.length]),n.useEffect(()=>{const s=a=>{a.target.closest("[data-dropdown]")||$(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[]),n.useEffect(()=>{if(M===0)return;const s=new IntersectionObserver(a=>{a[0].isIntersecting&&qMath.min(t+M,p.length))},{threshold:.1,rootMargin:"100px"});return je.current&&s.observe(je.current),()=>s.disconnect()},[M,q,p.length]);const Ye=n.useCallback(s=>{Qe(s),oe(s||p.length)},[p.length]),es=n.useCallback(s=>{j===s?ae(a=>a==="desc"?"asc":"desc"):(te(s),ae("desc"))},[j]),ss=n.useCallback(s=>{const a=I[s];a!=null&&a.latitude&&(a!=null&&a.longitude)&&a.latitude!==0&&a.longitude!==0&&Pe(s)},[I]),ts=n.useCallback(()=>{Pe(null)},[]),as=n.useCallback((s,a)=>{V({hash:s,name:a})},[]),Te=Ps((Fe=($e=m==null?void 0:m.config)==null?void 0:$e.mesh)==null?void 0:Fe.path_hash_mode),ns=n.useCallback(async(s,a)=>{if(a.stopPropagation(),!fe){_e(s),ge(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,Te)}`,c=await $s(r,30);c.success&&c.data?(ge(i=>new Map(i).set(s,c.data)),setTimeout(()=>{ge(i=>{const f=new Map(i);return f.delete(s),f})},1e4)):(X(i=>new Map(i).set(s,c.error||"Ping failed")),setTimeout(()=>{X(i=>{const f=new Map(i);return f.delete(s),f})},5e3))}catch(t){const r=t instanceof Error?t.message:"Ping failed";X(c=>new Map(c).set(s,r)),setTimeout(()=>{X(c=>{const i=new Map(c);return i.delete(s),i})},5e3)}finally{_e(null)}}},[fe,Te]);return e.jsxs(Fs,{children:[e.jsx(Ds,{title:o,icon:e.jsx(se,{}),subtitle:e.jsx(Os,{}),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:`${x.total} discovered node${x.total!==1?"s":""} on the mesh network`,children:[e.jsx(se,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:x.total})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Types:"}),x.repeaters>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Repeaters",children:[e.jsx(xe,{className:"w-3.5 h-3.5 text-sys-blue"}),e.jsx("span",{children:x.repeaters})]}),x.companions>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Companions",children:[e.jsx(Ee,{className:"w-3.5 h-3.5 text-fg-muted"}),e.jsx("span",{children:x.companions})]}),x.roomServers>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Room Servers",children:[e.jsx(ue,{className:"w-3.5 h-3.5 text-sys-pink"}),e.jsx("span",{children:x.roomServers})]}),x.withLocation>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"With GPS location",children:[e.jsx(et,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{children:x.withLocation})]}),x.unknown>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Unknown type",children:[e.jsx(Ae,{className:"w-3.5 h-3.5 text-sys-amber"}),e.jsx("span",{children:x.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(se,{className:"w-3 h-3 text-fg-secondary"}),e.jsx("span",{children:x.total})]}),x.repeaters>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(xe,{className:"w-3 h-3 text-sys-blue"}),e.jsx("span",{children:x.repeaters})]}),x.companions>0&&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-muted"}),e.jsx("span",{children:x.companions})]}),x.roomServers>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(ue,{className:"w-3 h-3 text-sys-pink"}),e.jsx("span",{children:x.roomServers})]}),e.jsx(De,{ranges:ve,selectedIndex:u,onSelect:k,size:"sm"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(De,{ranges:ve,selectedIndex:u,onSelect:k})})]})}),e.jsxs(Es,{children:[d!=="list"&&e.jsx(xt,{neighbors:I,localNode:L??void 0,localHash:z,onRemoveNode:N,selectedNodeHash:he,onNodeSelected:ts}),d!=="map"&&e.jsxs(_s,{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(se,{})}),e.jsx("span",{className:"type-micro flex-shrink-0 mr-auto hidden sm:block",children:"Discovered Contacts"}),e.jsx(Rs,{type:"search",size:"sm",value:w,onChange:s=>Q(s.target.value),placeholder:"Search...",leadingIcon:e.jsx(st,{className:"w-3.5 h-3.5"}),trailingIcon:w?e.jsx("button",{onClick:()=>{Q(""),(w.toLowerCase().trim()==="neighbor"||w.toLowerCase().trim()==="neighbors")&&K(!1)},className:"text-fg-muted hover:text-fg-secondary",children:e.jsx(Ls,{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:()=>$(!re),className:Ce(b.size>0,{border:!0}),title:"Filter by contact type",children:[e.jsx(it,{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})]}),re&&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:()=>{ne(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:ke("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(Me,{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:()=>ne(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"})]})]})]}),le.size>0&&e.jsxs("button",{onClick:()=>K(!R),className:Ce(R,{color:"success",border:!0}),title:R?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(xe,{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:[jt.map(({field:s,icon:a,label:t})=>e.jsxs("button",{onClick:()=>es(s),className:Ce(j===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}),j===s&&e.jsx(nt,{className:ke("w-3 h-3",E==="asc"&&"rotate-180")})]},s)),e.jsx("div",{className:"h-4 w-px bg-border-subtle"}),e.jsxs(Hs,{value:M,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(me,{value:25,children:"25"}),e.jsx(me,{value:50,children:"50"}),e.jsx(me,{value:100,children:"100"}),e.jsx(me,{value:0,children:"All"})]})]})]}),p.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:Le.map(([s,a])=>{const t=W(s),r=Je.has(s),c=le.has(s),i=ie.get(s)??null,f=l.get(s)||0,g=c?Ze.get(s):void 0,y=t?D.get(t)??null:null,F=_.has(s),S=c?null:Xe.get(s)??null,U=Ke.get(s)??null,ye=A.get(s);let J=null;if(ye&&ye.length>0){const de=ye.reduce((cs,is)=>cs+is.count,0);de>0&&(J=de/24)}const Ne=a.first_seen?ze(a.first_seen).replace(/ ago$/i,""):null,Y=[],ee=[];if(S){const de=S.name??S.prefix;Y.push(`→${de} +${S.hopCount}`),ee.push(`Gateway: ${S.name??S.prefix} (${S.hopCount} hop${S.hopCount!==1?"s":""})`)}U&&(Y.push(`↙${U}`),ee.push(`Last forwarder: ${U}`)),J!==null&&(Y.push(`${J<1?"<1":Math.round(J)}/hr`),ee.push(`Packet rate: ${J.toFixed(1)}/hr`)),Ne&&(Y.push(Ne),ee.push(`First seen: ${Ne} ago`));const rs=Y.join(" · "),os=ee.join(` +`);return e.jsx(ft,{hash:s,contact:a,isHub:r,isNeighbor:c,distance:i,centrality:f,neighborSignal:g,collisionInfo:y,isViterbiResolved:G,pingingHash:fe,pingResult:We.get(s),pingError:Ge.get(s),isMobile:F,metaSummary:rs,metaTooltip:os,onRowClick:ss,onPing:ns,onRemove:as},s)})}),M>0&&q0&&qoe(s=>Math.min(s+M,p.length)),className:"text-sys-blue hover:text-sys-blue/80 transition-base",children:"Load more"})]})]}):e.jsxs("div",{className:"roster-empty",children:[e.jsx(se,{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(Ys,{isOpen:!!T,title:"Remove Contact",message:`Remove ${(T==null?void 0:T.name)||"this contact"} from the contacts list? The node will reappear if it advertises again.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{T&&N(T.hash),V(null)},onCancel:()=>V(null)})]})}const Gt=Object.freeze(Object.defineProperty({__proto__:null,default:vt},Symbol.toStringTag,{value:"Module"}));export{Gt as C,pt as P,qe as R}; diff --git a/frontend/dist/assets/ContactsMapMapLibre-B7iu4Wrl.js b/frontend/dist/assets/ContactsMapMapLibre-B7iu4Wrl.js new file mode 100644 index 00000000..e2d76ff5 --- /dev/null +++ b/frontend/dist/assets/ContactsMapMapLibre-B7iu4Wrl.js @@ -0,0 +1,120 @@ +import{e as nn,as as ka,r as R,hl as Ca,cB as Ea,dH as Sa,dI as Ma,j as m,aB as So,dJ as Ba,aC as Mo,m as tr,a7 as Yn,aD as Bo,c as Cn,a9 as J0,Y as cr,Z as vn,hm as X0,hn as Do,ho as Da,co as _a,cw as ja,cy as Ta,dD as _o,au as jo,aE as To,d as Dr,b as En,B as Qt,cr as gs,H as Vs,S as Ws,dP as Ro,w as Io,d4 as Lo,R as No,bO as Sn,hp as Ra,z as Kn,N as Ia,cz as Fo,bK as vi,hq as Po,$ as La,ad as Na,dX as Fa,hr as Pa,ay as Qo,cq as bi,bS as Qa,a8 as As,aa as es,ct as Oa,bb as za,fc as Oo,hs as Ha,ht as Ga,dY as Ua,dG as Va,hu as Wa,hv as Ya,aT as zo,a2 as wt,cL as Ho,cA as Ka,gN as Za,hw as $a,hx as qa,hy as Go,gW as Ja,at as _r,bY as Uo,dO as Xa,hz as Vo,hA as Wo,cf as Au,hj as eu,ci as tu,dM as Yo,dQ as ru,ag as nu,hB as su,fo as iu,hC as ys,gm as ou,fW as lu,dC as au}from"./index-Ch85h29t.js";import{u as Gr,M as uu,S as cu,B as fu}from"./BasemapLayer-DEvncc0Q.js";import{u as Ko,r as Zo,e as ki,f as Ci,g as hu}from"./consumer-registry-CcmnLgp9.js";import{L as W0,c as du}from"./link-scoring-CktBMF1N.js";import{C as mu}from"./ConfirmModal-DdfUdqSh.js";import{s as pu,a as gu,M as yu}from"./variants-DSc9sq6e.js";import{G as Ds}from"./git-branch-B0JLmrv3.js";import{D as xu}from"./database-DdztsIWz.js";import{H as wu,A as x0,D as Ei,u as mn}from"./useMapViewStore-CaKi0BBI.js";import{E as $o}from"./eye-CrxD2Rly.js";import{b as vu,e as bu,a as qo,m as Si,W as ku,E as Cu,u as Eu,G as Su,g as Mu,d as Bu,f as Du}from"./max-BLfoWvHq.js";import{F as _u}from"./funnel-CubiYDNe.js";import{P as ju}from"./plus-C7tLXNBe.js";import{C as Tu}from"./compass-D1WTkLry.js";import{Z as Ru}from"./zap-B2tEMCsA.js";import{T as Iu}from"./trash-2-D_NWmP0i.js";import{W as Lu}from"./wifi-off-8456H55-.js";import{W as Nu}from"./wifi-N54J6ORS.js";import{C as Fu}from"./circle-alert-BYJOlPMS.js";import{C as Jo}from"./clock-BDyTFNOi.js";import{C as Pu}from"./WorkspaceNav-ZTG5UTjF.js";import{u as Ys,a as Xo,b as Al,c as Qu,d as Ou,e as Ks,f as Mi,R as zu,g as Hu,h as el,t as Gu,i as Uu,j as Vu,k as Wu}from"./useReplayTick-DnxaulGE.js";import{L as Yu}from"./LightSparkline-D_Ijf43d.js";import{P as tl,R as Ku}from"./Contacts-BgIs_Jxv.js";import{H as Z0,C as fr,N as Zu,a as $u}from"./badge-colors-Dl76Mz8m.js";import{M as qu}from"./map-pin-c0Hi1adb.js";import{W as Ju}from"./wrench-CwAAn8Ca.js";import{S as Hr,L as er}from"./layer-Xsjnvj9G.js";import{c as Bi}from"./node-types-CUHPebtj.js";import{a as rl,b as _s,c as Xu}from"./easing-CZi_Z9ob.js";import"./index-DT64AA0T.js";import"./index-Ds7D6791.js";import"./payload-detail-CX4NrBt7.js";import"./usePipelineStore-BfPa6Qak.js";import"./ping-RnwmT7Gq.js";import"./PageLayout-BB80XCAa.js";import"./listbox-BSlt6lH8.js";import"./use-by-comparator-DeUfymOv.js";import"./floating-wXUaY1-5.js";import"./element-movement-CCLCtDhK.js";import"./use-text-value-CQ3ua4o5.js";import"./frozen-DKHgF7-0.js";import"./TimeRangeStepper-DpFgHm1c.js";import"./MqttModeBadge-Bi4reIK5.js";import"./chat-utils-CSGjqJAH.js";import"./SignalIndicator-ouvwsHYL.js";import"./CollisionExplorerModal-BPdmq3zY.js";import"./share-2-xeKwph2s.js";import"./monitor-smartphone-CTx9MPdz.js";import"./circle-question-mark-BCu1neoJ.js";import"./map-pin-off-D_9hye06.js";import"./activity-Uf5hjDsb.js";import"./target-ISEIkLpl.js";import"./search-Dp7kJbPL.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 Ac=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],js=nn("boxes",Ac);/** + * @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 ec=[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]],nl=nn("ghost",ec);/** + * @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 tc=[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]],rc=nn("mountain",tc);/** + * @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 nc=[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]],sc=nn("navigation",nc);/** + * @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 ic=[["path",{d:"M6 8.32a7.43 7.43 0 0 1 0 7.36",key:"9iaqei"}],["path",{d:"M9.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"1yha7l"}],["path",{d:"M12.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"4iu2gk"}],["path",{d:"M16.37 2a20.16 20.16 0 0 1 0 20",key:"sap9u2"}]],sl=nn("nfc",ic);/** + * @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 oc=[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]],lc=nn("sigma",oc);/** + * @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 ac=[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]],uc=nn("swords",ac);/** + * @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 cc=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],fc=nn("trending-down",cc);function hc(a,c){return c.filter(x=>x.nodes.includes(a)).sort((x,y)=>y.avgCertainCount-x.avgCertainCount)}function dc(a,c,g){const x=hc(a,c),y=new Set,b=[];for(const D of x)for(const P of D.edgeKeys)if(!y.has(P)){y.add(P);const B=g.get(P);b.push({key:P,certainCount:(B==null?void 0:B.certainCount)??0})}return b.sort((D,P)=>P.certainCount-D.certainCount),{loops:x,highlightedEdgeKeys:y,sortedEdges:b}}function mc(a){const c=new Map;for(const g of a)for(const x of g.edgeKeys){const y=c.get(x)??[];y.push(g),c.set(x,y)}return c}const j0={MAX_THICKNESS_AT:300,MIN_VALIDATIONS:5},pc=6,Di=1;function Ts(a,c){const g=Math.max(j0.MIN_VALIDATIONS,Math.min(a,j0.MAX_THICKNESS_AT)),x=Math.log(j0.MIN_VALIDATIONS),y=Math.log(j0.MAX_THICKNESS_AT),D=(Math.log(g)-x)/(y-x);return Di+(pc-Di)*D}const gc=yc(xc);function yc(a){return function(c,g,x=g){if(!((g=+g)>=0))throw new RangeError("invalid rx");if(!((x=+x)>=0))throw new RangeError("invalid ry");let{data:y,width:b,height:D}=c;if(!((b=Math.floor(b))>=0))throw new RangeError("invalid width");if(!((D=Math.floor(D!==void 0?D:y.length/b))>=0))throw new RangeError("invalid height");if(!b||!D||!g&&!x)return c;const P=g&&a(g),B=x&&a(x),E=y.slice();return P&&B?(Qn(P,E,y,b,D),Qn(P,y,E,b,D),Qn(P,E,y,b,D),On(B,y,E,b,D),On(B,E,y,b,D),On(B,y,E,b,D)):P?(Qn(P,y,E,b,D),Qn(P,E,y,b,D),Qn(P,y,E,b,D)):B&&(On(B,y,E,b,D),On(B,E,y,b,D),On(B,y,E,b,D)),c}}function Qn(a,c,g,x,y){for(let b=0,D=x*y;b{if(!((P-=B)>=D))return;let E=c*b[D];const T=B*c,Q=T+B;for(let z=D,U=D+T;z{if(!((b-=D)>=y))return;let P=a*x[y];const B=D*a;for(let E=y,T=y+B;E=x&&++g;return g}function bc(a,c,g){let x;for(;;){const y=vu(a,c,g);if(y===x||y===0||!isFinite(y))return[a,c];y>0?(a=Math.floor(a/y)*y,c=Math.ceil(c/y)*y):y<0&&(a=Math.ceil(a*y)/y,c=Math.floor(c*y)/y),x=y}}function kc(a){return Math.max(1,Math.ceil(Math.log(vc(a))/Math.LN2)+1)}var Cc=Array.prototype,il=Cc.slice;function Ec(a,c){return a-c}function Sc(a){for(var c=0,g=a.length,x=a[g-1][1]*a[0][0]-a[g-1][0]*a[0][1];++c()=>a;function Mc(a,c){for(var g=-1,x=c.length,y;++gx!=U>x&&g<(z-E)*(x-T)/(U-T)+E&&(y=-y)}return y}function Dc(a,c,g){var x;return _c(a,c,g)&&jc(a[x=+(a[0]===c[0])],g[x],c[x])}function _c(a,c,g){return(c[0]-a[0])*(g[1]-a[1])===(g[0]-a[0])*(c[1]-a[1])}function jc(a,c,g){return a<=c&&c<=g||g<=c&&c<=a}function Tc(){}var zr=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function _i(){var a=1,c=1,g=kc,x=B;function y(E){var T=g(E);if(Array.isArray(T))T=T.slice().sort(Ec);else{const Q=bu(E,Rc);for(T=qo(...bc(Q[0],Q[1],T),T);T[T.length-1]>=Q[1];)T.pop();for(;T[1]b(E,Q))}function b(E,T){const Q=T==null?NaN:+T;if(isNaN(Q))throw new Error(`invalid value: ${T}`);var z=[],U=[];return D(E,Q,function(W){x(W,E,Q),Sc(W)>0?z.push([W]):U.push(W)}),U.forEach(function(W){for(var $=0,sA=z.length,AA;$=T,zr[J<<2].forEach(uA);++W0&&U0&&W=0&&Q>=0))throw new Error("invalid size");return a=T,c=Q,y},y.thresholds=function(E){return arguments.length?(g=typeof E=="function"?E:Array.isArray(E)?rn(il.call(E)):rn(E),y):g},y.smooth=function(E){return arguments.length?(x=E?B:Tc,y):x===B},y}function Rc(a){return isFinite(a)?a:NaN}function pn(a,c){return a==null?!1:+a>=c}function xs(a){return a==null||isNaN(a=+a)?-1/0:a}function ji(a,c,g,x){const y=x-c,b=g-c,D=isFinite(y)||isFinite(b)?y/b:Math.sign(y)/Math.sign(b);return isNaN(D)?a:a+D-.5}function Ic(a){return a[0]}function Lc(a){return a[1]}function Nc(){return 1}function Fc(){var a=Ic,c=Lc,g=Nc,x=960,y=500,b=20,D=2,P=b*3,B=x+P*2>>D,E=y+P*2>>D,T=rn(20);function Q(J){var fA=new Float32Array(B*E),uA=Math.pow(2,-D),TA=-1;for(const kA of J){var lA=(a(kA,++TA,J)+P)*uA,iA=(c(kA,TA,J)+P)*uA,EA=+g(kA,TA,J);if(EA&&lA>=0&&lA=0&&iAlA*TA))(fA).map((lA,iA)=>(lA.value=+uA[iA],U(lA)))}z.contours=function(J){var fA=Q(J),uA=_i().size([B,E]),TA=Math.pow(2,2*D),lA=iA=>{iA=+iA;var EA=U(uA.contour(fA,iA*TA));return EA.value=iA,EA};return Object.defineProperty(lA,"max",{get:()=>Si(fA)/TA}),lA};function U(J){return J.coordinates.forEach(W),J}function W(J){J.forEach($)}function $(J){J.forEach(sA)}function sA(J){J[0]=J[0]*Math.pow(2,D)-P,J[1]=J[1]*Math.pow(2,D)-P}function AA(){return P=b*3,B=x+P*2>>D,E=y+P*2>>D,z}return z.x=function(J){return arguments.length?(a=typeof J=="function"?J:rn(+J),z):a},z.y=function(J){return arguments.length?(c=typeof J=="function"?J:rn(+J),z):c},z.weight=function(J){return arguments.length?(g=typeof J=="function"?J:rn(+J),z):g},z.size=function(J){if(!arguments.length)return[x,y];var fA=+J[0],uA=+J[1];if(!(fA>=0&&uA>=0))throw new Error("invalid size");return x=fA,y=uA,AA()},z.cellSize=function(J){if(!arguments.length)return 1<=1))throw new Error("invalid cell size");return D=Math.floor(Math.log(J)/Math.LN2),AA()},z.thresholds=function(J){return arguments.length?(T=typeof J=="function"?J:Array.isArray(J)?rn(il.call(J)):rn(J),z):T},z.bandwidth=function(J){if(!arguments.length)return Math.sqrt(b*(b+1));if(!((J=+J)>=0))throw new Error("invalid bandwidth");return b=(Math.sqrt(4*J*J+1)-1)/2,AA()},z}function Rs(){const a=ka();return R.useMemo(()=>Ca.getPackets(),[a])}function T0({label:a,icon:c,status:g,detail:x}){return m.jsxs("div",{className:Cn("flex items-center gap-3 py-3 px-4 radius-inset transition-base",g==="active"&&"bg-sys-blue/10",g==="complete"&&"bg-sys-blue/10 ring-2 ring-inset ring-sys-blue",g==="pending"&&"opacity-40"),children:[m.jsx("div",{className:Cn("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300",g==="active"&&"bg-sys-blue/20",g==="complete"&&"bg-sys-blue/20",g==="pending"&&"bg-subtle-fill"),children:g==="complete"?m.jsx(Yn,{className:"w-4 h-4 text-sys-blue"}):g==="active"?m.jsx(J0,{className:"w-4 h-4 animate-spin text-sys-blue"}):m.jsx("span",{className:"text-fg-muted",children:c})}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:Cn("text-sm font-medium transition-colors",g==="active"&&"text-sys-blue",g==="complete"&&"text-sys-blue",g==="pending"&&"text-fg-muted"),children:a}),x&&g!=="pending"&&m.jsx("div",{className:"text-xs text-fg-muted mt-0.5 truncate",children:x})]})]})}function Pc({isOpen:a,onClose:c}){const{packetCacheState:g,triggerDeepAnalysis:x}=Ea(),y=Sa(),b=Ma(),D=g.packetCount,[P,B]=R.useState("fetching");R.useEffect(()=>{a&&x()},[a,x]),R.useEffect(()=>{if(a){if(g.isTopologyLoading)B("fetching");else if(y)B("analyzing"),setTimeout(()=>B("building"),500),setTimeout(()=>B("discovering"),1e3);else if(b>0&&!g.isTopologyLoading){B("complete");const W=setTimeout(()=>{c()},1500);return()=>clearTimeout(W)}}},[a,g.isTopologyLoading,y,b,c]);const E=P==="complete",T=g.loadProgress,Q=R.useMemo(()=>{if(T&&T.target>0){const W=(T.loaded/1e3).toFixed(1),$=(T.target/1e3).toFixed(1);return`Loading... ${W}k / ${$}k packets (${T.percent}%)`}return D>0?`${D.toLocaleString()} packets loaded`:"Connecting to database..."},[T,D]),z=W=>{const $=["fetching","analyzing","building","discovering","complete"],sA=$.indexOf(P),AA=$.indexOf(W);return AA{};return m.jsx(So,{open:a,onClose:U,size:"sm",bottomSheet:!1,children:m.jsx(Ba,{isLoading:!E,borderRadius:16,children:m.jsx(Mo,{className:"p-6 radius-card overflow-hidden",children:E?m.jsxs("div",{className:"flex flex-col items-center py-6",children:[m.jsx(tr.div,{variants:pu,initial:"hidden",animate:"visible",className:"w-16 h-16 rounded-full flex items-center justify-center mb-4 bg-sys-blue/20",children:m.jsx(Yn,{className:"w-8 h-8 text-sys-blue"})}),m.jsx("h3",{className:"type-micro text-sys-blue",children:"Ready!"}),m.jsx("button",{onClick:c,className:"mt-3 sm:hidden min-h-[44px] min-w-[44px] px-4 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"})]}):m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[m.jsx("div",{className:"w-10 h-10 radius-inset flex items-center justify-center bg-sys-blue/15",children:m.jsx(Ds,{className:"w-5 h-5 text-sys-blue"})}),m.jsxs("div",{children:[m.jsx("h3",{className:"type-micro",children:"Deep Analysis"}),m.jsx("p",{className:"text-xs text-fg-muted",children:"Building mesh topology"})]})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(T0,{label:"Fetching Packets",icon:m.jsx(Bo,{className:"w-4 h-4"}),status:z("fetching"),detail:Q}),m.jsx(T0,{label:"Analyzing Database",icon:m.jsx(xu,{className:"w-4 h-4"}),status:z("analyzing"),detail:"Processing packet paths"}),m.jsx(T0,{label:"Building Topology",icon:m.jsx(Ds,{className:"w-4 h-4"}),status:z("building"),detail:"Computing mesh edges"}),m.jsx(T0,{label:"Discovering Nodes",icon:m.jsx(nl,{className:"w-4 h-4"}),status:z("discovering"),detail:"Viterbi HMM ghost detection"})]}),m.jsx("p",{className:"text-xs text-fg-muted text-center mt-5",children:"This may take a few seconds..."})]})})})})}const Qc=R.memo(Pc),ol=16,Is=24,Oc=ol,zc=5,bn={nodeFill:cr.blue,nodeStroke:"rgba(255,255,255,0.9)",nodeColor:cr.indigo,localColor:cr.amber,hubColor:cr.purple,gatewayColor:cr.indigo,mobileColor:cr.orange,roomServerColor:cr.pink,neighborColor:cr.amber,edges:{rest:vn[700],restBright:vn[600],restDim:vn[800],hoverDirect:"#6FBCBD",hoverLoop:"#8B7BAD",hoverStandard:vn[400],hoverNeighbor:cr.amber,neighborRest:vn[500],neighborHover:cr.amber,highlight:"#FFD700"},edgeOpacity:.82};function Zs(){if(typeof window>"u")return bn;const a=X0(),c=Do();return{nodeFill:a.nodeFill,nodeStroke:a.nodeStroke,nodeColor:bn.nodeColor,localColor:a.localColor,hubColor:a.hubColor,gatewayColor:a.gatewayColor,mobileColor:a.mobileColor,roomServerColor:a.roomColor,neighborColor:a.neighborColor,edges:{rest:c.rest,restBright:c.restBright,restDim:c.restDim,hoverDirect:c.hoverDirect,hoverLoop:c.hoverLoop,hoverStandard:c.hoverStandard,hoverNeighbor:c.hoverNeighbor,neighborRest:bn.edges.neighborRest,neighborHover:bn.edges.neighborHover,highlight:c.highlight},edgeOpacity:bn.edgeOpacity}}const R0=2e3,I0=750,Hc="#00FF00",Gc=500,Ti=500,Ri=250,Uc=150,ll=200,Vc=En.snappy;function zn({color:a,ring:c}){const g=Oc-2;return m.jsx("span",{className:"shrink-0 rounded-full","aria-hidden":"true",style:{width:g,height:g,backgroundColor:c?"transparent":a,border:c?`${zc-1}px solid ${a}`:void 0,boxSizing:"border-box"}})}function ws({color:a,pattern:c="solid"}){return m.jsx("svg",{className:"shrink-0","aria-hidden":"true",width:18,height:6,viewBox:"0 0 18 6",children:m.jsx("line",{x1:0,y1:3,x2:18,y2:3,stroke:a,strokeWidth:3,strokeLinecap:"round",strokeDasharray:c==="dashed"?"5,3":c==="dotted"?"2,3":void 0})})}function ur({indicator:a,label:c,tooltip:g}){return m.jsxs("div",{className:"flex items-center gap-1.5",children:[a,m.jsx("span",{className:"text-fg-secondary",children:c}),g&&m.jsx(jo,{content:g,delay:ll,children:m.jsx("span",{className:"cursor-help text-[11px] text-fg-muted opacity-75 hover:opacity-100 transition-opacity",children:"ⓘ"})})]})}function Wc(a){return`legend-section-${a.toLowerCase().replace(/\s+/g,"-")}`}function vs({title:a,tooltip:c,isOpen:g,onToggle:x,showDivider:y,children:b}){const D=Wc(a);return m.jsxs("div",{className:y?"mt-2 pt-2 border-t border-edge-subtle":"",children:[m.jsxs("button",{type:"button",onClick:x,"aria-expanded":g,"aria-controls":D,className:"group w-full flex items-center justify-between py-1 min-h-[44px] sm:min-h-0 font-medium text-fg-secondary hover:text-fg-primary transition-colors",children:[m.jsxs("span",{className:"flex items-center gap-1",children:[a,m.jsx(jo,{content:c,delay:ll,children:m.jsx("span",{className:"cursor-help text-[11px] text-fg-muted opacity-75 group-hover:opacity-100 transition-opacity",children:"ⓘ"})})]}),m.jsx(tr.span,{animate:{rotate:g?0:-90},transition:{duration:.15},"aria-hidden":"true",children:m.jsx(To,{className:"w-3 h-3 text-fg-muted"})})]}),m.jsx(Dr,{initial:!1,children:g&&m.jsx(tr.div,{id:D,role:"region","aria-label":a,initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:Vc,className:"overflow-hidden",children:m.jsx("div",{className:"flex flex-col gap-1 pt-1.5",children:b})})})]})}function Ii({label:a,value:c,color:g}){return m.jsxs("div",{className:"flex justify-between tabular-nums text-fg-muted",children:[m.jsx("span",{children:a}),m.jsx("span",{className:g?"":"text-fg-secondary",style:g?{color:g}:void 0,children:c})]})}function Li({icon:a,color:c,title:g,subtitle:x}){return m.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-edge-subtle",children:m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("span",{className:"shrink-0",style:{color:c},children:a}),m.jsxs("div",{className:"flex flex-col min-w-0",children:[m.jsx("span",{className:"font-medium truncate",style:{color:c},children:g}),m.jsx("span",{className:"text-[10px] leading-tight text-fg-muted",children:x})]})]})})}function Yc(a){return a.some(([,c])=>{var x;const g=(x=c.contact_type)==null?void 0:x.toLowerCase();return g==="room server"||g==="room_server"||g==="room"||g==="server"})}function Kc(a){let c=0;for(const g of a.txDelayRecommendations.values())g.networkRole==="backbone"&&c++;return c}function Zc({showTopology:a,validatedPolylineCount:c,filteredNeighborCount:g,hasLocalNode:x,meshTopology:y,zeroHopNeighbors:b,neighborsWithLocation:D,basemapMode:P="dark"}){const B=Da(),E=_a(),T=ja(),Q=E.filter(uA=>uA.isLikelyReal).length,z=Kc(y),U=b.size>0,[W,$]=R.useState(!0),[sA,AA]=R.useState(!0),[J,fA]=R.useState(!0);return m.jsxs("div",{className:"map-control-surface p-2.5 text-xs",children:[m.jsxs(vs,{title:"Nodes",tooltip:"Node type shown by shape + color. Yellow = direct RF neighbor.",isOpen:W,onToggle:()=>$(uA=>!uA),children:[m.jsx(ur,{indicator:m.jsx(zn,{color:B.nodeFill}),label:"Node",tooltip:"Standard mesh node. Repeater, client, or companion device."}),m.jsx(ur,{indicator:m.jsx(zn,{color:B.hubColor}),label:"Hub",tooltip:"Network hub (≥10% of last-hop traffic)."}),Yc(D)&&m.jsx(ur,{indicator:m.jsx(Ta,{className:"w-3 h-3 shrink-0",style:{color:B.roomColor},strokeWidth:2.5}),label:"Room",tooltip:"Room Server identity for client sync."}),m.jsx(ur,{indicator:m.jsx(wu,{className:"w-3 h-3 shrink-0",style:{color:B.localColor},strokeWidth:2.5}),label:"Local",tooltip:"Your repeater running openHop Repeater."}),U&&m.jsx(ur,{indicator:m.jsx(zn,{color:B.neighborColor}),label:"Neighbor",tooltip:"Zero-hop direct RF contact."}),y.gatewayNodes.length>0&&m.jsx(ur,{indicator:m.jsx(zn,{color:B.gatewayColor}),label:"Gateway",tooltip:"Significant forwarder (7-10% traffic)."}),z>0&&m.jsx(ur,{indicator:m.jsx(zn,{color:B.hubColor}),label:"Backbone",tooltip:"Critical relay with high centrality."}),y.mobileNodes.length>0&&m.jsx(ur,{indicator:m.jsx(zn,{color:B.mobileColor,ring:!0}),label:"Mobile",tooltip:"Volatile node that appears/disappears."}),Q>0&&m.jsx(ur,{indicator:m.jsx(nl,{className:"w-3 h-3 shrink-0",style:{color:B.ghostColor},strokeWidth:2.5}),label:`Ghost (${Q})`,tooltip:"Unknown repeater from Viterbi analysis."})]}),U&&m.jsxs(vs,{title:"Link Quality",tooltip:"Neighbor edge colors based on bidirectional balance.",isOpen:sA,onToggle:()=>AA(uA=>!uA),showDivider:!0,children:[m.jsx(ur,{indicator:m.jsx(ws,{color:W0.YELLOW,pattern:"solid"}),label:"2-Way",tooltip:"33-67% balanced. Ideal bidirectional link."}),m.jsx(ur,{indicator:m.jsx(ws,{color:W0.GREEN,pattern:"dashed"}),label:"Listener",tooltip:">67% listener. They hear us well."}),m.jsx(ur,{indicator:m.jsx(ws,{color:W0.RED,pattern:"dotted"}),label:"Loud",tooltip:"<33% listener. They route more to us."})]}),a&&c>0&&m.jsxs(vs,{title:"Topology",tooltip:"Links with 5+ validations. Thickness = strength.",isOpen:J,onToggle:()=>fA(uA=>!uA),showDivider:!0,children:[m.jsx(Ii,{label:"Nodes",value:g+(x?1:0)}),y.hubNodes.length>0&&m.jsx(Ii,{label:"Hubs",value:y.hubNodes.length,color:bn.hubColor}),y.loops.length>0&&m.jsx(Li,{icon:m.jsx(_o,{className:"w-3 h-3"}),color:bn.edges.hoverLoop,title:`${y.loops.length} ${y.loops.length===1?"Loop":"Loops"}`,subtitle:"Redundant paths"}),T.totalPaths>0&&m.jsx(Li,{icon:m.jsx($o,{className:"w-3 h-3"}),color:B.ghostColor,title:`${T.totalPaths.toLocaleString()} Viterbi`,subtitle:"HMM decoded paths"})]})]})}const Ni={repeater:"blue",companion:"cyan",room_server:"pink",hubs:"indigo",direct:"green"},L0={repeater:"Repeaters",companion:"Companions",room_server:"Rooms",hubs:"Hubs",direct:"Direct"},Fi={repeater:"Repeater nodes (mesh relays)",companion:"Companion devices (clients)",room_server:"Room server nodes",hubs:"Hub nodes and their connections",direct:"Zero-hop (direct RF) neighbors"},$c=["repeater","companion","room_server"],Pi=["hubs","direct"],Hn="!p-2.5 sm:!p-1.5 !rounded-md min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 shrink-0 flex items-center justify-center",N0="!p-2.5 sm:!p-1.5 !rounded-none min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 shrink-0 flex items-center justify-center",qc=()=>typeof window>"u"?!1:window.innerWidth<640;function Jc({mapRef:a,showNeighborLines:c,onToggleNeighborLines:g,hasNeighborPolylines:x,nodeFilters:y,onToggleFilter:b,onToggleAll:D,filterCounts:P,showCoverage:B,onToggleCoverage:E,showMinCut:T=!1,onToggleMinCut:Q,hasMinCutData:z=!1,show3DTerrain:U,onToggle3DTerrain:W,basemapMode:$,onToggleBasemap:sA,isFullscreen:AA,onToggleFullscreen:J,showLinkQuality:fA=!1,onToggleLinkQuality:uA,hasTraceLinks:TA=!1}){const[lA,iA]=R.useState(()=>!qc()),EA=()=>{var LA,HA;(HA=(LA=a.current)==null?void 0:LA.getMap())==null||HA.zoomIn()},MA=()=>{var LA,HA;(HA=(LA=a.current)==null?void 0:LA.getMap())==null||HA.zoomOut()},xA=()=>{var HA;const LA=(HA=a.current)==null?void 0:HA.getMap();LA&&LA.easeTo({bearing:0,pitch:0,duration:300})},bA="w-4 h-4",IA=$==="light"?"#525252":"var(--fg-secondary)",kA=y.length>=x0.length;return m.jsx(m.Fragment,{children:m.jsxs("div",{className:"absolute top-3 right-3 z-[600] flex flex-col gap-2 sm:top-4 sm:right-4 max-w-[calc(100vw-1.5rem)] sm:max-w-none pr-[env(safe-area-inset-right)] pointer-events-none",children:[m.jsxs("div",{className:"map-control-surface flex flex-nowrap items-center gap-0.5 sm:gap-1 p-1 overflow-hidden pointer-events-auto",children:[x&&m.jsx(Qt,{plain:!0,color:c?"warning":"muted",onClick:g,title:c?"Hide edge lines":"Show edge lines","aria-label":c?"Hide edge lines":"Show edge lines","aria-pressed":c,className:Hn,"data-tint":c?"warning":void 0,children:m.jsx(ku,{className:bA})}),m.jsx(Qt,{plain:!0,color:"muted",onClick:()=>iA(LA=>!LA),title:lA?"Hide node filters":"Show node filters","aria-label":lA?"Collapse node filters":"Expand node filters","aria-expanded":lA,className:Hn,children:m.jsx(_u,{className:bA})}),m.jsx(Dr,{initial:!1,children:lA&&m.jsxs(tr.div,{className:"flex items-center gap-0.5 flex-nowrap overflow-x-auto scrollbar-none max-w-[50vw] sm:max-w-none sm:overflow-visible",role:"group","aria-label":"Node type filters",initial:{width:0,opacity:0},animate:{width:"auto",opacity:1},exit:{width:0,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1]},children:[m.jsx(gs,{color:kA?"green":"zinc",customColor:kA?void 0:IA,onClick:D,title:"Show all nodes","aria-pressed":kA,"aria-label":"Show all node types",className:"shrink-0",children:"All"}),$c.map(LA=>{const HA=P[LA];if(HA===0)return null;const wA=!kA&&y.includes(LA);return m.jsx(gs,{color:wA?Ni[LA]:"zinc",customColor:wA?void 0:IA,onClick:()=>b(LA),title:Fi[LA],"aria-pressed":wA,"aria-label":`${L0[LA]} (${HA})`,className:"shrink-0",children:L0[LA]},LA)}),Pi.some(LA=>P[LA]>0)&&m.jsx("span",{className:"mx-0.5 h-3 w-px bg-[var(--map-ui-border,var(--edge-subtle))] hidden sm:block shrink-0","aria-hidden":"true"}),Pi.map(LA=>{const HA=P[LA];if(HA===0)return null;const wA=!kA&&y.includes(LA);return m.jsx(gs,{color:wA?Ni[LA]:"zinc",customColor:wA?void 0:IA,onClick:()=>b(LA),title:Fi[LA],"aria-pressed":wA,"aria-label":`${L0[LA]} (${HA})`,className:"shrink-0",children:L0[LA]},LA)})]})}),z&&Q&&m.jsx(Qt,{plain:!0,color:T?"primary":"muted",onClick:Q,title:T?"Hide community partition":"Show community partition","aria-label":T?"Hide community partition":"Show community partition","aria-pressed":T,className:Hn,"data-tint":T?"primary":void 0,children:m.jsx(js,{className:bA})}),m.jsx(Qt,{plain:!0,color:$==="light"?"primary":"muted",onClick:sA,title:$==="light"?"Switch to dark map":"Switch to light map","aria-label":$==="light"?"Switch to dark map":"Switch to light map","aria-pressed":$==="light",className:Hn,"data-tint":$==="light"?"primary":void 0,children:$==="light"?m.jsx(Vs,{className:bA}):m.jsx(Ws,{className:bA})}),m.jsx(Qt,{plain:!0,color:U?"success":"muted",onClick:W,title:U?"Disable 3D terrain":"Enable 3D terrain","aria-label":U?"Disable 3D terrain":"Enable 3D terrain","aria-pressed":U,className:Hn,"data-tint":U?"success":void 0,children:m.jsx(rc,{className:bA})}),m.jsx(Qt,{plain:!0,color:"muted",onClick:J,title:AA?"Exit fullscreen":"Fullscreen","aria-label":AA?"Exit fullscreen":"Enter fullscreen","aria-pressed":AA,className:Hn,children:AA?m.jsx(gu,{className:bA}):m.jsx(yu,{className:bA})})]}),m.jsxs("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0 pointer-events-auto",children:[m.jsx(Qt,{plain:!0,color:"muted",onClick:EA,title:"Zoom in","aria-label":"Zoom in",className:N0,children:m.jsx(ju,{className:bA})}),m.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),m.jsx(Qt,{plain:!0,color:"muted",onClick:MA,title:"Zoom out","aria-label":"Zoom out",className:N0,children:m.jsx(Ro,{className:bA})}),m.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),m.jsx(Qt,{plain:!0,color:"muted",onClick:xA,title:"Reset bearing to north","aria-label":"Reset bearing to north",className:N0,children:m.jsx(Tu,{className:bA})})]}),TA&&uA&&m.jsx("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0 pointer-events-auto",children:m.jsx(Qt,{plain:!0,color:fA?"success":"muted",onClick:uA,title:fA?"Hide link quality overlay":"Show link quality overlay","aria-label":fA?"Hide link quality overlay":"Show link quality overlay","aria-pressed":fA,className:N0,"data-tint":fA?"success":void 0,children:m.jsx(sl,{className:bA})})})]})})}const Xc="#4ADE80",Af="#16A34A",ef="rgba(10, 26, 10, 1)",tf="rgba(220, 252, 231, 1)",gn="DeepAnalysis",rf=700,Qi="abcdefghijklmnopqrstuvwxyz0123456789";function nf(){return Qi[Math.floor(Math.random()*Qi.length)]}function sf({isActive:a,hasAnalyzed:c,isLoading:g,onClick:x,basemapMode:y="dark"}){const b=y==="light",D=b?Af:Xc,[P,B]=R.useState(!1),[E,T]=R.useState(gn),Q=R.useRef(!1),z=R.useRef(null),[U]=R.useState(()=>{var AA;return typeof window<"u"&&(((AA=window.matchMedia)==null?void 0:AA.call(window,"(hover: hover)").matches)??!1)}),W=P&&!a&&!g&&U;R.useEffect(()=>{if(P&&!a&&!g&&!Q.current){Q.current=!0;const AA=performance.now(),J=fA=>{const uA=fA-AA,TA=Math.min(uA/rf,1),lA=Math.floor(TA*gn.length);let iA="";for(let EA=0;EA{z.current&&cancelAnimationFrame(z.current)}},[P,a,g]);const $=g?"Analyzing...":E,sA=g?"Analyzing packet history":c?a?"Hide topology edges":"Show topology edges":"Load full packet history and build topology";return m.jsxs("button",{onClick:x,onMouseEnter:()=>U&&B(!0),onMouseLeave:()=>U&&B(!1),onPointerEnter:()=>U&&B(!0),onPointerLeave:()=>U&&B(!1),disabled:g,className:`map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base ${g?"cursor-wait":""}`,style:{padding:"0.5rem 0.625rem",...a&&{backgroundColor:b?tf:ef}},title:sA,"aria-label":sA,"aria-pressed":a,children:[g?m.jsx(J0,{className:"w-3.5 h-3.5 shrink-0 animate-spin",style:{color:D}}):m.jsx(Ds,{className:`w-3.5 h-3.5 shrink-0 transition-colors ${a?"":"text-fg-secondary"}`,style:{...a&&{color:D},...W&&{color:D}}}),m.jsx("span",{className:`${a?"":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:a||W?700:500,letterSpacing:"-0.01em",lineHeight:1,...a&&{color:D},...W&&{color:D}},children:$})]})}const of=cr.teal,lf="#0D7377",af="rgba(10, 36, 32, 1)",uf="rgba(204, 251, 241, 1)",Oi="LiveTrace",cf=400,zi=100;function ff({isActive:a,onClick:c,basemapMode:g="dark"}){const x=g==="light",y=x?lf:of,[b,D]=R.useState(!1),[P,B]=R.useState(0),E=R.useRef(!1),T=R.useRef(null),[Q,z]=R.useState(0),U=R.useRef(!1),[W]=R.useState(()=>{var J;return typeof window<"u"&&(((J=window.matchMedia)==null?void 0:J.call(window,"(hover: hover)").matches)??!1)}),$=b&&!a&&W;R.useEffect(()=>{$&&!U.current&&(U.current=!0,z(1),setTimeout(()=>z(2),zi),setTimeout(()=>z(3),zi*2)),b||(U.current=!1,z(0))},[$,b]),R.useEffect(()=>{if(b&&!a&&!E.current){E.current=!0;const J=performance.now(),fA=uA=>{const TA=uA-J,lA=Math.min(TA/cf,1);B(lA),lA<1&&(T.current=requestAnimationFrame(fA))};T.current=requestAnimationFrame(fA)}return b||(T.current&&(cancelAnimationFrame(T.current),T.current=null),E.current=!1,B(0)),()=>{T.current&&cancelAnimationFrame(T.current)}},[b,a]);const sA=J=>{if(a)return y;if(!$)return;const fA=Oi.length,uA=P*(fA+2);return J>=uA-2&&JW&&D(!0),onMouseLeave:()=>W&&D(!1),onPointerEnter:()=>W&&D(!0),onPointerLeave:()=>W&&D(!1),className:"map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base",style:{padding:"0.5rem 0.625rem",...a&&{backgroundColor:x?uf:af}},title:a?"Disable live packet tracing (reduces CPU usage)":"Enable live packet tracing","aria-label":AA,"aria-pressed":a,children:[m.jsx(Ru,{className:`w-3.5 h-3.5 shrink-0 ${a?"":"text-fg-secondary"}`,fill:Q===1?"#FFFFFF":Q===3?y:"none",stroke:Q===1||Q===2?"#FFFFFF":a||$?y:"currentColor",style:{transition:"fill 0.05s, stroke 0.05s"}}),m.jsx("span",{className:`${a?"":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:a||$?700:500,letterSpacing:"-0.01em",lineHeight:1},children:Oi.split("").map((J,fA)=>m.jsx("span",{style:{color:sA(fA)||void 0},children:J},fA))})]})}const Hi=.2,hf="rgba(26, 20, 8, 1)",df="rgba(254, 243, 199, 1)",bs=.01,ks=1,Gi="#fe8019",mf="'Wardrive', serif",Ls=1.45,pf=Ls*1.1,gf=80;function yf({isActive:a,onClick:c,brightness:g=.7,onBrightnessChange:x,basemapMode:y="dark"}){const b=y==="light",[D,P]=R.useState(!1),[B,E]=R.useState(!1),[T]=R.useState(()=>{var J;return typeof window<"u"&&(((J=window.matchMedia)==null?void 0:J.call(window,"(hover: hover)").matches)??!1)});R.useEffect(()=>{if(!D||a)return;const J=requestAnimationFrame(()=>E(!0)),fA=setTimeout(()=>E(!1),gf);return()=>{cancelAnimationFrame(J),clearTimeout(fA)}},[D,a]);const Q=Math.max(bs,Math.min(ks,g)),z=J=>{J.stopPropagation();const fA=Math.min(ks,Q+Hi);x==null||x(fA)},U=J=>{J.stopPropagation();const fA=Math.max(bs,Q-Hi);x==null||x(fA)},W=Qbs+.001,sA=D&&!a&&T,AA=a?"Configure wardriving coverage":"Show wardriving coverage";return m.jsxs("button",{onClick:c,onMouseEnter:()=>T&&P(!0),onMouseLeave:()=>T&&P(!1),onPointerEnter:()=>T&&P(!0),onPointerLeave:()=>T&&P(!1),className:"map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base",style:{padding:"0.5rem 0.625rem",...a&&{backgroundColor:b?df:hf}},title:AA,"aria-label":AA,"aria-pressed":a,children:[m.jsx(uc,{className:`w-3.5 h-3.5 shrink-0 transition-colors ${a?"text-sys-amber":"text-fg-secondary"}`,style:sA?{color:Gi}:void 0}),m.jsx("span",{className:`${a?"text-sys-amber":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:a||sA?mf:"ui-monospace, SFMono-Regular, monospace",fontSize:a||sA?"0.75rem":"0.6875rem",fontWeight:500,letterSpacing:"-0.01em",lineHeight:1,transition:"none",transform:a?`scale(${Ls})`:sA?`scale(${B?pf:Ls})`:void 0,transformOrigin:"left center",...sA?{color:Gi}:{}},children:"Wardrive"}),a&&x&&m.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[m.jsx("button",{onClick:U,disabled:!$,className:`p-1 sm:p-0.5 min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center rounded transition-colors ${$?"text-sys-amber hover:bg-[var(--map-ui-hover,var(--elevated))] active:bg-[var(--map-ui-active,var(--subtle))]":"cursor-not-allowed"}`,style:$?void 0:{color:b?"rgba(0, 0, 0, 0.25)":"rgba(251, 191, 36, 0.3)"},title:`Decrease opacity (${Math.round(Q*100)}%)`,"aria-label":`Decrease opacity, currently ${Math.round(Q*100)}%`,children:m.jsx(Vs,{className:"w-3.5 h-3.5"})}),m.jsx("button",{onClick:z,disabled:!W,className:`p-1 sm:p-0.5 min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center rounded transition-colors ${W?"text-sys-amber hover:bg-[var(--map-ui-hover,var(--elevated))] active:bg-[var(--map-ui-active,var(--subtle))]":"cursor-not-allowed"}`,style:W?void 0:{color:b?"rgba(0, 0, 0, 0.25)":"rgba(251, 191, 36, 0.3)"},title:`Increase opacity (${Math.round(Q*100)}%)`,"aria-label":`Increase opacity, currently ${Math.round(Q*100)}%`,children:m.jsx(Ws,{className:"w-3.5 h-3.5"})})]})]})}const xf="0123456789bcdefghjkmnpqrstuvwxyz";function wf(a){let c=!0,g=-90,x=90,y=-180,b=180;for(const D of a.toLowerCase()){const P=xf.indexOf(D);if(P!==-1)for(let B=4;B>=0;B--){const E=P>>B&1;if(c){const T=(y+b)/2;E?y=T:b=T}else{const T=(g+x)/2;E?g=T:x=T}c=!c}}return{lat:(g+x)/2,lon:(y+b)/2}}function vf(a){return Math.exp(-a*Math.LN2/7)}const Ns="pymc-wardriving-url",al="pymc-wardriving-enabled",ul="pymc-wardriving-brightness",Ui=.7;function bf(){return typeof localStorage>"u"?"":localStorage.getItem(Ns)||""}function Vi(a){typeof localStorage>"u"||(a?localStorage.setItem(Ns,a):localStorage.removeItem(Ns))}function kf(){return typeof localStorage>"u"?!1:localStorage.getItem(al)==="true"}function F0(a){typeof localStorage>"u"||localStorage.setItem(al,String(a))}function Cf(){if(typeof localStorage>"u")return Ui;const a=localStorage.getItem(ul);if(a){const c=parseFloat(a);if(!isNaN(c)&&c>=.01&&c<=1)return c}return Ui}function Ef(a){if(typeof localStorage>"u")return;const c=Math.max(.01,Math.min(1,a));localStorage.setItem(ul,String(c))}const Sf=8e3;async function Mf(a,c={},g=Sf){const x=new AbortController,y=setTimeout(()=>x.abort(),g);try{return await fetch(a,{...c,signal:x.signal})}catch(b){throw b instanceof Error&&b.name==="AbortError"?new Error(`Connection timed out after ${g/1e3}s`):b}finally{clearTimeout(y)}}async function Bf(a){const g=`${a.replace(/\/+$/,"").replace(/\/get-nodes$/,"").replace(/\/get-samples$/,"")}/get-samples`,x=await Mf(g,{headers:{Accept:"application/json"}});if(!x.ok)throw new Error(`Failed to fetch precise samples: ${x.status}`);return x.json()}function Df(a,c=null){if(a!==null){const x=(Math.max(-12,Math.min(12,a))+12)/24;if(c!==null){const b=(Math.max(-120,Math.min(-50,c))+120)/70;return x*.8+b*.2}return x}return c!==null?(Math.max(-120,Math.min(-50,c))+120)/70:.5}function _f(a){var g;const c=[];for(const x of a.keys){if(!x.observed)continue;const{lat:y,lon:b}=wf(x.hash),D=parseInt(x.time,10),P=isNaN(D)?30:(Date.now()-D)/(1e3*60*60*24),B=vf(P),T=Df(x.snr,x.rssi)*(.3+B*.7);c.push({lat:y,lon:b,successRate:x.observed?1:0,weight:T,totalSamples:1,ageDays:P,geohash:x.hash,repeaters:((g=x.path)==null?void 0:g.map(Q=>Q.toLowerCase()))||[]})}return c}const w0=Io((a,c)=>({status:"idle",isVisible:kf(),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:bf(),brightness:Cf(),isModalOpen:!1,openModal:()=>a({isModalOpen:!0}),closeModal:()=>a({isModalOpen:!1}),setUrl:g=>a({url:g}),setBrightness:g=>{const x=Math.max(.01,Math.min(1,g));Ef(x),a({brightness:x})},toggleVisibility:()=>{const g=!c().isVisible;F0(g),a({isVisible:g})},setVisible:g=>{F0(g),a({isVisible:g})},loadCoverage:async g=>{if(!g.trim())return a({error:"Please enter a URL",status:"error"}),!1;try{new URL(g.trim())}catch{return a({error:"Invalid URL format",status:"error"}),!1}a({error:null,status:"connecting"});try{a({status:"loading"});const x=await Bf(g.trim());if(!x||typeof x!="object")throw new Error("Invalid response from server");if(!Array.isArray(x.keys))throw new Error("No sample data found in response");a({status:"processing"});const y=_f(x);if(y.length===0)throw new Error("No valid coverage points found");return a({coveragePoints:y,repeaters:[],stats:{coverageCount:y.length,repeaterCount:0,lastUpdated:new Date},status:"success",isVisible:!0,url:g.trim()}),Vi(g.trim()),F0(!0),!0}catch(x){const y=x instanceof Error?x.message:"Failed to load coverage data";let b=y;return y.includes("timed out")?b="Connection timed out. Server may be unreachable or slow.":y.includes("Failed to fetch")||y.includes("NetworkError")?b="Could not connect to server. Check the URL and try again.":y.includes("CORS")?b="Server does not allow cross-origin requests.":y.includes("404")?b="Coverage endpoint not found. Check the URL.":(y.includes("ERR_NAME_NOT_RESOLVED")||y.includes("DNS"))&&(b="Server not found. Check the URL for typos."),a({error:b,status:"error"}),!1}},clearCoverage:()=>{a({coveragePoints:[],repeaters:[],stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},status:"idle",error:null,isVisible:!1,url:""}),Vi(""),F0(!1)}})),jf={bg:"#F8F8F8",bgSubtle:"#F0F0F0",bgElevated:"#FFFFFF",bgInput:"#FFFFFF",border:"rgba(0, 0, 0, 0.12)",borderStrong:"rgba(0, 0, 0, 0.20)",borderFocus:"#3B82F6",text:"#1A1A1A",textSecondary:"#4A4A4A",textMuted:"#737373",success:"#059669",successBg:"#ECFDF5",successBorder:"#A7F3D0",error:"#DC2626",errorBg:"#FEF2F2",errorBorder:"#FECACA",info:"#2563EB",infoBg:"#EFF6FF",infoBorder:"#BFDBFE",warning:"#D97706",warningBg:"#FFFBEB",warningBorder:"#FDE68A",primary:"#F59E0B",hoverBg:"rgba(0, 0, 0, 0.04)",sliderTrack:"#E5E7EB",sliderThumb:"#F59E0B"},cl={bg:"var(--surface)",bgSubtle:"var(--subtle)",bgElevated:"var(--elevated)",bgInput:"var(--subtle)",border:"var(--edge-subtle)",borderStrong:"var(--edge-strong)",borderFocus:"var(--sys-blue)",text:"var(--fg-primary)",textSecondary:"var(--fg-secondary)",textMuted:"var(--fg-muted)",success:"var(--sys-green)",successBg:"rgba(74, 222, 128, 0.1)",successBorder:"rgba(74, 222, 128, 0.3)",error:"var(--sys-red)",errorBg:"rgba(239, 68, 68, 0.1)",errorBorder:"rgba(239, 68, 68, 0.3)",info:"var(--sys-indigo)",infoBg:"rgba(249, 210, 111, 0.1)",infoBorder:"rgba(249, 210, 111, 0.3)",warning:"var(--sys-indigo)",warningBg:"rgba(249, 210, 111, 0.1)",warningBorder:"rgba(249, 210, 111, 0.3)",primary:"var(--sys-indigo)",hoverBg:"var(--hover-tint)",sliderTrack:"var(--elevated)",sliderThumb:"var(--sys-indigo)"},fl=R.createContext({theme:cl,isLight:!1});function Mn(){return R.useContext(fl)}function Tf({status:a,hasData:c}){const{theme:g,isLight:x}=Mn(),y=R.useMemo(()=>a==="connecting"||a==="loading"||a==="processing"?{icon:m.jsx(J0,{className:"w-3.5 h-3.5 animate-spin"}),label:a==="connecting"?"Connecting...":a==="loading"?"Loading...":"Processing...",color:g.warning,bg:g.warningBg}:a==="error"?{icon:m.jsx(Lu,{className:"w-3.5 h-3.5"}),label:"Disconnected",color:g.error,bg:g.errorBg}:c?{icon:m.jsx(Nu,{className:"w-3.5 h-3.5"}),label:"Connected",color:g.success,bg:g.successBg}:{icon:m.jsx(No,{className:"w-3.5 h-3.5"}),label:"Ready",color:g.textMuted,bg:x?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},[a,c,g,x]);return m.jsxs(tr.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium",style:{backgroundColor:y.bg,color:y.color},children:[y.icon,m.jsx("span",{children:y.label})]},y.label)}function Rf({status:a}){const{theme:c}=Mn(),g=R.useMemo(()=>{switch(a){case"connecting":return 25;case"loading":return 60;case"processing":return 90;default:return 0}},[a]);return g===0?null:m.jsx(tr.div,{initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},exit:{opacity:0,scaleY:0},className:"h-1 rounded-full overflow-hidden origin-top",style:{backgroundColor:c.sliderTrack},children:m.jsx(tr.div,{className:"h-full rounded-full",style:{backgroundColor:c.primary},initial:{width:0},animate:{width:`${g}%`},transition:{duration:.4,ease:"easeOut"}})})}function Wi({variant:a,title:c,description:g,onDismiss:x}){const{theme:y}=Mn(),b=R.useMemo(()=>{switch(a){case"success":return{icon:m.jsx(Yn,{className:"w-4 h-4"}),color:y.success,bg:y.successBg,border:y.successBorder};case"error":return{icon:m.jsx(Fu,{className:"w-4 h-4"}),color:y.error,bg:y.errorBg,border:y.errorBorder};case"info":return{icon:m.jsx(Ra,{className:"w-4 h-4"}),color:y.info,bg:y.infoBg,border:y.infoBorder}}},[a,y]);return m.jsxs(tr.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:En.snappy,className:"flex items-start gap-3 p-3 rounded-lg border",style:{backgroundColor:b.bg,borderColor:b.border,color:b.color},children:[m.jsx("div",{className:"shrink-0 mt-0.5",children:b.icon}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"text-sm font-medium",children:c}),g&&m.jsx("p",{className:"text-xs mt-0.5 opacity-80",children:g})]}),x&&m.jsx("button",{onClick:x,className:"shrink-0 p-1 rounded hover:bg-black/10 transition-colors","aria-label":"Dismiss",children:m.jsx(Sn,{className:"w-3.5 h-3.5"})})]})}function If({value:a,onChange:c,onSubmit:g,disabled:x}){const{theme:y,isLight:b}=Mn(),[D,P]=R.useState(!1),B=E=>{E.key==="Enter"&&!E.shiftKey&&!x&&(E.preventDefault(),g())};return m.jsxs("div",{className:"space-y-1.5",children:[m.jsx("label",{className:"block text-sm font-medium",style:{color:y.textSecondary},children:"Coverage Server URL"}),m.jsxs("div",{className:"relative",children:[m.jsx("input",{type:"url",value:a,onChange:E=>c(E.target.value),onKeyDown:B,onFocus:()=>P(!0),onBlur:()=>P(!1),placeholder:"https://coverage.wcmesh.com",disabled:x,className:Cn("w-full pl-3 pr-10 py-2.5 rounded-lg border text-sm transition-all duration-150","focus:outline-none",x&&"opacity-50 cursor-not-allowed"),style:{backgroundColor:y.bgInput,borderColor:D?y.borderFocus:y.border,color:y.text,boxShadow:D?`0 0 0 3px ${b?"rgba(59, 130, 246, 0.15)":"rgba(139, 92, 246, 0.15)"}`:"none"}}),a&&!x&&m.jsx("button",{onClick:()=>c(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 rounded transition-colors",style:{color:y.textMuted},onMouseEnter:E=>E.currentTarget.style.color=y.text,onMouseLeave:E=>E.currentTarget.style.color=y.textMuted,"aria-label":"Clear URL",children:m.jsx(Sn,{className:"w-4 h-4"})})]}),m.jsx("p",{className:"text-xs",style:{color:y.textMuted},children:"Press Enter to connect, or use the Connect button below"})]})}function Lf({value:a,onChange:c}){const{theme:g,isLight:x}=Mn(),y=Math.round(a*100);return m.jsx(tr.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:En.gentle,className:"overflow-hidden",children:m.jsx("div",{className:"p-3 rounded-lg border",style:{backgroundColor:g.bgSubtle,borderColor:g.border},children:m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsxs("div",{className:"relative w-4 h-4",children:[m.jsx(Vs,{className:"w-4 h-4 absolute inset-0 transition-opacity",style:{color:g.textMuted,opacity:a<.5?1:0}}),m.jsx(Ws,{className:"w-4 h-4 absolute inset-0 transition-opacity",style:{color:g.primary,opacity:a>=.5?1:0}})]}),m.jsxs("div",{className:"flex-1",children:[m.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[m.jsx("span",{className:"text-xs font-medium",style:{color:g.textSecondary},children:"Layer Opacity"}),m.jsxs("span",{className:"text-xs font-mono tabular-nums px-1.5 py-0.5 rounded",style:{color:g.text,backgroundColor:x?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.06)"},children:[y,"%"]})]}),m.jsx("input",{type:"range",min:5,max:100,value:y,onChange:b=>c(Number(b.target.value)/100),className:Cn("w-full h-2 rounded-full appearance-none cursor-pointer","[&::-webkit-slider-thumb]:appearance-none","[&::-webkit-slider-thumb]:w-4","[&::-webkit-slider-thumb]:h-4","[&::-webkit-slider-thumb]:rounded-full","[&::-webkit-slider-thumb]:cursor-pointer","[&::-webkit-slider-thumb]:transition-transform","[&::-webkit-slider-thumb]:hover:scale-110","[&::-webkit-slider-thumb]:shadow-lg","[&::-moz-range-thumb]:appearance-none","[&::-moz-range-thumb]:w-4","[&::-moz-range-thumb]:h-4","[&::-moz-range-thumb]:rounded-full","[&::-moz-range-thumb]:border-0","[&::-moz-range-thumb]:cursor-pointer"),style:{background:`linear-gradient(to right, ${g.primary} ${y}%, ${g.sliderTrack} ${y}%)`,"--thumb-color":g.sliderThumb}}),m.jsx("style",{children:` + input[type="range"]::-webkit-slider-thumb { + background-color: ${g.sliderThumb}; + } + input[type="range"]::-moz-range-thumb { + background-color: ${g.sliderThumb}; + } + `})]})]})})})}function Nf({coverageCount:a,repeaterCount:c,lastUpdated:g}){const{theme:x}=Mn(),y=Kn();return m.jsxs("div",{className:"grid grid-cols-3 gap-2 p-3 rounded-lg border",style:{backgroundColor:x.bgSubtle,borderColor:x.border},children:[m.jsxs("div",{className:"text-center",children:[m.jsx(Ei,{value:a,format:{useGrouping:!0,maximumFractionDigits:0},className:"text-lg font-semibold tabular-nums block",style:{color:x.text}}),m.jsx("div",{className:"text-xs mt-0.5",style:{color:x.textMuted},children:"Points"})]}),m.jsxs("div",{className:"text-center border-x",style:{borderColor:x.border},children:[m.jsx(Ei,{value:c,format:{useGrouping:!0,maximumFractionDigits:0},className:"text-lg font-semibold tabular-nums block",style:{color:x.text}}),m.jsx("div",{className:"text-xs mt-0.5",style:{color:x.textMuted},children:"Repeaters"})]}),m.jsxs("div",{className:"text-center",children:[m.jsxs("div",{className:"flex items-center justify-center gap-1",children:[m.jsx(Jo,{className:"w-3.5 h-3.5",style:{color:x.textMuted}}),m.jsx("span",{className:"text-lg font-semibold tabular-nums",style:{color:x.text},children:g?Ia(g,y):"—"})]}),m.jsx("div",{className:"text-xs mt-0.5",style:{color:x.textMuted},children:"Updated"})]})]})}function Yi({icon:a,label:c,onClick:g,disabled:x,variant:y="default",active:b}){const{theme:D,isLight:P}=Mn(),B=R.useMemo(()=>y==="danger"?{text:D.error,hoverBg:P?"rgba(220, 38, 38, 0.08)":"rgba(239, 68, 68, 0.15)"}:{text:b?D.primary:D.textSecondary,hoverBg:D.hoverBg},[y,b,D,P]);return m.jsxs("button",{onClick:g,disabled:x,className:Cn("flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-sm font-medium transition-colors",x&&"opacity-50 cursor-not-allowed"),style:{color:B.text},onMouseEnter:E=>!x&&(E.currentTarget.style.backgroundColor=B.hoverBg),onMouseLeave:E=>E.currentTarget.style.backgroundColor="transparent",children:[a,m.jsx("span",{children:c})]})}function Ff(){const a=Lo(),c=a==="light",g=c?jf:cl,{isModalOpen:x,closeModal:y,status:b,isVisible:D,stats:P,error:B,url:E,brightness:T,loadCoverage:Q,clearCoverage:z,toggleVisibility:U,setUrl:W,setBrightness:$}=w0(),sA=b==="connecting"||b==="loading"||b==="processing",AA=P.coverageCount>0,[J,fA]=R.useState(!0),[uA,TA]=R.useState(E);R.useEffect(()=>{TA(E)},[E]),R.useEffect(()=>{b==="error"&&fA(!0)},[b]);const lA=R.useCallback(async()=>{await Q(uA)},[uA,Q]),iA=R.useCallback(()=>{TA(""),z()},[z]),EA=R.useCallback(bA=>{TA(bA),W(bA)},[W]),MA=R.useCallback(()=>{sA||y()},[sA,y]),xA=uA.trim().length>0&&!sA;return m.jsx(fl.Provider,{value:{theme:g,isLight:c},children:m.jsxs(So,{open:x,onClose:MA,size:"md",bottomSheet:!0,basemapMode:a,children:[m.jsxs("div",{className:"flex items-center justify-between p-4 border-b",style:{borderColor:g.border},children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:g.bgSubtle,color:g.primary},children:m.jsx(No,{className:"w-5 h-5"})}),m.jsxs("div",{children:[m.jsx("h2",{className:"type-micro",style:{color:g.text},children:"Wardriving Coverage"}),m.jsx("p",{className:"text-xs",style:{color:g.textMuted},children:"RF coverage heatmap overlay"})]})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Tf,{status:b,hasData:AA}),!sA&&m.jsxs(m.Fragment,{children:[m.jsx("button",{onClick:MA,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium transition-base radius-inner active:bg-subtle-fill",style:{color:g.primary},children:"Done"}),m.jsx("button",{onClick:MA,className:"hidden sm:flex items-center justify-center p-2 rounded-lg transition-colors",style:{color:g.textMuted},onMouseEnter:bA=>{bA.currentTarget.style.color=g.text,bA.currentTarget.style.backgroundColor=g.hoverBg},onMouseLeave:bA=>{bA.currentTarget.style.color=g.textMuted,bA.currentTarget.style.backgroundColor="transparent"},"aria-label":"Close",children:m.jsx(Sn,{className:"w-5 h-5"})})]})]})]}),m.jsx(Dr,{children:sA&&m.jsx(Rf,{status:b})}),m.jsxs(Mo,{className:"space-y-4",children:[m.jsx(If,{value:uA,onChange:EA,onSubmit:lA,disabled:sA}),m.jsx(Dr,{children:b==="error"&&B&&J&&m.jsx(Wi,{variant:"error",title:"Connection Failed",description:B,onDismiss:()=>fA(!1)})}),m.jsx(Dr,{children:b==="success"&&AA&&m.jsx(Wi,{variant:"success",title:"Coverage Data Loaded",description:"Adjust opacity below, then close to view on map"})}),m.jsx(Dr,{children:AA&&!sA&&m.jsx(tr.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:En.snappy,children:m.jsx(Nf,{coverageCount:P.coverageCount,repeaterCount:P.repeaterCount,lastUpdated:P.lastUpdated})})}),m.jsx(Dr,{children:AA&&!sA&&m.jsx(Lf,{value:T,onChange:$})})]}),m.jsxs("div",{className:"flex items-center justify-between p-4 border-t",style:{borderColor:g.border},children:[m.jsx("div",{className:"flex items-center gap-1",children:m.jsx(Dr,{children:AA&&m.jsxs(tr.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:-10},transition:En.snappy,className:"flex items-center gap-1",children:[m.jsx(Yi,{icon:D?m.jsx(Cu,{className:"w-4 h-4"}):m.jsx($o,{className:"w-4 h-4"}),label:D?"Hide":"Show",onClick:U,disabled:sA,active:D}),m.jsx(Yi,{icon:m.jsx(Iu,{className:"w-4 h-4"}),label:"Clear",onClick:iA,disabled:sA,variant:"danger"})]})})}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Qt,{plain:!0,color:"muted",onClick:MA,disabled:sA,children:AA?"Done":"Cancel"}),m.jsx(Qt,{color:"warning",onClick:lA,disabled:!xA,children:sA?m.jsxs(m.Fragment,{children:[m.jsx(J0,{"data-slot":"icon",className:"animate-spin"}),b==="connecting"?"Connecting...":b==="loading"?"Loading...":"Processing..."]}):AA?m.jsxs(m.Fragment,{children:[m.jsx(_o,{"data-slot":"icon"}),"Refresh"]}):m.jsxs(m.Fragment,{children:[m.jsx(Bo,{"data-slot":"icon"}),"Connect"]})})]})]})]})})}const Pf={bandwidth:.07,threshold:.1,opacity:1,strokeWidth:4.5};function P0({label:a,value:c,min:g,max:x,step:y,unit:b,formatValue:D,onChange:P}){const B=D?D(c):c.toFixed(2);return m.jsxs("div",{className:"flex items-center gap-2 sm:gap-2",children:[m.jsx("span",{className:"text-xs font-medium w-14 sm:w-16 shrink-0 text-fg-secondary",children:a}),m.jsx("input",{type:"range",min:g,max:x,step:y,value:c,onChange:E=>P(parseFloat(E.target.value)),className:`flex-1 h-1.5 rounded-full appearance-none cursor-pointer bg-elevated + [&::-webkit-slider-thumb]:appearance-none + [&::-webkit-slider-thumb]:w-3.5 + [&::-webkit-slider-thumb]:h-3.5 + [&::-webkit-slider-thumb]:rounded-full + [&::-webkit-slider-thumb]:bg-sys-indigo + [&::-webkit-slider-thumb]:cursor-pointer + [&::-webkit-slider-thumb]:transition-transform + [&::-webkit-slider-thumb]:hover:scale-110 + [&::-webkit-slider-thumb]:shadow-md`}),m.jsxs("span",{className:"text-xs font-mono tabular-nums w-12 sm:w-14 text-right shrink-0 text-fg-muted",children:[B,b&&m.jsx("span",{className:"ml-0.5 opacity-70",children:b})]})]})}function Q0({icon:a,label:c,value:g,subtext:x}){return m.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 py-0.5 sm:py-1",children:[m.jsx("div",{className:"text-fg-muted",children:a}),m.jsx("div",{className:"flex-1 min-w-0",children:m.jsx("div",{className:"text-[10px] sm:text-xs truncate text-fg-secondary",children:c})}),m.jsxs("div",{className:"text-right",children:[m.jsx("div",{className:"text-xs font-mono tabular-nums text-fg-primary",children:g}),x&&m.jsx("div",{className:"text-[9px] leading-tight opacity-70 text-fg-muted",children:x})]})]})}function Qf({visible:a,onClose:c,settings:g,onSettingsChange:x,partition:y,totalNodes:b,basemapMode:D="dark"}){const P=Eu(),B=R.useRef(null),E=Kn(),T=R.useMemo(()=>{if(!y)return{numCommunities:0,avgCommunitySize:0,minCommunitySize:0,maxCommunitySize:0,fiedlerValue:0,modularity:0,coveragePercent:0};const U=Array.from(y.communities.values()).map($=>$.length),W=U.reduce(($,sA)=>$+sA,0);return{numCommunities:y.numCommunities,avgCommunitySize:U.length>0?Math.round(W/U.length):0,minCommunitySize:U.length>0?Math.min(...U):0,maxCommunitySize:U.length>0?Math.max(...U):0,fiedlerValue:y.fiedlerValue,modularity:0,coveragePercent:b>0?Math.round(W/b*100):0}},[y,b]),Q=(U,W)=>{x({...g,[U]:W})},z=Fo(g.bandwidth*111e3,E,{maximumFractionDigits:1});return m.jsx("div",{ref:B,className:"absolute inset-0 z-[600] pointer-events-none",children:m.jsx(Dr,{children:a&&m.jsx(tr.div,{drag:!0,dragControls:P,dragConstraints:B,dragElastic:.1,dragMomentum:!1,initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:En.smooth,className:` + absolute pointer-events-auto + /* Mobile: bottom sheet style, full width with margins */ + bottom-2 left-2 right-2 + /* sm+: floating panel in bottom-right */ + sm:bottom-16 sm:left-auto sm:right-3 sm:w-64 + /* md+: slightly wider */ + md:w-72 + `,style:{touchAction:"none"},children:m.jsxs("div",{className:` + map-control-surface rounded-lg overflow-hidden shadow-lg + /* Mobile: limit height, allow scroll */ + max-h-[45vh] sm:max-h-[calc(100vh-180px)] overflow-y-auto + /* iOS momentum scrolling */ + overscroll-contain + `,children:[m.jsxs("div",{className:` + flex items-center justify-between + px-3 py-2 sm:px-2.5 sm:py-1.5 + border-b border-edge-subtle + cursor-grab active:cursor-grabbing + min-h-[44px] sm:min-h-0 + `,onPointerDown:U=>P.start(U),children:[m.jsxs("div",{className:"flex items-center gap-2 sm:gap-1.5",children:[m.jsx(Su,{className:"w-4 h-4 sm:w-3 sm:h-3 text-fg-muted"}),m.jsx(js,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5 text-sys-blue"}),m.jsx("span",{className:"text-sm sm:text-xs font-medium text-fg-primary",children:"Partition"})]}),m.jsx(Qt,{plain:!0,color:"muted",onClick:c,className:"!p-1.5 sm:!p-0.5 !rounded min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center","aria-label":"Close toolbox",children:m.jsx(Sn,{className:"w-4 h-4 sm:w-3 sm:h-3"})})]}),m.jsx("div",{className:"px-3 py-2 sm:px-2.5 sm:py-1.5 border-b border-edge-subtle",children:m.jsxs("div",{className:"grid grid-cols-2 gap-x-4 sm:gap-x-3 gap-y-1 sm:gap-y-0.5",children:[m.jsx(Q0,{icon:m.jsx(js,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Communities",value:T.numCommunities}),m.jsx(Q0,{icon:m.jsx(vi,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Avg Size",value:T.avgCommunitySize,subtext:`${T.minCommunitySize}–${T.maxCommunitySize}`}),m.jsx(Q0,{icon:m.jsx(lc,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Fiedler λ₂",value:T.fiedlerValue.toFixed(3)}),m.jsx(Q0,{icon:m.jsx(vi,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Coverage",value:`${T.coveragePercent}%`,subtext:`of ${b}`})]})}),m.jsx("div",{className:"px-3 py-2 sm:px-2.5 sm:py-1.5",children:m.jsxs("div",{className:"space-y-3 sm:space-y-1.5",children:[m.jsx(P0,{label:"Bandwidth",value:g.bandwidth,min:.01,max:.15,step:.005,formatValue:()=>z,onChange:U=>Q("bandwidth",U)}),m.jsx(P0,{label:"Threshold",value:g.threshold,min:.05,max:.5,step:.01,formatValue:U=>`${Math.round((1-U)*100)}%`,unit:"cov",onChange:U=>Q("threshold",U)}),m.jsx(P0,{label:"Opacity",value:g.opacity,min:.1,max:1,step:.05,formatValue:U=>`${Math.round(U*100)}%`,onChange:U=>Q("opacity",U)}),m.jsx(P0,{label:"Stroke",value:g.strokeWidth,min:0,max:5,step:.5,unit:"px",formatValue:U=>U.toFixed(1),onChange:U=>Q("strokeWidth",U)})]})})]})})})})}const Of={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-signal-poor",critical:"text-signal-critical"};function v0(a,c){return Of[Oo(a,c)]}const zf={backgroundColor:"var(--map-ui-hover, var(--elevated))",color:"var(--map-ui-text, var(--fg-primary))",boxShadow:"inset 0 0 0 1px var(--map-ui-border-strong, var(--edge-strong))"},Hf={backgroundColor:"var(--map-ui-bg, var(--body))",color:"var(--map-ui-text, var(--fg-primary))",boxShadow:"0 1px 4px rgba(0,0,0,0.15), inset 0 0 0 1px var(--map-ui-border, var(--edge-subtle))"};function Gn({prefix:a,name:c}){const g=R.useRef(null),[x,y]=R.useState(!1),[b,D]=R.useState({top:0,left:0}),P=()=>{if(!c||!g.current)return;const B=g.current.getBoundingClientRect();D({top:B.top-4,left:B.left+B.width/2}),y(!0)};return m.jsxs(m.Fragment,{children:[m.jsx("span",{ref:g,className:"inline-flex items-center px-1.5 py-0.5 rounded font-mono text-[10px] font-semibold transition-opacity hover:opacity-80 cursor-default",style:zf,onMouseEnter:P,onMouseLeave:()=>y(!1),children:a}),c&&x&&za.createPortal(m.jsx("span",{className:"fixed z-[9999] pointer-events-none -translate-x-1/2 -translate-y-full whitespace-nowrap rounded px-1.5 py-0.5 text-[10px] font-medium",style:{...Hf,top:b.top,left:b.left},children:c}),document.body)]})}function hl(a){if(a._tracePathHashes)return a._tracePathHashes;if(a.payload&&a.payload.length>=20){const c=parseInt(a.payload.slice(16,18),16),x=(isNaN(c)?1:1<<(c&3))*2,y=a.payload.slice(18),b=[];for(let D=0;D+x<=y.length;D+=x)b.push(y.slice(D,D+x).toUpperCase());return b.length>0?b:null}return null}function dl(a,c){return a.src_hash?[a.src_hash.replace(/^0x/i,"").slice(0,2).toUpperCase(),...c.map(x=>x.toUpperCase())]:c.map(g=>g.toUpperCase())}function Gf(a,c,g,x=15){const y=[],b=c.toUpperCase(),D=g.toUpperCase();for(const P of a){if((P.type??P.payload_type)!==Oa.TRACE)continue;const E=hl(P);if(!E||E.length<1)continue;const T=dl(P,E);if(!(T.length<2)){for(let Q=0;Q=x)break}}return y}function Uf(a){switch(a){case"improving":return m.jsx(Ga,{className:"w-3 h-3 text-sys-green"});case"degrading":return m.jsx(fc,{className:"w-3 h-3 text-sys-red"});case"stable":return m.jsx(Ro,{className:"w-3 h-3 text-fg-muted"});default:return null}}const Vf={backgroundColor:"var(--map-ui-stripe)"};function Y0({label:a,value:c,unit:g,color:x,tooltip:y}){return m.jsxs("div",{className:`flex items-center justify-between gap-2 py-[3px] ${y?"cursor-help":""}`,title:y,children:[m.jsx("span",{className:"type-data-xs text-fg-muted",children:a}),m.jsxs("span",{className:`data-box data-box-compact ${x||""}`,children:[c,g&&m.jsx("span",{className:"text-fg-muted ml-0.5",children:g})]})]})}function Ki({stats:a,direction:c,sf:g,noiseFloor:x}){if(!a)return m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"flex items-center justify-between mb-1.5",children:m.jsx("p",{className:"type-data-xs text-fg-secondary font-medium",children:c})}),m.jsx("p",{className:"type-data-xs text-fg-muted italic px-1.5",children:"No data"})]});const y=a.max-a.min,b=a.median-a.mean,D=Ha(g),P=a.mean-D,B=Oo(a.mean,g),E=[`Mean SNR: ${a.mean.toFixed(1)} dB (${B}) from ${a.count} measurement${a.count!==1?"s":""}`,`Variability: ±${a.stdDev.toFixed(1)} dB`,"",`Link budget (SF${g}, 3.5 dBi omni):`,` Demod threshold: ${D.toFixed(1)} dB`,` SNR margin: ${P>=0?"+":""}${P.toFixed(1)} dB`];return x!=null&&E.push(` Noise floor: ${x} dBm`),m.jsxs("div",{className:"min-w-0",children:[m.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[m.jsx("p",{className:"type-data-xs text-fg-secondary font-medium",children:c}),m.jsxs("span",{className:"type-data-xs text-fg-muted tabular-nums",title:`${a.count} measurement${a.count!==1?"s":""}`,children:["n=",a.count]})]}),m.jsx(Y0,{label:"Mean",value:a.mean.toFixed(1),unit:"dB",color:v0(a.mean,g),tooltip:E.join(` +`)}),m.jsx(Y0,{label:"Median",value:a.median.toFixed(1),unit:"dB",tooltip:`Middle value — less affected by unusual readings than the average.${Math.abs(b)>=.15?` +Differs from mean by ${b>0?"+":""}${b.toFixed(1)} dB`:""}`}),m.jsx(Y0,{label:"Range",value:`${a.min.toFixed(1)}–${a.max.toFixed(1)}`,unit:"dB",tooltip:`Best to worst signal observed. Total spread: ${y.toFixed(1)} dB.`})]})}function Wf({pair:a,onClose:c,prefixToName:g}){var lA,iA,EA,MA,xA,bA,IA,kA,LA,HA,wA,vA;const x=Po(),y=La(),b=Na(),D=Fa(),P=Kn(),[B,E]=R.useState(null),T=((iA=(lA=b==null?void 0:b.config)==null?void 0:lA.radio)==null?void 0:iA.spreading_factor)??Pa,Q=R.useMemo(()=>{const aA=`${a.nodeA.hash}>${a.nodeB.hash}`,_A=`${a.nodeB.hash}>${a.nodeA.hash}`;return{forward:x.get(aA)??null,reverse:x.get(_A)??null}},[x,a.nodeA.hash,a.nodeB.hash]),z=R.useMemo(()=>!y||y.length===0?[]:Gf(y,a.nodeA.prefix,a.nodeB.prefix),[y,a.nodeA.prefix,a.nodeB.prefix]),U=a.nodeA.name||(g==null?void 0:g.get(a.nodeA.prefix.toUpperCase()))||null,W=a.nodeB.name||(g==null?void 0:g.get(a.nodeB.prefix.toUpperCase()))||null,$=((EA=Q.forward)==null?void 0:EA.trend)??((MA=Q.reverse)==null?void 0:MA.trend)??"insufficient",sA=Math.max(((xA=Q.forward)==null?void 0:xA.lastSeen)??0,((bA=Q.reverse)==null?void 0:bA.lastSeen)??0),AA=(((IA=Q.forward)==null?void 0:IA.uniqueTraceCount)??0)+(((kA=Q.reverse)==null?void 0:kA.uniqueTraceCount)??0),J=$==="insufficient"?"Not enough data to determine trend (need at least 4 measurements).":`Whether signal quality is getting better or worse over time. +Compares older measurements to newer ones.`,fA=((LA=Q.forward)==null?void 0:LA.uniqueTraceCount)??0,uA=((HA=Q.reverse)==null?void 0:HA.uniqueTraceCount)??0,TA=["Number of trace packets that traveled through this link.",`${a.nodeA.prefix}→${a.nodeB.prefix}: ${fA}`,`${a.nodeB.prefix}→${a.nodeA.prefix}: ${uA}`].join(` +`);return m.jsx("div",{className:` + absolute z-[700] overflow-hidden + /* Mobile: full-width bottom sheet with breathing room */ + bottom-2 left-2 right-2 + /* sm+: right-aligned floating panel */ + sm:bottom-16 sm:left-auto sm:right-4 sm:w-[280px] + `,children:m.jsxs("div",{className:` + map-control-surface flex flex-col + /* Mobile: cap at 45vh so map stays visible */ + max-h-[45vh] + /* sm+: taller allowance */ + sm:max-h-[420px] + `,children:[m.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 sm:py-2 min-h-[44px] sm:min-h-0 border-b border-edge-subtle",children:[m.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[m.jsx(sl,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5 text-sys-green shrink-0"}),m.jsx(Gn,{prefix:a.nodeA.prefix,name:U}),m.jsx("span",{className:"type-data-xs text-fg-muted",children:"↔"}),m.jsx(Gn,{prefix:a.nodeB.prefix,name:W})]}),m.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[sA>0&&m.jsx("span",{className:"type-data-xs text-fg-muted",title:bi(sA,P),children:Qo(sA)}),m.jsx(Qt,{plain:!0,color:"muted",onClick:c,className:"!p-1.5 sm:!p-0.5 !rounded-md min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center",children:m.jsx(Sn,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5"})})]})]}),m.jsxs("div",{className:"px-3 py-2.5 border-b border-edge-subtle",children:[m.jsxs("div",{className:"space-y-1.5 mb-2",children:[m.jsxs("div",{className:"flex items-center justify-between cursor-help",title:`${a.nodeA.prefix}→${a.nodeB.prefix}: mean of ${((wA=a.aToB)==null?void 0:wA.count)??0} measurements`,children:[m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx(Gn,{prefix:a.nodeA.prefix,name:U}),m.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),m.jsx(Gn,{prefix:a.nodeB.prefix,name:W})]}),a.aToB?m.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${v0(a.aToB.mean,T)}`,children:[a.aToB.mean.toFixed(1),m.jsx("span",{className:"text-fg-muted font-normal ml-0.5",children:"dB"})]}):m.jsx("span",{className:"type-data-sm text-fg-muted",children:"—"})]}),m.jsxs("div",{className:"flex items-center justify-between cursor-help",title:`${a.nodeB.prefix}→${a.nodeA.prefix}: mean of ${((vA=a.bToA)==null?void 0:vA.count)??0} measurements`,children:[m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx(Gn,{prefix:a.nodeB.prefix,name:W}),m.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),m.jsx(Gn,{prefix:a.nodeA.prefix,name:U})]}),a.bToA?m.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${v0(a.bToA.mean,T)}`,children:[a.bToA.mean.toFixed(1),m.jsx("span",{className:"text-fg-muted font-normal ml-0.5",children:"dB"})]}):m.jsx("span",{className:"type-data-sm text-fg-muted",children:"—"})]})]}),m.jsxs("div",{className:"grid grid-cols-2 gap-0 -mx-3 border-t border-edge-subtle",children:[m.jsx("div",{className:"px-3 pt-2 pb-1 border-r border-edge-subtle",children:m.jsx(Ki,{stats:a.aToB,direction:`${a.nodeA.prefix}→${a.nodeB.prefix}`,sf:T,noiseFloor:D})}),m.jsx("div",{className:"px-3 pt-2 pb-1",children:m.jsx(Ki,{stats:a.bToA,direction:`${a.nodeB.prefix}→${a.nodeA.prefix}`,sf:T,noiseFloor:D})})]})]}),m.jsxs("div",{className:"px-3 py-1.5 border-b border-edge-subtle",children:[$!=="insufficient"&&m.jsxs("div",{className:"flex items-center justify-between gap-2 py-[3px] cursor-help",title:J,children:[m.jsx("span",{className:"type-data-xs text-fg-muted",children:"Trend"}),m.jsx("span",{className:"data-box data-box-compact",children:m.jsxs("span",{className:"flex items-center gap-1",children:[Uf($),m.jsx("span",{className:"text-fg-secondary capitalize",children:$})]})})]}),AA>0&&m.jsx(Y0,{label:"Unique traces",value:AA.toString(),tooltip:TA})]}),z.length>0&&m.jsxs("div",{className:"px-3 py-2 flex-1 min-h-0 flex flex-col",children:[m.jsxs("p",{className:"type-micro text-fg-secondary mb-1 shrink-0",children:["Source packets (",z.length,")"]}),m.jsx("div",{className:"overflow-y-auto flex-1 min-h-0 overscroll-contain",style:{scrollbarGutter:"stable"},children:z.map((aA,_A)=>{const FA=hl(aA),zA=FA?dl(aA,FA):null,qA=zA?Math.max(0,zA.length-1):0,XA=zA?zA.map(De=>(g==null?void 0:g.get(De))??De).join(" → "):null,VA=B===_A,KA=aA.id??`${aA.packet_hash}-${aA.timestamp}`;return m.jsxs("div",{className:"rounded-sm",style:_A%2===1?Vf:void 0,children:[m.jsxs("button",{onClick:()=>E(VA?null:_A),className:"flex items-center gap-1.5 py-[3px] px-1 w-full text-left text-[10px] font-mono text-fg-secondary hover:text-fg-primary transition-colors group",children:[VA?m.jsx(To,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"}):m.jsx(Pu,{className:"w-2.5 h-2.5 text-fg-muted shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),m.jsx("span",{className:"text-fg-muted w-[52px] shrink-0",children:bi(aA.timestamp,P)}),XA?m.jsx("span",{className:"text-fg-secondary truncate min-w-0",title:zA.join(" → "),children:XA}):m.jsx("span",{className:"text-fg-muted truncate min-w-0 italic",children:"path n/a"}),m.jsxs("span",{className:"text-fg-muted shrink-0",children:[qA,"h"]}),aA.snr!=null&&m.jsx("span",{className:`shrink-0 tabular-nums ${v0(aA.snr,T)}`,children:aA.snr.toFixed(1)})]}),VA&&m.jsxs("div",{className:"mb-1 mt-0.5 mx-1 pl-2 border-l border-edge-subtle space-y-0.5 text-[10px]",children:[aA.rssi!=null&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"RSSI"}),m.jsxs("span",{className:"font-mono tabular-nums text-fg-secondary",children:[aA.rssi," dBm"]})]}),aA.snr!=null&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"SNR"}),m.jsxs("span",{className:`font-mono tabular-nums ${v0(aA.snr,T)}`,children:[aA.snr.toFixed(1)," dB"]})]}),m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"Route"}),m.jsx("span",{className:"font-mono text-fg-secondary",children:Qa(aA.route??aA.route_type)})]}),aA.packet_hash&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"Hash"}),m.jsxs("button",{onClick:De=>{De.stopPropagation(),es(aA.packet_hash)},className:"flex items-center gap-1 font-mono text-fg-secondary hover:text-fg-primary transition-colors",title:"Copy packet hash",children:[m.jsx("span",{className:"truncate max-w-[120px]",children:aA.packet_hash}),m.jsx(As,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"})]})]}),aA.src_hash&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"Source"}),m.jsx("span",{className:"font-mono text-fg-secondary truncate max-w-[140px]",title:aA.src_hash,children:aA.src_hash})]}),zA&&zA.length>0&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"Path"}),m.jsx("span",{className:"font-mono text-fg-secondary truncate max-w-[140px]",title:zA.join(" → "),children:zA.join(" → ")})]})]})]},KA)})})]})]})})}function Yf({channels:a,messages:c}){const g=R.useMemo(()=>a.find(b=>b.name.toLowerCase().includes("wardrive"))??null,[a]),x=R.useMemo(()=>g?c.get(`ch:${g.index}`)??[]:[],[g,c]);if(!g||x.length===0)return null;const y=()=>{const b=Hu(x);b.length>=2&&Ks.getState().startRewind(b,"contacts-map")};return m.jsxs("button",{onClick:y,className:"map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base",style:{padding:"0.5rem 0.625rem"},title:`Replay #wardrive journey (${x.length} msgs)`,"aria-label":"Replay #wardrive journey",children:[m.jsx(sc,{className:"w-3.5 h-3.5 shrink-0 text-fg-secondary"}),m.jsx("span",{className:"text-fg-secondary",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:500,letterSpacing:"-0.01em",lineHeight:1},children:"Replay"}),m.jsx("span",{className:"ml-auto text-fg-muted tabular-nums",style:{fontSize:"0.625rem"},children:x.length})]})}function Kf(){const a=Ys(),c=Xo(),g=Al(),x=Qu(),y=Ou(),{togglePlay:b,setSpeed:D,seek:P,stopRewind:B}=Ks.getState(),E=y.end-y.start,T=y.end-g,Q=E>0?(g-y.start)/E:1,z=R.useCallback(U=>{const W=parseFloat(U.target.value)/100;P(y.start+W*E)},[P,y.start,E]);return a?m.jsx("div",{className:"absolute bottom-3 left-3 right-3 z-[700] sm:bottom-4 sm:left-4 sm:right-4",children:m.jsxs("div",{className:"map-control-surface flex items-center gap-2 px-2.5 py-2 sm:gap-3 sm:px-3",children:[m.jsx("button",{onClick:B,className:"p-1 rounded text-fg-muted hover:text-fg-primary hover:bg-[var(--map-ui-hover,var(--elevated))] transition-colors shrink-0",title:"Stop rewind","aria-label":"Stop rewind",children:m.jsx(Sn,{className:"w-3.5 h-3.5"})}),m.jsx("button",{onClick:b,className:"p-1.5 rounded-full bg-sys-blue/20 text-sys-blue hover:bg-sys-blue/30 transition-colors shrink-0",title:c?"Pause":"Rewind","aria-label":c?"Pause rewind":"Rewind",children:c?m.jsx(Ua,{className:"w-3.5 h-3.5"}):m.jsx(Va,{className:"w-3.5 h-3.5"})}),m.jsx("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:m.jsx("input",{type:"range",min:0,max:100,step:.1,value:Q*100,onChange:z,className:"replay-scrubber w-full h-1 appearance-none bg-edge-subtle rounded-full cursor-pointer","aria-label":"Replay timeline","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(Q*100)})}),m.jsxs("span",{className:"text-[10px] sm:text-xs tabular-nums text-fg-muted whitespace-nowrap shrink-0",children:["-",Mi(T)," / ",Mi(E)]}),m.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:zu.map(U=>m.jsxs("button",{onClick:()=>D(U),className:Cn("px-1.5 py-0.5 rounded text-[10px] sm:text-xs font-medium transition-colors",U===x?"bg-sys-blue/20 text-sys-blue shadow-[inset_0_0_0_1px_var(--sys-blue)]":"text-fg-muted hover:text-fg-secondary hover:bg-[var(--map-ui-hover,var(--elevated))]"),title:`${U}× speed`,"aria-label":`${U} times speed`,"aria-pressed":U===x,children:[U,"×"]},U))})]})}):null}const ml=[{target:"Sparklines",fn:"sparklines",minStage:2}];Zo(ml);const pl=R.memo(function({nodeHash:c,width:g=60,height:x=20,color:y,showArea:b=!0,showTooltip:D=!1,className:P=""}){Ko(ml);const B=Wa(c),E=Ya(),Q=!zo().backgroundLoadComplete||E,z=typeof g=="number"?g:60;return m.jsx(Yu,{data:B,width:z,height:x,color:y,isLoading:Q,className:P})});function Zf({txDelayRec:a,networkRole:c,roleTitles:g,dataConfidence:x,dataQualityTitles:y}){const[b,D]=R.useState(!1),P=a.floodFactor??a.txDelayFactor,B=a.directFactor??a.directTxDelayFactor,E=async()=>{const T=`set txdelay ${P.toFixed(1)} +set direct.txdelay ${B.toFixed(1)}`;await es(T),D(!0),setTimeout(()=>D(!1),1500)};return m.jsxs("div",{className:"flex flex-col gap-1.5 text-sm",children:[(c||x)&&m.jsxs("div",{className:"flex items-center gap-2",children:[c&&m.jsx(wt,{color:Zu[c],compact:!0,title:g[c],children:c}),x&&m.jsxs(wt,{color:$u[x],compact:!0,title:y[x],children:[x," data"]})]}),m.jsxs("button",{onClick:E,className:"flex items-center gap-2 py-1.5 px-2 bg-subtle-fill hover:bg-subtle-fill-hover rounded transition-colors group",title:"Click to copy CLI commands",children:[m.jsx(Ju,{className:"w-3.5 h-3.5 text-sys-amber shrink-0"}),m.jsx("span",{className:"text-fg-muted",children:"TxDelay"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"text-fg-muted",children:"F"}),m.jsxs("span",{className:"data-box text-sys-amber",children:["×",P.toFixed(1)]})]}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"text-fg-muted",children:"D"}),m.jsxs("span",{className:"data-box text-sys-amber",children:["×",B.toFixed(1)]})]})]}),b?m.jsx(Yn,{className:"w-3.5 h-3.5 text-sys-green ml-auto"}):m.jsx(As,{className:"w-3.5 h-3.5 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity ml-auto"})]})]})}function $f({hash:a,hashPrefix:c,name:g,isHub:x,isGateway:y,isBackbone:b,isZeroHop:D,isMobile:P,isRoomServer:B,isStale:E,lastSeenTimestamp:T,centrality:Q,affinity:z,meanSnr:U,meanRssi:W,neighbor:$,onRemove:sA,txDelayRec:AA,hideHeader:J=!1}){const[fA,uA]=R.useState(!1),TA=Kn(),lA=$.last_seen?new Date($.last_seen*1e3):null,iA=async()=>{await es(a),uA(!0),setTimeout(()=>uA(!1),1500)},EA=D?"Direct":z!=null&&z.typicalHopPosition?`${z.typicalHopPosition}-hop`:null,MA=AA&&!AA.insufficientData,xA={hub:"Hub: High-connectivity node that bridges many paths",backbone:"Backbone: Critical relay with high traffic",relay:"Relay: Standard forwarding node",edge:"Edge: Peripheral node"},bA={high:"1000+ packets",medium:"500-999 packets",low:"100-499 packets",insufficient:"Insufficient data"};return m.jsxs("div",{children:[!J&&m.jsx("div",{className:"text-[14px] font-semibold text-fg-primary leading-tight truncate mb-1",children:g}),!J&&m.jsxs("div",{className:"flex items-center gap-1 flex-wrap mb-1.5",children:[m.jsx("code",{className:"type-data-xs text-fg-secondary bg-data-box-bg border border-data-box-border px-1 py-0.5 rounded",children:c}),m.jsx("button",{onClick:iA,className:"p-0.5 hover:bg-subtle-fill-hover rounded transition-colors",title:"Copy full hash",children:fA?m.jsx(Yn,{className:"w-3 h-3 text-sys-green"}):m.jsx(As,{className:"w-3 h-3 text-fg-secondary"})}),m.jsx(tl,{hash:a,size:"sm"}),EA&&m.jsx(wt,{color:D?Z0.direct:Z0.multihop,compact:!0,children:EA}),$.is_repeater&&m.jsx(wt,{color:fr.repeater,compact:!0,children:"Rptr"}),x&&m.jsx(wt,{color:fr.hub,compact:!0,title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),y&&!x&&m.jsx(wt,{color:fr.gateway,compact:!0,title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),b&&m.jsx(wt,{color:fr.backbone,compact:!0,title:"Backbone",children:"Bone"}),P&&m.jsx(wt,{color:fr.mobile,compact:!0,children:"Mobile"}),B&&m.jsx(wt,{color:fr.room,compact:!0,children:"Room"}),E&&T&&m.jsxs(wt,{compact:!0,title:"Neighbor not heard in 7+ days",children:["Idle ",Ho(new Date(T*1e3),TA,{month:"short",day:"numeric"})]})]}),m.jsx("div",{title:"7-day activity trend (6-hour buckets)",children:m.jsx(pl,{nodeHash:a,width:224,height:28,showArea:!0,showTooltip:!0,className:"w-full"})}),m.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 text-sm text-fg-secondary mt-2",children:[m.jsxs("span",{className:"flex items-center gap-0.5",title:lA?`Last heard: ${Ka(lA,TA,!1)}`:"Last heard time",children:[m.jsx(Jo,{className:"w-3 h-3 text-fg-muted shrink-0"}),m.jsx("span",{className:"font-mono",children:Qo($.last_seen)})]}),(z==null?void 0:z.distanceMeters)&&m.jsxs("span",{className:"flex items-center gap-0.5",title:"Line-of-sight distance from local node",children:[m.jsx(Ku,{className:"w-3 h-3 text-fg-muted shrink-0"}),m.jsx("span",{className:"font-mono font-semibold text-fg-primary",children:Fo(z.distanceMeters,TA,{compact:!0})})]}),$.latitude&&$.longitude&&$.latitude!==0&&$.longitude!==0&&m.jsxs("span",{className:"flex items-center gap-0.5",title:"GPS coordinates (lat, lon)",children:[m.jsx(qu,{className:"w-3 h-3 text-fg-muted shrink-0"}),m.jsxs("span",{className:"font-mono text-fg-muted",children:[$.latitude.toFixed(2),", ",$.longitude.toFixed(2)]})]})]}),m.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1.5 text-sm mt-2",children:[m.jsxs("div",{className:"flex justify-between items-center gap-2",title:"Total packets seen from this node",children:[m.jsx("span",{className:"text-fg-muted",children:"Packets"}),m.jsx("span",{className:"data-box",children:(z==null?void 0:z.frequency)||0})]}),m.jsxs("div",{className:"flex justify-between items-center gap-2",title:"ADVERT beacon packets received",children:[m.jsx("span",{className:"text-fg-muted",children:"Adverts"}),m.jsx("span",{className:"data-box",children:$.advert_count||0})]}),D&&U!==void 0&&m.jsxs("div",{className:"flex justify-between items-center gap-2",title:"Average Signal-to-Noise Ratio (direct zero-hop)",children:[m.jsx("span",{className:"text-fg-muted",children:"SNR"}),m.jsxs("span",{className:"data-box",children:[U.toFixed(1)," dB"]})]}),D&&W!==void 0&&m.jsxs("div",{className:"flex justify-between items-center gap-2",title:"Average Received Signal Strength (direct zero-hop)",children:[m.jsx("span",{className:"text-fg-muted",children:"RSSI"}),m.jsxs("span",{className:"data-box",children:[Math.round(W)," dBm"]})]})]}),MA&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"border-t border-edge-subtle mt-2.5 mb-2"}),m.jsx(Zf,{txDelayRec:AA,networkRole:AA.networkRole,roleTitles:xA,dataConfidence:AA.dataConfidence,dataQualityTitles:bA})]}),sA&&m.jsx("button",{onClick:sA,className:"w-full text-center text-sm mt-2 py-3 sm:py-1.5 rounded text-fg-muted hover:text-sys-red hover:bg-sys-red/10 transition-colors",children:"Remove from Contacts"})]})}function qf(a,c){return Ho(new Date(a*1e3),c,{month:"2-digit",day:"2-digit"})}function Jf({data:a,localNode:c,localColor:g,onClose:x,onRemove:y}){var T,Q,z,U;const[b,D]=R.useState(!1),P=Kn();R.useEffect(()=>{if(!a)return;const W=$=>{$.key==="Escape"&&x()};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[a,x]);const B=async()=>{a!=null&&a.hash&&(await es(a.hash),D(!0),setTimeout(()=>D(!1),1500))},E=a!=null&&a.isZeroHop?"Direct":(T=a==null?void 0:a.affinity)!=null&&T.typicalHopPosition?`${a.affinity.typicalHopPosition}-hop`:null;return m.jsx(Dr,{children:a&&m.jsx(tr.div,{className:"map-node-panel",initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:16},transition:En.smooth,children:m.jsxs("div",{className:"map-control-surface flex flex-col max-h-[38dvh] sm:max-h-[50vh]",children:[m.jsx("div",{className:"map-node-panel-drag-handle sm:hidden"}),m.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2.5 shrink-0",children:[m.jsxs("div",{className:"flex items-start justify-between gap-2",children:[m.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[m.jsx("span",{className:"text-sm font-semibold truncate text-fg-primary",children:a.name||"Unknown"}),a.hash&&m.jsxs(m.Fragment,{children:[m.jsx("code",{className:"type-data-xs text-fg-secondary bg-data-box-bg border border-data-box-border px-1 py-0.5 rounded ml-1",children:a.hashPrefix||a.hash.substring(0,2)}),m.jsx("button",{onClick:B,className:"p-2 -m-1.5 sm:p-0.5 sm:m-0 hover:bg-subtle-fill-hover rounded transition-colors",title:"Copy full hash",children:b?m.jsx(Yn,{className:"w-3 h-3 text-sys-green"}):m.jsx(As,{className:"w-3 h-3 text-fg-secondary"})}),m.jsx(tl,{hash:a.hash,size:"sm"})]})]}),m.jsx(Qt,{plain:!0,color:"muted",onClick:x,className:"!p-1 !rounded-md -mr-1 -mt-1 hover:bg-subtle-fill-hover min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center","aria-label":"Close node detail",children:m.jsx(Sn,{className:"w-4 h-4"})})]}),(E||((Q=a.neighbor)==null?void 0:Q.is_repeater)||a.isHub||a.isGateway&&!a.isHub||a.isBackbone||a.isMobile||a.isRoomServer||a.isStale&&a.lastSeenTimestamp)&&m.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[E&&m.jsx(wt,{color:a.isZeroHop?Z0.direct:Z0.multihop,compact:!0,title:a.isZeroHop?"Direct RF contact (zero-hop)":`${((z=a.affinity)==null?void 0:z.typicalHopPosition)??"?"} hops from local node`,children:E}),((U=a.neighbor)==null?void 0:U.is_repeater)&&m.jsx(wt,{color:fr.repeater,compact:!0,title:"Repeater node (forwards packets)",children:"Rptr"}),a.isHub&&m.jsx(wt,{color:fr.hub,compact:!0,title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),a.isGateway&&!a.isHub&&m.jsx(wt,{color:fr.gateway,compact:!0,title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),a.isBackbone&&m.jsx(wt,{color:fr.backbone,compact:!0,title:"Backbone: critical relay with high traffic",children:"Bone"}),a.isMobile&&m.jsx(wt,{color:fr.mobile,compact:!0,title:"Mobile repeater (path volatility detected)",children:"Mobile"}),a.isRoomServer&&m.jsx(wt,{color:fr.room,compact:!0,title:"Room server node",children:"Room"}),a.isStale&&a.lastSeenTimestamp&&m.jsxs(wt,{compact:!0,title:"Neighbor not heard in 7+ days",children:["Idle ",qf(a.lastSeenTimestamp,P)]})]})]}),m.jsx("div",{className:"overflow-y-auto flex-1 min-h-0 overscroll-contain px-3 pt-2 pb-3",children:a.isLocal?m.jsxs("div",{className:"text-sm",children:[m.jsx("div",{className:"mb-2",children:m.jsx("span",{style:{color:g},className:"font-medium",children:"This Node (Local)"})}),a.hash&&m.jsx("div",{className:"mb-2",children:m.jsx(pl,{nodeHash:a.hash,width:224,height:28,showArea:!0,showTooltip:!0,className:"w-full"})}),c&&m.jsxs("div",{className:"text-xs text-fg-muted font-mono border-t border-edge-subtle pt-2",children:[c.latitude.toFixed(5),", ",c.longitude.toFixed(5)]})]}):a.neighbor&&a.hash?m.jsx($f,{hash:a.hash,hashPrefix:a.hashPrefix,name:a.name,isHub:a.isHub,isGateway:a.isGateway,isBackbone:a.isBackbone,isZeroHop:a.isZeroHop,isMobile:a.isMobile,isRoomServer:a.isRoomServer,isStale:a.isStale,lastSeenTimestamp:a.lastSeenTimestamp,centrality:a.centrality,affinity:a.affinity,meanSnr:a.meanSnr,meanRssi:a.meanRssi,neighbor:a.neighbor,txDelayRec:a.txDelayRec,onRemove:y?()=>y(a.hash,a.name):void 0,hideHeader:!0}):null})]})})})}const Xf={getItem:a=>{try{return localStorage.getItem(a)}catch{return null}},setItem:(a,c)=>{try{localStorage.setItem(a,c)}catch{}},removeItem:a=>{try{localStorage.removeItem(a)}catch{}}},gl=Io()(Za(a=>({isEnabled:!1,toggle:()=>a(c=>({isEnabled:!c.isEnabled})),setEnabled:c=>a({isEnabled:c})}),{name:"pymc-live-trace",storage:$a(()=>Xf)})),A2=()=>gl(a=>a.isEnabled),e2=()=>gl(a=>a.toggle);var Ot=(function(a){a=a||{};var c=typeof a<"u"?a:{},g={},x;for(x in c)c.hasOwnProperty(x)&&(g[x]=c[x]);var y="";function b(tA){return c.locateFile?c.locateFile(tA,y):y+tA}var D;typeof document<"u"&&document.currentScript&&(y=document.currentScript.src),y.indexOf("blob:")!==0?y=y.substr(0,y.lastIndexOf("/")+1):y="",D=function(mA,RA,gA){var t=new XMLHttpRequest;t.open("GET",mA,!0),t.responseType="arraybuffer",t.onload=function(){if(t.status==200||t.status==0&&t.response){RA(t.response);return}var xe=dr(mA);if(xe){RA(xe.buffer);return}gA()},t.onerror=gA,t.send(null)};var P=c.print||console.log.bind(console),B=c.printErr||console.warn.bind(console);for(x in g)g.hasOwnProperty(x)&&(c[x]=g[x]);g=null,c.arguments&&c.arguments;var E=0,T=function(tA){E=tA},Q=function(){return E},z=8;function U(tA,mA,RA,gA){switch(RA=RA||"i8",RA.charAt(RA.length-1)==="*"&&(RA="i32"),RA){case"i1":IA[tA>>0]=mA;break;case"i8":IA[tA>>0]=mA;break;case"i16":LA[tA>>1]=mA;break;case"i32":HA[tA>>2]=mA;break;case"i64":zt=[mA>>>0,(Ze=mA,+Ee(Ze)>=1?Ze>0?(Le(+ge(Ze/4294967296),4294967295)|0)>>>0:~~+Me((Ze-+(~~Ze>>>0))/4294967296)>>>0:0)],HA[tA>>2]=zt[0],HA[tA+4>>2]=zt[1];break;case"float":wA[tA>>2]=mA;break;case"double":vA[tA>>3]=mA;break;default:Ht("invalid type for setValue: "+RA)}}function W(tA,mA,RA){switch(mA=mA||"i8",mA.charAt(mA.length-1)==="*"&&(mA="i32"),mA){case"i1":return IA[tA>>0];case"i8":return IA[tA>>0];case"i16":return LA[tA>>1];case"i32":return HA[tA>>2];case"i64":return HA[tA>>2];case"float":return wA[tA>>2];case"double":return vA[tA>>3];default:Ht("invalid type for getValue: "+mA)}return null}var $=!1;function sA(tA,mA){tA||Ht("Assertion failed: "+mA)}function AA(tA){var mA=c["_"+tA];return sA(mA,"Cannot call unknown function "+tA+", make sure it is exported"),mA}function J(tA,mA,RA,gA,t){var k={string:function(WA){var it=0;if(WA!=null&&WA!==0){var Dt=(WA.length<<2)+1;it=rr(Dt),EA(WA,it,Dt)}return it},array:function(WA){var it=rr(WA.length);return MA(WA,it),it}};function xe(WA){return mA==="string"?lA(WA):mA==="boolean"?!!WA:WA}var _e=AA(tA),$e=[],oe=0;if(gA)for(var fe=0;fe=gA);)++t;if(t-mA>16&&tA.subarray&&uA)return uA.decode(tA.subarray(mA,t));for(var k="";mA>10,56320|oe&1023)}}return k}function lA(tA,mA){return tA?TA(kA,tA,mA):""}function iA(tA,mA,RA,gA){if(!(gA>0))return 0;for(var t=RA,k=RA+gA-1,xe=0;xe=55296&&_e<=57343){var $e=tA.charCodeAt(++xe);_e=65536+((_e&1023)<<10)|$e&1023}if(_e<=127){if(RA>=k)break;mA[RA++]=_e}else if(_e<=2047){if(RA+1>=k)break;mA[RA++]=192|_e>>6,mA[RA++]=128|_e&63}else if(_e<=65535){if(RA+2>=k)break;mA[RA++]=224|_e>>12,mA[RA++]=128|_e>>6&63,mA[RA++]=128|_e&63}else{if(RA+3>=k)break;mA[RA++]=240|_e>>18,mA[RA++]=128|_e>>12&63,mA[RA++]=128|_e>>6&63,mA[RA++]=128|_e&63}}return mA[RA]=0,RA-t}function EA(tA,mA,RA){return iA(tA,kA,mA,RA)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function MA(tA,mA){IA.set(tA,mA)}function xA(tA,mA){return tA%mA>0&&(tA+=mA-tA%mA),tA}var bA,IA,kA,LA,HA,wA,vA;function aA(tA){bA=tA,c.HEAP8=IA=new Int8Array(tA),c.HEAP16=LA=new Int16Array(tA),c.HEAP32=HA=new Int32Array(tA),c.HEAPU8=kA=new Uint8Array(tA),c.HEAPU16=new Uint16Array(tA),c.HEAPU32=new Uint32Array(tA),c.HEAPF32=wA=new Float32Array(tA),c.HEAPF64=vA=new Float64Array(tA)}var _A=5271536,FA=28624,zA=c.TOTAL_MEMORY||33554432;c.buffer?bA=c.buffer:bA=new ArrayBuffer(zA),zA=bA.byteLength,aA(bA),HA[FA>>2]=_A;function qA(tA){for(;tA.length>0;){var mA=tA.shift();if(typeof mA=="function"){mA();continue}var RA=mA.func;typeof RA=="number"?mA.arg===void 0?c.dynCall_v(RA):c.dynCall_vi(RA,mA.arg):RA(mA.arg===void 0?null:mA.arg)}}var XA=[],VA=[],KA=[],De=[];function Ie(){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)Ye(c.preRun.shift());qA(XA)}function ue(){qA(VA)}function pe(){qA(KA)}function ke(){if(c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;)Te(c.postRun.shift());qA(De)}function Ye(tA){XA.unshift(tA)}function Te(tA){De.unshift(tA)}var Ee=Math.abs,Me=Math.ceil,ge=Math.floor,Le=Math.min,tt=0,At=null;function nt(tA){tt++,c.monitorRunDependencies&&c.monitorRunDependencies(tt)}function bt(tA){if(tt--,c.monitorRunDependencies&&c.monitorRunDependencies(tt),tt==0&&At){var mA=At;At=null,mA()}}c.preloadedImages={},c.preloadedAudios={};var Ke=null,st="data:application/octet-stream;base64,";function ye(tA){return String.prototype.startsWith?tA.startsWith(st):tA.indexOf(st)===0}var Ze,zt;Ke="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var kt=28640;function Yt(tA,mA,RA,gA){Ht("Assertion failed: "+lA(tA)+", at: "+[mA?lA(mA):"unknown filename",RA,gA?lA(gA):"unknown function"])}function Mt(){return IA.length}function Tr(tA,mA,RA){kA.set(kA.subarray(mA,mA+RA),tA)}function Rr(tA){return c.___errno_location&&(HA[c.___errno_location()>>2]=tA),tA}function hr(tA){Ht("OOM")}function Ir(tA){try{var mA=new ArrayBuffer(tA);return mA.byteLength!=tA?void 0:(new Int8Array(mA).set(IA),vr(mA),aA(mA),1)}catch{}}function xr(tA){var mA=Mt(),RA=16777216,gA=2147483648-RA;if(tA>gA)return!1;for(var t=16777216,k=Math.max(mA,t);k>4,t=(_e&15)<<4|$e>>2,k=($e&3)<<6|oe,RA=RA+String.fromCharCode(gA),$e!==64&&(RA=RA+String.fromCharCode(t)),oe!==64&&(RA=RA+String.fromCharCode(k));while(fe13780509?(A=S0(15,A)|0,A|0):(r=((e|0)<0)<<31>>31,s=yt(e|0,r|0,3,0)|0,n=S()|0,r=ZA(e|0,r|0,1,0)|0,r=yt(s|0,n|0,r|0,S()|0)|0,r=ZA(r|0,S()|0,1,0)|0,e=S()|0,t[A>>2]=r,t[A+4>>2]=e,A=0,A|0)}function v(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,j(e,A,r,n,0)|0}function j(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,u=0,f=0;if(u=C,C=C+16|0,o=u,!(O(e,A,r,n,s)|0))return n=0,C=u,n|0;do if((r|0)>=0){if((r|0)>13780509){if(i=S0(15,o)|0,i|0)break;l=o,o=t[l>>2]|0,l=t[l+4>>2]|0}else i=((r|0)<0)<<31>>31,f=yt(r|0,i|0,3,0)|0,l=S()|0,i=ZA(r|0,i|0,1,0)|0,i=yt(f|0,l|0,i|0,S()|0)|0,i=ZA(i|0,S()|0,1,0)|0,l=S()|0,t[o>>2]=i,t[o+4>>2]=l,o=i;if(Jr(n|0,0,o<<3|0)|0,s|0){Jr(s|0,0,o<<2|0)|0,i=X(e,A,r,n,s,o,l,0)|0;break}i=Wt(o,4)|0,i?(f=X(e,A,r,n,i,o,l,0)|0,$A(i),i=f):i=13}else i=2;while(!1);return f=i,C=u,f|0}function O(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0;if(G=C,C=C+16|0,L=G,N=G+8|0,I=L,t[I>>2]=e,t[I+4>>2]=A,(r|0)<0)return N=2,C=G,N|0;if(i=n,t[i>>2]=e,t[i+4>>2]=A,i=(s|0)!=0,i&&(t[s>>2]=0),Qe(e,A)|0)return N=9,C=G,N|0;t[N>>2]=0;A:do if((r|0)>=1)if(i)for(p=1,f=0,M=0,I=1,i=e;;){if(!(f|M)){if(i=K(i,A,4,N,L)|0,i|0)break A;if(A=L,i=t[A>>2]|0,A=t[A+4>>2]|0,Qe(i,A)|0){i=9;break A}}if(i=K(i,A,t[26800+(M<<2)>>2]|0,N,L)|0,i|0)break A;if(A=L,i=t[A>>2]|0,A=t[A+4>>2]|0,e=n+(p<<3)|0,t[e>>2]=i,t[e+4>>2]=A,t[s+(p<<2)>>2]=I,e=f+1|0,o=(e|0)==(I|0),l=M+1|0,u=(l|0)==6,Qe(i,A)|0){i=9;break A}if(I=I+(u&o&1)|0,(I|0)>(r|0)){i=0;break}else p=p+1|0,f=o?0:e,M=o?u?0:l:M}else for(p=1,f=0,M=0,I=1,i=e;;){if(!(f|M)){if(i=K(i,A,4,N,L)|0,i|0)break A;if(A=L,i=t[A>>2]|0,A=t[A+4>>2]|0,Qe(i,A)|0){i=9;break A}}if(i=K(i,A,t[26800+(M<<2)>>2]|0,N,L)|0,i|0)break A;if(A=L,i=t[A>>2]|0,A=t[A+4>>2]|0,e=n+(p<<3)|0,t[e>>2]=i,t[e+4>>2]=A,e=f+1|0,o=(e|0)==(I|0),l=M+1|0,u=(l|0)==6,Qe(i,A)|0){i=9;break A}if(I=I+(u&o&1)|0,(I|0)>(r|0)){i=0;break}else p=p+1|0,f=o?0:e,M=o?u?0:l:M}else i=0;while(!1);return N=i,C=G,N|0}function X(e,A,r,n,s,i,o,l){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,i=i|0,o=o|0,l=l|0;var u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0;if(G=C,C=C+16|0,L=G+8|0,N=G,u=Fn(e|0,A|0,i|0,o|0)|0,p=S()|0,M=n+(u<<3)|0,Y=M,nA=t[Y>>2]|0,Y=t[Y+4>>2]|0,f=(nA|0)==(e|0)&(Y|0)==(A|0),!((nA|0)==0&(Y|0)==0|f))do u=ZA(u|0,p|0,1,0)|0,u=Nn(u|0,S()|0,i|0,o|0)|0,p=S()|0,M=n+(u<<3)|0,nA=M,Y=t[nA>>2]|0,nA=t[nA+4>>2]|0,f=(Y|0)==(e|0)&(nA|0)==(A|0);while(!((Y|0)==0&(nA|0)==0|f));if(u=s+(u<<2)|0,f&&(t[u>>2]|0)<=(l|0)||(nA=M,t[nA>>2]=e,t[nA+4>>2]=A,t[u>>2]=l,(l|0)>=(r|0)))return nA=0,C=G,nA|0;switch(f=l+1|0,t[L>>2]=0,u=K(e,A,2,L,N)|0,u|0){case 9:{I=9;break}case 0:{u=N,u=X(t[u>>2]|0,t[u+4>>2]|0,r,n,s,i,o,f)|0,u||(I=9);break}}A:do if((I|0)==9){switch(t[L>>2]=0,u=K(e,A,3,L,N)|0,u|0){case 9:break;case 0:{if(u=N,u=X(t[u>>2]|0,t[u+4>>2]|0,r,n,s,i,o,f)|0,u|0)break A;break}default:break A}switch(t[L>>2]=0,u=K(e,A,1,L,N)|0,u|0){case 9:break;case 0:{if(u=N,u=X(t[u>>2]|0,t[u+4>>2]|0,r,n,s,i,o,f)|0,u|0)break A;break}default:break A}switch(t[L>>2]=0,u=K(e,A,5,L,N)|0,u|0){case 9:break;case 0:{if(u=N,u=X(t[u>>2]|0,t[u+4>>2]|0,r,n,s,i,o,f)|0,u|0)break A;break}default:break A}switch(t[L>>2]=0,u=K(e,A,4,L,N)|0,u|0){case 9:break;case 0:{if(u=N,u=X(t[u>>2]|0,t[u+4>>2]|0,r,n,s,i,o,f)|0,u|0)break A;break}default:break A}switch(t[L>>2]=0,u=K(e,A,6,L,N)|0,u|0){case 9:break;case 0:{if(u=N,u=X(t[u>>2]|0,t[u+4>>2]|0,r,n,s,i,o,f)|0,u|0)break A;break}default:break A}return nA=0,C=G,nA|0}while(!1);return nA=u,C=G,nA|0}function K(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0;if(r>>>0>6)return s=1,s|0;if(M=(t[n>>2]|0)%6|0,t[n>>2]=M,(M|0)>0){i=0;do r=rt(r)|0,i=i+1|0;while((i|0)<(t[n>>2]|0))}if(M=yA(e|0,A|0,45)|0,S()|0,p=M&127,p>>>0>121)return s=5,s|0;u=Vt(e,A)|0,i=yA(e|0,A|0,52)|0,S()|0,i=i&15;A:do if(!i)f=8;else{for(;;){if(o=(15-i|0)*3|0,l=yA(e|0,A|0,o|0)|0,S()|0,l=l&7,(l|0)==7){A=5;break}if(N=(lr(i)|0)==0,i=i+-1|0,I=CA(7,0,o|0)|0,A=A&~(S()|0),L=CA(t[(N?432:16)+(l*28|0)+(r<<2)>>2]|0,0,o|0)|0,o=S()|0,r=t[(N?640:224)+(l*28|0)+(r<<2)>>2]|0,e=L|e&~I,A=o|A,!r){r=0;break A}if(!i){f=8;break A}}return A|0}while(!1);(f|0)==8&&(N=t[848+(p*28|0)+(r<<2)>>2]|0,L=CA(N|0,0,45)|0,e=L|e,A=S()|0|A&-1040385,r=t[4272+(p*28|0)+(r<<2)>>2]|0,(N&127|0)==127&&(N=CA(t[848+(p*28|0)+20>>2]|0,0,45)|0,A=S()|0|A&-1040385,r=t[4272+(p*28|0)+20>>2]|0,e=hn(N|e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+1)),l=yA(e|0,A|0,45)|0,S()|0,l=l&127;A:do if(be(l)|0){e:do if((Vt(e,A)|0)==1){if((p|0)!=(l|0))if(Fr(l,t[7696+(p*28|0)>>2]|0)|0){e=ss(e,A)|0,o=1,A=S()|0;break}else OA(27795,26864,533,26872);switch(u|0){case 3:{e=hn(e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+1,o=0;break e}case 5:{e=ss(e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+5,o=0;break e}case 0:return N=9,N|0;default:return N=1,N|0}}else o=0;while(!1);if((r|0)>0){i=0;do e=ns(e,A)|0,A=S()|0,i=i+1|0;while((i|0)!=(r|0))}if((p|0)!=(l|0)){if(!(Tt(l)|0)){if((o|0)!=0|(Vt(e,A)|0)!=5)break;t[n>>2]=(t[n>>2]|0)+1;break}switch(M&127){case 8:case 118:break A}(Vt(e,A)|0)!=3&&(t[n>>2]=(t[n>>2]|0)+1)}}else if((r|0)>0){i=0;do e=hn(e,A)|0,A=S()|0,i=i+1|0;while((i|0)!=(r|0))}while(!1);return t[n>>2]=((t[n>>2]|0)+r|0)%6|0,N=s,t[N>>2]=e,t[N+4>>2]=A,N=0,N|0}function cA(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,jA(e,A,r,n)|0?(Jr(n|0,0,r*48|0)|0,n=Ae(e,A,r,n)|0,n|0):(n=0,n|0)}function jA(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0;if(N=C,C=C+16|0,I=N,L=N+8|0,M=I,t[M>>2]=e,t[M+4>>2]=A,(r|0)<0)return L=2,C=N,L|0;if(!r)return L=n,t[L>>2]=e,t[L+4>>2]=A,L=0,C=N,L|0;t[L>>2]=0;A:do if(Qe(e,A)|0)e=9;else{s=0,M=e;do{if(e=K(M,A,4,L,I)|0,e|0)break A;if(A=I,M=t[A>>2]|0,A=t[A+4>>2]|0,s=s+1|0,Qe(M,A)|0){e=9;break A}}while((s|0)<(r|0));p=n,t[p>>2]=M,t[p+4>>2]=A,p=r+-1|0,f=0,e=1;do{if(s=26800+(f<<2)|0,(f|0)==5)for(o=t[s>>2]|0,i=0,s=e;;){if(e=I,e=K(t[e>>2]|0,t[e+4>>2]|0,o,L,I)|0,e|0)break A;if((i|0)!=(p|0))if(u=I,l=t[u>>2]|0,u=t[u+4>>2]|0,e=n+(s<<3)|0,t[e>>2]=l,t[e+4>>2]=u,!(Qe(l,u)|0))e=s+1|0;else{e=9;break A}else e=s;if(i=i+1|0,(i|0)>=(r|0))break;s=e}else for(o=I,u=t[s>>2]|0,l=0,s=e,i=t[o>>2]|0,o=t[o+4>>2]|0;;){if(e=K(i,o,u,L,I)|0,e|0)break A;if(o=I,i=t[o>>2]|0,o=t[o+4>>2]|0,e=n+(s<<3)|0,t[e>>2]=i,t[e+4>>2]=o,e=s+1|0,Qe(i,o)|0){e=9;break A}if(l=l+1|0,(l|0)>=(r|0))break;s=e}f=f+1|0}while(f>>>0<6);e=I,e=(M|0)==(t[e>>2]|0)&&(A|0)==(t[e+4>>2]|0)?0:9}while(!1);return L=e,C=N,L|0}function Ae(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0;if(M=C,C=C+16|0,o=M,!r)return t[n>>2]=e,t[n+4>>2]=A,n=0,C=M,n|0;do if((r|0)>=0){if((r|0)>13780509){if(s=S0(15,o)|0,s|0)break;i=o,s=t[i>>2]|0,i=t[i+4>>2]|0}else s=((r|0)<0)<<31>>31,p=yt(r|0,s|0,3,0)|0,i=S()|0,s=ZA(r|0,s|0,1,0)|0,s=yt(p|0,i|0,s|0,S()|0)|0,s=ZA(s|0,S()|0,1,0)|0,i=S()|0,p=o,t[p>>2]=s,t[p+4>>2]=i;if(f=Wt(s,8)|0,!f)s=13;else{if(p=Wt(s,4)|0,!p){$A(f),s=13;break}if(s=X(e,A,r,f,p,s,i,0)|0,s|0){$A(f),$A(p);break}if(A=t[o>>2]|0,o=t[o+4>>2]|0,(o|0)>0|(o|0)==0&A>>>0>0){s=0,l=0,u=0;do e=f+(l<<3)|0,i=t[e>>2]|0,e=t[e+4>>2]|0,!((i|0)==0&(e|0)==0)&&(t[p+(l<<2)>>2]|0)==(r|0)&&(I=n+(s<<3)|0,t[I>>2]=i,t[I+4>>2]=e,s=s+1|0),l=ZA(l|0,u|0,1,0)|0,u=S()|0;while((u|0)<(o|0)|(u|0)==(o|0)&l>>>0>>0)}$A(f),$A(p),s=0}}else s=2;while(!1);return I=s,C=M,I|0}function ee(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0;for(l=C,C=C+16|0,i=l,o=l+8|0,s=(Qe(e,A)|0)==0,s=s?1:2;;){if(t[o>>2]=0,f=(K(e,A,s,o,i)|0)==0,u=i,f&((t[u>>2]|0)==(r|0)?(t[u+4>>2]|0)==(n|0):0)){e=4;break}if(s=s+1|0,s>>>0>=7){s=7,e=4;break}}return(e|0)==4?(C=l,s|0):0}function he(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0;if(l=C,C=C+48|0,s=l+16|0,i=l+8|0,o=l,r=a0(r)|0,r|0)return o=r,C=l,o|0;if(f=e,u=t[f+4>>2]|0,r=i,t[r>>2]=t[f>>2],t[r+4>>2]=u,ii(i,s),r=$t(s,A,o)|0,!r){if(A=t[i>>2]|0,i=t[e+8>>2]|0,(i|0)>0){s=t[e+12>>2]|0,r=0;do A=(t[s+(r<<3)>>2]|0)+A|0,r=r+1|0;while((r|0)<(i|0))}r=o,s=t[r>>2]|0,r=t[r+4>>2]|0,i=((A|0)<0)<<31>>31,(r|0)<(i|0)|(r|0)==(i|0)&s>>>0>>0?(r=o,t[r>>2]=A,t[r+4>>2]=i,r=i):A=s,u=ZA(A|0,r|0,12,0)|0,f=S()|0,r=o,t[r>>2]=u,t[r+4>>2]=f,r=n,t[r>>2]=u,t[r+4>>2]=f,r=0}return f=r,C=l,f|0}function Pe(e,A,r,n,s,i,o){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,i=i|0,o=o|0;var l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,Z=0,V=0,BA=0,GA=0,QA=0,ce=0,de=0,Se=0,ie=0,UA=0,SA=0,ve=0,Ve=0,me=0,We=0,Pt=0,wi=0;if(Ve=C,C=C+64|0,ie=Ve+48|0,UA=Ve+32|0,SA=Ve+24|0,BA=Ve+8|0,GA=Ve,u=t[e>>2]|0,(u|0)<=0)return ve=0,C=Ve,ve|0;for(QA=e+4|0,ce=ie+8|0,de=UA+8|0,Se=BA+8|0,l=0,Z=0;;){f=t[QA>>2]|0,q=f+(Z<<4)|0,t[ie>>2]=t[q>>2],t[ie+4>>2]=t[q+4>>2],t[ie+8>>2]=t[q+8>>2],t[ie+12>>2]=t[q+12>>2],(Z|0)==(u+-1|0)?(t[UA>>2]=t[f>>2],t[UA+4>>2]=t[f+4>>2],t[UA+8>>2]=t[f+8>>2],t[UA+12>>2]=t[f+12>>2]):(q=f+(Z+1<<4)|0,t[UA>>2]=t[q>>2],t[UA+4>>2]=t[q+4>>2],t[UA+8>>2]=t[q+8>>2],t[UA+12>>2]=t[q+12>>2]),u=Yr(ie,UA,n,SA)|0;A:do if(u)f=0,l=u;else if(u=SA,f=t[u>>2]|0,u=t[u+4>>2]|0,(u|0)>0|(u|0)==0&f>>>0>0){nA=0,q=0;e:for(;;){if(We=1/(+(f>>>0)+4294967296*+(u|0)),wi=+k[ie>>3],u=gt(f|0,u|0,nA|0,q|0)|0,Pt=+(u>>>0)+4294967296*+(S()|0),me=+(nA>>>0)+4294967296*+(q|0),k[BA>>3]=We*(wi*Pt)+We*(+k[UA>>3]*me),k[Se>>3]=We*(+k[ce>>3]*Pt)+We*(+k[de>>3]*me),u=is(BA,n,GA)|0,u|0){l=u;break}Y=GA,G=t[Y>>2]|0,Y=t[Y+4>>2]|0,I=Fn(G|0,Y|0,A|0,r|0)|0,p=S()|0,u=o+(I<<3)|0,M=u,f=t[M>>2]|0,M=t[M+4>>2]|0;t:do if((f|0)==0&(M|0)==0)V=u,ve=16;else for(L=0,N=0;;){if((L|0)>(r|0)|(L|0)==(r|0)&N>>>0>A>>>0){l=1;break e}if((f|0)==(G|0)&(M|0)==(Y|0))break t;if(u=ZA(I|0,p|0,1,0)|0,I=Nn(u|0,S()|0,A|0,r|0)|0,p=S()|0,N=ZA(N|0,L|0,1,0)|0,L=S()|0,u=o+(I<<3)|0,M=u,f=t[M>>2]|0,M=t[M+4>>2]|0,(f|0)==0&(M|0)==0){V=u,ve=16;break}}while(!1);if((ve|0)==16&&(ve=0,!((G|0)==0&(Y|0)==0))&&(N=V,t[N>>2]=G,t[N+4>>2]=Y,N=i+(t[s>>2]<<3)|0,t[N>>2]=G,t[N+4>>2]=Y,N=s,N=ZA(t[N>>2]|0,t[N+4>>2]|0,1,0)|0,G=S()|0,Y=s,t[Y>>2]=N,t[Y+4>>2]=G),nA=ZA(nA|0,q|0,1,0)|0,q=S()|0,u=SA,f=t[u>>2]|0,u=t[u+4>>2]|0,!((u|0)>(q|0)|(u|0)==(q|0)&f>>>0>nA>>>0)){f=1;break A}}f=0}else f=1;while(!1);if(Z=Z+1|0,!f){ve=21;break}if(u=t[e>>2]|0,(Z|0)>=(u|0)){l=0,ve=21;break}}return(ve|0)==21?(C=Ve,l|0):0}function jt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,Z=0,V=0,BA=0,GA=0,QA=0,ce=0,de=0,Se=0,ie=0,UA=0,SA=0,ve=0,Ve=0,me=0,We=0,Pt=0;if(Pt=C,C=C+112|0,ve=Pt+80|0,u=Pt+72|0,Ve=Pt,me=Pt+56|0,s=a0(r)|0,s|0)return We=s,C=Pt,We|0;if(f=e+8|0,We=Br((t[f>>2]<<5)+32|0)|0,!We)return We=13,C=Pt,We|0;if(hs(e,We),s=a0(r)|0,!s){if(UA=e,SA=t[UA+4>>2]|0,s=u,t[s>>2]=t[UA>>2],t[s+4>>2]=SA,ii(u,ve),s=$t(ve,A,Ve)|0,s)UA=0,SA=0;else{if(s=t[u>>2]|0,i=t[f>>2]|0,(i|0)>0){o=t[e+12>>2]|0,r=0;do s=(t[o+(r<<3)>>2]|0)+s|0,r=r+1|0;while((r|0)!=(i|0));r=s}else r=s;s=Ve,i=t[s>>2]|0,s=t[s+4>>2]|0,o=((r|0)<0)<<31>>31,(s|0)<(o|0)|(s|0)==(o|0)&i>>>0>>0?(s=Ve,t[s>>2]=r,t[s+4>>2]=o,s=o):r=i,UA=ZA(r|0,s|0,12,0)|0,SA=S()|0,s=Ve,t[s>>2]=UA,t[s+4>>2]=SA,s=0}if(!s){if(r=Wt(UA,8)|0,!r)return $A(We),We=13,C=Pt,We|0;if(l=Wt(UA,8)|0,!l)return $A(We),$A(r),We=13,C=Pt,We|0;Se=ve,t[Se>>2]=0,t[Se+4>>2]=0,Se=e,ie=t[Se+4>>2]|0,s=u,t[s>>2]=t[Se>>2],t[s+4>>2]=ie,s=Pe(u,UA,SA,A,ve,r,l)|0;A:do if(s)$A(r),$A(l),$A(We);else{e:do if((t[f>>2]|0)>0){for(o=e+12|0,i=0;s=Pe((t[o>>2]|0)+(i<<3)|0,UA,SA,A,ve,r,l)|0,i=i+1|0,!(s|0);)if((i|0)>=(t[f>>2]|0))break e;$A(r),$A(l),$A(We);break A}while(!1);(SA|0)>0|(SA|0)==0&UA>>>0>0&&Jr(l|0,0,UA<<3|0)|0,ie=ve,Se=t[ie+4>>2]|0;e:do if((Se|0)>0|(Se|0)==0&(t[ie>>2]|0)>>>0>0){QA=r,ce=l,de=r,Se=l,ie=r,s=r,V=r,BA=l,GA=l,r=l;t:for(;;){for(Y=0,nA=0,q=0,Z=0,i=0,o=0;;){l=Ve,u=l+56|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(u|0));if(A=QA+(Y<<3)|0,f=t[A>>2]|0,A=t[A+4>>2]|0,O(f,A,1,Ve,0)|0){l=Ve,u=l+56|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(u|0));l=Wt(7,4)|0,l|0&&(X(f,A,1,Ve,l,7,0,0)|0,$A(l))}for(G=0;;){N=Ve+(G<<3)|0,L=t[N>>2]|0,N=t[N+4>>2]|0;r:do if((L|0)==0&(N|0)==0)l=i,u=o;else{if(p=Fn(L|0,N|0,UA|0,SA|0)|0,f=S()|0,l=n+(p<<3)|0,A=l,u=t[A>>2]|0,A=t[A+4>>2]|0,!((u|0)==0&(A|0)==0)){M=0,I=0;do{if((M|0)>(SA|0)|(M|0)==(SA|0)&I>>>0>UA>>>0)break t;if((u|0)==(L|0)&(A|0)==(N|0)){l=i,u=o;break r}l=ZA(p|0,f|0,1,0)|0,p=Nn(l|0,S()|0,UA|0,SA|0)|0,f=S()|0,I=ZA(I|0,M|0,1,0)|0,M=S()|0,l=n+(p<<3)|0,A=l,u=t[A>>2]|0,A=t[A+4>>2]|0}while(!((u|0)==0&(A|0)==0))}if((L|0)==0&(N|0)==0){l=i,u=o;break}dn(L,N,me)|0,ds(e,We,me)|0&&(I=ZA(i|0,o|0,1,0)|0,o=S()|0,M=l,t[M>>2]=L,t[M+4>>2]=N,i=ce+(i<<3)|0,t[i>>2]=L,t[i+4>>2]=N,i=I),l=i,u=o}while(!1);if(G=G+1|0,G>>>0>=7)break;i=l,o=u}if(Y=ZA(Y|0,nA|0,1,0)|0,nA=S()|0,q=ZA(q|0,Z|0,1,0)|0,Z=S()|0,o=ve,i=t[o>>2]|0,o=t[o+4>>2]|0,(Z|0)<(o|0)|(Z|0)==(o|0)&q>>>0>>0)i=l,o=u;else break}if((o|0)>0|(o|0)==0&i>>>0>0){i=0,o=0;do Z=QA+(i<<3)|0,t[Z>>2]=0,t[Z+4>>2]=0,i=ZA(i|0,o|0,1,0)|0,o=S()|0,Z=ve,q=t[Z+4>>2]|0;while((o|0)<(q|0)|((o|0)==(q|0)?i>>>0<(t[Z>>2]|0)>>>0:0))}if(Z=ve,t[Z>>2]=l,t[Z+4>>2]=u,(u|0)>0|(u|0)==0&l>>>0>0)G=r,Y=GA,nA=ie,q=BA,Z=ce,r=V,GA=s,BA=de,V=G,s=Y,ie=Se,Se=nA,de=q,ce=QA,QA=Z;else break e}$A(de),$A(Se),$A(We),s=1;break A}else s=l;while(!1);$A(We),$A(r),$A(s),s=0}while(!1);return We=s,C=Pt,We|0}}return $A(We),We=s,C=Pt,We|0}function dt(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;if(p=C,C=C+176|0,u=p,(A|0)<1)return fi(r,0,0),f=0,C=p,f|0;for(l=e,l=yA(t[l>>2]|0,t[l+4>>2]|0,52)|0,S()|0,fi(r,(A|0)>6?A:6,l&15),l=0;n=e+(l<<3)|0,n=In(t[n>>2]|0,t[n+4>>2]|0,u)|0,!(n|0);){if(n=t[u>>2]|0,(n|0)>0){o=0;do i=u+8+(o<<4)|0,o=o+1|0,n=u+8+(((o|0)%(n|0)|0)<<4)|0,s=xa(r,n,i)|0,s?mi(r,s)|0:ya(r,i,n)|0,n=t[u>>2]|0;while((o|0)<(n|0))}if(l=l+1|0,(l|0)>=(A|0)){n=0,f=13;break}}return(f|0)==13?(C=p,n|0):(hi(r),f=n,C=p,f|0)}function vt(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;if(i=C,C=C+32|0,n=i,s=i+16|0,e=dt(e,A,s)|0,e|0)return r=e,C=i,r|0;if(t[r>>2]=0,t[r+4>>2]=0,t[r+8>>2]=0,e=di(s)|0,e|0)do{A=Kl(r)|0;do Zl(A,e)|0,o=e+16|0,t[n>>2]=t[o>>2],t[n+4>>2]=t[o+4>>2],t[n+8>>2]=t[o+8>>2],t[n+12>>2]=t[o+12>>2],mi(s,e)|0,e=wa(s,n)|0;while((e|0)!=0);e=di(s)|0}while((e|0)!=0);return hi(s),e=$l(r)|0,e?(ti(r),o=e,C=i,o|0):(o=0,C=i,o|0)}function be(e){return e=e|0,e>>>0>121?(e=0,e|0):(e=t[7696+(e*28|0)+16>>2]|0,e|0)}function Tt(e){return e=e|0,(e|0)==4|(e|0)==117|0}function Cr(e){return e=e|0,t[11120+((t[e>>2]|0)*216|0)+((t[e+4>>2]|0)*72|0)+((t[e+8>>2]|0)*24|0)+(t[e+12>>2]<<3)>>2]|0}function gr(e){return e=e|0,t[11120+((t[e>>2]|0)*216|0)+((t[e+4>>2]|0)*72|0)+((t[e+8>>2]|0)*24|0)+(t[e+12>>2]<<3)+4>>2]|0}function Wr(e,A){e=e|0,A=A|0,e=7696+(e*28|0)|0,t[A>>2]=t[e>>2],t[A+4>>2]=t[e+4>>2],t[A+8>>2]=t[e+8>>2],t[A+12>>2]=t[e+12>>2]}function Zt(e,A){e=e|0,A=A|0;var r=0,n=0;if(A>>>0>20)return A=-1,A|0;do if((t[11120+(A*216|0)>>2]|0)!=(e|0))if((t[11120+(A*216|0)+8>>2]|0)!=(e|0))if((t[11120+(A*216|0)+16>>2]|0)!=(e|0))if((t[11120+(A*216|0)+24>>2]|0)!=(e|0))if((t[11120+(A*216|0)+32>>2]|0)!=(e|0))if((t[11120+(A*216|0)+40>>2]|0)!=(e|0))if((t[11120+(A*216|0)+48>>2]|0)!=(e|0))if((t[11120+(A*216|0)+56>>2]|0)!=(e|0))if((t[11120+(A*216|0)+64>>2]|0)!=(e|0))if((t[11120+(A*216|0)+72>>2]|0)!=(e|0))if((t[11120+(A*216|0)+80>>2]|0)!=(e|0))if((t[11120+(A*216|0)+88>>2]|0)!=(e|0))if((t[11120+(A*216|0)+96>>2]|0)!=(e|0))if((t[11120+(A*216|0)+104>>2]|0)!=(e|0))if((t[11120+(A*216|0)+112>>2]|0)!=(e|0))if((t[11120+(A*216|0)+120>>2]|0)!=(e|0))if((t[11120+(A*216|0)+128>>2]|0)!=(e|0))if((t[11120+(A*216|0)+136>>2]|0)==(e|0))e=2,r=1,n=2;else{if((t[11120+(A*216|0)+144>>2]|0)==(e|0)){e=0,r=2,n=0;break}if((t[11120+(A*216|0)+152>>2]|0)==(e|0)){e=0,r=2,n=1;break}if((t[11120+(A*216|0)+160>>2]|0)==(e|0)){e=0,r=2,n=2;break}if((t[11120+(A*216|0)+168>>2]|0)==(e|0)){e=1,r=2,n=0;break}if((t[11120+(A*216|0)+176>>2]|0)==(e|0)){e=1,r=2,n=1;break}if((t[11120+(A*216|0)+184>>2]|0)==(e|0)){e=1,r=2,n=2;break}if((t[11120+(A*216|0)+192>>2]|0)==(e|0)){e=2,r=2,n=0;break}if((t[11120+(A*216|0)+200>>2]|0)==(e|0)){e=2,r=2,n=1;break}if((t[11120+(A*216|0)+208>>2]|0)==(e|0)){e=2,r=2,n=2;break}else e=-1;return e|0}else e=2,r=1,n=1;else e=2,r=1,n=0;else e=1,r=1,n=2;else e=1,r=1,n=1;else e=1,r=1,n=0;else e=0,r=1,n=2;else e=0,r=1,n=1;else e=0,r=1,n=0;else e=2,r=0,n=2;else e=2,r=0,n=1;else e=2,r=0,n=0;else e=1,r=0,n=2;else e=1,r=0,n=1;else e=1,r=0,n=0;else e=0,r=0,n=2;else e=0,r=0,n=1;else e=0,r=0,n=0;while(!1);return A=t[11120+(A*216|0)+(r*72|0)+(e*24|0)+(n<<3)+4>>2]|0,A|0}function Fr(e,A){return e=e|0,A=A|0,(t[7696+(e*28|0)+20>>2]|0)==(A|0)?(A=1,A|0):(A=(t[7696+(e*28|0)+24>>2]|0)==(A|0),A|0)}function ln(e,A){return e=e|0,A=A|0,t[848+(e*28|0)+(A<<2)>>2]|0}function an(e,A){return e=e|0,A=A|0,(t[848+(e*28|0)>>2]|0)==(A|0)?(A=0,A|0):(t[848+(e*28|0)+4>>2]|0)==(A|0)?(A=1,A|0):(t[848+(e*28|0)+8>>2]|0)==(A|0)?(A=2,A|0):(t[848+(e*28|0)+12>>2]|0)==(A|0)?(A=3,A|0):(t[848+(e*28|0)+16>>2]|0)==(A|0)?(A=4,A|0):(t[848+(e*28|0)+20>>2]|0)==(A|0)?(A=5,A|0):((t[848+(e*28|0)+24>>2]|0)==(A|0)?6:7)|0}function Zn(){return 122}function $n(e){e=e|0;var A=0,r=0,n=0;A=0;do CA(A|0,0,45)|0,n=S()|0|134225919,r=e+(A<<3)|0,t[r>>2]=-1,t[r+4>>2]=n,A=A+1|0;while((A|0)!=122);return 0}function qn(e){e=e|0;var A=0,r=0,n=0;return n=+k[e+16>>3],r=+k[e+24>>3],A=n-r,+(n>3]<+k[e+24>>3]|0}function un(e){return e=e|0,+(+k[e>>3]-+k[e+8>>3])}function Er(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;return r=+k[A>>3],!(r>=+k[e+8>>3])||!(r<=+k[e>>3])?(A=0,A|0):(n=+k[e+16>>3],r=+k[e+24>>3],s=+k[A+8>>3],A=s>=r,e=s<=n&1,n>3]<+k[A+8>>3]||+k[e+8>>3]>+k[A>>3]?(n=0,n|0):(i=+k[e+16>>3],r=e+24|0,p=+k[r>>3],o=i>3],s=A+24|0,u=+k[s>>3],l=f>3],A)||(p=+Xt(+k[r>>3],e),p>+Xt(+k[n>>3],A))?(l=0,l|0):(l=1,l|0))}function Pr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0;i=+k[e+16>>3],u=+k[e+24>>3],e=i>3],o=+k[A+24>>3],s=l>2]=e?s|A?1:2:0,t[n>>2]=s?e?1:A?2:1:0}function Qr(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;return+k[e>>3]<+k[A>>3]||+k[e+8>>3]>+k[A+8>>3]?(n=0,n|0):(n=e+16|0,u=+k[n>>3],i=+k[e+24>>3],o=u>3],s=A+24|0,f=+k[s>>3],l=p>3],A)?(p=+Xt(+k[n>>3],e),l=p>=+Xt(+k[r>>3],A),l|0):(l=0,l|0))}function Sr(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0;s=C,C=C+176|0,n=s,t[n>>2]=4,l=+k[A>>3],k[n+8>>3]=l,i=+k[A+16>>3],k[n+16>>3]=i,k[n+24>>3]=l,l=+k[A+24>>3],k[n+32>>3]=l,o=+k[A+8>>3],k[n+40>>3]=o,k[n+48>>3]=l,k[n+56>>3]=o,k[n+64>>3]=i,A=n+72|0,r=A+96|0;do t[A>>2]=0,A=A+4|0;while((A|0)<(r|0));Pn(e|0,n|0,168)|0,C=s}function $t(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0;N=C,C=C+288|0,p=N+264|0,M=N+96|0,f=N,l=f,u=l+96|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(u|0));return A=ls(A,f)|0,A|0?(L=A,C=N,L|0):(u=f,f=t[u>>2]|0,u=t[u+4>>2]|0,dn(f,u,p)|0,In(f,u,M)|0,o=+o0(p,M+8|0),k[p>>3]=+k[e>>3],u=p+8|0,k[u>>3]=+k[e+16>>3],k[M>>3]=+k[e+8>>3],f=M+8|0,k[f>>3]=+k[e+24>>3],s=+o0(p,M),Y=+k[u>>3]-+k[f>>3],i=+oe(+Y),G=+k[p>>3]-+k[M>>3],n=+oe(+G),!(Y==0|G==0)&&(Y=+yi(+i,+n),Y=+Et(+(s*s/+D0(+(Y/+D0(+i,+n)),3)/(o*(o*2.59807621135)*.8))),k[xe>>3]=Y,I=~~Y>>>0,L=+oe(Y)>=1?Y>0?~~+ot(+$e(Y/4294967296),4294967295)>>>0:~~+Et((Y-+(~~Y>>>0))/4294967296)>>>0:0,(t[xe+4>>2]&2146435072|0)!=2146435072)?(M=(I|0)==0&(L|0)==0,A=r,t[A>>2]=M?1:I,t[A+4>>2]=M?0:L,A=0):A=1,L=A,C=N,L|0)}function Yr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0;f=C,C=C+288|0,o=f+264|0,l=f+96|0,u=f,s=u,i=s+96|0;do t[s>>2]=0,s=s+4|0;while((s|0)<(i|0));return r=ls(r,u)|0,r|0?(n=r,C=f,n|0):(r=u,s=t[r>>2]|0,r=t[r+4>>2]|0,dn(s,r,o)|0,In(s,r,l)|0,p=+o0(o,l+8|0),p=+Et(+(+o0(e,A)/(p*2))),k[xe>>3]=p,r=~~p>>>0,s=+oe(p)>=1?p>0?~~+ot(+$e(p/4294967296),4294967295)>>>0:~~+Et((p-+(~~p>>>0))/4294967296)>>>0:0,(t[xe+4>>2]&2146435072|0)==2146435072?(n=1,C=f,n|0):(u=(r|0)==0&(s|0)==0,t[n>>2]=u?1:r,t[n+4>>2]=u?0:s,n=0,C=f,n|0))}function yr(e,A){e=e|0,A=+A;var r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;i=e+16|0,o=+k[i>>3],r=e+24|0,s=+k[r>>3],n=o-s,n=o>3],l=e+8|0,u=+k[l>>3],p=f-u,n=(n*A-n)*.5,A=(p*A-p)*.5,f=f+A,k[e>>3]=f>1.5707963267948966?1.5707963267948966:f,A=u-A,k[l>>3]=A<-1.5707963267948966?-1.5707963267948966:A,A=o+n,A=A>3.141592653589793?A+-6.283185307179586:A,k[i>>3]=A<-3.141592653589793?A+6.283185307179586:A,A=s-n,A=A>3.141592653589793?A+-6.283185307179586:A,k[r>>3]=A<-3.141592653589793?A+6.283185307179586:A}function Bn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0,t[e>>2]=A,t[e+4>>2]=r,t[e+8>>2]=n}function cn(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0;M=A+8|0,t[M>>2]=0,u=+k[e>>3],o=+oe(+u),f=+k[e+8>>3],l=+oe(+f)*1.1547005383792515,o=o+l*.5,r=~~o,e=~~l,o=o-+(r|0),l=l-+(e|0);do if(o<.5)if(o<.3333333333333333)if(t[A>>2]=r,l<(o+1)*.5){t[A+4>>2]=e;break}else{e=e+1|0,t[A+4>>2]=e;break}else if(I=1-o,e=(!(l>2]=e,I<=l&l>2]=r;break}else{t[A>>2]=r;break}else{if(!(o<.6666666666666666))if(r=r+1|0,t[A>>2]=r,l>2]=e;break}else{e=e+1|0,t[A+4>>2]=e;break}if(l<1-o){if(t[A+4>>2]=e,o*2+-1>2]=r;break}}else e=e+1|0,t[A+4>>2]=e;r=r+1|0,t[A>>2]=r}while(!1);do if(u<0)if(e&1){p=(e+1|0)/2|0,p=gt(r|0,((r|0)<0)<<31>>31|0,p|0,((p|0)<0)<<31>>31|0)|0,r=~~(+(r|0)-((+(p>>>0)+4294967296*+(S()|0))*2+1)),t[A>>2]=r;break}else{p=(e|0)/2|0,p=gt(r|0,((r|0)<0)<<31>>31|0,p|0,((p|0)<0)<<31>>31|0)|0,r=~~(+(r|0)-(+(p>>>0)+4294967296*+(S()|0))*2),t[A>>2]=r;break}while(!1);p=A+4|0,f<0&&(r=r-((e<<1|1|0)/2|0)|0,t[A>>2]=r,e=0-e|0,t[p>>2]=e),n=e-r|0,(r|0)<0?(s=0-r|0,t[p>>2]=n,t[M>>2]=s,t[A>>2]=0,e=n,r=0):s=0,(e|0)<0&&(r=r-e|0,t[A>>2]=r,s=s-e|0,t[M>>2]=s,t[p>>2]=0,e=0),i=r-s|0,n=e-s|0,(s|0)<0&&(t[A>>2]=i,t[p>>2]=n,t[M>>2]=0,e=n,r=i,s=0),n=(e|0)<(r|0)?e:r,n=(s|0)<(n|0)?s:n,!((n|0)<=0)&&(t[A>>2]=r-n,t[p>>2]=e-n,t[M>>2]=s-n)}function et(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0;A=t[e>>2]|0,o=e+4|0,r=t[o>>2]|0,(A|0)<0&&(r=r-A|0,t[o>>2]=r,i=e+8|0,t[i>>2]=(t[i>>2]|0)-A,t[e>>2]=0,A=0),(r|0)<0?(A=A-r|0,t[e>>2]=A,i=e+8|0,s=(t[i>>2]|0)-r|0,t[i>>2]=s,t[o>>2]=0,r=0):(s=e+8|0,i=s,s=t[s>>2]|0),(s|0)<0&&(A=A-s|0,t[e>>2]=A,r=r-s|0,t[o>>2]=r,t[i>>2]=0,s=0),n=(r|0)<(A|0)?r:A,n=(s|0)<(n|0)?s:n,!((n|0)<=0)&&(t[e>>2]=A-n,t[o>>2]=r-n,t[i>>2]=s-n)}function qt(e,A){e=e|0,A=A|0;var r=0,n=0;n=t[e+8>>2]|0,r=+((t[e+4>>2]|0)-n|0),k[A>>3]=+((t[e>>2]|0)-n|0)-r*.5,k[A+8>>3]=r*.8660254037844386}function ut(e,A,r){e=e|0,A=A|0,r=r|0,t[r>>2]=(t[A>>2]|0)+(t[e>>2]|0),t[r+4>>2]=(t[A+4>>2]|0)+(t[e+4>>2]|0),t[r+8>>2]=(t[A+8>>2]|0)+(t[e+8>>2]|0)}function H(e,A,r){e=e|0,A=A|0,r=r|0,t[r>>2]=(t[e>>2]|0)-(t[A>>2]|0),t[r+4>>2]=(t[e+4>>2]|0)-(t[A+4>>2]|0),t[r+8>>2]=(t[e+8>>2]|0)-(t[A+8>>2]|0)}function oA(e,A){e=e|0,A=A|0;var r=0,n=0;r=ht(t[e>>2]|0,A)|0,t[e>>2]=r,r=e+4|0,n=ht(t[r>>2]|0,A)|0,t[r>>2]=n,e=e+8|0,A=ht(t[e>>2]|0,A)|0,t[e>>2]=A}function hA(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;o=t[e>>2]|0,l=(o|0)<0,n=(t[e+4>>2]|0)-(l?o:0)|0,i=(n|0)<0,s=(i?0-n|0:0)+((t[e+8>>2]|0)-(l?o:0))|0,r=(s|0)<0,e=r?0:s,A=(i?0:n)-(r?s:0)|0,s=(l?0:o)-(i?n:0)-(r?s:0)|0,r=(A|0)<(s|0)?A:s,r=(e|0)<(r|0)?e:r,n=(r|0)>0,e=e-(n?r:0)|0,A=A-(n?r:0)|0;A:do switch(s-(n?r:0)|0){case 0:switch(A|0){case 0:return l=(e|0)==0?0:(e|0)==1?1:7,l|0;case 1:return l=(e|0)==0?2:(e|0)==1?3:7,l|0;default:break A}case 1:switch(A|0){case 0:return l=(e|0)==0?4:(e|0)==1?5:7,l|0;case 1:{if(!e)e=6;else break A;return e|0}default:break A}}while(!1);return l=7,l|0}function NA(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0;if(u=e+8|0,o=t[u>>2]|0,l=(t[e>>2]|0)-o|0,f=e+4|0,o=(t[f>>2]|0)-o|0,l>>>0>715827881|o>>>0>715827881){if(n=(l|0)>0,s=2147483647-l|0,i=-2147483648-l|0,(n?(s|0)<(l|0):(i|0)>(l|0))||(r=l<<1,n?(2147483647-r|0)<(l|0):(-2147483648-r|0)>(l|0))||((o|0)>0?(2147483647-o|0)<(o|0):(-2147483648-o|0)>(o|0))||(A=l*3|0,r=o<<1,(n?(s|0)<(r|0):(i|0)>(r|0))||((l|0)>-1?(A|-2147483648|0)>=(o|0):(A^-2147483648|0)<(o|0))))return f=1,f|0}else r=o<<1,A=l*3|0;return n=$r(+(A-o|0)*.14285714285714285)|0,t[e>>2]=n,s=$r(+(r+l|0)*.14285714285714285)|0,t[f>>2]=s,t[u>>2]=0,r=(s|0)<(n|0),A=r?n:s,r=r?s:n,(r|0)<0&&(((r|0)==-2147483648||((A|0)>0?(2147483647-A|0)<(r|0):(-2147483648-A|0)>(r|0)))&&OA(27795,26892,354,26903),((A|0)>-1?(A|-2147483648|0)>=(r|0):(A^-2147483648|0)<(r|0))&&OA(27795,26892,354,26903)),A=s-n|0,(n|0)<0?(r=0-n|0,t[f>>2]=A,t[u>>2]=r,t[e>>2]=0,n=0):(A=s,r=0),(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[u>>2]=r,t[f>>2]=0,A=0),i=n-r|0,s=A-r|0,(r|0)<0?(t[e>>2]=i,t[f>>2]=s,t[u>>2]=0,A=s,s=i,r=0):s=n,n=(A|0)<(s|0)?A:s,n=(r|0)<(n|0)?r:n,(n|0)<=0?(f=0,f|0):(t[e>>2]=s-n,t[f>>2]=A-n,t[u>>2]=r-n,f=0,f|0)}function YA(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=0;if(o=e+8|0,s=t[o>>2]|0,i=(t[e>>2]|0)-s|0,l=e+4|0,s=(t[l>>2]|0)-s|0,i>>>0>715827881|s>>>0>715827881){if(r=(i|0)>0,(r?(2147483647-i|0)<(i|0):(-2147483648-i|0)>(i|0))||(A=i<<1,n=(s|0)>0,n?(2147483647-s|0)<(s|0):(-2147483648-s|0)>(s|0)))return l=1,l|0;if(u=s<<1,(n?(2147483647-u|0)<(s|0):(-2147483648-u|0)>(s|0))||(r?(2147483647-A|0)<(s|0):(-2147483648-A|0)>(s|0))||(r=s*3|0,(s|0)>-1?(r|-2147483648|0)>=(i|0):(r^-2147483648|0)<(i|0)))return u=1,u|0}else r=s*3|0,A=i<<1;return n=$r(+(A+s|0)*.14285714285714285)|0,t[e>>2]=n,s=$r(+(r-i|0)*.14285714285714285)|0,t[l>>2]=s,t[o>>2]=0,r=(s|0)<(n|0),A=r?n:s,r=r?s:n,(r|0)<0&&(((r|0)==-2147483648||((A|0)>0?(2147483647-A|0)<(r|0):(-2147483648-A|0)>(r|0)))&&OA(27795,26892,402,26917),((A|0)>-1?(A|-2147483648|0)>=(r|0):(A^-2147483648|0)<(r|0))&&OA(27795,26892,402,26917)),A=s-n|0,(n|0)<0?(r=0-n|0,t[l>>2]=A,t[o>>2]=r,t[e>>2]=0,n=0):(A=s,r=0),(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[o>>2]=r,t[l>>2]=0,A=0),i=n-r|0,s=A-r|0,(r|0)<0?(t[e>>2]=i,t[l>>2]=s,t[o>>2]=0,A=s,s=i,r=0):s=n,n=(A|0)<(s|0)?A:s,n=(r|0)<(n|0)?r:n,(n|0)<=0?(u=0,u|0):(t[e>>2]=s-n,t[l>>2]=A-n,t[o>>2]=r-n,u=0,u|0)}function re(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;o=e+8|0,r=t[o>>2]|0,A=(t[e>>2]|0)-r|0,l=e+4|0,r=(t[l>>2]|0)-r|0,n=$r(+((A*3|0)-r|0)*.14285714285714285)|0,t[e>>2]=n,A=$r(+((r<<1)+A|0)*.14285714285714285)|0,t[l>>2]=A,t[o>>2]=0,r=A-n|0,(n|0)<0?(i=0-n|0,t[l>>2]=r,t[o>>2]=i,t[e>>2]=0,A=r,n=0,r=i):r=0,(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[o>>2]=r,t[l>>2]=0,A=0),i=n-r|0,s=A-r|0,(r|0)<0?(t[e>>2]=i,t[l>>2]=s,t[o>>2]=0,A=s,s=i,r=0):s=n,n=(A|0)<(s|0)?A:s,n=(r|0)<(n|0)?r:n,!((n|0)<=0)&&(t[e>>2]=s-n,t[l>>2]=A-n,t[o>>2]=r-n)}function je(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;o=e+8|0,r=t[o>>2]|0,A=(t[e>>2]|0)-r|0,l=e+4|0,r=(t[l>>2]|0)-r|0,n=$r(+((A<<1)+r|0)*.14285714285714285)|0,t[e>>2]=n,A=$r(+((r*3|0)-A|0)*.14285714285714285)|0,t[l>>2]=A,t[o>>2]=0,r=A-n|0,(n|0)<0?(i=0-n|0,t[l>>2]=r,t[o>>2]=i,t[e>>2]=0,A=r,n=0,r=i):r=0,(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[o>>2]=r,t[l>>2]=0,A=0),i=n-r|0,s=A-r|0,(r|0)<0?(t[e>>2]=i,t[l>>2]=s,t[o>>2]=0,A=s,s=i,r=0):s=n,n=(A|0)<(s|0)?A:s,n=(r|0)<(n|0)?r:n,!((n|0)<=0)&&(t[e>>2]=s-n,t[l>>2]=A-n,t[o>>2]=r-n)}function ze(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;A=t[e>>2]|0,o=e+4|0,r=t[o>>2]|0,l=e+8|0,n=t[l>>2]|0,s=r+(A*3|0)|0,t[e>>2]=s,r=n+(r*3|0)|0,t[o>>2]=r,A=(n*3|0)+A|0,t[l>>2]=A,n=r-s|0,(s|0)<0?(A=A-s|0,t[o>>2]=n,t[l>>2]=A,t[e>>2]=0,r=n,n=0):n=s,(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),i=n-A|0,s=r-A|0,(A|0)<0?(t[e>>2]=i,t[o>>2]=s,t[l>>2]=0,n=i,A=0):s=r,r=(s|0)<(n|0)?s:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[o>>2]=s-r,t[l>>2]=A-r)}function Ge(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;s=t[e>>2]|0,o=e+4|0,A=t[o>>2]|0,l=e+8|0,r=t[l>>2]|0,n=(A*3|0)+s|0,s=r+(s*3|0)|0,t[e>>2]=s,t[o>>2]=n,A=(r*3|0)+A|0,t[l>>2]=A,r=n-s|0,(s|0)<0?(A=A-s|0,t[o>>2]=r,t[l>>2]=A,t[e>>2]=0,s=0):r=n,(r|0)<0&&(s=s-r|0,t[e>>2]=s,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),i=s-A|0,n=r-A|0,(A|0)<0?(t[e>>2]=i,t[o>>2]=n,t[l>>2]=0,s=i,A=0):n=r,r=(n|0)<(s|0)?n:s,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=s-r,t[o>>2]=n-r,t[l>>2]=A-r)}function Rt(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0;(A+-1|0)>>>0>=6||(s=(t[15440+(A*12|0)>>2]|0)+(t[e>>2]|0)|0,t[e>>2]=s,l=e+4|0,n=(t[15440+(A*12|0)+4>>2]|0)+(t[l>>2]|0)|0,t[l>>2]=n,o=e+8|0,A=(t[15440+(A*12|0)+8>>2]|0)+(t[o>>2]|0)|0,t[o>>2]=A,r=n-s|0,(s|0)<0?(A=A-s|0,t[l>>2]=r,t[o>>2]=A,t[e>>2]=0,n=0):(r=n,n=s),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[o>>2]=A,t[l>>2]=0,r=0),i=n-A|0,s=r-A|0,(A|0)<0?(t[e>>2]=i,t[l>>2]=s,t[o>>2]=0,n=i,A=0):s=r,r=(s|0)<(n|0)?s:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[l>>2]=s-r,t[o>>2]=A-r))}function ct(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;s=t[e>>2]|0,o=e+4|0,A=t[o>>2]|0,l=e+8|0,r=t[l>>2]|0,n=A+s|0,s=r+s|0,t[e>>2]=s,t[o>>2]=n,A=r+A|0,t[l>>2]=A,r=n-s|0,(s|0)<0?(A=A-s|0,t[o>>2]=r,t[l>>2]=A,t[e>>2]=0,n=0):(r=n,n=s),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),i=n-A|0,s=r-A|0,(A|0)<0?(t[e>>2]=i,t[o>>2]=s,t[l>>2]=0,n=i,A=0):s=r,r=(s|0)<(n|0)?s:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[o>>2]=s-r,t[l>>2]=A-r)}function Xe(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;A=t[e>>2]|0,o=e+4|0,n=t[o>>2]|0,l=e+8|0,r=t[l>>2]|0,s=n+A|0,t[e>>2]=s,n=r+n|0,t[o>>2]=n,A=r+A|0,t[l>>2]=A,r=n-s|0,(s|0)<0?(A=A-s|0,t[o>>2]=r,t[l>>2]=A,t[e>>2]=0,n=0):(r=n,n=s),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),i=n-A|0,s=r-A|0,(A|0)<0?(t[e>>2]=i,t[o>>2]=s,t[l>>2]=0,n=i,A=0):s=r,r=(s|0)<(n|0)?s:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[o>>2]=s-r,t[l>>2]=A-r)}function rt(e){switch(e=e|0,e|0){case 1:{e=5;break}case 5:{e=4;break}case 4:{e=6;break}case 6:{e=2;break}case 2:{e=3;break}case 3:{e=1;break}}return e|0}function Jt(e){switch(e=e|0,e|0){case 1:{e=3;break}case 3:{e=2;break}case 2:{e=6;break}case 6:{e=4;break}case 4:{e=5;break}case 5:{e=1;break}}return e|0}function Jn(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;A=t[e>>2]|0,o=e+4|0,r=t[o>>2]|0,l=e+8|0,n=t[l>>2]|0,s=r+(A<<1)|0,t[e>>2]=s,r=n+(r<<1)|0,t[o>>2]=r,A=(n<<1)+A|0,t[l>>2]=A,n=r-s|0,(s|0)<0?(A=A-s|0,t[o>>2]=n,t[l>>2]=A,t[e>>2]=0,r=n,n=0):n=s,(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),i=n-A|0,s=r-A|0,(A|0)<0?(t[e>>2]=i,t[o>>2]=s,t[l>>2]=0,n=i,A=0):s=r,r=(s|0)<(n|0)?s:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[o>>2]=s-r,t[l>>2]=A-r)}function Xn(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;s=t[e>>2]|0,o=e+4|0,A=t[o>>2]|0,l=e+8|0,r=t[l>>2]|0,n=(A<<1)+s|0,s=r+(s<<1)|0,t[e>>2]=s,t[o>>2]=n,A=(r<<1)+A|0,t[l>>2]=A,r=n-s|0,(s|0)<0?(A=A-s|0,t[o>>2]=r,t[l>>2]=A,t[e>>2]=0,s=0):r=n,(r|0)<0&&(s=s-r|0,t[e>>2]=s,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),i=s-A|0,n=r-A|0,(A|0)<0?(t[e>>2]=i,t[o>>2]=n,t[l>>2]=0,s=i,A=0):n=r,r=(n|0)<(s|0)?n:s,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=s-r,t[o>>2]=n-r,t[l>>2]=A-r)}function Dn(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0;return o=(t[e>>2]|0)-(t[A>>2]|0)|0,l=(o|0)<0,n=(t[e+4>>2]|0)-(t[A+4>>2]|0)-(l?o:0)|0,i=(n|0)<0,s=(l?0-o|0:0)+(t[e+8>>2]|0)-(t[A+8>>2]|0)+(i?0-n|0:0)|0,e=(s|0)<0,A=e?0:s,r=(i?0:n)-(e?s:0)|0,s=(l?0:o)-(i?n:0)-(e?s:0)|0,e=(r|0)<(s|0)?r:s,e=(A|0)<(e|0)?A:e,n=(e|0)>0,A=A-(n?e:0)|0,r=r-(n?e:0)|0,e=s-(n?e:0)|0,e=(e|0)>-1?e:0-e|0,r=(r|0)>-1?r:0-r|0,A=(A|0)>-1?A:0-A|0,A=(r|0)>(A|0)?r:A,((e|0)>(A|0)?e:A)|0}function A0(e,A){e=e|0,A=A|0;var r=0;r=t[e+8>>2]|0,t[A>>2]=(t[e>>2]|0)-r,t[A+4>>2]=(t[e+4>>2]|0)-r}function It(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0;return n=t[e>>2]|0,t[A>>2]=n,s=t[e+4>>2]|0,o=A+4|0,t[o>>2]=s,l=A+8|0,t[l>>2]=0,r=(s|0)<(n|0),e=r?n:s,r=r?s:n,(r|0)<0&&((r|0)==-2147483648||((e|0)>0?(2147483647-e|0)<(r|0):(-2147483648-e|0)>(r|0))||((e|0)>-1?(e|-2147483648|0)>=(r|0):(e^-2147483648|0)<(r|0)))?(A=1,A|0):(e=s-n|0,(n|0)<0?(r=0-n|0,t[o>>2]=e,t[l>>2]=r,t[A>>2]=0,n=0):(e=s,r=0),(e|0)<0&&(n=n-e|0,t[A>>2]=n,r=r-e|0,t[l>>2]=r,t[o>>2]=0,e=0),i=n-r|0,s=e-r|0,(r|0)<0?(t[A>>2]=i,t[o>>2]=s,t[l>>2]=0,e=s,s=i,r=0):s=n,n=(e|0)<(s|0)?e:s,n=(r|0)<(n|0)?r:n,(n|0)<=0?(A=0,A|0):(t[A>>2]=s-n,t[o>>2]=e-n,t[l>>2]=r-n,A=0,A|0))}function e0(e){e=e|0;var A=0,r=0,n=0,s=0;A=e+8|0,s=t[A>>2]|0,r=s-(t[e>>2]|0)|0,t[e>>2]=r,n=e+4|0,e=(t[n>>2]|0)-s|0,t[n>>2]=e,t[A>>2]=0-(e+r)}function t0(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;r=t[e>>2]|0,A=0-r|0,t[e>>2]=A,o=e+8|0,t[o>>2]=0,l=e+4|0,n=t[l>>2]|0,s=n+r|0,(r|0)>0?(t[l>>2]=s,t[o>>2]=r,t[e>>2]=0,A=0,n=s):r=0,(n|0)<0?(i=A-n|0,t[e>>2]=i,r=r-n|0,t[o>>2]=r,t[l>>2]=0,s=i-r|0,A=0-r|0,(r|0)<0?(t[e>>2]=s,t[l>>2]=A,t[o>>2]=0,n=A,r=0):(n=0,s=i)):s=A,A=(n|0)<(s|0)?n:s,A=(r|0)<(A|0)?r:A,!((A|0)<=0)&&(t[e>>2]=s-A,t[l>>2]=n-A,t[o>>2]=r-A)}function rs(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,u=0,f=0,p=0,M=0;if(M=C,C=C+64|0,p=M,l=M+56|0,!(!0&(A&2013265920|0)==134217728&(!0&(n&2013265920|0)==134217728)))return s=5,C=M,s|0;if((e|0)==(r|0)&(A|0)==(n|0))return t[s>>2]=0,s=0,C=M,s|0;if(o=yA(e|0,A|0,52)|0,S()|0,o=o&15,f=yA(r|0,n|0,52)|0,S()|0,(o|0)!=(f&15|0))return s=12,C=M,s|0;if(i=o+-1|0,o>>>0>1){Ft(e,A,i,p)|0,Ft(r,n,i,l)|0,f=p,u=t[f>>2]|0,f=t[f+4>>2]|0;A:do if((u|0)==(t[l>>2]|0)&&(f|0)==(t[l+4>>2]|0)){o=(o^15)*3|0,i=yA(e|0,A|0,o|0)|0,S()|0,i=i&7,o=yA(r|0,n|0,o|0)|0,S()|0,o=o&7;do if((i|0)==0|(o|0)==0)t[s>>2]=1,i=0;else if((i|0)==7)i=5;else{if((i|0)==1|(o|0)==1&&Qe(u,f)|0){i=5;break}if((t[15536+(i<<2)>>2]|0)!=(o|0)&&(t[15568+(i<<2)>>2]|0)!=(o|0))break A;t[s>>2]=1,i=0}while(!1);return s=i,C=M,s|0}while(!1)}i=p,o=i+56|0;do t[i>>2]=0,i=i+4|0;while((i|0)<(o|0));return v(e,A,1,p)|0,A=p,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0))&&(A=p+8|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=p+16|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=p+24|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=p+32|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=p+40|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))?(i=p+48|0,i=((t[i>>2]|0)==(r|0)?(t[i+4>>2]|0)==(n|0):0)&1):i=1,t[s>>2]=i,s=0,C=M,s|0}function b0(e,A,r,n,s){return e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,r=ee(e,A,r,n)|0,(r|0)==7?(s=11,s|0):(n=CA(r|0,0,56)|0,A=A&-2130706433|(S()|0)|268435456,t[s>>2]=e|n,t[s+4>>2]=A,s=0,s|0)}function _n(e,A,r){return e=e|0,A=A|0,r=r|0,!0&(A&2013265920|0)==268435456?(t[r>>2]=e,t[r+4>>2]=A&-2130706433|134217728,r=0,r|0):(r=6,r|0)}function k0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;return s=C,C=C+16|0,n=s,t[n>>2]=0,!0&(A&2013265920|0)==268435456?(i=yA(e|0,A|0,56)|0,S()|0,n=K(e,A&-2130706433|134217728,i&7,n,r)|0,C=s,n|0):(n=6,C=s,n|0)}function r0(e,A){e=e|0,A=A|0;var r=0;switch(r=yA(e|0,A|0,56)|0,S()|0,r&7){case 0:case 7:return r=0,r|0}return r=A&-2130706433|134217728,!(!0&(A&2013265920|0)==268435456)||!0&(A&117440512|0)==16777216&(Qe(e,r)|0)!=0?(r=0,r|0):(r=Ue(e,r)|0,r|0)}function jn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;return s=C,C=C+16|0,n=s,!0&(A&2013265920|0)==268435456?(i=A&-2130706433|134217728,o=r,t[o>>2]=e,t[o+4>>2]=i,t[n>>2]=0,A=yA(e|0,A|0,56)|0,S()|0,n=K(e,i,A&7,n,r+8|0)|0,C=s,n|0):(n=6,C=s,n|0)}function Tn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;return s=(Qe(e,A)|0)==0,A=A&-2130706433,n=r,t[n>>2]=s?e:0,t[n+4>>2]=s?A|285212672:0,n=r+8|0,t[n>>2]=e,t[n+4>>2]=A|301989888,n=r+16|0,t[n>>2]=e,t[n+4>>2]=A|318767104,n=r+24|0,t[n>>2]=e,t[n+4>>2]=A|335544320,n=r+32|0,t[n>>2]=e,t[n+4>>2]=A|352321536,r=r+40|0,t[r>>2]=e,t[r+4>>2]=A|369098752,0}function fn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;return o=C,C=C+16|0,s=o,i=A&-2130706433|134217728,!0&(A&2013265920|0)==268435456?(n=yA(e|0,A|0,56)|0,S()|0,n=ma(e,i,n&7)|0,(n|0)==-1?(t[r>>2]=0,i=6,C=o,i|0):(Rn(e,i,s)|0&&OA(27795,26932,282,26947),A=yA(e|0,A|0,52)|0,S()|0,A=A&15,Qe(e,i)|0?w(s,A,n,2,r):eA(s,A,n,2,r),i=0,C=o,i|0)):(i=6,C=o,i|0)}function C0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;n=C,C=C+16|0,s=n,E0(e,A,r,s),cn(s,r+4|0),C=n}function E0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0;if(l=C,C=C+16|0,u=l,n0(e,r,u),i=+Dt(+(1-+k[u>>3]*.5)),i<1e-16){t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,t[n+12>>2]=0,C=l;return}if(u=t[r>>2]|0,s=+k[15920+(u*24|0)>>3],s=+i0(s-+i0(+Pl(15600+(u<<4)|0,e))),lr(A)|0?o=+i0(s+-.3334731722518321):o=s,s=+it(+i)*2.618033988749896,(A|0)>0){e=0;do s=s*2.6457513110645907,e=e+1|0;while((e|0)!=(A|0))}i=+Be(+o)*s,k[n>>3]=i,o=+WA(+o)*s,k[n+8>>3]=o,C=l}function n0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if(i=C,C=C+32|0,s=i,da(e,s),t[A>>2]=0,k[r>>3]=5,n=+ft(16400,s),n<+k[r>>3]&&(t[A>>2]=0,k[r>>3]=n),n=+ft(16424,s),n<+k[r>>3]&&(t[A>>2]=1,k[r>>3]=n),n=+ft(16448,s),n<+k[r>>3]&&(t[A>>2]=2,k[r>>3]=n),n=+ft(16472,s),n<+k[r>>3]&&(t[A>>2]=3,k[r>>3]=n),n=+ft(16496,s),n<+k[r>>3]&&(t[A>>2]=4,k[r>>3]=n),n=+ft(16520,s),n<+k[r>>3]&&(t[A>>2]=5,k[r>>3]=n),n=+ft(16544,s),n<+k[r>>3]&&(t[A>>2]=6,k[r>>3]=n),n=+ft(16568,s),n<+k[r>>3]&&(t[A>>2]=7,k[r>>3]=n),n=+ft(16592,s),n<+k[r>>3]&&(t[A>>2]=8,k[r>>3]=n),n=+ft(16616,s),n<+k[r>>3]&&(t[A>>2]=9,k[r>>3]=n),n=+ft(16640,s),n<+k[r>>3]&&(t[A>>2]=10,k[r>>3]=n),n=+ft(16664,s),n<+k[r>>3]&&(t[A>>2]=11,k[r>>3]=n),n=+ft(16688,s),n<+k[r>>3]&&(t[A>>2]=12,k[r>>3]=n),n=+ft(16712,s),n<+k[r>>3]&&(t[A>>2]=13,k[r>>3]=n),n=+ft(16736,s),n<+k[r>>3]&&(t[A>>2]=14,k[r>>3]=n),n=+ft(16760,s),n<+k[r>>3]&&(t[A>>2]=15,k[r>>3]=n),n=+ft(16784,s),n<+k[r>>3]&&(t[A>>2]=16,k[r>>3]=n),n=+ft(16808,s),n<+k[r>>3]&&(t[A>>2]=17,k[r>>3]=n),n=+ft(16832,s),n<+k[r>>3]&&(t[A>>2]=18,k[r>>3]=n),n=+ft(16856,s),!(n<+k[r>>3])){C=i;return}t[A>>2]=19,k[r>>3]=n,C=i}function Kr(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0;if(i=+ha(e),i<1e-16){A=15600+(A<<4)|0,t[s>>2]=t[A>>2],t[s+4>>2]=t[A+4>>2],t[s+8>>2]=t[A+8>>2],t[s+12>>2]=t[A+12>>2];return}if(o=+Je(+ +k[e+8>>3],+ +k[e>>3]),(r|0)>0){e=0;do i=i*.37796447300922725,e=e+1|0;while((e|0)!=(r|0))}l=i*.3333333333333333,n?(r=(lr(r)|0)==0,i=+ir(+((r?l:l*.37796447300922725)*.381966011250105))):(i=+ir(+(i*.381966011250105)),lr(r)|0&&(o=+i0(o+.3334731722518321))),Ql(15600+(A<<4)|0,+i0(+k[15920+(A*24|0)>>3]-o),i,s)}function d(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;n=C,C=C+16|0,s=n,qt(e+4|0,s),Kr(s,t[e>>2]|0,A,0,r),C=n}function w(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,Z=0,V=0,BA=0,GA=0,QA=0,ce=0,de=0,Se=0,ie=0,UA=0,SA=0,ve=0,Ve=0,me=0;if(ve=C,C=C+272|0,i=ve+256|0,q=ve+240|0,ie=ve,UA=ve+224|0,SA=ve+208|0,Z=ve+176|0,V=ve+160|0,BA=ve+192|0,GA=ve+144|0,QA=ve+128|0,ce=ve+112|0,de=ve+96|0,Se=ve+80|0,t[i>>2]=A,t[q>>2]=t[e>>2],t[q+4>>2]=t[e+4>>2],t[q+8>>2]=t[e+8>>2],t[q+12>>2]=t[e+12>>2],_(q,i,ie),t[s>>2]=0,q=n+r+((n|0)==5&1)|0,(q|0)<=(r|0)){C=ve;return}u=t[i>>2]|0,f=UA+4|0,p=Z+4|0,M=r+5|0,I=16880+(u<<2)|0,L=16960+(u<<2)|0,N=QA+8|0,G=ce+8|0,Y=de+8|0,nA=SA+4|0,l=r;A:for(;;){o=ie+(((l|0)%5|0)<<4)|0,t[SA>>2]=t[o>>2],t[SA+4>>2]=t[o+4>>2],t[SA+8>>2]=t[o+8>>2],t[SA+12>>2]=t[o+12>>2];do;while((F(SA,u,0,1)|0)==2);if((l|0)>(r|0)&(lr(A)|0)!=0){if(t[Z>>2]=t[SA>>2],t[Z+4>>2]=t[SA+4>>2],t[Z+8>>2]=t[SA+8>>2],t[Z+12>>2]=t[SA+12>>2],qt(f,V),n=t[Z>>2]|0,i=t[17040+(n*80|0)+(t[UA>>2]<<2)>>2]|0,t[Z>>2]=t[18640+(n*80|0)+(i*20|0)>>2],o=t[18640+(n*80|0)+(i*20|0)+16>>2]|0,(o|0)>0){e=0;do ct(p),e=e+1|0;while((e|0)<(o|0))}switch(o=18640+(n*80|0)+(i*20|0)+4|0,t[BA>>2]=t[o>>2],t[BA+4>>2]=t[o+4>>2],t[BA+8>>2]=t[o+8>>2],oA(BA,(t[I>>2]|0)*3|0),ut(p,BA,p),et(p),qt(p,GA),Ve=+(t[L>>2]|0),k[QA>>3]=Ve*3,k[N>>3]=0,me=Ve*-1.5,k[ce>>3]=me,k[G>>3]=Ve*2.598076211353316,k[de>>3]=me,k[Y>>3]=Ve*-2.598076211353316,t[17040+((t[Z>>2]|0)*80|0)+(t[SA>>2]<<2)>>2]|0){case 1:{e=ce,n=QA;break}case 3:{e=de,n=ce;break}case 2:{e=QA,n=de;break}default:{e=12;break A}}ai(V,GA,n,e,Se),Kr(Se,t[Z>>2]|0,u,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1}if((l|0)<(M|0)&&(qt(nA,Z),Kr(Z,t[SA>>2]|0,u,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1),t[UA>>2]=t[SA>>2],t[UA+4>>2]=t[SA+4>>2],t[UA+8>>2]=t[SA+8>>2],t[UA+12>>2]=t[SA+12>>2],l=l+1|0,(l|0)>=(q|0)){e=3;break}}if((e|0)==3){C=ve;return}else(e|0)==12&&OA(26970,27017,572,27027)}function _(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0;u=C,C=C+128|0,n=u+64|0,s=u,i=n,o=20240,l=i+60|0;do t[i>>2]=t[o>>2],i=i+4|0,o=o+4|0;while((i|0)<(l|0));i=s,o=20304,l=i+60|0;do t[i>>2]=t[o>>2],i=i+4|0,o=o+4|0;while((i|0)<(l|0));l=(lr(t[A>>2]|0)|0)==0,n=l?n:s,s=e+4|0,Jn(s),Xn(s),lr(t[A>>2]|0)|0&&(Ge(s),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,ut(s,n,A),et(A),t[r+16>>2]=t[e>>2],A=r+20|0,ut(s,n+12|0,A),et(A),t[r+32>>2]=t[e>>2],A=r+36|0,ut(s,n+24|0,A),et(A),t[r+48>>2]=t[e>>2],A=r+52|0,ut(s,n+36|0,A),et(A),t[r+64>>2]=t[e>>2],r=r+68|0,ut(s,n+48|0,r),et(r),C=u}function F(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0;if(N=C,C=C+32|0,I=N+12|0,l=N,L=e+4|0,M=t[16960+(A<<2)>>2]|0,p=(n|0)!=0,M=p?M*3|0:M,s=t[L>>2]|0,f=e+8|0,o=t[f>>2]|0,p){if(i=e+12|0,n=t[i>>2]|0,s=o+s+n|0,(s|0)==(M|0))return L=1,C=N,L|0;u=i}else u=e+12|0,n=t[u>>2]|0,s=o+s+n|0;if((s|0)<=(M|0))return L=0,C=N,L|0;do if((n|0)>0){if(n=t[e>>2]|0,(o|0)>0){i=18640+(n*80|0)+60|0,n=e;break}n=18640+(n*80|0)+40|0,r?(Bn(I,M,0,0),H(L,I,l),Xe(l),ut(l,I,L),i=n,n=e):(i=n,n=e)}else i=18640+((t[e>>2]|0)*80|0)+20|0,n=e;while(!1);if(t[n>>2]=t[i>>2],s=i+16|0,(t[s>>2]|0)>0){n=0;do ct(L),n=n+1|0;while((n|0)<(t[s>>2]|0))}return e=i+4|0,t[I>>2]=t[e>>2],t[I+4>>2]=t[e+4>>2],t[I+8>>2]=t[e+8>>2],A=t[16880+(A<<2)>>2]|0,oA(I,p?A*3|0:A),ut(L,I,L),et(L),p?n=((t[f>>2]|0)+(t[L>>2]|0)+(t[u>>2]|0)|0)==(M|0)?1:2:n=2,L=n,C=N,L|0}function rA(e,A){e=e|0,A=A|0;var r=0;do r=F(e,A,0,1)|0;while((r|0)==2);return r|0}function eA(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,Z=0,V=0,BA=0,GA=0,QA=0,ce=0,de=0,Se=0,ie=0;if(de=C,C=C+240|0,i=de+224|0,BA=de+208|0,GA=de,QA=de+192|0,ce=de+176|0,Y=de+160|0,nA=de+144|0,q=de+128|0,Z=de+112|0,V=de+96|0,t[i>>2]=A,t[BA>>2]=t[e>>2],t[BA+4>>2]=t[e+4>>2],t[BA+8>>2]=t[e+8>>2],t[BA+12>>2]=t[e+12>>2],dA(BA,i,GA),t[s>>2]=0,G=n+r+((n|0)==6&1)|0,(G|0)<=(r|0)){C=de;return}u=t[i>>2]|0,f=r+6|0,p=16960+(u<<2)|0,M=nA+8|0,I=q+8|0,L=Z+8|0,N=QA+4|0,o=0,l=r,n=-1;A:for(;;){if(i=(l|0)%6|0,e=GA+(i<<4)|0,t[QA>>2]=t[e>>2],t[QA+4>>2]=t[e+4>>2],t[QA+8>>2]=t[e+8>>2],t[QA+12>>2]=t[e+12>>2],e=o,o=F(QA,u,0,1)|0,(l|0)>(r|0)&(lr(A)|0)!=0&&(e|0)!=1&&(t[QA>>2]|0)!=(n|0)){switch(qt(GA+(((i+5|0)%6|0)<<4)+4|0,ce),qt(GA+(i<<4)+4|0,Y),Se=+(t[p>>2]|0),k[nA>>3]=Se*3,k[M>>3]=0,ie=Se*-1.5,k[q>>3]=ie,k[I>>3]=Se*2.598076211353316,k[Z>>3]=ie,k[L>>3]=Se*-2.598076211353316,i=t[BA>>2]|0,t[17040+(i*80|0)+(((n|0)==(i|0)?t[QA>>2]|0:n)<<2)>>2]|0){case 1:{e=q,n=nA;break}case 3:{e=Z,n=q;break}case 2:{e=nA,n=Z;break}default:{e=8;break A}}ai(ce,Y,n,e,V),!(ui(ce,V)|0)&&!(ui(Y,V)|0)&&(Kr(V,t[BA>>2]|0,u,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1)}if((l|0)<(f|0)&&(qt(N,ce),Kr(ce,t[QA>>2]|0,u,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1),l=l+1|0,(l|0)>=(G|0)){e=3;break}else n=t[QA>>2]|0}if((e|0)==3){C=de;return}else(e|0)==8&&OA(27054,27017,737,27099)}function dA(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0;u=C,C=C+160|0,n=u+80|0,s=u,i=n,o=20368,l=i+72|0;do t[i>>2]=t[o>>2],i=i+4|0,o=o+4|0;while((i|0)<(l|0));i=s,o=20448,l=i+72|0;do t[i>>2]=t[o>>2],i=i+4|0,o=o+4|0;while((i|0)<(l|0));l=(lr(t[A>>2]|0)|0)==0,n=l?n:s,s=e+4|0,Jn(s),Xn(s),lr(t[A>>2]|0)|0&&(Ge(s),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,ut(s,n,A),et(A),t[r+16>>2]=t[e>>2],A=r+20|0,ut(s,n+12|0,A),et(A),t[r+32>>2]=t[e>>2],A=r+36|0,ut(s,n+24|0,A),et(A),t[r+48>>2]=t[e>>2],A=r+52|0,ut(s,n+36|0,A),et(A),t[r+64>>2]=t[e>>2],A=r+68|0,ut(s,n+48|0,A),et(A),t[r+80>>2]=t[e>>2],r=r+84|0,ut(s,n+60|0,r),et(r),C=u}function DA(e,A){return e=e|0,A=A|0,A=yA(e|0,A|0,52)|0,S()|0,A&15|0}function ne(e,A){return e=e|0,A=A|0,A=yA(e|0,A|0,45)|0,S()|0,A&127|0}function Ce(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,(r+-1|0)>>>0>14?(n=4,n|0):(r=yA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,t[n>>2]=r&7,n=0,n|0)}function we(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0;if(e>>>0>15)return n=4,n|0;if(A>>>0>121)return n=17,n|0;o=CA(e|0,0,52)|0,s=S()|0,l=CA(A|0,0,45)|0,s=s|(S()|0)|134225919;A:do if((e|0)>=1){for(l=1,o=(gA[20528+A>>0]|0)!=0,i=-1;;){if(A=t[r+(l+-1<<2)>>2]|0,A>>>0>6){s=18,A=10;break}if(!((A|0)==0|o^1))if((A|0)==1){s=19,A=10;break}else o=0;if(f=(15-l|0)*3|0,u=CA(7,0,f|0)|0,s=s&~(S()|0),A=CA(A|0,((A|0)<0)<<31>>31|0,f|0)|0,i=A|i&~u,s=S()|0|s,(l|0)<(e|0))l=l+1|0;else break A}if((A|0)==10)return s|0}else i=-1;while(!1);return f=n,t[f>>2]=i,t[f+4>>2]=s,f=0,f|0}function Ue(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0;return!(!0&(A&-16777216|0)==134217728)||(n=yA(e|0,A|0,52)|0,S()|0,n=n&15,r=yA(e|0,A|0,45)|0,S()|0,r=r&127,r>>>0>121)?(e=0,e|0):(o=(n^15)*3|0,s=yA(e|0,A|0,o|0)|0,o=CA(s|0,S()|0,o|0)|0,s=S()|0,i=gt(-1227133514,-1171,o|0,s|0)|0,!((o&613566756&i|0)==0&(s&4681&(S()|0)|0)==0)||(o=(n*3|0)+19|0,i=CA(~e|0,~A|0,o|0)|0,o=yA(i|0,S()|0,o|0)|0,!((n|0)==15|(o|0)==0&(S()|0)==0))?(o=0,o|0):!(gA[20528+r>>0]|0)||(A=A&8191,(e|0)==0&(A|0)==0)?(o=1,o|0):(o=ps(e|0,A|0)|0,S()|0,((63-o|0)%3|0|0)!=0|0))}function Lt(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0;return!0&(A&-16777216|0)==134217728&&(n=yA(e|0,A|0,52)|0,S()|0,n=n&15,r=yA(e|0,A|0,45)|0,S()|0,r=r&127,r>>>0<=121)&&(o=(n^15)*3|0,s=yA(e|0,A|0,o|0)|0,o=CA(s|0,S()|0,o|0)|0,s=S()|0,i=gt(-1227133514,-1171,o|0,s|0)|0,(o&613566756&i|0)==0&(s&4681&(S()|0)|0)==0)&&(o=(n*3|0)+19|0,i=CA(~e|0,~A|0,o|0)|0,o=yA(i|0,S()|0,o|0)|0,(n|0)==15|(o|0)==0&(S()|0)==0)&&(!(gA[20528+r>>0]|0)||(r=A&8191,(e|0)==0&(r|0)==0)||(o=ps(e|0,r|0)|0,S()|0,(63-o|0)%3|0|0))||r0(e,A)|0?(o=1,o|0):(o=(ci(e,A)|0)!=0&1,o|0)}function Nt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0;if(s=CA(A|0,0,52)|0,i=S()|0,r=CA(r|0,0,45)|0,r=i|(S()|0)|134225919,(A|0)<1){i=-1,n=r,A=e,t[A>>2]=i,e=e+4|0,t[e>>2]=n;return}for(i=1,s=-1;o=(15-i|0)*3|0,l=CA(7,0,o|0)|0,r=r&~(S()|0),o=CA(n|0,0,o|0)|0,s=s&~l|o,r=r|(S()|0),(i|0)!=(A|0);)i=i+1|0;l=e,o=l,t[o>>2]=s,l=l+4|0,t[l>>2]=r}function Ft(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0;if(i=yA(e|0,A|0,52)|0,S()|0,i=i&15,r>>>0>15)return n=4,n|0;if((i|0)<(r|0))return n=12,n|0;if((i|0)==(r|0))return t[n>>2]=e,t[n+4>>2]=A,n=0,n|0;if(s=CA(r|0,0,52)|0,s=s|e,e=S()|0|A&-15728641,(i|0)>(r|0))do A=CA(7,0,(14-r|0)*3|0)|0,r=r+1|0,s=A|s,e=S()|0|e;while((r|0)<(i|0));return t[n>>2]=s,t[n+4>>2]=e,n=0,n|0}function Mr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0;if(i=yA(e|0,A|0,52)|0,S()|0,i=i&15,!((r|0)<16&(i|0)<=(r|0)))return n=4,n|0;s=r-i|0,r=yA(e|0,A|0,45)|0,S()|0;A:do if(!(be(r&127)|0))r=Zr(7,0,s,((s|0)<0)<<31>>31)|0,s=S()|0;else{e:do if(i|0){for(r=1;o=CA(7,0,(15-r|0)*3|0)|0,!!((o&e|0)==0&((S()|0)&A|0)==0);)if(r>>>0>>0)r=r+1|0;else break e;r=Zr(7,0,s,((s|0)<0)<<31>>31)|0,s=S()|0;break A}while(!1);r=Zr(7,0,s,((s|0)<0)<<31>>31)|0,r=yt(r|0,S()|0,5,0)|0,r=ZA(r|0,S()|0,-5,-1)|0,r=qr(r|0,S()|0,6,0)|0,r=ZA(r|0,S()|0,1,0)|0,s=S()|0}while(!1);return o=n,t[o>>2]=r,t[o+4>>2]=s,o=0,o|0}function Qe(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;if(s=yA(e|0,A|0,45)|0,S()|0,!(be(s&127)|0))return s=0,s|0;s=yA(e|0,A|0,52)|0,S()|0,s=s&15;A:do if(!s)r=0;else for(n=1;;){if(r=yA(e|0,A|0,(15-n|0)*3|0)|0,S()|0,r=r&7,r|0)break A;if(n>>>0>>0)n=n+1|0;else{r=0;break}}while(!1);return s=(r|0)==0&1,s|0}function s0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0;if(o=C,C=C+16|0,i=o,as(i,e,A,r),A=i,e=t[A>>2]|0,A=t[A+4>>2]|0,(e|0)==0&(A|0)==0)return C=o,0;s=0,r=0;do l=n+(s<<3)|0,t[l>>2]=e,t[l+4>>2]=A,s=ZA(s|0,r|0,1,0)|0,r=S()|0,us(i),l=i,e=t[l>>2]|0,A=t[l+4>>2]|0;while(!((e|0)==0&(A|0)==0));return C=o,0}function $s(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,(n|0)<(r|0)?(r=A,n=e,JA(r|0),n|0):(r=CA(-1,-1,((n-r|0)*3|0)+3|0)|0,n=CA(~r|0,~(S()|0)|0,(15-n|0)*3|0)|0,r=~(S()|0)&A,n=~n&e,JA(r|0),n|0)}function qs(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0;return s=yA(e|0,A|0,52)|0,S()|0,s=s&15,(r|0)<16&(s|0)<=(r|0)?((s|0)<(r|0)&&(s=CA(-1,-1,((r+-1-s|0)*3|0)+3|0)|0,s=CA(~s|0,~(S()|0)|0,(15-r|0)*3|0)|0,A=~(S()|0)&A,e=~s&e),s=CA(r|0,0,52)|0,r=A&-15728641|(S()|0),t[n>>2]=e|s,t[n+4>>2]=r,n=0,n|0):(n=4,n|0)}function Sl(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,Z=0,V=0,BA=0,GA=0,QA=0,ce=0,de=0,Se=0,ie=0,UA=0,SA=0;if((r|0)==0&(n|0)==0)return SA=0,SA|0;if(s=e,i=t[s>>2]|0,s=t[s+4>>2]|0,!0&(s&15728640|0)==0){if(!((n|0)>0|(n|0)==0&r>>>0>0)||(SA=A,t[SA>>2]=i,t[SA+4>>2]=s,(r|0)==1&(n|0)==0))return SA=0,SA|0;s=1,i=0;do ie=e+(s<<3)|0,UA=t[ie+4>>2]|0,SA=A+(s<<3)|0,t[SA>>2]=t[ie>>2],t[SA+4>>2]=UA,s=ZA(s|0,i|0,1,0)|0,i=S()|0;while((i|0)<(n|0)|(i|0)==(n|0)&s>>>0>>0);return s=0,s|0}if(Se=r<<3,UA=Br(Se)|0,!UA)return SA=13,SA|0;if(Pn(UA|0,e|0,Se|0)|0,ie=Wt(r,8)|0,!ie)return $A(UA),SA=13,SA|0;A:for(;;){s=UA,f=t[s>>2]|0,s=t[s+4>>2]|0,ce=yA(f|0,s|0,52)|0,S()|0,ce=ce&15,de=ce+-1|0,QA=(ce|0)!=0,GA=(n|0)>0|(n|0)==0&r>>>0>0;e:do if(QA&GA){if(q=CA(de|0,0,52)|0,Z=S()|0,de>>>0>15){if(!((f|0)==0&(s|0)==0)){SA=16;break A}for(i=0,e=0;;){if(i=ZA(i|0,e|0,1,0)|0,e=S()|0,!((e|0)<(n|0)|(e|0)==(n|0)&i>>>0>>0))break e;if(o=UA+(i<<3)|0,BA=t[o>>2]|0,o=t[o+4>>2]|0,!((BA|0)==0&(o|0)==0)){s=o,SA=16;break A}}}for(l=f,e=s,i=0,o=0;;){if(!((l|0)==0&(e|0)==0)){if(!(!0&(e&117440512|0)==0)){SA=21;break A}if(p=yA(l|0,e|0,52)|0,S()|0,p=p&15,(p|0)<(de|0)){s=12,SA=27;break A}if((p|0)!=(de|0)&&(l=l|q,e=e&-15728641|Z,p>>>0>=ce>>>0)){u=de;do BA=CA(7,0,(14-u|0)*3|0)|0,u=u+1|0,l=BA|l,e=S()|0|e;while(u>>>0

>>0)}if(I=Fn(l|0,e|0,r|0,n|0)|0,L=S()|0,u=ie+(I<<3)|0,p=u,M=t[p>>2]|0,p=t[p+4>>2]|0,!((M|0)==0&(p|0)==0)){Y=0,nA=0;do{if((Y|0)>(n|0)|(Y|0)==(n|0)&nA>>>0>r>>>0){SA=31;break A}if((M|0)==(l|0)&(p&-117440513|0)==(e|0)){N=yA(M|0,p|0,56)|0,S()|0,N=N&7,G=N+1|0,BA=yA(M|0,p|0,45)|0,S()|0;t:do if(!(be(BA&127)|0))p=7;else{if(M=yA(M|0,p|0,52)|0,S()|0,M=M&15,!M){p=6;break}for(p=1;;){if(BA=CA(7,0,(15-p|0)*3|0)|0,!((BA&l|0)==0&((S()|0)&e|0)==0)){p=7;break t}if(p>>>0>>0)p=p+1|0;else{p=6;break}}}while(!1);if((N+2|0)>>>0>p>>>0){SA=41;break A}BA=CA(G|0,0,56)|0,e=S()|0|e&-117440513,V=u,t[V>>2]=0,t[V+4>>2]=0,l=BA|l}else I=ZA(I|0,L|0,1,0)|0,I=Nn(I|0,S()|0,r|0,n|0)|0,L=S()|0;nA=ZA(nA|0,Y|0,1,0)|0,Y=S()|0,u=ie+(I<<3)|0,p=u,M=t[p>>2]|0,p=t[p+4>>2]|0}while(!((M|0)==0&(p|0)==0))}BA=u,t[BA>>2]=l,t[BA+4>>2]=e}if(i=ZA(i|0,o|0,1,0)|0,o=S()|0,!((o|0)<(n|0)|(o|0)==(n|0)&i>>>0>>0))break e;e=UA+(i<<3)|0,l=t[e>>2]|0,e=t[e+4>>2]|0}}while(!1);if(BA=ZA(r|0,n|0,5,0)|0,V=S()|0,V>>>0<0|(V|0)==0&BA>>>0<11){SA=85;break}if(BA=qr(r|0,n|0,6,0)|0,S()|0,BA=Wt(BA,8)|0,!BA){SA=48;break}do if(GA){for(G=0,e=0,N=0,Y=0;;){if(p=ie+(G<<3)|0,o=p,i=t[o>>2]|0,o=t[o+4>>2]|0,(i|0)==0&(o|0)==0)V=N;else{M=yA(i|0,o|0,56)|0,S()|0,M=M&7,l=M+1|0,I=o&-117440513,V=yA(i|0,o|0,45)|0,S()|0;e:do if(be(V&127)|0){if(L=yA(i|0,o|0,52)|0,S()|0,L=L&15,L|0)for(u=1;;){if(V=CA(7,0,(15-u|0)*3|0)|0,!((i&V|0)==0&(I&(S()|0)|0)==0))break e;if(u>>>0>>0)u=u+1|0;else break}o=CA(l|0,0,56)|0,i=o|i,o=S()|0|I,l=p,t[l>>2]=i,t[l+4>>2]=o,l=M+2|0}while(!1);(l|0)==7?(V=BA+(e<<3)|0,t[V>>2]=i,t[V+4>>2]=o&-117440513,e=ZA(e|0,N|0,1,0)|0,V=S()|0):V=N}if(G=ZA(G|0,Y|0,1,0)|0,Y=S()|0,(Y|0)<(n|0)|(Y|0)==(n|0)&G>>>0>>0)N=V;else break}if(GA){if(nA=de>>>0>15,q=CA(de|0,0,52)|0,Z=S()|0,!QA){for(i=0,u=0,l=0,o=0;(f|0)==0&(s|0)==0||(de=A+(i<<3)|0,t[de>>2]=f,t[de+4>>2]=s,i=ZA(i|0,u|0,1,0)|0,u=S()|0),l=ZA(l|0,o|0,1,0)|0,o=S()|0,!!((o|0)<(n|0)|(o|0)==(n|0)&l>>>0>>0);)s=UA+(l<<3)|0,f=t[s>>2]|0,s=t[s+4>>2]|0;s=V;break}for(i=0,u=0,o=0,l=0;;){do if(!((f|0)==0&(s|0)==0)){if(L=yA(f|0,s|0,52)|0,S()|0,L=L&15,nA|(L|0)<(de|0)){SA=80;break A}if((L|0)!=(de|0)){if(p=f|q,M=s&-15728641|Z,L>>>0>=ce>>>0){I=de;do QA=CA(7,0,(14-I|0)*3|0)|0,I=I+1|0,p=QA|p,M=S()|0|M;while(I>>>0>>0)}}else p=f,M=s;N=Fn(p|0,M|0,r|0,n|0)|0,I=0,L=0,Y=S()|0;do{if((I|0)>(n|0)|(I|0)==(n|0)&L>>>0>r>>>0){SA=81;break A}if(QA=ie+(N<<3)|0,G=t[QA+4>>2]|0,(G&-117440513|0)==(M|0)&&(t[QA>>2]|0)==(p|0)){SA=65;break}QA=ZA(N|0,Y|0,1,0)|0,N=Nn(QA|0,S()|0,r|0,n|0)|0,Y=S()|0,L=ZA(L|0,I|0,1,0)|0,I=S()|0,QA=ie+(N<<3)|0}while(!((t[QA>>2]|0)==(p|0)&&(t[QA+4>>2]|0)==(M|0)));if((SA|0)==65&&(SA=0,!0&(G&117440512|0)==100663296))break;QA=A+(i<<3)|0,t[QA>>2]=f,t[QA+4>>2]=s,i=ZA(i|0,u|0,1,0)|0,u=S()|0}while(!1);if(o=ZA(o|0,l|0,1,0)|0,l=S()|0,!((l|0)<(n|0)|(l|0)==(n|0)&o>>>0>>0))break;s=UA+(o<<3)|0,f=t[s>>2]|0,s=t[s+4>>2]|0}s=V}else i=0,s=V}else i=0,e=0,s=0;while(!1);if(Jr(ie|0,0,Se|0)|0,Pn(UA|0,BA|0,e<<3|0)|0,$A(BA),(e|0)==0&(s|0)==0){SA=89;break}else A=A+(i<<3)|0,n=s,r=e}if((SA|0)==16)!0&(s&117440512|0)==0?(s=4,SA=27):SA=21;else if((SA|0)==31)OA(27795,27122,620,27132);else{if((SA|0)==41)return $A(UA),$A(ie),SA=10,SA|0;if((SA|0)==48)return $A(UA),$A(ie),SA=13,SA|0;(SA|0)==80?OA(27795,27122,711,27132):(SA|0)==81?OA(27795,27122,723,27132):(SA|0)==85&&(Pn(A|0,UA|0,r<<3|0)|0,SA=89)}return(SA|0)==21?($A(UA),$A(ie),SA=5,SA|0):(SA|0)==27?($A(UA),$A(ie),SA=s,SA|0):(SA|0)==89?($A(UA),$A(ie),SA=0,SA|0):0}function Ml(e,A,r,n,s,i,o){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,i=i|0,o=o|0;var l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0;if(G=C,C=C+16|0,N=G,!((r|0)>0|(r|0)==0&A>>>0>0))return N=0,C=G,N|0;if((o|0)>=16)return N=12,C=G,N|0;I=0,L=0,M=0,l=0;A:for(;;){if(f=e+(I<<3)|0,u=t[f>>2]|0,f=t[f+4>>2]|0,p=yA(u|0,f|0,52)|0,S()|0,(p&15|0)>(o|0)){l=12,u=11;break}if(as(N,u,f,o),p=N,f=t[p>>2]|0,p=t[p+4>>2]|0,(f|0)==0&(p|0)==0)u=M;else{u=M;do{if(!((l|0)<(i|0)|(l|0)==(i|0)&u>>>0>>0)){u=10;break A}M=n+(u<<3)|0,t[M>>2]=f,t[M+4>>2]=p,u=ZA(u|0,l|0,1,0)|0,l=S()|0,us(N),M=N,f=t[M>>2]|0,p=t[M+4>>2]|0}while(!((f|0)==0&(p|0)==0))}if(I=ZA(I|0,L|0,1,0)|0,L=S()|0,(L|0)<(r|0)|(L|0)==(r|0)&I>>>0>>0)M=u;else{l=0,u=11;break}}return(u|0)==10?(N=14,C=G,N|0):(u|0)==11?(C=G,l|0):0}function Bl(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0;I=C,C=C+16|0,M=I;A:do if((r|0)>0|(r|0)==0&A>>>0>0){for(f=0,o=0,i=0,p=0;;){if(u=e+(f<<3)|0,l=t[u>>2]|0,u=t[u+4>>2]|0,!((l|0)==0&(u|0)==0)&&(u=(Mr(l,u,n,M)|0)==0,l=M,o=ZA(t[l>>2]|0,t[l+4>>2]|0,o|0,i|0)|0,i=S()|0,!u)){i=12;break}if(f=ZA(f|0,p|0,1,0)|0,p=S()|0,!((p|0)<(r|0)|(p|0)==(r|0)&f>>>0>>0))break A}return C=I,i|0}else o=0,i=0;while(!1);return t[s>>2]=o,t[s+4>>2]=i,s=0,C=I,s|0}function Dl(e,A){return e=e|0,A=A|0,A=yA(e|0,A|0,52)|0,S()|0,A&1|0}function Vt(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;if(s=yA(e|0,A|0,52)|0,S()|0,s=s&15,!s)return s=0,s|0;for(n=1;;){if(r=yA(e|0,A|0,(15-n|0)*3|0)|0,S()|0,r=r&7,r|0){n=5;break}if(n>>>0>>0)n=n+1|0;else{r=0,n=5;break}}return(n|0)==5?r|0:0}function ns(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0;if(u=yA(e|0,A|0,52)|0,S()|0,u=u&15,!u)return l=A,u=e,JA(l|0),u|0;for(l=1,r=0;;){i=(15-l|0)*3|0,n=CA(7,0,i|0)|0,s=S()|0,o=yA(e|0,A|0,i|0)|0,S()|0,i=CA(rt(o&7)|0,0,i|0)|0,o=S()|0,e=i|e&~n,A=o|A&~s;A:do if(!r)if((i&n|0)==0&(o&s|0)==0)r=0;else if(n=yA(e|0,A|0,52)|0,S()|0,n=n&15,!n)r=1;else{r=1;e:for(;;){switch(o=yA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,o&7){case 1:break e;case 0:break;default:{r=1;break A}}if(r>>>0>>0)r=r+1|0;else{r=1;break A}}for(r=1;;)if(o=(15-r|0)*3|0,s=yA(e|0,A|0,o|0)|0,S()|0,i=CA(7,0,o|0)|0,A=A&~(S()|0),o=CA(rt(s&7)|0,0,o|0)|0,e=e&~i|o,A=A|(S()|0),r>>>0>>0)r=r+1|0;else{r=1;break}}while(!1);if(l>>>0>>0)l=l+1|0;else break}return JA(A|0),e|0}function hn(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0;if(n=yA(e|0,A|0,52)|0,S()|0,n=n&15,!n)return r=A,n=e,JA(r|0),n|0;for(r=1;i=(15-r|0)*3|0,o=yA(e|0,A|0,i|0)|0,S()|0,s=CA(7,0,i|0)|0,A=A&~(S()|0),i=CA(rt(o&7)|0,0,i|0)|0,e=i|e&~s,A=S()|0|A,r>>>0>>0;)r=r+1|0;return JA(A|0),e|0}function _l(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0;if(u=yA(e|0,A|0,52)|0,S()|0,u=u&15,!u)return l=A,u=e,JA(l|0),u|0;for(l=1,r=0;;){i=(15-l|0)*3|0,n=CA(7,0,i|0)|0,s=S()|0,o=yA(e|0,A|0,i|0)|0,S()|0,i=CA(Jt(o&7)|0,0,i|0)|0,o=S()|0,e=i|e&~n,A=o|A&~s;A:do if(!r)if((i&n|0)==0&(o&s|0)==0)r=0;else if(n=yA(e|0,A|0,52)|0,S()|0,n=n&15,!n)r=1;else{r=1;e:for(;;){switch(o=yA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,o&7){case 1:break e;case 0:break;default:{r=1;break A}}if(r>>>0>>0)r=r+1|0;else{r=1;break A}}for(r=1;;)if(s=(15-r|0)*3|0,i=CA(7,0,s|0)|0,o=A&~(S()|0),A=yA(e|0,A|0,s|0)|0,S()|0,A=CA(Jt(A&7)|0,0,s|0)|0,e=e&~i|A,A=o|(S()|0),r>>>0>>0)r=r+1|0;else{r=1;break}}while(!1);if(l>>>0>>0)l=l+1|0;else break}return JA(A|0),e|0}function ss(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0;if(n=yA(e|0,A|0,52)|0,S()|0,n=n&15,!n)return r=A,n=e,JA(r|0),n|0;for(r=1;o=(15-r|0)*3|0,i=CA(7,0,o|0)|0,s=A&~(S()|0),A=yA(e|0,A|0,o|0)|0,S()|0,A=CA(Jt(A&7)|0,0,o|0)|0,e=A|e&~i,A=S()|0|s,r>>>0>>0;)r=r+1|0;return JA(A|0),e|0}function jl(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;if(u=C,C=C+64|0,l=u+40|0,n=u+24|0,s=u+12|0,i=u,CA(A|0,0,52)|0,r=S()|0|134225919,!A)return(t[e+4>>2]|0)>2||(t[e+8>>2]|0)>2||(t[e+12>>2]|0)>2?(o=0,l=0,JA(o|0),C=u,l|0):(CA(Cr(e)|0,0,45)|0,o=S()|0|r,l=-1,JA(o|0),C=u,l|0);if(t[l>>2]=t[e>>2],t[l+4>>2]=t[e+4>>2],t[l+8>>2]=t[e+8>>2],t[l+12>>2]=t[e+12>>2],o=l+4|0,(A|0)>0)for(e=-1;t[n>>2]=t[o>>2],t[n+4>>2]=t[o+4>>2],t[n+8>>2]=t[o+8>>2],A&1?(re(o),t[s>>2]=t[o>>2],t[s+4>>2]=t[o+4>>2],t[s+8>>2]=t[o+8>>2],ze(s)):(je(o),t[s>>2]=t[o>>2],t[s+4>>2]=t[o+4>>2],t[s+8>>2]=t[o+8>>2],Ge(s)),H(n,s,i),et(i),p=(15-A|0)*3|0,f=CA(7,0,p|0)|0,r=r&~(S()|0),p=CA(hA(i)|0,0,p|0)|0,e=p|e&~f,r=S()|0|r,(A|0)>1;)A=A+-1|0;else e=-1;A:do if((t[o>>2]|0)<=2&&(t[l+8>>2]|0)<=2&&(t[l+12>>2]|0)<=2){if(n=Cr(l)|0,A=CA(n|0,0,45)|0,A=A|e,e=S()|0|r&-1040385,i=gr(l)|0,!(be(n)|0)){if((i|0)<=0)break;for(s=0;;){if(n=yA(A|0,e|0,52)|0,S()|0,n=n&15,n)for(r=1;p=(15-r|0)*3|0,l=yA(A|0,e|0,p|0)|0,S()|0,f=CA(7,0,p|0)|0,e=e&~(S()|0),p=CA(rt(l&7)|0,0,p|0)|0,A=A&~f|p,e=e|(S()|0),r>>>0>>0;)r=r+1|0;if(s=s+1|0,(s|0)==(i|0))break A}}s=yA(A|0,e|0,52)|0,S()|0,s=s&15;e:do if(s){r=1;t:for(;;){switch(p=yA(A|0,e|0,(15-r|0)*3|0)|0,S()|0,p&7){case 1:break t;case 0:break;default:break e}if(r>>>0>>0)r=r+1|0;else break e}if(Fr(n,t[l>>2]|0)|0)for(r=1;l=(15-r|0)*3|0,f=CA(7,0,l|0)|0,p=e&~(S()|0),e=yA(A|0,e|0,l|0)|0,S()|0,e=CA(Jt(e&7)|0,0,l|0)|0,A=A&~f|e,e=p|(S()|0),r>>>0>>0;)r=r+1|0;else for(r=1;p=(15-r|0)*3|0,l=yA(A|0,e|0,p|0)|0,S()|0,f=CA(7,0,p|0)|0,e=e&~(S()|0),p=CA(rt(l&7)|0,0,p|0)|0,A=A&~f|p,e=e|(S()|0),r>>>0>>0;)r=r+1|0}while(!1);if((i|0)>0){r=0;do A=ns(A,e)|0,e=S()|0,r=r+1|0;while((r|0)!=(i|0))}}else A=0,e=0;while(!1);return f=e,p=A,JA(f|0),C=u,p|0}function lr(e){return e=e|0,(e|0)%2|0|0}function is(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;return s=C,C=C+16|0,n=s,A>>>0>15?(n=4,C=s,n|0):(t[e+4>>2]&2146435072|0)==2146435072||(t[e+8+4>>2]&2146435072|0)==2146435072?(n=3,C=s,n|0):(C0(e,A,n),A=jl(n,A)|0,n=S()|0,t[r>>2]=A,t[r+4>>2]=n,(A|0)==0&(n|0)==0&&OA(27795,27122,1050,27145),n=0,C=s,n|0)}function os(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;if(s=r+4|0,i=yA(e|0,A|0,52)|0,S()|0,i=i&15,o=yA(e|0,A|0,45)|0,S()|0,n=(i|0)==0,be(o&127)|0){if(n)return o=1,o|0;n=1}else{if(n)return o=0,o|0;(t[s>>2]|0)==0&&(t[r+8>>2]|0)==0?n=(t[r+12>>2]|0)!=0&1:n=1}for(r=1;r&1?ze(s):Ge(s),o=yA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,Rt(s,o&7),r>>>0>>0;)r=r+1|0;return n|0}function Rn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;if(p=C,C=C+16|0,u=p,f=yA(e|0,A|0,45)|0,S()|0,f=f&127,f>>>0>121)return t[r>>2]=0,t[r+4>>2]=0,t[r+8>>2]=0,t[r+12>>2]=0,f=5,C=p,f|0;A:do if((be(f)|0)!=0&&(i=yA(e|0,A|0,52)|0,S()|0,i=i&15,(i|0)!=0)){n=1;e:for(;;){switch(l=yA(e|0,A|0,(15-n|0)*3|0)|0,S()|0,l&7){case 5:break e;case 0:break;default:{n=A;break A}}if(n>>>0>>0)n=n+1|0;else{n=A;break A}}for(s=1,n=A;A=(15-s|0)*3|0,o=CA(7,0,A|0)|0,l=n&~(S()|0),n=yA(e|0,n|0,A|0)|0,S()|0,n=CA(Jt(n&7)|0,0,A|0)|0,e=e&~o|n,n=l|(S()|0),s>>>0>>0;)s=s+1|0}else n=A;while(!1);if(l=7696+(f*28|0)|0,t[r>>2]=t[l>>2],t[r+4>>2]=t[l+4>>2],t[r+8>>2]=t[l+8>>2],t[r+12>>2]=t[l+12>>2],!(os(e,n,r)|0))return f=0,C=p,f|0;if(o=r+4|0,t[u>>2]=t[o>>2],t[u+4>>2]=t[o+4>>2],t[u+8>>2]=t[o+8>>2],i=yA(e|0,n|0,52)|0,S()|0,l=i&15,i&1?(Ge(o),i=l+1|0):i=l,!(be(f)|0))n=0;else{A:do if(!l)n=0;else for(A=1;;){if(s=yA(e|0,n|0,(15-A|0)*3|0)|0,S()|0,s=s&7,s|0){n=s;break A}if(A>>>0>>0)A=A+1|0;else{n=0;break}}while(!1);n=(n|0)==4&1}if(!(F(r,i,n,0)|0))(i|0)!=(l|0)&&(t[o>>2]=t[u>>2],t[o+4>>2]=t[u+4>>2],t[o+8>>2]=t[u+8>>2]);else{if(be(f)|0)do;while((F(r,i,0,0)|0)!=0);(i|0)!=(l|0)&&je(o)}return f=0,C=p,f|0}function dn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;return i=C,C=C+16|0,n=i,s=Rn(e,A,n)|0,s|0?(C=i,s|0):(s=yA(e|0,A|0,52)|0,S()|0,d(n,s&15,r),s=0,C=i,s|0)}function In(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0;if(o=C,C=C+16|0,i=o,n=Rn(e,A,i)|0,n|0)return i=n,C=o,i|0;n=yA(e|0,A|0,45)|0,S()|0,n=(be(n&127)|0)==0,s=yA(e|0,A|0,52)|0,S()|0,s=s&15;A:do if(!n){if(s|0)for(n=1;;){if(l=CA(7,0,(15-n|0)*3|0)|0,!((l&e|0)==0&((S()|0)&A|0)==0))break A;if(n>>>0>>0)n=n+1|0;else break}return w(i,s,0,5,r),l=0,C=o,l|0}while(!1);return eA(i,s,0,6,r),l=0,C=o,l|0}function Tl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if(s=yA(e|0,A|0,45)|0,S()|0,!(be(s&127)|0))return s=2,t[r>>2]=s,0;if(s=yA(e|0,A|0,52)|0,S()|0,s=s&15,!s)return s=5,t[r>>2]=s,0;for(n=1;;){if(i=CA(7,0,(15-n|0)*3|0)|0,!((i&e|0)==0&((S()|0)&A|0)==0)){n=2,e=6;break}if(n>>>0>>0)n=n+1|0;else{n=5,e=6;break}}return(e|0)==6&&(t[r>>2]=n),0}function Js(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0;M=C,C=C+128|0,f=M+112|0,i=M+96|0,p=M,s=yA(e|0,A|0,52)|0,S()|0,l=s&15,t[f>>2]=l,o=yA(e|0,A|0,45)|0,S()|0,o=o&127;A:do if(be(o)|0){if(l|0)for(n=1;;){if(u=CA(7,0,(15-n|0)*3|0)|0,!((u&e|0)==0&((S()|0)&A|0)==0)){s=0;break A}if(n>>>0>>0)n=n+1|0;else break}if(s&1)s=1;else return u=CA(l+1|0,0,52)|0,p=S()|0|A&-15728641,f=CA(7,0,(14-l|0)*3|0)|0,p=Js((u|e)&~f,p&~(S()|0),r)|0,C=M,p|0}else s=0;while(!1);if(n=Rn(e,A,i)|0,!n){s?(_(i,f,p),u=5):(dA(i,f,p),u=6);A:do if(be(o)|0)if(!l)e=5;else for(n=1;;){if(o=CA(7,0,(15-n|0)*3|0)|0,!((o&e|0)==0&((S()|0)&A|0)==0)){e=2;break A}if(n>>>0>>0)n=n+1|0;else{e=5;break}}else e=2;while(!1);Jr(r|0,-1,e<<2|0)|0;A:do if(s)for(i=0;;){if(o=p+(i<<4)|0,rA(o,t[f>>2]|0)|0,o=t[o>>2]|0,l=t[r>>2]|0,(l|0)==-1|(l|0)==(o|0))n=r;else{s=0;do{if(s=s+1|0,s>>>0>=e>>>0){n=1;break A}n=r+(s<<2)|0,l=t[n>>2]|0}while(!((l|0)==-1|(l|0)==(o|0)))}if(t[n>>2]=o,i=i+1|0,i>>>0>=u>>>0){n=0;break}}else for(i=0;;){if(o=p+(i<<4)|0,F(o,t[f>>2]|0,0,1)|0,o=t[o>>2]|0,l=t[r>>2]|0,(l|0)==-1|(l|0)==(o|0))n=r;else{s=0;do{if(s=s+1|0,s>>>0>=e>>>0){n=1;break A}n=r+(s<<2)|0,l=t[n>>2]|0}while(!((l|0)==-1|(l|0)==(o|0)))}if(t[n>>2]=o,i=i+1|0,i>>>0>=u>>>0){n=0;break}}while(!1)}return p=n,C=M,p|0}function Rl(){return 12}function ls(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0;if(e>>>0>15)return l=4,l|0;if(CA(e|0,0,52)|0,l=S()|0|134225919,!e){r=0,n=0;do be(n)|0&&(CA(n|0,0,45)|0,o=l|(S()|0),e=A+(r<<3)|0,t[e>>2]=-1,t[e+4>>2]=o,r=r+1|0),n=n+1|0;while((n|0)!=122);return r=0,r|0}r=0,o=0;do{if(be(o)|0){for(CA(o|0,0,45)|0,n=1,s=-1,i=l|(S()|0);u=CA(7,0,(15-n|0)*3|0)|0,s=s&~u,i=i&~(S()|0),(n|0)!=(e|0);)n=n+1|0;u=A+(r<<3)|0,t[u>>2]=s,t[u+4>>2]=i,r=r+1|0}o=o+1|0}while((o|0)!=122);return r=0,r|0}function Il(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0;if(q=C,C=C+16|0,Y=q,nA=yA(e|0,A|0,52)|0,S()|0,nA=nA&15,r>>>0>15)return nA=4,C=q,nA|0;if((nA|0)<(r|0))return nA=12,C=q,nA|0;if((nA|0)!=(r|0))if(i=CA(r|0,0,52)|0,i=i|e,l=S()|0|A&-15728641,(nA|0)>(r|0)){u=r;do G=CA(7,0,(14-u|0)*3|0)|0,u=u+1|0,i=G|i,l=S()|0|l;while((u|0)<(nA|0));G=i}else G=i;else G=e,l=A;N=yA(G|0,l|0,45)|0,S()|0;A:do if(be(N&127)|0){if(u=yA(G|0,l|0,52)|0,S()|0,u=u&15,u|0)for(i=1;;){if(N=CA(7,0,(15-i|0)*3|0)|0,!((N&G|0)==0&((S()|0)&l|0)==0)){f=33;break A}if(i>>>0>>0)i=i+1|0;else break}if(N=n,t[N>>2]=0,t[N+4>>2]=0,(nA|0)>(r|0)){for(N=A&-15728641,L=nA;;){if(I=L,L=L+-1|0,L>>>0>15|(nA|0)<(L|0)){f=19;break}if((nA|0)!=(L|0))if(i=CA(L|0,0,52)|0,i=i|e,u=S()|0|N,(nA|0)<(I|0))M=i;else{f=L;do M=CA(7,0,(14-f|0)*3|0)|0,f=f+1|0,i=M|i,u=S()|0|u;while((f|0)<(nA|0));M=i}else M=e,u=A;if(p=yA(M|0,u|0,45)|0,S()|0,!(be(p&127)|0))i=0;else{p=yA(M|0,u|0,52)|0,S()|0,p=p&15;e:do if(!p)i=0;else for(f=1;;){if(i=yA(M|0,u|0,(15-f|0)*3|0)|0,S()|0,i=i&7,i|0)break e;if(f>>>0

>>0)f=f+1|0;else{i=0;break}}while(!1);i=(i|0)==0&1}if(u=yA(e|0,A|0,(15-I|0)*3|0)|0,S()|0,u=u&7,(u|0)==7){s=5,f=42;break}if(i=(i|0)!=0,(u|0)==1&i){s=5,f=42;break}if(M=u+(((u|0)!=0&i)<<31>>31)|0,M|0&&(f=nA-I|0,f=Zr(7,0,f,((f|0)<0)<<31>>31)|0,p=S()|0,i?(i=yt(f|0,p|0,5,0)|0,i=ZA(i|0,S()|0,-5,-1)|0,i=qr(i|0,S()|0,6,0)|0,i=ZA(i|0,S()|0,1,0)|0,u=S()|0):(i=f,u=p),I=M+-1|0,I=yt(f|0,p|0,I|0,((I|0)<0)<<31>>31|0)|0,I=ZA(i|0,u|0,I|0,S()|0)|0,M=S()|0,p=n,p=ZA(I|0,M|0,t[p>>2]|0,t[p+4>>2]|0)|0,M=S()|0,I=n,t[I>>2]=p,t[I+4>>2]=M),(L|0)<=(r|0)){f=37;break}}if((f|0)==19)OA(27795,27122,1367,27158);else if((f|0)==37){o=n,s=t[o+4>>2]|0,o=t[o>>2]|0;break}else if((f|0)==42)return C=q,s|0}else s=0,o=0}else f=33;while(!1);A:do if((f|0)==33)if(N=n,t[N>>2]=0,t[N+4>>2]=0,(nA|0)>(r|0)){for(i=nA;;){if(s=yA(e|0,A|0,(15-i|0)*3|0)|0,S()|0,s=s&7,(s|0)==7){s=5;break}if(o=nA-i|0,o=Zr(7,0,o,((o|0)<0)<<31>>31)|0,s=yt(o|0,S()|0,s|0,0)|0,o=S()|0,N=n,o=ZA(t[N>>2]|0,t[N+4>>2]|0,s|0,o|0)|0,s=S()|0,N=n,t[N>>2]=o,t[N+4>>2]=s,i=i+-1|0,(i|0)<=(r|0))break A}return C=q,s|0}else s=0,o=0;while(!1);return Mr(G,l,nA,Y)|0&&OA(27795,27122,1327,27173),nA=Y,Y=t[nA+4>>2]|0,((s|0)>-1|(s|0)==-1&o>>>0>4294967295)&((Y|0)>(s|0)|((Y|0)==(s|0)?(t[nA>>2]|0)>>>0>o>>>0:0))?(nA=0,C=q,nA|0):(OA(27795,27122,1407,27158),0)}function Ll(e,A,r,n,s,i){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,i=i|0;var o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0;if(M=C,C=C+16|0,o=M,s>>>0>15)return i=4,C=M,i|0;if(l=yA(r|0,n|0,52)|0,S()|0,l=l&15,(l|0)>(s|0))return i=12,C=M,i|0;if(Mr(r,n,s,o)|0&&OA(27795,27122,1327,27173),p=o,f=t[p+4>>2]|0,!(((A|0)>-1|(A|0)==-1&e>>>0>4294967295)&((f|0)>(A|0)|((f|0)==(A|0)?(t[p>>2]|0)>>>0>e>>>0:0))))return i=2,C=M,i|0;p=s-l|0,s=CA(s|0,0,52)|0,u=S()|0|n&-15728641,f=i,t[f>>2]=s|r,t[f+4>>2]=u,f=yA(r|0,n|0,45)|0,S()|0;A:do if(be(f&127)|0){if(l|0)for(o=1;;){if(f=CA(7,0,(15-o|0)*3|0)|0,!((f&r|0)==0&((S()|0)&n|0)==0))break A;if(o>>>0>>0)o=o+1|0;else break}if((p|0)<1)return i=0,C=M,i|0;for(f=l^15,n=-1,u=1,o=1;;){l=p-u|0,l=Zr(7,0,l,((l|0)<0)<<31>>31)|0,r=S()|0;do if(o)if(o=yt(l|0,r|0,5,0)|0,o=ZA(o|0,S()|0,-5,-1)|0,o=qr(o|0,S()|0,6,0)|0,s=S()|0,(A|0)>(s|0)|(A|0)==(s|0)&e>>>0>o>>>0){A=ZA(e|0,A|0,-1,-1)|0,A=gt(A|0,S()|0,o|0,s|0)|0,o=S()|0,I=i,N=t[I>>2]|0,I=t[I+4>>2]|0,G=(f+n|0)*3|0,L=CA(7,0,G|0)|0,I=I&~(S()|0),n=qr(A|0,o|0,l|0,r|0)|0,e=S()|0,s=ZA(n|0,e|0,2,0)|0,G=CA(s|0,S()|0,G|0)|0,I=S()|0|I,s=i,t[s>>2]=G|N&~L,t[s+4>>2]=I,e=yt(n|0,e|0,l|0,r|0)|0,e=gt(A|0,o|0,e|0,S()|0)|0,o=0,A=S()|0;break}else{G=i,L=t[G>>2]|0,G=t[G+4>>2]|0,N=CA(7,0,(f+n|0)*3|0)|0,G=G&~(S()|0),o=i,t[o>>2]=L&~N,t[o+4>>2]=G,o=1;break}else L=i,s=t[L>>2]|0,L=t[L+4>>2]|0,n=(f+n|0)*3|0,I=CA(7,0,n|0)|0,L=L&~(S()|0),G=qr(e|0,A|0,l|0,r|0)|0,o=S()|0,n=CA(G|0,o|0,n|0)|0,L=S()|0|L,N=i,t[N>>2]=n|s&~I,t[N+4>>2]=L,o=yt(G|0,o|0,l|0,r|0)|0,e=gt(e|0,A|0,o|0,S()|0)|0,o=0,A=S()|0;while(!1);if((p|0)>(u|0))n=~u,u=u+1|0;else{A=0;break}}return C=M,A|0}while(!1);if((p|0)<1)return G=0,C=M,G|0;for(s=l^15,o=1;;)if(N=p-o|0,N=Zr(7,0,N,((N|0)<0)<<31>>31)|0,G=S()|0,u=i,r=t[u>>2]|0,u=t[u+4>>2]|0,l=(s-o|0)*3|0,n=CA(7,0,l|0)|0,u=u&~(S()|0),I=qr(e|0,A|0,N|0,G|0)|0,L=S()|0,l=CA(I|0,L|0,l|0)|0,u=S()|0|u,f=i,t[f>>2]=l|r&~n,t[f+4>>2]=u,G=yt(I|0,L|0,N|0,G|0)|0,e=gt(e|0,A|0,G|0,S()|0)|0,A=S()|0,(p|0)<=(o|0)){A=0;break}else o=o+1|0;return C=M,A|0}function as(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0;s=yA(A|0,r|0,52)|0,S()|0,s=s&15,(A|0)==0&(r|0)==0|((n|0)>15|(s|0)>(n|0))?(i=-1,A=-1,r=0,s=0):(A=$s(A,r,s+1|0,n)|0,o=(S()|0)&-15728641,r=CA(n|0,0,52)|0,r=A|r,o=o|(S()|0),A=(Qe(r,o)|0)==0,i=s,A=A?-1:n,s=o),o=e,t[o>>2]=r,t[o+4>>2]=s,t[e+8>>2]=i,t[e+12>>2]=A}function Xs(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0;if(s=yA(e|0,A|0,52)|0,S()|0,s=s&15,i=n+8|0,t[i>>2]=s,(e|0)==0&(A|0)==0|((r|0)>15|(s|0)>(r|0))){r=n,t[r>>2]=0,t[r+4>>2]=0,t[i>>2]=-1,t[n+12>>2]=-1;return}if(e=$s(e,A,s+1|0,r)|0,i=(S()|0)&-15728641,s=CA(r|0,0,52)|0,s=e|s,i=i|(S()|0),e=n,t[e>>2]=s,t[e+4>>2]=i,e=n+12|0,Qe(s,i)|0){t[e>>2]=r;return}else{t[e>>2]=-1;return}}function us(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0;if(r=e,A=t[r>>2]|0,r=t[r+4>>2]|0,!((A|0)==0&(r|0)==0)&&(n=yA(A|0,r|0,52)|0,S()|0,n=n&15,l=CA(1,0,(n^15)*3|0)|0,A=ZA(l|0,S()|0,A|0,r|0)|0,r=S()|0,l=e,t[l>>2]=A,t[l+4>>2]=r,l=e+8|0,o=t[l>>2]|0,!((n|0)<(o|0)))){for(u=e+12|0,i=n;;){if((i|0)==(o|0)){n=5;break}if(f=(i|0)==(t[u>>2]|0),s=(15-i|0)*3|0,n=yA(A|0,r|0,s|0)|0,S()|0,n=n&7,f&((n|0)==1&!0)){n=7;break}if(!((n|0)==7&!0)){n=10;break}if(f=CA(1,0,s|0)|0,A=ZA(A|0,r|0,f|0,S()|0)|0,r=S()|0,f=e,t[f>>2]=A,t[f+4>>2]=r,(i|0)>(o|0))i=i+-1|0;else{n=10;break}}if((n|0)==5){f=e,t[f>>2]=0,t[f+4>>2]=0,t[l>>2]=-1,t[u>>2]=-1;return}else if((n|0)==7){o=CA(1,0,s|0)|0,o=ZA(A|0,r|0,o|0,S()|0)|0,l=S()|0,f=e,t[f>>2]=o,t[f+4>>2]=l,t[u>>2]=i+-1;return}else if((n|0)==10)return}}function i0(e){e=+e;var A=0;return A=e<0?e+6.283185307179586:e,+(e>=6.283185307179586?A+-6.283185307179586:A)}function Ln(e,A){return e=e|0,A=A|0,+oe(+(+k[e>>3]-+k[A>>3]))<17453292519943298e-27?(A=+oe(+(+k[e+8>>3]-+k[A+8>>3]))<17453292519943298e-27,A|0):(A=0,A|0)}function Xt(e,A){switch(e=+e,A=A|0,A|0){case 1:{e=e<0?e+6.283185307179586:e;break}case 2:{e=e>0?e+-6.283185307179586:e;break}}return+e}function Nl(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return s=+k[A>>3],n=+k[e>>3],i=+WA(+((s-n)*.5)),r=+WA(+((+k[A+8>>3]-+k[e+8>>3])*.5)),r=i*i+r*(+Be(+s)*+Be(+n)*r),+(+Je(+ +fe(+r),+ +fe(+(1-r)))*2)}function o0(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return s=+k[A>>3],n=+k[e>>3],i=+WA(+((s-n)*.5)),r=+WA(+((+k[A+8>>3]-+k[e+8>>3])*.5)),r=i*i+r*(+Be(+s)*+Be(+n)*r),+(+Je(+ +fe(+r),+ +fe(+(1-r)))*2*6371.007180918475)}function Fl(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return s=+k[A>>3],n=+k[e>>3],i=+WA(+((s-n)*.5)),r=+WA(+((+k[A+8>>3]-+k[e+8>>3])*.5)),r=i*i+r*(+Be(+s)*+Be(+n)*r),+(+Je(+ +fe(+r),+ +fe(+(1-r)))*2*6371.007180918475*1e3)}function Pl(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0;return i=+k[A>>3],n=+Be(+i),s=+k[A+8>>3]-+k[e+8>>3],o=n*+WA(+s),r=+k[e>>3],+ +Je(+o,+(+WA(+i)*+Be(+r)-+Be(+s)*(n*+WA(+r))))}function Ql(e,A,r,n){e=e|0,A=+A,r=+r,n=n|0;var s=0,i=0,o=0,l=0;if(r<1e-16){t[n>>2]=t[e>>2],t[n+4>>2]=t[e+4>>2],t[n+8>>2]=t[e+8>>2],t[n+12>>2]=t[e+12>>2];return}i=A<0?A+6.283185307179586:A,i=A>=6.283185307179586?i+-6.283185307179586:i;do if(i<1e-16)A=+k[e>>3]+r,k[n>>3]=A,s=n;else{if(s=+oe(+(i+-3.141592653589793))<1e-16,A=+k[e>>3],s){A=A-r,k[n>>3]=A,s=n;break}if(o=+Be(+r),r=+WA(+r),A=o*+WA(+A)+ +Be(+i)*(r*+Be(+A)),A=A>1?1:A,A=+pr(+(A<-1?-1:A)),k[n>>3]=A,+oe(+(A+-1.5707963267948966))<1e-16){k[n>>3]=1.5707963267948966,k[n+8>>3]=0;return}if(+oe(+(A+1.5707963267948966))<1e-16){k[n>>3]=-1.5707963267948966,k[n+8>>3]=0;return}if(l=1/+Be(+A),i=r*+WA(+i)*l,r=+k[e>>3],A=l*((o-+WA(+A)*+WA(+r))/+Be(+r)),o=i>1?1:i,A=A>1?1:A,A=+k[e+8>>3]+ +Je(+(o<-1?-1:o),+(A<-1?-1:A)),A>3.141592653589793)do A=A+-6.283185307179586;while(A>3.141592653589793);if(A<-3.141592653589793)do A=A+6.283185307179586;while(A<-3.141592653589793);k[n+8>>3]=A;return}while(!1);if(+oe(+(A+-1.5707963267948966))<1e-16){k[s>>3]=1.5707963267948966,k[n+8>>3]=0;return}if(+oe(+(A+1.5707963267948966))<1e-16){k[s>>3]=-1.5707963267948966,k[n+8>>3]=0;return}if(A=+k[e+8>>3],A>3.141592653589793)do A=A+-6.283185307179586;while(A>3.141592653589793);if(A<-3.141592653589793)do A=A+6.283185307179586;while(A<-3.141592653589793);k[n+8>>3]=A}function Ai(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(k[A>>3]=+k[20656+(e<<3)>>3],A=0,A|0)}function Ol(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(k[A>>3]=+k[20784+(e<<3)>>3],A=0,A|0)}function zl(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(k[A>>3]=+k[20912+(e<<3)>>3],A=0,A|0)}function Hl(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(k[A>>3]=+k[21040+(e<<3)>>3],A=0,A|0)}function S0(e,A){e=e|0,A=A|0;var r=0;return e>>>0>15?(A=4,A|0):(r=Zr(7,0,e,((e|0)<0)<<31>>31)|0,r=yt(r|0,S()|0,120,0)|0,e=S()|0,t[A>>2]=r|2,t[A+4>>2]=e,A=0,A|0)}function ei(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0;return I=+k[A>>3],p=+k[e>>3],u=+WA(+((I-p)*.5)),i=+k[A+8>>3],f=+k[e+8>>3],o=+WA(+((i-f)*.5)),l=+Be(+p),M=+Be(+I),o=u*u+o*(M*l*o),o=+Je(+ +fe(+o),+ +fe(+(1-o)))*2,u=+k[r>>3],I=+WA(+((u-I)*.5)),n=+k[r+8>>3],i=+WA(+((n-i)*.5)),s=+Be(+u),i=I*I+i*(M*s*i),i=+Je(+ +fe(+i),+ +fe(+(1-i)))*2,u=+WA(+((p-u)*.5)),n=+WA(+((f-n)*.5)),n=u*u+n*(l*s*n),n=+Je(+ +fe(+n),+ +fe(+(1-n)))*2,s=(o+i+n)*.5,+(+ir(+ +fe(+(+it(+(s*.5))*+it(+((s-o)*.5))*+it(+((s-i)*.5))*+it(+((s-n)*.5)))))*4)}function cs(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0;if(l=C,C=C+192|0,i=l+168|0,o=l,s=dn(e,A,i)|0,s|0)return r=s,C=l,r|0;if(In(e,A,o)|0&&OA(27795,27190,415,27199),A=t[o>>2]|0,(A|0)>0){if(n=+ei(o+8|0,o+8+(((A|0)!=1&1)<<4)|0,i)+0,(A|0)!=1){e=1;do s=e,e=e+1|0,n=n+ +ei(o+8+(s<<4)|0,o+8+(((e|0)%(A|0)|0)<<4)|0,i);while((e|0)<(A|0))}}else n=0;return k[r>>3]=n,r=0,C=l,r|0}function Gl(e,A,r){return e=e|0,A=A|0,r=r|0,e=cs(e,A,r)|0,e|0||(k[r>>3]=+k[r>>3]*6371.007180918475*6371.007180918475),e|0}function Ul(e,A,r){return e=e|0,A=A|0,r=r|0,e=cs(e,A,r)|0,e|0||(k[r>>3]=+k[r>>3]*6371.007180918475*6371.007180918475*1e3*1e3),e|0}function Vl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;if(l=C,C=C+176|0,o=l,e=fn(e,A,o)|0,e|0)return o=e,C=l,o|0;if(k[r>>3]=0,e=t[o>>2]|0,(e|0)<=1)return o=0,C=l,o|0;A=e+-1|0,e=0,n=+k[o+8>>3],s=+k[o+16>>3],i=0;do e=e+1|0,f=n,n=+k[o+8+(e<<4)>>3],p=+WA(+((n-f)*.5)),u=s,s=+k[o+8+(e<<4)+8>>3],u=+WA(+((s-u)*.5)),u=p*p+u*(+Be(+n)*+Be(+f)*u),i=i+ +Je(+ +fe(+u),+ +fe(+(1-u)))*2;while((e|0)<(A|0));return k[r>>3]=i,o=0,C=l,o|0}function Wl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;if(l=C,C=C+176|0,o=l,e=fn(e,A,o)|0,e|0)return o=e,i=+k[r>>3],i=i*6371.007180918475,k[r>>3]=i,C=l,o|0;if(k[r>>3]=0,e=t[o>>2]|0,(e|0)<=1)return o=0,i=0,i=i*6371.007180918475,k[r>>3]=i,C=l,o|0;A=e+-1|0,e=0,n=+k[o+8>>3],s=+k[o+16>>3],i=0;do e=e+1|0,f=n,n=+k[o+8+(e<<4)>>3],p=+WA(+((n-f)*.5)),u=s,s=+k[o+8+(e<<4)+8>>3],u=+WA(+((s-u)*.5)),u=p*p+u*(+Be(+f)*+Be(+n)*u),i=i+ +Je(+ +fe(+u),+ +fe(+(1-u)))*2;while((e|0)!=(A|0));return k[r>>3]=i,o=0,p=i,p=p*6371.007180918475,k[r>>3]=p,C=l,o|0}function Yl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;if(l=C,C=C+176|0,o=l,e=fn(e,A,o)|0,e|0)return o=e,i=+k[r>>3],i=i*6371.007180918475,i=i*1e3,k[r>>3]=i,C=l,o|0;if(k[r>>3]=0,e=t[o>>2]|0,(e|0)<=1)return o=0,i=0,i=i*6371.007180918475,i=i*1e3,k[r>>3]=i,C=l,o|0;A=e+-1|0,e=0,n=+k[o+8>>3],s=+k[o+16>>3],i=0;do e=e+1|0,f=n,n=+k[o+8+(e<<4)>>3],p=+WA(+((n-f)*.5)),u=s,s=+k[o+8+(e<<4)+8>>3],u=+WA(+((s-u)*.5)),u=p*p+u*(+Be(+f)*+Be(+n)*u),i=i+ +Je(+ +fe(+u),+ +fe(+(1-u)))*2;while((e|0)!=(A|0));return k[r>>3]=i,o=0,p=i,p=p*6371.007180918475,p=p*1e3,k[r>>3]=p,C=l,o|0}function Kl(e){e=e|0;var A=0,r=0,n=0;return A=Wt(1,12)|0,A||OA(27280,27235,49,27293),r=e+4|0,n=t[r>>2]|0,n|0?(n=n+8|0,t[n>>2]=A,t[r>>2]=A,A|0):(t[e>>2]|0&&OA(27310,27235,61,27333),n=e,t[n>>2]=A,t[r>>2]=A,A|0)}function Zl(e,A){e=e|0,A=A|0;var r=0,n=0;return n=Br(24)|0,n||OA(27347,27235,78,27361),t[n>>2]=t[A>>2],t[n+4>>2]=t[A+4>>2],t[n+8>>2]=t[A+8>>2],t[n+12>>2]=t[A+12>>2],t[n+16>>2]=0,A=e+4|0,r=t[A>>2]|0,r|0?(t[r+16>>2]=n,t[A>>2]=n,n|0):(t[e>>2]|0&&OA(27376,27235,82,27361),t[e>>2]=n,t[A>>2]=n,n|0)}function ti(e){e=e|0;var A=0,r=0,n=0,s=0;if(e)for(n=1;;){if(A=t[e>>2]|0,A|0)do{if(r=t[A>>2]|0,r|0)do s=r,r=t[r+16>>2]|0,$A(s);while((r|0)!=0);s=A,A=t[A+8>>2]|0,$A(s)}while((A|0)!=0);if(A=e,e=t[e+8>>2]|0,n||$A(A),e)n=0;else break}}function $l(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,Z=0,V=0,BA=0,GA=0,QA=0,ce=0,de=0,Se=0,ie=0,UA=0,SA=0,ve=0,Ve=0,me=0;if(s=e+8|0,t[s>>2]|0)return me=1,me|0;if(n=t[e>>2]|0,!n)return me=0,me|0;A=n,r=0;do r=r+1|0,A=t[A+8>>2]|0;while((A|0)!=0);if(r>>>0<2)return me=0,me|0;ve=Br(r<<2)|0,ve||OA(27396,27235,317,27415),SA=Br(r<<5)|0,SA||OA(27437,27235,321,27415),t[e>>2]=0,GA=e+4|0,t[GA>>2]=0,t[s>>2]=0,r=0,UA=0,BA=0,M=0;A:for(;;){if(p=t[n>>2]|0,p){i=0,o=p;do{if(u=+k[o+8>>3],A=o,o=t[o+16>>2]|0,f=(o|0)==0,s=f?p:o,l=+k[s+8>>3],+oe(+(u-l))>3.141592653589793){me=14;break}i=i+(l-u)*(+k[A>>3]+ +k[s>>3])}while(!f);if((me|0)==14){me=0,i=0,A=p;do V=+k[A+8>>3],ie=A+16|0,Se=t[ie>>2]|0,Se=(Se|0)==0?p:Se,Z=+k[Se+8>>3],i=i+(+k[A>>3]+ +k[Se>>3])*((Z<0?Z+6.283185307179586:Z)-(V<0?V+6.283185307179586:V)),A=t[((A|0)==0?n:ie)>>2]|0;while((A|0)!=0)}i>0?(t[ve+(UA<<2)>>2]=n,UA=UA+1|0,s=BA,A=M):me=19}else me=19;if((me|0)==19){me=0;do if(r){if(A=r+8|0,t[A>>2]|0){me=21;break A}if(r=Wt(1,12)|0,!r){me=23;break A}t[A>>2]=r,s=r+4|0,o=r,A=M}else if(M){s=GA,o=M+8|0,A=n,r=e;break}else if(t[e>>2]|0){me=27;break A}else{s=GA,o=e,A=n,r=e;break}while(!1);if(t[o>>2]=n,t[s>>2]=n,o=SA+(BA<<5)|0,f=t[n>>2]|0,f){for(p=SA+(BA<<5)+8|0,k[p>>3]=17976931348623157e292,M=SA+(BA<<5)+24|0,k[M>>3]=17976931348623157e292,k[o>>3]=-17976931348623157e292,I=SA+(BA<<5)+16|0,k[I>>3]=-17976931348623157e292,nA=17976931348623157e292,q=-17976931348623157e292,s=0,L=f,u=17976931348623157e292,G=17976931348623157e292,Y=-17976931348623157e292,l=-17976931348623157e292;i=+k[L>>3],V=+k[L+8>>3],L=t[L+16>>2]|0,N=(L|0)==0,Z=+k[(N?f:L)+8>>3],i>3]=i,u=i),V>3]=V,G=V),i>Y?k[o>>3]=i:i=Y,V>l&&(k[I>>3]=V,l=V),nA=V>0&Vq?V:q,s=s|+oe(+(V-Z))>3.141592653589793,!N;)Y=i;s&&(k[I>>3]=q,k[M>>3]=nA)}else t[o>>2]=0,t[o+4>>2]=0,t[o+8>>2]=0,t[o+12>>2]=0,t[o+16>>2]=0,t[o+20>>2]=0,t[o+24>>2]=0,t[o+28>>2]=0;s=BA+1|0}if(ie=n+8|0,n=t[ie>>2]|0,t[ie>>2]=0,n)BA=s,M=A;else{me=45;break}}if((me|0)==21)OA(27213,27235,35,27247);else if((me|0)==23)OA(27267,27235,37,27247);else if((me|0)==27)OA(27310,27235,61,27333);else if((me|0)==45){A:do if((UA|0)>0){for(ie=(s|0)==0,de=s<<2,Se=(e|0)==0,ce=0,A=0;;){if(QA=t[ve+(ce<<2)>>2]|0,ie)me=73;else{if(BA=Br(de)|0,!BA){me=50;break}if(GA=Br(de)|0,!GA){me=52;break}e:do if(Se)r=0;else{for(s=0,r=0,o=e;n=SA+(s<<5)|0,ri(t[o>>2]|0,n,t[QA>>2]|0)|0?(t[BA+(r<<2)>>2]=o,t[GA+(r<<2)>>2]=n,N=r+1|0):N=r,o=t[o+8>>2]|0,o;)s=s+1|0,r=N;if((N|0)>0)if(n=t[BA>>2]|0,(N|0)==1)r=n;else for(I=0,L=-1,r=n,M=n;;){for(f=t[M>>2]|0,n=0,o=0;s=t[t[BA+(o<<2)>>2]>>2]|0,(s|0)==(f|0)?p=n:p=n+((ri(s,t[GA+(o<<2)>>2]|0,t[f>>2]|0)|0)&1)|0,o=o+1|0,(o|0)!=(N|0);)n=p;if(s=(p|0)>(L|0),r=s?M:r,n=I+1|0,(n|0)==(N|0))break e;I=n,L=s?p:L,M=t[BA+(n<<2)>>2]|0}else r=0}while(!1);if($A(BA),$A(GA),r){if(s=r+4|0,n=t[s>>2]|0,n)r=n+8|0;else if(t[r>>2]|0){me=70;break}t[r>>2]=QA,t[s>>2]=QA}else me=73}if((me|0)==73){if(me=0,A=t[QA>>2]|0,A|0)do GA=A,A=t[A+16>>2]|0,$A(GA);while((A|0)!=0);$A(QA),A=1}if(ce=ce+1|0,(ce|0)>=(UA|0)){Ve=A;break A}}(me|0)==50?OA(27452,27235,249,27471):(me|0)==52?OA(27490,27235,252,27471):(me|0)==70&&OA(27310,27235,61,27333)}else Ve=0;while(!1);return $A(ve),$A(SA),me=Ve,me|0}return 0}function ri(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;if(!(Er(A,r)|0)||(A=Ut(A)|0,n=+k[r>>3],s=+k[r+8>>3],s=A&s<0?s+6.283185307179586:s,e=t[e>>2]|0,!e))return e=0,e|0;if(A){A=0,f=s,r=e;A:for(;;){for(;o=+k[r>>3],s=+k[r+8>>3],r=r+16|0,p=t[r>>2]|0,p=(p|0)==0?e:p,i=+k[p>>3],l=+k[p+8>>3],o>i?(u=o,o=l):(u=i,i=o,o=s,s=l),n=n==i|n==u?n+2220446049250313e-31:n,!!(nu);)if(r=t[r>>2]|0,!r){r=22;break A}if(l=o<0?o+6.283185307179586:o,o=s<0?s+6.283185307179586:s,f=l==f|o==f?f+-2220446049250313e-31:f,u=l+(o-l)*((n-i)/(u-i)),(u<0?u+6.283185307179586:u)>f&&(A=A^1),r=t[r>>2]|0,!r){r=22;break}}if((r|0)==22)return A|0}else{A=0,f=s,r=e;A:for(;;){for(;o=+k[r>>3],s=+k[r+8>>3],r=r+16|0,p=t[r>>2]|0,p=(p|0)==0?e:p,i=+k[p>>3],l=+k[p+8>>3],o>i?(u=o,o=l):(u=i,i=o,o=s,s=l),n=n==i|n==u?n+2220446049250313e-31:n,!!(nu);)if(r=t[r>>2]|0,!r){r=22;break A}if(f=o==f|s==f?f+-2220446049250313e-31:f,o+(s-o)*((n-i)/(u-i))>f&&(A=A^1),r=t[r>>2]|0,!r){r=22;break}}if((r|0)==22)return A|0}return 0}function Or(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0;if(q=C,C=C+32|0,nA=q+16|0,Y=q,i=yA(e|0,A|0,52)|0,S()|0,i=i&15,L=yA(r|0,n|0,52)|0,S()|0,(i|0)!=(L&15|0))return nA=12,C=q,nA|0;if(f=yA(e|0,A|0,45)|0,S()|0,f=f&127,p=yA(r|0,n|0,45)|0,S()|0,p=p&127,f>>>0>121|p>>>0>121)return nA=5,C=q,nA|0;if(L=(f|0)!=(p|0),L){if(l=an(f,p)|0,(l|0)==7)return nA=1,C=q,nA|0;u=an(p,f)|0,(u|0)==7?OA(27514,27538,161,27548):(N=l,o=u)}else N=0,o=0;M=be(f)|0,I=be(p)|0,t[nA>>2]=0,t[nA+4>>2]=0,t[nA+8>>2]=0,t[nA+12>>2]=0;do if(N){if(p=t[4272+(f*28|0)+(N<<2)>>2]|0,l=(p|0)>0,I)if(l){f=0,u=r,l=n;do u=_l(u,l)|0,l=S()|0,o=Jt(o)|0,(o|0)==1&&(o=Jt(1)|0),f=f+1|0;while((f|0)!=(p|0));p=o,f=u,u=l}else p=o,f=r,u=n;else if(l){f=0,u=r,l=n;do u=ss(u,l)|0,l=S()|0,o=Jt(o)|0,f=f+1|0;while((f|0)!=(p|0));p=o,f=u,u=l}else p=o,f=r,u=n;if(os(f,u,nA)|0,L||OA(27563,27538,191,27548),l=(M|0)!=0,o=(I|0)!=0,l&o&&OA(27590,27538,192,27548),l){if(o=Vt(e,A)|0,(o|0)==7){i=5;break}if(gA[22e3+(o*7|0)+N>>0]|0){i=1;break}u=t[21168+(o*28|0)+(N<<2)>>2]|0,f=u}else if(o){if(o=Vt(f,u)|0,(o|0)==7){i=5;break}if(gA[22e3+(o*7|0)+p>>0]|0){i=1;break}f=0,u=t[21168+(p*28|0)+(o<<2)>>2]|0}else f=0,u=0;if((f|u|0)<0)i=5;else{if((u|0)>0){l=nA+4|0,o=0;do Xe(l),o=o+1|0;while((o|0)!=(u|0))}if(t[Y>>2]=0,t[Y+4>>2]=0,t[Y+8>>2]=0,Rt(Y,N),i|0)for(;lr(i)|0?ze(Y):Ge(Y),(i|0)>1;)i=i+-1|0;if((f|0)>0){i=0;do Xe(Y),i=i+1|0;while((i|0)!=(f|0))}G=nA+4|0,ut(G,Y,G),et(G),G=51}}else if(os(r,n,nA)|0,(M|0)!=0&(I|0)!=0)if((p|0)!=(f|0)&&OA(27621,27538,261,27548),o=Vt(e,A)|0,i=Vt(r,n)|0,(o|0)==7|(i|0)==7)i=5;else if(gA[22e3+(o*7|0)+i>>0]|0)i=1;else if(o=t[21168+(o*28|0)+(i<<2)>>2]|0,(o|0)>0){l=nA+4|0,i=0;do Xe(l),i=i+1|0;while((i|0)!=(o|0));G=51}else G=51;else G=51;while(!1);return(G|0)==51&&(i=nA+4|0,t[s>>2]=t[i>>2],t[s+4>>2]=t[i+4>>2],t[s+8>>2]=t[i+8>>2],i=0),nA=i,C=q,nA|0}function ni(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,Z=0;if(G=C,C=C+48|0,f=G+36|0,o=G+24|0,l=G+12|0,u=G,s=yA(e|0,A|0,52)|0,S()|0,s=s&15,I=yA(e|0,A|0,45)|0,S()|0,I=I&127,I>>>0>121)return n=5,C=G,n|0;if(p=be(I)|0,CA(s|0,0,52)|0,Y=S()|0|134225919,i=n,t[i>>2]=-1,t[i+4>>2]=Y,!s)return s=hA(r)|0,(s|0)==7||(s=ln(I,s)|0,(s|0)==127)?(Y=1,C=G,Y|0):(L=CA(s|0,0,45)|0,N=S()|0,I=n,N=t[I+4>>2]&-1040385|N,Y=n,t[Y>>2]=t[I>>2]|L,t[Y+4>>2]=N,Y=0,C=G,Y|0);for(t[f>>2]=t[r>>2],t[f+4>>2]=t[r+4>>2],t[f+8>>2]=t[r+8>>2],r=s;;){if(i=r,r=r+-1|0,t[o>>2]=t[f>>2],t[o+4>>2]=t[f+4>>2],t[o+8>>2]=t[f+8>>2],lr(i)|0){if(s=NA(f)|0,s|0){r=13;break}t[l>>2]=t[f>>2],t[l+4>>2]=t[f+4>>2],t[l+8>>2]=t[f+8>>2],ze(l)}else{if(s=YA(f)|0,s|0){r=13;break}t[l>>2]=t[f>>2],t[l+4>>2]=t[f+4>>2],t[l+8>>2]=t[f+8>>2],Ge(l)}if(H(o,l,u),et(u),s=n,q=t[s>>2]|0,s=t[s+4>>2]|0,Z=(15-i|0)*3|0,nA=CA(7,0,Z|0)|0,s=s&~(S()|0),Z=CA(hA(u)|0,0,Z|0)|0,s=S()|0|s,Y=n,t[Y>>2]=Z|q&~nA,t[Y+4>>2]=s,(i|0)<=1){r=14;break}}A:do if((r|0)!=13&&(r|0)==14)if((t[f>>2]|0)<=1&&(t[f+4>>2]|0)<=1&&(t[f+8>>2]|0)<=1){r=hA(f)|0,s=ln(I,r)|0,(s|0)==127?u=0:u=be(s)|0;e:do if(r){if(p){if(s=Vt(e,A)|0,(s|0)==7){s=5;break A}if(i=t[21376+(s*28|0)+(r<<2)>>2]|0,(i|0)>0){s=r,r=0;do s=rt(s)|0,r=r+1|0;while((r|0)!=(i|0))}else s=r;if((s|0)==1){s=9;break A}r=ln(I,s)|0,(r|0)==127&&OA(27648,27538,411,27678),be(r)|0?OA(27693,27538,412,27678):(N=r,L=i,M=s)}else N=s,L=0,M=r;if(l=t[4272+(I*28|0)+(M<<2)>>2]|0,(l|0)<=-1&&OA(27724,27538,419,27678),!u){if((L|0)<0){s=5;break A}if(L|0){i=n,s=0,r=t[i>>2]|0,i=t[i+4>>2]|0;do r=hn(r,i)|0,i=S()|0,Z=n,t[Z>>2]=r,t[Z+4>>2]=i,s=s+1|0;while((s|0)<(L|0))}if((l|0)<=0){s=N,r=58;break}for(i=n,s=0,r=t[i>>2]|0,i=t[i+4>>2]|0;;)if(r=hn(r,i)|0,i=S()|0,Z=n,t[Z>>2]=r,t[Z+4>>2]=i,s=s+1|0,(s|0)==(l|0)){s=N,r=58;break e}}if(o=an(N,I)|0,(o|0)==7&&OA(27514,27538,428,27678),s=n,r=t[s>>2]|0,s=t[s+4>>2]|0,(l|0)>0){i=0;do r=hn(r,s)|0,s=S()|0,Z=n,t[Z>>2]=r,t[Z+4>>2]=s,i=i+1|0;while((i|0)!=(l|0))}if(s=Vt(r,s)|0,(s|0)==7&&OA(27795,27538,440,27678),r=Tt(N)|0,r=t[(r?21792:21584)+(o*28|0)+(s<<2)>>2]|0,(r|0)<0&&OA(27795,27538,454,27678),!r)s=N,r=58;else{o=n,s=0,i=t[o>>2]|0,o=t[o+4>>2]|0;do i=ns(i,o)|0,o=S()|0,Z=n,t[Z>>2]=i,t[Z+4>>2]=o,s=s+1|0;while((s|0)<(r|0));s=N,r=58}}else if((p|0)!=0&(u|0)!=0){if(r=Vt(e,A)|0,i=n,i=Vt(t[i>>2]|0,t[i+4>>2]|0)|0,(r|0)==7|(i|0)==7){s=5;break A}if(i=t[21376+(r*28|0)+(i<<2)>>2]|0,(i|0)<0){s=5;break A}if(!i)r=59;else{l=n,r=0,o=t[l>>2]|0,l=t[l+4>>2]|0;do o=hn(o,l)|0,l=S()|0,Z=n,t[Z>>2]=o,t[Z+4>>2]=l,r=r+1|0;while((r|0)<(i|0));r=58}}else r=58;while(!1);if((r|0)==58&&u&&(r=59),(r|0)==59&&(Z=n,(Vt(t[Z>>2]|0,t[Z+4>>2]|0)|0)==1)){s=9;break}Z=n,nA=t[Z>>2]|0,Z=t[Z+4>>2]&-1040385,q=CA(s|0,0,45)|0,Z=Z|(S()|0),s=n,t[s>>2]=nA|q,t[s+4>>2]=Z,s=0}else s=1;while(!1);return Z=s,C=G,Z|0}function ql(e,A,r,n,s,i){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,i=i|0;var o=0,l=0;return l=C,C=C+16|0,o=l,s?e=15:(e=Or(e,A,r,n,o)|0,e||(A0(o,i),e=0)),C=l,e|0}function Jl(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0;return o=C,C=C+16|0,i=o,n?r=15:(r=It(r,i)|0,r||(r=ni(e,A,i,s)|0)),C=o,r|0}function Xl(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,u=0;return u=C,C=C+32|0,o=u+12|0,l=u,i=Or(e,A,e,A,o)|0,i|0?(l=i,C=u,l|0):(e=Or(e,A,r,n,l)|0,e|0?(l=e,C=u,l|0):(o=Dn(o,l)|0,l=s,t[l>>2]=o,t[l+4>>2]=((o|0)<0)<<31>>31,l=0,C=u,l|0))}function Aa(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,u=0;return u=C,C=C+32|0,o=u+12|0,l=u,i=Or(e,A,e,A,o)|0,!i&&(i=Or(e,A,r,n,l)|0,!i)?(n=Dn(o,l)|0,n=ZA(n|0,((n|0)<0)<<31>>31|0,1,0)|0,o=S()|0,l=s,t[l>>2]=n,t[l+4>>2]=o,l=0,C=u,l|0):(l=i,C=u,l|0)}function ea(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,Z=0,V=0,BA=0,GA=0,QA=0,ce=0;if(QA=C,C=C+48|0,BA=QA+24|0,o=QA+12|0,GA=QA,i=Or(e,A,e,A,BA)|0,!i&&(i=Or(e,A,r,n,o)|0,!i)){Z=Dn(BA,o)|0,V=((Z|0)<0)<<31>>31,t[BA>>2]=0,t[BA+4>>2]=0,t[BA+8>>2]=0,t[o>>2]=0,t[o+4>>2]=0,t[o+8>>2]=0,Or(e,A,e,A,BA)|0&&OA(27795,27538,692,27747),Or(e,A,r,n,o)|0&&OA(27795,27538,697,27747),e0(BA),e0(o),p=(Z|0)==0?0:1/+(Z|0),r=t[BA>>2]|0,G=p*+((t[o>>2]|0)-r|0),Y=BA+4|0,n=t[Y>>2]|0,nA=p*+((t[o+4>>2]|0)-n|0),q=BA+8|0,i=t[q>>2]|0,p=p*+((t[o+8>>2]|0)-i|0),t[GA>>2]=r,M=GA+4|0,t[M>>2]=n,I=GA+8|0,t[I>>2]=i;A:do if((Z|0)<0)i=0;else for(L=0,N=0;;){u=+(N>>>0)+4294967296*+(L|0),ce=G*u+ +(r|0),l=nA*u+ +(n|0),u=p*u+ +(i|0),r=~~+_0(+ce),o=~~+_0(+l),i=~~+_0(+u),ce=+oe(+(+(r|0)-ce)),l=+oe(+(+(o|0)-l)),u=+oe(+(+(i|0)-u));do if(ce>l&ce>u)r=0-(o+i)|0,n=o;else if(f=0-r|0,l>u){n=f-i|0;break}else{n=o,i=f-o|0;break}while(!1);if(t[GA>>2]=r,t[M>>2]=n,t[I>>2]=i,t0(GA),i=ni(e,A,GA,s+(N<<3)|0)|0,i|0)break A;if(!((L|0)<(V|0)|(L|0)==(V|0)&N>>>0>>0)){i=0;break A}r=ZA(N|0,L|0,1,0)|0,n=S()|0,L=n,N=r,r=t[BA>>2]|0,n=t[Y>>2]|0,i=t[q>>2]|0}while(!1);return GA=i,C=QA,GA|0}return GA=i,C=QA,GA|0}function Zr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0;if((r|0)==0&(n|0)==0)return s=0,i=1,JA(s|0),i|0;i=e,s=A,e=1,A=0;do o=(r&1|0)==0&!0,e=yt((o?1:i)|0,(o?0:s)|0,e|0,A|0)|0,A=S()|0,r=gi(r|0,n|0,1)|0,n=S()|0,i=yt(i|0,s|0,i|0,s|0)|0,s=S()|0;while(!((r|0)==0&(n|0)==0));return JA(A|0),e|0}function fs(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0;l=C,C=C+16|0,i=l,o=yA(e|0,A|0,52)|0,S()|0,o=o&15;do if(o){if(s=dn(e,A,i)|0,!s){f=+k[i>>3],u=1/+Be(+f),p=+k[25968+(o<<3)>>3],k[r>>3]=f+p,k[r+8>>3]=f-p,f=+k[i+8>>3],u=p*u,k[r+16>>3]=u+f,k[r+24>>3]=f-u;break}return o=s,C=l,o|0}else{if(s=yA(e|0,A|0,45)|0,S()|0,s=s&127,s>>>0>121)return o=5,C=l,o|0;i=22064+(s<<5)|0,t[r>>2]=t[i>>2],t[r+4>>2]=t[i+4>>2],t[r+8>>2]=t[i+8>>2],t[r+12>>2]=t[i+12>>2],t[r+16>>2]=t[i+16>>2],t[r+20>>2]=t[i+20>>2],t[r+24>>2]=t[i+24>>2],t[r+28>>2]=t[i+28>>2];break}while(!1);return yr(r,n?1.4:1.1),n=26096+(o<<3)|0,(t[n>>2]|0)==(e|0)&&(t[n+4>>2]|0)==(A|0)&&(k[r>>3]=1.5707963267948966),o=26224+(o<<3)|0,(t[o>>2]|0)==(e|0)&&(t[o+4>>2]|0)==(A|0)&&(k[r+8>>3]=-1.5707963267948966),+k[r>>3]!=1.5707963267948966&&+k[r+8>>3]!=-1.5707963267948966?(o=0,C=l,o|0):(k[r+16>>3]=3.141592653589793,k[r+24>>3]=-3.141592653589793,o=0,C=l,o|0)}function ta(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0;f=C,C=C+48|0,o=f+32|0,i=f+40|0,l=f,Nt(o,0,0,0),u=t[o>>2]|0,o=t[o+4>>2]|0;do if(r>>>0<=15){if(s=a0(n)|0,s|0){n=l,t[n>>2]=0,t[n+4>>2]=0,t[l+8>>2]=s,t[l+12>>2]=-1,n=l+16|0,u=l+29|0,t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,gA[n+12>>0]=0,gA[u>>0]=gA[i>>0]|0,gA[u+1>>0]=gA[i+1>>0]|0,gA[u+2>>0]=gA[i+2>>0]|0;break}if(s=Wt((t[A+8>>2]|0)+1|0,32)|0,s){hs(A,s),p=l,t[p>>2]=u,t[p+4>>2]=o,t[l+8>>2]=0,t[l+12>>2]=r,t[l+16>>2]=n,t[l+20>>2]=A,t[l+24>>2]=s,gA[l+28>>0]=0,u=l+29|0,gA[u>>0]=gA[i>>0]|0,gA[u+1>>0]=gA[i+1>>0]|0,gA[u+2>>0]=gA[i+2>>0]|0;break}else{n=l,t[n>>2]=0,t[n+4>>2]=0,t[l+8>>2]=13,t[l+12>>2]=-1,n=l+16|0,u=l+29|0,t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,gA[n+12>>0]=0,gA[u>>0]=gA[i>>0]|0,gA[u+1>>0]=gA[i+1>>0]|0,gA[u+2>>0]=gA[i+2>>0]|0;break}}else u=l,t[u>>2]=0,t[u+4>>2]=0,t[l+8>>2]=4,t[l+12>>2]=-1,u=l+16|0,p=l+29|0,t[u>>2]=0,t[u+4>>2]=0,t[u+8>>2]=0,gA[u+12>>0]=0,gA[p>>0]=gA[i>>0]|0,gA[p+1>>0]=gA[i+1>>0]|0,gA[p+2>>0]=gA[i+2>>0]|0;while(!1);M0(l),t[e>>2]=t[l>>2],t[e+4>>2]=t[l+4>>2],t[e+8>>2]=t[l+8>>2],t[e+12>>2]=t[l+12>>2],t[e+16>>2]=t[l+16>>2],t[e+20>>2]=t[l+20>>2],t[e+24>>2]=t[l+24>>2],t[e+28>>2]=t[l+28>>2],C=f}function M0(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,Z=0,V=0;if(V=C,C=C+336|0,L=V+168|0,N=V,n=e,r=t[n>>2]|0,n=t[n+4>>2]|0,(r|0)==0&(n|0)==0){C=V;return}if(A=e+28|0,gA[A>>0]|0?(r=si(r,n)|0,n=S()|0):gA[A>>0]=1,Z=e+20|0,!(t[t[Z>>2]>>2]|0)){A=e+24|0,r=t[A>>2]|0,r|0&&$A(r),q=e,t[q>>2]=0,t[q+4>>2]=0,t[e+8>>2]=0,t[Z>>2]=0,t[e+12>>2]=-1,t[e+16>>2]=0,t[A>>2]=0,C=V;return}q=e+16|0,A=t[q>>2]|0,s=A&15;A:do if((r|0)==0&(n|0)==0)nA=e+24|0;else{G=e+12|0,M=(s|0)==3,p=A&255,u=(s|1|0)==3,I=e+24|0,f=(s+-1|0)>>>0<3,o=(s|2|0)==3,l=N+8|0;e:for(;;){if(i=yA(r|0,n|0,52)|0,S()|0,i=i&15,(i|0)==(t[G>>2]|0)){switch(p&15){case 0:case 2:case 3:{if(s=dn(r,n,L)|0,s|0){Y=15;break e}if(ds(t[Z>>2]|0,t[I>>2]|0,L)|0){Y=19;break e}break}}if(u&&(s=t[(t[Z>>2]|0)+4>>2]|0,t[L>>2]=t[s>>2],t[L+4>>2]=t[s+4>>2],t[L+8>>2]=t[s+8>>2],t[L+12>>2]=t[s+12>>2],Er(26832,L)|0)){if(is(t[(t[Z>>2]|0)+4>>2]|0,i,N)|0){Y=25;break}if(s=N,(t[s>>2]|0)==(r|0)&&(t[s+4>>2]|0)==(n|0)){Y=29;break}}if(f){if(s=In(r,n,L)|0,s|0){Y=32;break}if(fs(r,n,N,0)|0){Y=36;break}if(o&&oi(t[Z>>2]|0,t[I>>2]|0,L,N)|0){Y=42;break}if(u&&li(t[Z>>2]|0,t[I>>2]|0,L,N)|0){Y=42;break}}if(M){if(A=fs(r,n,L,1)|0,s=t[I>>2]|0,A|0){Y=45;break}if(Fe(s,L)|0){if(Sr(N,L),Qr(L,t[I>>2]|0)|0){Y=53;break}if(ds(t[Z>>2]|0,t[I>>2]|0,l)|0){Y=53;break}if(li(t[Z>>2]|0,t[I>>2]|0,N,L)|0){Y=53;break}}}}do if((i|0)<(t[G>>2]|0)){if(A=fs(r,n,L,1)|0,s=t[I>>2]|0,A|0){Y=58;break e}if(!(Fe(s,L)|0)){Y=73;break}if(Qr(t[I>>2]|0,L)|0&&(Sr(N,L),oi(t[Z>>2]|0,t[I>>2]|0,N,L)|0)){Y=65;break e}if(r=qs(r,n,i+1|0,N)|0,r|0){Y=67;break e}n=N,r=t[n>>2]|0,n=t[n+4>>2]|0}else Y=73;while(!1);if((Y|0)==73&&(Y=0,r=si(r,n)|0,n=S()|0),(r|0)==0&(n|0)==0){nA=I;break A}}switch(Y|0){case 15:{A=t[I>>2]|0,A|0&&$A(A),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[Z>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[I>>2]=0,t[e+8>>2]=s,Y=20;break}case 19:{t[e>>2]=r,t[e+4>>2]=n,Y=20;break}case 25:{OA(27795,27761,470,27772);break}case 29:{t[e>>2]=r,t[e+4>>2]=n,C=V;return}case 32:{A=t[I>>2]|0,A|0&&$A(A),nA=e,t[nA>>2]=0,t[nA+4>>2]=0,t[Z>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[I>>2]=0,t[e+8>>2]=s,C=V;return}case 36:{OA(27795,27761,493,27772);break}case 42:{t[e>>2]=r,t[e+4>>2]=n,C=V;return}case 45:{s|0&&$A(s),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[Z>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[I>>2]=0,t[e+8>>2]=A,Y=55;break}case 53:{t[e>>2]=r,t[e+4>>2]=n,Y=55;break}case 58:{s|0&&$A(s),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[Z>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[I>>2]=0,t[e+8>>2]=A,Y=71;break}case 65:{t[e>>2]=r,t[e+4>>2]=n,Y=71;break}case 67:{A=t[I>>2]|0,A|0&&$A(A),nA=e,t[nA>>2]=0,t[nA+4>>2]=0,t[Z>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[I>>2]=0,t[e+8>>2]=r,C=V;return}}if((Y|0)==20){C=V;return}else if((Y|0)==55){C=V;return}else if((Y|0)==71){C=V;return}}while(!1);A=t[nA>>2]|0,A|0&&$A(A),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[e+8>>2]=0,t[Z>>2]=0,t[e+12>>2]=-1,t[q>>2]=0,t[nA>>2]=0,C=V}function si(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0;M=C,C=C+16|0,p=M,n=yA(e|0,A|0,52)|0,S()|0,n=n&15,r=yA(e|0,A|0,45)|0,S()|0;do if(n){for(;r=CA(n+4095|0,0,52)|0,s=S()|0|A&-15728641,i=(15-n|0)*3|0,o=CA(7,0,i|0)|0,l=S()|0,r=r|e|o,s=s|l,u=yA(e|0,A|0,i|0)|0,S()|0,u=u&7,n=n+-1|0,!(u>>>0<6);)if(n)A=s,e=r;else{f=4;break}if((f|0)==4){r=yA(r|0,s|0,45)|0,S()|0;break}return p=(u|0)==0&(Qe(r,s)|0)!=0,p=CA((p?2:1)+u|0,0,i|0)|0,f=S()|0|A&~l,p=p|e&~o,JA(f|0),C=M,p|0}while(!1);return r=r&127,r>>>0>120?(f=0,p=0,JA(f|0),C=M,p|0):(Nt(p,0,r+1|0,0),f=t[p+4>>2]|0,p=t[p>>2]|0,JA(f|0),C=M,p|0)}function ra(e,A,r,n,s,i){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,i=i|0;var o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0;Y=C,C=C+160|0,M=Y+80|0,l=Y+64|0,I=Y+112|0,G=Y,ta(M,e,A,r),f=M,as(l,t[f>>2]|0,t[f+4>>2]|0,A),f=l,u=t[f>>2]|0,f=t[f+4>>2]|0,o=t[M+8>>2]|0,L=I+4|0,t[L>>2]=t[M>>2],t[L+4>>2]=t[M+4>>2],t[L+8>>2]=t[M+8>>2],t[L+12>>2]=t[M+12>>2],t[L+16>>2]=t[M+16>>2],t[L+20>>2]=t[M+20>>2],t[L+24>>2]=t[M+24>>2],t[L+28>>2]=t[M+28>>2],L=G,t[L>>2]=u,t[L+4>>2]=f,L=G+8|0,t[L>>2]=o,e=G+12|0,A=I,r=e+36|0;do t[e>>2]=t[A>>2],e=e+4|0,A=A+4|0;while((e|0)<(r|0));if(I=G+48|0,t[I>>2]=t[l>>2],t[I+4>>2]=t[l+4>>2],t[I+8>>2]=t[l+8>>2],t[I+12>>2]=t[l+12>>2],(u|0)==0&(f|0)==0)return G=o,C=Y,G|0;r=G+16|0,p=G+24|0,M=G+28|0,o=0,l=0,A=u,e=f;do{if(!((o|0)<(s|0)|(o|0)==(s|0)&l>>>0>>0)){N=4;break}if(f=l,l=ZA(l|0,o|0,1,0)|0,o=S()|0,f=i+(f<<3)|0,t[f>>2]=A,t[f+4>>2]=e,us(I),e=I,A=t[e>>2]|0,e=t[e+4>>2]|0,(A|0)==0&(e|0)==0){if(M0(r),A=r,e=t[A>>2]|0,A=t[A+4>>2]|0,(e|0)==0&(A|0)==0){N=10;break}Xs(e,A,t[M>>2]|0,I),e=I,A=t[e>>2]|0,e=t[e+4>>2]|0}f=G,t[f>>2]=A,t[f+4>>2]=e}while(!((A|0)==0&(e|0)==0));return(N|0)==4?(e=G+40|0,A=t[e>>2]|0,A|0&&$A(A),N=G+16|0,t[N>>2]=0,t[N+4>>2]=0,t[p>>2]=0,t[G+36>>2]=0,t[M>>2]=-1,t[G+32>>2]=0,t[e>>2]=0,Xs(0,0,0,I),t[G>>2]=0,t[G+4>>2]=0,t[L>>2]=0,G=14,C=Y,G|0):((N|0)==10&&(t[G>>2]=0,t[G+4>>2]=0,t[L>>2]=t[p>>2]),G=t[L>>2]|0,C=Y,G|0)}function na(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0;if(M=C,C=C+48|0,u=M+32|0,l=M+40|0,f=M,!(t[e>>2]|0))return p=n,t[p>>2]=0,t[p+4>>2]=0,p=0,C=M,p|0;Nt(u,0,0,0),o=u,s=t[o>>2]|0,o=t[o+4>>2]|0;do if(A>>>0>15)p=f,t[p>>2]=0,t[p+4>>2]=0,t[f+8>>2]=4,t[f+12>>2]=-1,p=f+16|0,r=f+29|0,t[p>>2]=0,t[p+4>>2]=0,t[p+8>>2]=0,gA[p+12>>0]=0,gA[r>>0]=gA[l>>0]|0,gA[r+1>>0]=gA[l+1>>0]|0,gA[r+2>>0]=gA[l+2>>0]|0,r=4,p=9;else{if(r=a0(r)|0,r|0){u=f,t[u>>2]=0,t[u+4>>2]=0,t[f+8>>2]=r,t[f+12>>2]=-1,u=f+16|0,p=f+29|0,t[u>>2]=0,t[u+4>>2]=0,t[u+8>>2]=0,gA[u+12>>0]=0,gA[p>>0]=gA[l>>0]|0,gA[p+1>>0]=gA[l+1>>0]|0,gA[p+2>>0]=gA[l+2>>0]|0,p=9;break}if(r=Wt((t[e+8>>2]|0)+1|0,32)|0,!r){p=f,t[p>>2]=0,t[p+4>>2]=0,t[f+8>>2]=13,t[f+12>>2]=-1,p=f+16|0,r=f+29|0,t[p>>2]=0,t[p+4>>2]=0,t[p+8>>2]=0,gA[p+12>>0]=0,gA[r>>0]=gA[l>>0]|0,gA[r+1>>0]=gA[l+1>>0]|0,gA[r+2>>0]=gA[l+2>>0]|0,r=13,p=9;break}hs(e,r),L=f,t[L>>2]=s,t[L+4>>2]=o,o=f+8|0,t[o>>2]=0,t[f+12>>2]=A,t[f+20>>2]=e,t[f+24>>2]=r,gA[f+28>>0]=0,s=f+29|0,gA[s>>0]=gA[l>>0]|0,gA[s+1>>0]=gA[l+1>>0]|0,gA[s+2>>0]=gA[l+2>>0]|0,t[f+16>>2]=3,I=+un(r),I=I*+qn(r),i=+oe(+ +k[r>>3]),i=I/+Be(+ +D0(+i,+ +oe(+ +k[r+8>>3])))*6371.007180918475*6371.007180918475,s=f+12|0,r=t[s>>2]|0;A:do if((r|0)>0)do{if(Ai(r+-1|0,u)|0,!(i/+k[u>>3]>10))break A;L=t[s>>2]|0,r=L+-1|0,t[s>>2]=r}while((L|0)>1);while(!1);if(M0(f),s=n,t[s>>2]=0,t[s+4>>2]=0,s=f,r=t[s>>2]|0,s=t[s+4>>2]|0,!((r|0)==0&(s|0)==0))do Mr(r,s,A,u)|0,l=u,e=n,l=ZA(t[e>>2]|0,t[e+4>>2]|0,t[l>>2]|0,t[l+4>>2]|0)|0,e=S()|0,L=n,t[L>>2]=l,t[L+4>>2]=e,M0(f),L=f,r=t[L>>2]|0,s=t[L+4>>2]|0;while(!((r|0)==0&(s|0)==0));r=t[o>>2]|0}while(!1);return L=r,C=M,L|0}function l0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0;if(!(Er(A,r)|0)||(A=Ut(A)|0,n=+k[r>>3],s=+k[r+8>>3],s=A&s<0?s+6.283185307179586:s,I=t[e>>2]|0,(I|0)<=0))return I=0,I|0;if(M=t[e+4>>2]|0,A){A=0,p=s,r=-1,e=0;A:for(;;){for(f=e;o=+k[M+(f<<4)>>3],s=+k[M+(f<<4)+8>>3],e=(r+2|0)%(I|0)|0,i=+k[M+(e<<4)>>3],l=+k[M+(e<<4)+8>>3],o>i?(u=o,o=l):(u=i,i=o,o=s,s=l),n=n==i|n==u?n+2220446049250313e-31:n,!!(nu);)if(r=f+1|0,(r|0)>=(I|0)){r=22;break A}else e=f,f=r,r=e;if(l=o<0?o+6.283185307179586:o,o=s<0?s+6.283185307179586:s,p=l==p|o==p?p+-2220446049250313e-31:p,u=l+(o-l)*((n-i)/(u-i)),(u<0?u+6.283185307179586:u)>p&&(A=A^1),e=f+1|0,(e|0)>=(I|0)){r=22;break}else r=f}if((r|0)==22)return A|0}else{A=0,p=s,r=-1,e=0;A:for(;;){for(f=e;o=+k[M+(f<<4)>>3],s=+k[M+(f<<4)+8>>3],e=(r+2|0)%(I|0)|0,i=+k[M+(e<<4)>>3],l=+k[M+(e<<4)+8>>3],o>i?(u=o,o=l):(u=i,i=o,o=s,s=l),n=n==i|n==u?n+2220446049250313e-31:n,!!(nu);)if(r=f+1|0,(r|0)>=(I|0)){r=22;break A}else e=f,f=r,r=e;if(p=o==p|s==p?p+-2220446049250313e-31:p,o+(s-o)*((n-i)/(u-i))>p&&(A=A^1),e=f+1|0,(e|0)>=(I|0)){r=22;break}else r=f}if((r|0)==22)return A|0}return 0}function ii(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0;if(N=t[e>>2]|0,!N){t[A>>2]=0,t[A+4>>2]=0,t[A+8>>2]=0,t[A+12>>2]=0,t[A+16>>2]=0,t[A+20>>2]=0,t[A+24>>2]=0,t[A+28>>2]=0;return}if(G=A+8|0,k[G>>3]=17976931348623157e292,Y=A+24|0,k[Y>>3]=17976931348623157e292,k[A>>3]=-17976931348623157e292,nA=A+16|0,k[nA>>3]=-17976931348623157e292,!((N|0)<=0)){for(I=t[e+4>>2]|0,f=17976931348623157e292,p=-17976931348623157e292,M=0,e=-1,i=17976931348623157e292,o=17976931348623157e292,u=-17976931348623157e292,n=-17976931348623157e292,L=0;r=+k[I+(L<<4)>>3],l=+k[I+(L<<4)+8>>3],e=e+2|0,s=+k[I+(((e|0)==(N|0)?0:e)<<4)+8>>3],r>3]=r,i=r),l>3]=l,o=l),r>u?k[A>>3]=r:r=u,l>n&&(k[nA>>3]=l,n=l),f=l>0&lp?l:p,M=M|+oe(+(l-s))>3.141592653589793,e=L+1|0,(e|0)!=(N|0);)q=L,u=r,L=e,e=q;M&&(k[nA>>3]=p,k[Y>>3]=f)}}function a0(e){return e=e|0,(e>>>0<4?0:15)|0}function hs(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,Z=0,V=0,BA=0,GA=0,QA=0;if(N=t[e>>2]|0,N){if(G=A+8|0,k[G>>3]=17976931348623157e292,Y=A+24|0,k[Y>>3]=17976931348623157e292,k[A>>3]=-17976931348623157e292,nA=A+16|0,k[nA>>3]=-17976931348623157e292,(N|0)>0){for(s=t[e+4>>2]|0,I=17976931348623157e292,L=-17976931348623157e292,n=0,r=-1,u=17976931348623157e292,f=17976931348623157e292,M=-17976931348623157e292,o=-17976931348623157e292,q=0;i=+k[s+(q<<4)>>3],p=+k[s+(q<<4)+8>>3],GA=r+2|0,l=+k[s+(((GA|0)==(N|0)?0:GA)<<4)+8>>3],i>3]=i,u=i),p>3]=p,f=p),i>M?k[A>>3]=i:i=M,p>o&&(k[nA>>3]=p,o=p),I=p>0&pL?p:L,n=n|+oe(+(p-l))>3.141592653589793,r=q+1|0,(r|0)!=(N|0);)GA=q,M=i,q=r,r=GA;n&&(k[nA>>3]=L,k[Y>>3]=I)}}else t[A>>2]=0,t[A+4>>2]=0,t[A+8>>2]=0,t[A+12>>2]=0,t[A+16>>2]=0,t[A+20>>2]=0,t[A+24>>2]=0,t[A+28>>2]=0;if(GA=e+8|0,r=t[GA>>2]|0,!((r|0)<=0)){BA=e+12|0,V=0;do if(s=t[BA>>2]|0,n=V,V=V+1|0,Y=A+(V<<5)|0,nA=t[s+(n<<3)>>2]|0,nA){if(q=A+(V<<5)+8|0,k[q>>3]=17976931348623157e292,e=A+(V<<5)+24|0,k[e>>3]=17976931348623157e292,k[Y>>3]=-17976931348623157e292,Z=A+(V<<5)+16|0,k[Z>>3]=-17976931348623157e292,(nA|0)>0){for(N=t[s+(n<<3)+4>>2]|0,I=17976931348623157e292,L=-17976931348623157e292,s=0,n=-1,G=0,u=17976931348623157e292,f=17976931348623157e292,p=-17976931348623157e292,o=-17976931348623157e292;i=+k[N+(G<<4)>>3],M=+k[N+(G<<4)+8>>3],n=n+2|0,l=+k[N+(((n|0)==(nA|0)?0:n)<<4)+8>>3],i>3]=i,u=i),M>3]=M,f=M),i>p?k[Y>>3]=i:i=p,M>o&&(k[Z>>3]=M,o=M),I=M>0&ML?M:L,s=s|+oe(+(M-l))>3.141592653589793,n=G+1|0,(n|0)!=(nA|0);)QA=G,G=n,p=i,n=QA;s&&(k[Z>>3]=L,k[e>>3]=I)}}else t[Y>>2]=0,t[Y+4>>2]=0,t[Y+8>>2]=0,t[Y+12>>2]=0,t[Y+16>>2]=0,t[Y+20>>2]=0,t[Y+24>>2]=0,t[Y+28>>2]=0,r=t[GA>>2]|0;while((V|0)<(r|0))}}function ds(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if(!(l0(e,A,r)|0))return s=0,s|0;if(s=e+8|0,(t[s>>2]|0)<=0)return s=1,s|0;for(n=e+12|0,e=0;;){if(i=e,e=e+1|0,l0((t[n>>2]|0)+(i<<3)|0,A+(e<<5)|0,r)|0){e=0,n=6;break}if((e|0)>=(t[s>>2]|0)){e=1,n=6;break}}return(n|0)==6?e|0:0}function oi(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0;if(f=C,C=C+16|0,l=f,o=r+8|0,!(l0(e,A,o)|0))return u=0,C=f,u|0;u=e+8|0;A:do if((t[u>>2]|0)>0){for(i=e+12|0,s=0;;){if(p=s,s=s+1|0,l0((t[i>>2]|0)+(p<<3)|0,A+(s<<5)|0,o)|0){s=0;break}if((s|0)>=(t[u>>2]|0))break A}return C=f,s|0}while(!1);if(B0(e,A,r,n)|0)return p=0,C=f,p|0;t[l>>2]=t[r>>2],t[l+4>>2]=o,s=t[u>>2]|0;A:do if((s|0)>0)for(e=e+12|0,o=0,i=s;;){if(s=t[e>>2]|0,(t[s+(o<<3)>>2]|0)>0){if(l0(l,n,t[s+(o<<3)+4>>2]|0)|0){s=0;break A}if(s=o+1|0,B0((t[e>>2]|0)+(o<<3)|0,A+(s<<5)|0,r,n)|0){s=0;break A}i=t[u>>2]|0}else s=o+1|0;if((s|0)<(i|0))o=s;else{s=1;break}}else s=1;while(!1);return p=s,C=f,p|0}function B0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,Z=0,V=0,BA=0,GA=0,QA=0,ce=0;if(GA=C,C=C+176|0,q=GA+172|0,s=GA+168|0,Z=GA,!(Fe(A,n)|0))return e=0,C=GA,e|0;if(Pr(A,n,q,s),Pn(Z|0,r|0,168)|0,(t[r>>2]|0)>0){A=0;do QA=Z+8+(A<<4)+8|0,nA=+Xt(+k[QA>>3],t[s>>2]|0),k[QA>>3]=nA,A=A+1|0;while((A|0)<(t[r>>2]|0))}G=+k[n>>3],Y=+k[n+8>>3],nA=+Xt(+k[n+16>>3],t[s>>2]|0),L=+Xt(+k[n+24>>3],t[s>>2]|0);A:do if((t[e>>2]|0)>0){if(n=e+4|0,s=t[Z>>2]|0,(s|0)<=0){for(A=0;;)if(A=A+1|0,(A|0)>=(t[e>>2]|0)){A=0;break A}}for(r=0;;){if(A=t[n>>2]|0,I=+k[A+(r<<4)>>3],N=+Xt(+k[A+(r<<4)+8>>3],t[q>>2]|0),A=t[n>>2]|0,r=r+1|0,QA=(r|0)%(t[e>>2]|0)|0,i=+k[A+(QA<<4)>>3],o=+Xt(+k[A+(QA<<4)+8>>3],t[q>>2]|0),!(I>=G)|!(i>=G)&&!(I<=Y)|!(i<=Y)&&!(N<=L)|!(o<=L)&&!(N>=nA)|!(o>=nA)){M=i-I,f=o-N,A=0;do if(ce=A,A=A+1|0,QA=(A|0)==(s|0)?0:A,i=+k[Z+8+(ce<<4)+8>>3],o=+k[Z+8+(QA<<4)+8>>3]-i,l=+k[Z+8+(ce<<4)>>3],u=+k[Z+8+(QA<<4)>>3]-l,p=M*o-f*u,p!=0&&(V=N-i,BA=I-l,u=(V*u-o*BA)/p,!(u<0|u>1))&&(p=(M*V-f*BA)/p,p>=0&p<=1)){A=1;break A}while((A|0)<(s|0))}if((r|0)>=(t[e>>2]|0)){A=0;break}}}else A=0;while(!1);return ce=A,C=GA,ce|0}function li(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0;if(B0(e,A,r,n)|0)return i=1,i|0;if(i=e+8|0,(t[i>>2]|0)<=0)return i=0,i|0;for(s=e+12|0,e=0;;){if(o=e,e=e+1|0,B0((t[s>>2]|0)+(o<<3)|0,A+(e<<5)|0,r,n)|0){e=1,s=6;break}if((e|0)>=(t[i>>2]|0)){e=0,s=6;break}}return(s|0)==6?e|0:0}function sa(){return 8}function ia(){return 16}function oa(){return 168}function la(){return 8}function aa(){return 16}function ua(){return 12}function ca(){return 8}function fa(e){return e=e|0,+(+((t[e>>2]|0)>>>0)+4294967296*+(t[e+4>>2]|0))}function ha(e){e=e|0;var A=0,r=0;return r=+k[e>>3],A=+k[e+8>>3],+ +fe(+(r*r+A*A))}function ai(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0;f=+k[e>>3],u=+k[A>>3]-f,l=+k[e+8>>3],o=+k[A+8>>3]-l,M=+k[r>>3],i=+k[n>>3]-M,I=+k[r+8>>3],p=+k[n+8>>3]-I,i=(i*(l-I)-(f-M)*p)/(u*p-o*i),k[s>>3]=f+u*i,k[s+8>>3]=l+o*i}function ui(e,A){return e=e|0,A=A|0,+oe(+(+k[e>>3]-+k[A>>3]))<11920928955078125e-23?(A=+oe(+(+k[e+8>>3]-+k[A+8>>3]))<11920928955078125e-23,A|0):(A=0,A|0)}function ft(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;return s=+k[e>>3]-+k[A>>3],n=+k[e+8>>3]-+k[A+8>>3],r=+k[e+16>>3]-+k[A+16>>3],+(s*s+n*n+r*r)}function da(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;r=+k[e>>3],n=+Be(+r),r=+WA(+r),k[A+16>>3]=r,r=+k[e+8>>3],s=n*+Be(+r),k[A>>3]=s,r=n*+WA(+r),k[A+8>>3]=r}function ma(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if(i=C,C=C+16|0,s=i,n=Qe(e,A)|0,(r+-1|0)>>>0>5||(n=(n|0)!=0,(r|0)==1&n))return s=-1,C=i,s|0;do if(u0(e,A,s)|0)n=-1;else if(n){n=((t[26352+(r<<2)>>2]|0)+5-(t[s>>2]|0)|0)%5|0;break}else{n=((t[26384+(r<<2)>>2]|0)+6-(t[s>>2]|0)|0)%6|0;break}while(!1);return s=n,C=i,s|0}function u0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;if(p=C,C=C+32|0,l=p+16|0,u=p,n=Rn(e,A,l)|0,n|0)return r=n,C=p,r|0;i=ne(e,A)|0,f=Vt(e,A)|0,Wr(i,u),n=Zt(i,t[l>>2]|0)|0;do if(be(i)|0){do switch(i|0){case 4:{s=0;break}case 14:{s=1;break}case 24:{s=2;break}case 38:{s=3;break}case 49:{s=4;break}case 58:{s=5;break}case 63:{s=6;break}case 72:{s=7;break}case 83:{s=8;break}case 97:{s=9;break}case 107:{s=10;break}case 117:{s=11;break}default:OA(27795,27797,75,27806)}while(!1);if(o=t[26416+(s*24|0)+8>>2]|0,A=t[26416+(s*24|0)+16>>2]|0,e=t[l>>2]|0,(e|0)!=(t[u>>2]|0)&&(u=Tt(i)|0,e=t[l>>2]|0,u|(e|0)==(A|0)&&(n=(n+1|0)%6|0)),(f|0)==3&(e|0)==(A|0)){n=(n+5|0)%6|0;break}(f|0)==5&(e|0)==(o|0)&&(n=(n+1|0)%6|0)}while(!1);return t[r>>2]=n,r=0,C=p,r|0}function ar(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,Z=0;if(Z=C,C=C+32|0,q=Z+24|0,Y=Z+20|0,N=Z+8|0,L=Z+16|0,I=Z,u=(Qe(e,A)|0)==0,u=u?6:5,p=yA(e|0,A|0,52)|0,S()|0,p=p&15,u>>>0<=r>>>0)return n=2,C=Z,n|0;M=(p|0)==0,!M&&(G=CA(7,0,(p^15)*3|0)|0,(G&e|0)==0&((S()|0)&A|0)==0)?s=r:i=4;A:do if((i|0)==4){if(s=(Qe(e,A)|0)!=0,((s?4:5)|0)<(r|0)||u0(e,A,q)|0||(i=(t[q>>2]|0)+r|0,s?s=26704+(((i|0)%5|0)<<2)|0:s=26736+(((i|0)%6|0)<<2)|0,G=t[s>>2]|0,(G|0)==7))return n=1,C=Z,n|0;t[Y>>2]=0,s=K(e,A,G,Y,N)|0;do if(!s){if(l=N,f=t[l>>2]|0,l=t[l+4>>2]|0,o=l>>>0>>0|(l|0)==(A|0)&f>>>0>>0,i=o?f:e,o=o?l:A,!M&&(M=CA(7,0,(p^15)*3|0)|0,(f&M|0)==0&(l&(S()|0)|0)==0))s=r;else{if(l=(r+-1+u|0)%(u|0)|0,s=Qe(e,A)|0,(l|0)<0&&OA(27795,27797,248,27822),u=(s|0)!=0,((u?4:5)|0)<(l|0)&&OA(27795,27797,248,27822),u0(e,A,q)|0&&OA(27795,27797,248,27822),s=(t[q>>2]|0)+l|0,u?s=26704+(((s|0)%5|0)<<2)|0:s=26736+(((s|0)%6|0)<<2)|0,l=t[s>>2]|0,(l|0)==7&&OA(27795,27797,248,27822),t[L>>2]=0,s=K(e,A,l,L,I)|0,s|0)break;f=I,u=t[f>>2]|0,f=t[f+4>>2]|0;do if(f>>>0>>0|(f|0)==(o|0)&u>>>0>>0){if(Qe(u,f)|0?i=ee(u,f,e,A)|0:i=t[26800+((((t[L>>2]|0)+(t[26768+(l<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,s=Qe(u,f)|0,(i+-1|0)>>>0>5){s=-1,i=u,o=f;break}if(s=(s|0)!=0,(i|0)==1&s){s=-1,i=u,o=f;break}do if(u0(u,f,q)|0)s=-1;else if(s){s=((t[26352+(i<<2)>>2]|0)+5-(t[q>>2]|0)|0)%5|0;break}else{s=((t[26384+(i<<2)>>2]|0)+6-(t[q>>2]|0)|0)%6|0;break}while(!1);i=u,o=f}else s=r;while(!1);l=N,f=t[l>>2]|0,l=t[l+4>>2]|0}if((i|0)==(f|0)&(o|0)==(l|0)){if(u=(Qe(f,l)|0)!=0,u?e=ee(f,l,e,A)|0:e=t[26800+((((t[Y>>2]|0)+(t[26768+(G<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,s=Qe(f,l)|0,(e+-1|0)>>>0<=5&&(nA=(s|0)!=0,!((e|0)==1&nA)))do if(u0(f,l,q)|0)s=-1;else if(nA){s=((t[26352+(e<<2)>>2]|0)+5-(t[q>>2]|0)|0)%5|0;break}else{s=((t[26384+(e<<2)>>2]|0)+6-(t[q>>2]|0)|0)%6|0;break}while(!1);else s=-1;s=s+1|0,s=(s|0)==6|u&(s|0)==5?0:s}A=o,e=i;break A}while(!1);return n=s,C=Z,n|0}while(!1);return nA=CA(s|0,0,56)|0,q=S()|0|A&-2130706433|536870912,t[n>>2]=nA|e,t[n+4>>2]=q,n=0,C=Z,n|0}function pa(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;return i=(Qe(e,A)|0)==0,n=ar(e,A,0,r)|0,s=(n|0)==0,i?!s||(n=ar(e,A,1,r+8|0)|0,n|0)||(n=ar(e,A,2,r+16|0)|0,n|0)||(n=ar(e,A,3,r+24|0)|0,n|0)||(n=ar(e,A,4,r+32|0)|0,n)?(i=n,i|0):ar(e,A,5,r+40|0)|0:!s||(n=ar(e,A,1,r+8|0)|0,n|0)||(n=ar(e,A,2,r+16|0)|0,n|0)||(n=ar(e,A,3,r+24|0)|0,n|0)||(n=ar(e,A,4,r+32|0)|0,n|0)?(i=n,i|0):(i=r+40|0,t[i>>2]=0,t[i+4>>2]=0,i=0,i|0)}function ga(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0;return u=C,C=C+192|0,s=u,i=u+168|0,o=yA(e|0,A|0,56)|0,S()|0,o=o&7,l=A&-2130706433|134217728,n=Rn(e,l,i)|0,n|0?(l=n,C=u,l|0):(A=yA(e|0,A|0,52)|0,S()|0,A=A&15,Qe(e,l)|0?w(i,A,o,1,s):eA(i,A,o,1,s),l=s+8|0,t[r>>2]=t[l>>2],t[r+4>>2]=t[l+4>>2],t[r+8>>2]=t[l+8>>2],t[r+12>>2]=t[l+12>>2],l=0,C=u,l|0)}function ci(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return s=C,C=C+16|0,r=s,!(!0&(A&2013265920|0)==536870912)||(n=A&-2130706433|134217728,!(Ue(e,n)|0))?(n=0,C=s,n|0):(i=yA(e|0,A|0,56)|0,S()|0,i=(ar(e,n,i&7,r)|0)==0,n=r,n=i&((t[n>>2]|0)==(e|0)?(t[n+4>>2]|0)==(A|0):0)&1,C=s,n|0)}function fi(e,A,r){e=e|0,A=A|0,r=r|0;var n=0;(A|0)>0?(n=Wt(A,4)|0,t[e>>2]=n,n||OA(27835,27858,40,27872)):t[e>>2]=0,t[e+4>>2]=A,t[e+8>>2]=0,t[e+12>>2]=r}function hi(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;s=e+4|0,i=e+12|0,o=e+8|0;A:for(;;){for(r=t[s>>2]|0,A=0;;){if((A|0)>=(r|0))break A;if(n=t[e>>2]|0,l=t[n+(A<<2)>>2]|0,!l)A=A+1|0;else break}A=n+(~~(+oe(+(+at(10,+ +(15-(t[i>>2]|0)|0))*(+k[l>>3]+ +k[l+8>>3])))%+(r|0))>>>0<<2)|0,r=t[A>>2]|0;e:do if(r|0){if(n=l+32|0,(r|0)==(l|0))t[A>>2]=t[n>>2];else{if(r=r+32|0,A=t[r>>2]|0,!A)break;for(;(A|0)!=(l|0);)if(r=A+32|0,A=t[r>>2]|0,!A)break e;t[r>>2]=t[n>>2]}$A(l),t[o>>2]=(t[o>>2]|0)+-1}while(!1)}$A(t[e>>2]|0)}function di(e){e=e|0;var A=0,r=0,n=0;for(n=t[e+4>>2]|0,r=0;;){if((r|0)>=(n|0)){A=0,r=4;break}if(A=t[(t[e>>2]|0)+(r<<2)>>2]|0,!A)r=r+1|0;else{r=4;break}}return(r|0)==4?A|0:0}function mi(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;if(r=~~(+oe(+(+at(10,+ +(15-(t[e+12>>2]|0)|0))*(+k[A>>3]+ +k[A+8>>3])))%+(t[e+4>>2]|0))>>>0,r=(t[e>>2]|0)+(r<<2)|0,n=t[r>>2]|0,!n)return i=1,i|0;i=A+32|0;do if((n|0)!=(A|0)){if(r=t[n+32>>2]|0,!r)return i=1,i|0;for(s=r;;){if((s|0)==(A|0)){s=8;break}if(r=t[s+32>>2]|0,r)n=s,s=r;else{r=1,s=10;break}}if((s|0)==8){t[n+32>>2]=t[i>>2];break}else if((s|0)==10)return r|0}else t[r>>2]=t[i>>2];while(!1);return $A(A),i=e+8|0,t[i>>2]=(t[i>>2]|0)+-1,i=0,i|0}function ya(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;i=Br(40)|0,i||OA(27888,27858,98,27901),t[i>>2]=t[A>>2],t[i+4>>2]=t[A+4>>2],t[i+8>>2]=t[A+8>>2],t[i+12>>2]=t[A+12>>2],s=i+16|0,t[s>>2]=t[r>>2],t[s+4>>2]=t[r+4>>2],t[s+8>>2]=t[r+8>>2],t[s+12>>2]=t[r+12>>2],t[i+32>>2]=0,s=~~(+oe(+(+at(10,+ +(15-(t[e+12>>2]|0)|0))*(+k[A>>3]+ +k[A+8>>3])))%+(t[e+4>>2]|0))>>>0,s=(t[e>>2]|0)+(s<<2)|0,n=t[s>>2]|0;do if(!n)t[s>>2]=i;else{for(;!(Ln(n,A)|0&&Ln(n+16|0,r)|0);)if(s=t[n+32>>2]|0,n=(s|0)==0?n:s,!(t[n+32>>2]|0)){o=10;break}if((o|0)==10){t[n+32>>2]=i;break}return $A(i),o=n,o|0}while(!1);return o=e+8|0,t[o>>2]=(t[o>>2]|0)+1,o=i,o|0}function xa(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;if(s=~~(+oe(+(+at(10,+ +(15-(t[e+12>>2]|0)|0))*(+k[A>>3]+ +k[A+8>>3])))%+(t[e+4>>2]|0))>>>0,s=t[(t[e>>2]|0)+(s<<2)>>2]|0,!s)return r=0,r|0;if(!r){for(e=s;;){if(Ln(e,A)|0){n=10;break}if(e=t[e+32>>2]|0,!e){e=0,n=10;break}}if((n|0)==10)return e|0}for(e=s;;){if(Ln(e,A)|0&&Ln(e+16|0,r)|0){n=10;break}if(e=t[e+32>>2]|0,!e){e=0,n=10;break}}return(n|0)==10?e|0:0}function wa(e,A){e=e|0,A=A|0;var r=0;if(r=~~(+oe(+(+at(10,+ +(15-(t[e+12>>2]|0)|0))*(+k[A>>3]+ +k[A+8>>3])))%+(t[e+4>>2]|0))>>>0,e=t[(t[e>>2]|0)+(r<<2)>>2]|0,!e)return r=0,r|0;for(;;){if(Ln(e,A)|0){A=5;break}if(e=t[e+32>>2]|0,!e){e=0,A=5;break}}return(A|0)==5?e|0:0}function va(){return 27920}function $r(e){return e=+e,~~+xi(+e)|0}function Br(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,Z=0,V=0,BA=0;BA=C,C=C+16|0,I=BA;do if(e>>>0<245){if(f=e>>>0<11?16:e+11&-8,e=f>>>3,M=t[6981]|0,r=M>>>e,r&3|0)return A=(r&1^1)+e|0,e=27964+(A<<1<<2)|0,r=e+8|0,n=t[r>>2]|0,s=n+8|0,i=t[s>>2]|0,(i|0)==(e|0)?t[6981]=M&~(1<>2]=e,t[r>>2]=i),V=A<<3,t[n+4>>2]=V|3,V=n+V+4|0,t[V>>2]=t[V>>2]|1,V=s,C=BA,V|0;if(p=t[6983]|0,f>>>0>p>>>0){if(r|0)return A=2<>>12&16,A=A>>>l,r=A>>>5&8,A=A>>>r,i=A>>>2&4,A=A>>>i,e=A>>>1&2,A=A>>>e,n=A>>>1&1,n=(r|l|i|e|n)+(A>>>n)|0,A=27964+(n<<1<<2)|0,e=A+8|0,i=t[e>>2]|0,l=i+8|0,r=t[l>>2]|0,(r|0)==(A|0)?(e=M&~(1<>2]=A,t[e>>2]=r,e=M),V=n<<3,o=V-f|0,t[i+4>>2]=f|3,s=i+f|0,t[s+4>>2]=o|1,t[i+V>>2]=o,p|0&&(n=t[6986]|0,A=p>>>3,r=27964+(A<<1<<2)|0,A=1<>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=n,t[A+12>>2]=n,t[n+8>>2]=A,t[n+12>>2]=r),t[6983]=o,t[6986]=s,V=l,C=BA,V|0;if(i=t[6982]|0,i){for(r=(i&0-i)+-1|0,s=r>>>12&16,r=r>>>s,n=r>>>5&8,r=r>>>n,o=r>>>2&4,r=r>>>o,l=r>>>1&2,r=r>>>l,u=r>>>1&1,u=t[28228+((n|s|o|l|u)+(r>>>u)<<2)>>2]|0,r=u,l=u,u=(t[u+4>>2]&-8)-f|0;e=t[r+16>>2]|0,!(!e&&(e=t[r+20>>2]|0,!e));)o=(t[e+4>>2]&-8)-f|0,s=o>>>0>>0,r=e,l=s?e:l,u=s?o:u;if(o=l+f|0,o>>>0>l>>>0){s=t[l+24>>2]|0,A=t[l+12>>2]|0;do if((A|0)==(l|0)){if(e=l+20|0,A=t[e>>2]|0,!A&&(e=l+16|0,A=t[e>>2]|0,!A)){r=0;break}for(;;)if(n=A+20|0,r=t[n>>2]|0,r)A=r,e=n;else if(n=A+16|0,r=t[n>>2]|0,r)A=r,e=n;else break;t[e>>2]=0,r=A}else r=t[l+8>>2]|0,t[r+12>>2]=A,t[A+8>>2]=r,r=A;while(!1);do if(s|0){if(A=t[l+28>>2]|0,e=28228+(A<<2)|0,(l|0)==(t[e>>2]|0)){if(t[e>>2]=r,!r){t[6982]=i&~(1<>2]|0)==(l|0)?V:s+20|0)>>2]=r,!r)break;t[r+24>>2]=s,A=t[l+16>>2]|0,A|0&&(t[r+16>>2]=A,t[A+24>>2]=r),A=t[l+20>>2]|0,A|0&&(t[r+20>>2]=A,t[A+24>>2]=r)}while(!1);return u>>>0<16?(V=u+f|0,t[l+4>>2]=V|3,V=l+V+4|0,t[V>>2]=t[V>>2]|1):(t[l+4>>2]=f|3,t[o+4>>2]=u|1,t[o+u>>2]=u,p|0&&(n=t[6986]|0,A=p>>>3,r=27964+(A<<1<<2)|0,A=1<>2]|0):(t[6981]=A|M,A=r,e=r+8|0),t[e>>2]=n,t[A+12>>2]=n,t[n+8>>2]=A,t[n+12>>2]=r),t[6983]=u,t[6986]=o),V=l+8|0,C=BA,V|0}else M=f}else M=f}else M=f}else if(e>>>0<=4294967231)if(e=e+11|0,f=e&-8,n=t[6982]|0,n){s=0-f|0,e=e>>>8,e?f>>>0>16777215?u=31:(M=(e+1048320|0)>>>16&8,G=e<>>16&4,G=G<>>16&2,u=14-(l|M|u)+(G<>>15)|0,u=f>>>(u+7|0)&1|u<<1):u=0,r=t[28228+(u<<2)>>2]|0;A:do if(!r)r=0,e=0,G=61;else for(e=0,l=f<<((u|0)==31?0:25-(u>>>1)|0),i=0;;){if(o=(t[r+4>>2]&-8)-f|0,o>>>0>>0)if(o)e=r,s=o;else{e=r,s=0,G=65;break A}if(G=t[r+20>>2]|0,r=t[r+16+(l>>>31<<2)>>2]|0,i=(G|0)==0|(G|0)==(r|0)?i:G,r)l=l<<1;else{r=i,G=61;break}}while(!1);if((G|0)==61){if((r|0)==0&(e|0)==0){if(e=2<>>12&16,M=M>>>o,i=M>>>5&8,M=M>>>i,l=M>>>2&4,M=M>>>l,u=M>>>1&2,M=M>>>u,r=M>>>1&1,e=0,r=t[28228+((i|o|l|u|r)+(M>>>r)<<2)>>2]|0}r?G=65:(l=e,o=s)}if((G|0)==65)for(i=r;;)if(M=(t[i+4>>2]&-8)-f|0,r=M>>>0>>0,s=r?M:s,e=r?i:e,r=t[i+16>>2]|0,r||(r=t[i+20>>2]|0),r)i=r;else{l=e,o=s;break}if((l|0)!=0&&o>>>0<((t[6983]|0)-f|0)>>>0&&(p=l+f|0,p>>>0>l>>>0)){i=t[l+24>>2]|0,A=t[l+12>>2]|0;do if((A|0)==(l|0)){if(e=l+20|0,A=t[e>>2]|0,!A&&(e=l+16|0,A=t[e>>2]|0,!A)){A=0;break}for(;;)if(s=A+20|0,r=t[s>>2]|0,r)A=r,e=s;else if(s=A+16|0,r=t[s>>2]|0,r)A=r,e=s;else break;t[e>>2]=0}else V=t[l+8>>2]|0,t[V+12>>2]=A,t[A+8>>2]=V;while(!1);do if(i){if(e=t[l+28>>2]|0,r=28228+(e<<2)|0,(l|0)==(t[r>>2]|0)){if(t[r>>2]=A,!A){n=n&~(1<>2]|0)==(l|0)?V:i+20|0)>>2]=A,!A)break;t[A+24>>2]=i,e=t[l+16>>2]|0,e|0&&(t[A+16>>2]=e,t[e+24>>2]=A),e=t[l+20>>2]|0,e&&(t[A+20>>2]=e,t[e+24>>2]=A)}while(!1);A:do if(o>>>0<16)V=o+f|0,t[l+4>>2]=V|3,V=l+V+4|0,t[V>>2]=t[V>>2]|1;else{if(t[l+4>>2]=f|3,t[p+4>>2]=o|1,t[p+o>>2]=o,A=o>>>3,o>>>0<256){r=27964+(A<<1<<2)|0,e=t[6981]|0,A=1<>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=p,t[A+12>>2]=p,t[p+8>>2]=A,t[p+12>>2]=r;break}if(A=o>>>8,A?o>>>0>16777215?r=31:(Z=(A+1048320|0)>>>16&8,V=A<>>16&4,V=V<>>16&2,r=14-(q|Z|r)+(V<>>15)|0,r=o>>>(r+7|0)&1|r<<1):r=0,A=28228+(r<<2)|0,t[p+28>>2]=r,e=p+16|0,t[e+4>>2]=0,t[e>>2]=0,e=1<>2]=p,t[p+24>>2]=A,t[p+12>>2]=p,t[p+8>>2]=p;break}A=t[A>>2]|0;e:do if((t[A+4>>2]&-8|0)!=(o|0)){for(n=o<<((r|0)==31?0:25-(r>>>1)|0);r=A+16+(n>>>31<<2)|0,e=t[r>>2]|0,!!e;)if((t[e+4>>2]&-8|0)==(o|0)){A=e;break e}else n=n<<1,A=e;t[r>>2]=p,t[p+24>>2]=A,t[p+12>>2]=p,t[p+8>>2]=p;break A}while(!1);Z=A+8|0,V=t[Z>>2]|0,t[V+12>>2]=p,t[Z>>2]=p,t[p+8>>2]=V,t[p+12>>2]=A,t[p+24>>2]=0}while(!1);return V=l+8|0,C=BA,V|0}else M=f}else M=f;else M=-1;while(!1);if(r=t[6983]|0,r>>>0>=M>>>0)return A=r-M|0,e=t[6986]|0,A>>>0>15?(V=e+M|0,t[6986]=V,t[6983]=A,t[V+4>>2]=A|1,t[e+r>>2]=A,t[e+4>>2]=M|3):(t[6983]=0,t[6986]=0,t[e+4>>2]=r|3,V=e+r+4|0,t[V>>2]=t[V>>2]|1),V=e+8|0,C=BA,V|0;if(o=t[6984]|0,o>>>0>M>>>0)return q=o-M|0,t[6984]=q,V=t[6987]|0,Z=V+M|0,t[6987]=Z,t[Z+4>>2]=q|1,t[V+4>>2]=M|3,V=V+8|0,C=BA,V|0;if(t[7099]|0?e=t[7101]|0:(t[7101]=4096,t[7100]=4096,t[7102]=-1,t[7103]=-1,t[7104]=0,t[7092]=0,t[7099]=I&-16^1431655768,e=4096),l=M+48|0,u=M+47|0,i=e+u|0,s=0-e|0,f=i&s,f>>>0<=M>>>0||(e=t[7091]|0,e|0&&(p=t[7089]|0,I=p+f|0,I>>>0<=p>>>0|I>>>0>e>>>0)))return V=0,C=BA,V|0;A:do if(t[7092]&4)A=0,G=143;else{r=t[6987]|0;e:do if(r){for(n=28372;I=t[n>>2]|0,!(I>>>0<=r>>>0&&(I+(t[n+4>>2]|0)|0)>>>0>r>>>0);)if(e=t[n+8>>2]|0,e)n=e;else{G=128;break e}if(A=i-o&s,A>>>0<2147483647)if(e=Xr(A|0)|0,(e|0)==((t[n>>2]|0)+(t[n+4>>2]|0)|0)){if((e|0)!=-1){o=A,i=e,G=145;break A}}else n=e,G=136;else A=0}else G=128;while(!1);do if((G|0)==128)if(r=Xr(0)|0,(r|0)!=-1&&(A=r,L=t[7100]|0,N=L+-1|0,A=((N&A|0)==0?0:(N+A&0-L)-A|0)+f|0,L=t[7089]|0,N=A+L|0,A>>>0>M>>>0&A>>>0<2147483647)){if(I=t[7091]|0,I|0&&N>>>0<=L>>>0|N>>>0>I>>>0){A=0;break}if(e=Xr(A|0)|0,(e|0)==(r|0)){o=A,i=r,G=145;break A}else n=e,G=136}else A=0;while(!1);do if((G|0)==136){if(r=0-A|0,!(l>>>0>A>>>0&(A>>>0<2147483647&(n|0)!=-1)))if((n|0)==-1){A=0;break}else{o=A,i=n,G=145;break A}if(e=t[7101]|0,e=u-A+e&0-e,e>>>0>=2147483647){o=A,i=n,G=145;break A}if((Xr(e|0)|0)==-1){Xr(r|0)|0,A=0;break}else{o=e+A|0,i=n,G=145;break A}}while(!1);t[7092]=t[7092]|4,G=143}while(!1);if((G|0)==143&&f>>>0<2147483647&&(q=Xr(f|0)|0,N=Xr(0)|0,Y=N-q|0,nA=Y>>>0>(M+40|0)>>>0,!((q|0)==-1|nA^1|q>>>0>>0&((q|0)!=-1&(N|0)!=-1)^1))&&(o=nA?Y:A,i=q,G=145),(G|0)==145){A=(t[7089]|0)+o|0,t[7089]=A,A>>>0>(t[7090]|0)>>>0&&(t[7090]=A),u=t[6987]|0;A:do if(u){for(A=28372;;){if(e=t[A>>2]|0,r=t[A+4>>2]|0,(i|0)==(e+r|0)){G=154;break}if(n=t[A+8>>2]|0,n)A=n;else break}if((G|0)==154&&(Z=A+4|0,(t[A+12>>2]&8|0)==0)&&i>>>0>u>>>0&e>>>0<=u>>>0){t[Z>>2]=r+o,V=(t[6984]|0)+o|0,q=u+8|0,q=(q&7|0)==0?0:0-q&7,Z=u+q|0,q=V-q|0,t[6987]=Z,t[6984]=q,t[Z+4>>2]=q|1,t[u+V+4>>2]=40,t[6988]=t[7103];break}for(i>>>0<(t[6985]|0)>>>0&&(t[6985]=i),r=i+o|0,A=28372;;){if((t[A>>2]|0)==(r|0)){G=162;break}if(e=t[A+8>>2]|0,e)A=e;else break}if((G|0)==162&&(t[A+12>>2]&8|0)==0){t[A>>2]=i,p=A+4|0,t[p>>2]=(t[p>>2]|0)+o,p=i+8|0,p=i+((p&7|0)==0?0:0-p&7)|0,A=r+8|0,A=r+((A&7|0)==0?0:0-A&7)|0,f=p+M|0,l=A-p-M|0,t[p+4>>2]=M|3;e:do if((u|0)==(A|0))V=(t[6984]|0)+l|0,t[6984]=V,t[6987]=f,t[f+4>>2]=V|1;else{if((t[6986]|0)==(A|0)){V=(t[6983]|0)+l|0,t[6983]=V,t[6986]=f,t[f+4>>2]=V|1,t[f+V>>2]=V;break}if(e=t[A+4>>2]|0,(e&3|0)==1){o=e&-8,n=e>>>3;t:do if(e>>>0<256)if(e=t[A+8>>2]|0,r=t[A+12>>2]|0,(r|0)==(e|0)){t[6981]=t[6981]&~(1<>2]=r,t[r+8>>2]=e;break}else{i=t[A+24>>2]|0,e=t[A+12>>2]|0;do if((e|0)==(A|0)){if(r=A+16|0,n=r+4|0,e=t[n>>2]|0,e)r=n;else if(e=t[r>>2]|0,!e){e=0;break}for(;;)if(s=e+20|0,n=t[s>>2]|0,n)e=n,r=s;else if(s=e+16|0,n=t[s>>2]|0,n)e=n,r=s;else break;t[r>>2]=0}else V=t[A+8>>2]|0,t[V+12>>2]=e,t[e+8>>2]=V;while(!1);if(!i)break;r=t[A+28>>2]|0,n=28228+(r<<2)|0;do if((t[n>>2]|0)!=(A|0)){if(V=i+16|0,t[((t[V>>2]|0)==(A|0)?V:i+20|0)>>2]=e,!e)break t}else{if(t[n>>2]=e,e|0)break;t[6982]=t[6982]&~(1<>2]=i,r=A+16|0,n=t[r>>2]|0,n|0&&(t[e+16>>2]=n,t[n+24>>2]=e),r=t[r+4>>2]|0,!r)break;t[e+20>>2]=r,t[r+24>>2]=e}while(!1);A=A+o|0,s=o+l|0}else s=l;if(A=A+4|0,t[A>>2]=t[A>>2]&-2,t[f+4>>2]=s|1,t[f+s>>2]=s,A=s>>>3,s>>>0<256){r=27964+(A<<1<<2)|0,e=t[6981]|0,A=1<>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=f,t[A+12>>2]=f,t[f+8>>2]=A,t[f+12>>2]=r;break}A=s>>>8;do if(!A)n=0;else{if(s>>>0>16777215){n=31;break}Z=(A+1048320|0)>>>16&8,V=A<>>16&4,V=V<>>16&2,n=14-(q|Z|n)+(V<>>15)|0,n=s>>>(n+7|0)&1|n<<1}while(!1);if(A=28228+(n<<2)|0,t[f+28>>2]=n,e=f+16|0,t[e+4>>2]=0,t[e>>2]=0,e=t[6982]|0,r=1<>2]=f,t[f+24>>2]=A,t[f+12>>2]=f,t[f+8>>2]=f;break}A=t[A>>2]|0;t:do if((t[A+4>>2]&-8|0)!=(s|0)){for(n=s<<((n|0)==31?0:25-(n>>>1)|0);r=A+16+(n>>>31<<2)|0,e=t[r>>2]|0,!!e;)if((t[e+4>>2]&-8|0)==(s|0)){A=e;break t}else n=n<<1,A=e;t[r>>2]=f,t[f+24>>2]=A,t[f+12>>2]=f,t[f+8>>2]=f;break e}while(!1);Z=A+8|0,V=t[Z>>2]|0,t[V+12>>2]=f,t[Z>>2]=f,t[f+8>>2]=V,t[f+12>>2]=A,t[f+24>>2]=0}while(!1);return V=p+8|0,C=BA,V|0}for(A=28372;e=t[A>>2]|0,!(e>>>0<=u>>>0&&(V=e+(t[A+4>>2]|0)|0,V>>>0>u>>>0));)A=t[A+8>>2]|0;s=V+-47|0,e=s+8|0,e=s+((e&7|0)==0?0:0-e&7)|0,s=u+16|0,e=e>>>0>>0?u:e,A=e+8|0,r=o+-40|0,q=i+8|0,q=(q&7|0)==0?0:0-q&7,Z=i+q|0,q=r-q|0,t[6987]=Z,t[6984]=q,t[Z+4>>2]=q|1,t[i+r+4>>2]=40,t[6988]=t[7103],r=e+4|0,t[r>>2]=27,t[A>>2]=t[7093],t[A+4>>2]=t[7094],t[A+8>>2]=t[7095],t[A+12>>2]=t[7096],t[7093]=i,t[7094]=o,t[7096]=0,t[7095]=A,A=e+24|0;do Z=A,A=A+4|0,t[A>>2]=7;while((Z+8|0)>>>0>>0);if((e|0)!=(u|0)){if(i=e-u|0,t[r>>2]=t[r>>2]&-2,t[u+4>>2]=i|1,t[e>>2]=i,A=i>>>3,i>>>0<256){r=27964+(A<<1<<2)|0,e=t[6981]|0,A=1<>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=u,t[A+12>>2]=u,t[u+8>>2]=A,t[u+12>>2]=r;break}if(A=i>>>8,A?i>>>0>16777215?n=31:(Z=(A+1048320|0)>>>16&8,V=A<>>16&4,V=V<>>16&2,n=14-(q|Z|n)+(V<>>15)|0,n=i>>>(n+7|0)&1|n<<1):n=0,r=28228+(n<<2)|0,t[u+28>>2]=n,t[u+20>>2]=0,t[s>>2]=0,A=t[6982]|0,e=1<>2]=u,t[u+24>>2]=r,t[u+12>>2]=u,t[u+8>>2]=u;break}A=t[r>>2]|0;e:do if((t[A+4>>2]&-8|0)!=(i|0)){for(n=i<<((n|0)==31?0:25-(n>>>1)|0);r=A+16+(n>>>31<<2)|0,e=t[r>>2]|0,!!e;)if((t[e+4>>2]&-8|0)==(i|0)){A=e;break e}else n=n<<1,A=e;t[r>>2]=u,t[u+24>>2]=A,t[u+12>>2]=u,t[u+8>>2]=u;break A}while(!1);Z=A+8|0,V=t[Z>>2]|0,t[V+12>>2]=u,t[Z>>2]=u,t[u+8>>2]=V,t[u+12>>2]=A,t[u+24>>2]=0}}else V=t[6985]|0,(V|0)==0|i>>>0>>0&&(t[6985]=i),t[7093]=i,t[7094]=o,t[7096]=0,t[6990]=t[7099],t[6989]=-1,t[6994]=27964,t[6993]=27964,t[6996]=27972,t[6995]=27972,t[6998]=27980,t[6997]=27980,t[7e3]=27988,t[6999]=27988,t[7002]=27996,t[7001]=27996,t[7004]=28004,t[7003]=28004,t[7006]=28012,t[7005]=28012,t[7008]=28020,t[7007]=28020,t[7010]=28028,t[7009]=28028,t[7012]=28036,t[7011]=28036,t[7014]=28044,t[7013]=28044,t[7016]=28052,t[7015]=28052,t[7018]=28060,t[7017]=28060,t[7020]=28068,t[7019]=28068,t[7022]=28076,t[7021]=28076,t[7024]=28084,t[7023]=28084,t[7026]=28092,t[7025]=28092,t[7028]=28100,t[7027]=28100,t[7030]=28108,t[7029]=28108,t[7032]=28116,t[7031]=28116,t[7034]=28124,t[7033]=28124,t[7036]=28132,t[7035]=28132,t[7038]=28140,t[7037]=28140,t[7040]=28148,t[7039]=28148,t[7042]=28156,t[7041]=28156,t[7044]=28164,t[7043]=28164,t[7046]=28172,t[7045]=28172,t[7048]=28180,t[7047]=28180,t[7050]=28188,t[7049]=28188,t[7052]=28196,t[7051]=28196,t[7054]=28204,t[7053]=28204,t[7056]=28212,t[7055]=28212,V=o+-40|0,q=i+8|0,q=(q&7|0)==0?0:0-q&7,Z=i+q|0,q=V-q|0,t[6987]=Z,t[6984]=q,t[Z+4>>2]=q|1,t[i+V+4>>2]=40,t[6988]=t[7103];while(!1);if(A=t[6984]|0,A>>>0>M>>>0)return q=A-M|0,t[6984]=q,V=t[6987]|0,Z=V+M|0,t[6987]=Z,t[Z+4>>2]=q|1,t[V+4>>2]=M|3,V=V+8|0,C=BA,V|0}return V=va()|0,t[V>>2]=12,V=0,C=BA,V|0}function $A(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=0;if(e){r=e+-8|0,s=t[6985]|0,e=t[e+-4>>2]|0,A=e&-8,u=r+A|0;do if(e&1)l=r,o=r;else{if(n=t[r>>2]|0,!(e&3)||(o=r+(0-n)|0,i=n+A|0,o>>>0>>0))return;if((t[6986]|0)==(o|0)){if(e=u+4|0,A=t[e>>2]|0,(A&3|0)!=3){l=o,A=i;break}t[6983]=i,t[e>>2]=A&-2,t[o+4>>2]=i|1,t[o+i>>2]=i;return}if(r=n>>>3,n>>>0<256)if(e=t[o+8>>2]|0,A=t[o+12>>2]|0,(A|0)==(e|0)){t[6981]=t[6981]&~(1<>2]=A,t[A+8>>2]=e,l=o,A=i;break}s=t[o+24>>2]|0,e=t[o+12>>2]|0;do if((e|0)==(o|0)){if(A=o+16|0,r=A+4|0,e=t[r>>2]|0,e)A=r;else if(e=t[A>>2]|0,!e){e=0;break}for(;;)if(n=e+20|0,r=t[n>>2]|0,r)e=r,A=n;else if(n=e+16|0,r=t[n>>2]|0,r)e=r,A=n;else break;t[A>>2]=0}else l=t[o+8>>2]|0,t[l+12>>2]=e,t[e+8>>2]=l;while(!1);if(s){if(A=t[o+28>>2]|0,r=28228+(A<<2)|0,(t[r>>2]|0)==(o|0)){if(t[r>>2]=e,!e){t[6982]=t[6982]&~(1<>2]|0)==(o|0)?l:s+20|0)>>2]=e,!e){l=o,A=i;break}t[e+24>>2]=s,A=o+16|0,r=t[A>>2]|0,r|0&&(t[e+16>>2]=r,t[r+24>>2]=e),A=t[A+4>>2]|0,A?(t[e+20>>2]=A,t[A+24>>2]=e,l=o,A=i):(l=o,A=i)}else l=o,A=i}while(!1);if(!(o>>>0>=u>>>0)&&(e=u+4|0,n=t[e>>2]|0,!!(n&1))){if(n&2)t[e>>2]=n&-2,t[l+4>>2]=A|1,t[o+A>>2]=A,s=A;else{if((t[6987]|0)==(u|0)){if(u=(t[6984]|0)+A|0,t[6984]=u,t[6987]=l,t[l+4>>2]=u|1,(l|0)!=(t[6986]|0))return;t[6986]=0,t[6983]=0;return}if((t[6986]|0)==(u|0)){u=(t[6983]|0)+A|0,t[6983]=u,t[6986]=o,t[l+4>>2]=u|1,t[o+u>>2]=u;return}s=(n&-8)+A|0,r=n>>>3;do if(n>>>0<256)if(A=t[u+8>>2]|0,e=t[u+12>>2]|0,(e|0)==(A|0)){t[6981]=t[6981]&~(1<>2]=e,t[e+8>>2]=A;break}else{i=t[u+24>>2]|0,e=t[u+12>>2]|0;do if((e|0)==(u|0)){if(A=u+16|0,r=A+4|0,e=t[r>>2]|0,e)A=r;else if(e=t[A>>2]|0,!e){r=0;break}for(;;)if(n=e+20|0,r=t[n>>2]|0,r)e=r,A=n;else if(n=e+16|0,r=t[n>>2]|0,r)e=r,A=n;else break;t[A>>2]=0,r=e}else r=t[u+8>>2]|0,t[r+12>>2]=e,t[e+8>>2]=r,r=e;while(!1);if(i|0){if(e=t[u+28>>2]|0,A=28228+(e<<2)|0,(t[A>>2]|0)==(u|0)){if(t[A>>2]=r,!r){t[6982]=t[6982]&~(1<>2]|0)==(u|0)?n:i+20|0)>>2]=r,!r)break;t[r+24>>2]=i,e=u+16|0,A=t[e>>2]|0,A|0&&(t[r+16>>2]=A,t[A+24>>2]=r),e=t[e+4>>2]|0,e|0&&(t[r+20>>2]=e,t[e+24>>2]=r)}}while(!1);if(t[l+4>>2]=s|1,t[o+s>>2]=s,(l|0)==(t[6986]|0)){t[6983]=s;return}}if(e=s>>>3,s>>>0<256){r=27964+(e<<1<<2)|0,A=t[6981]|0,e=1<>2]|0):(t[6981]=A|e,e=r,A=r+8|0),t[A>>2]=l,t[e+12>>2]=l,t[l+8>>2]=e,t[l+12>>2]=r;return}e=s>>>8,e?s>>>0>16777215?n=31:(o=(e+1048320|0)>>>16&8,u=e<>>16&4,u=u<>>16&2,n=14-(i|o|n)+(u<>>15)|0,n=s>>>(n+7|0)&1|n<<1):n=0,e=28228+(n<<2)|0,t[l+28>>2]=n,t[l+20>>2]=0,t[l+16>>2]=0,A=t[6982]|0,r=1<>2]=l,t[l+24>>2]=e,t[l+12>>2]=l,t[l+8>>2]=l;else{e=t[e>>2]|0;e:do if((t[e+4>>2]&-8|0)!=(s|0)){for(n=s<<((n|0)==31?0:25-(n>>>1)|0);r=e+16+(n>>>31<<2)|0,A=t[r>>2]|0,!!A;)if((t[A+4>>2]&-8|0)==(s|0)){e=A;break e}else n=n<<1,e=A;t[r>>2]=l,t[l+24>>2]=e,t[l+12>>2]=l,t[l+8>>2]=l;break A}while(!1);o=e+8|0,u=t[o>>2]|0,t[u+12>>2]=l,t[o>>2]=l,t[l+8>>2]=u,t[l+12>>2]=e,t[l+24>>2]=0}while(!1);if(u=(t[6989]|0)+-1|0,t[6989]=u,!(u|0)){for(e=28380;e=t[e>>2]|0,e;)e=e+8|0;t[6989]=-1}}}}function Wt(e,A){e=e|0,A=A|0;var r=0;return e?(r=ht(A,e)|0,(A|e)>>>0>65535&&(r=((r>>>0)/(e>>>0)|0|0)==(A|0)?r:-1)):r=0,e=Br(r)|0,!e||!(t[e+-4>>2]&3)||Jr(e|0,0,r|0)|0,e|0}function ZA(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,r=e+r>>>0,JA(A+n+(r>>>0>>0|0)>>>0|0),r|0|0}function gt(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,n=A-n-(r>>>0>e>>>0|0)>>>0,JA(n|0),e-r>>>0|0|0}function pi(e){return e=e|0,(e?31-(pt(e^e-1)|0)|0:32)|0}function ms(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,u=0,f=0,p=0,M=0,I=0,L=0,N=0;if(p=e,u=A,f=u,o=r,I=n,l=I,!f)return i=(s|0)!=0,l?i?(t[s>>2]=e|0,t[s+4>>2]=A&0,I=0,s=0,JA(I|0),s|0):(I=0,s=0,JA(I|0),s|0):(i&&(t[s>>2]=(p>>>0)%(o>>>0),t[s+4>>2]=0),I=0,s=(p>>>0)/(o>>>0)>>>0,JA(I|0),s|0);i=(l|0)==0;do if(o){if(!i){if(i=(pt(l|0)|0)-(pt(f|0)|0)|0,i>>>0<=31){M=i+1|0,l=31-i|0,A=i-31>>31,o=M,e=p>>>(M>>>0)&A|f<>>(M>>>0)&A,i=0,l=p<>2]=e|0,t[s+4>>2]=u|A&0,I=0,s=0,JA(I|0),s|0):(I=0,s=0,JA(I|0),s|0)}if(i=o-1|0,i&o|0){l=(pt(o|0)|0)+33-(pt(f|0)|0)|0,N=64-l|0,M=32-l|0,u=M>>31,L=l-32|0,A=L>>31,o=l,e=M-1>>31&f>>>(L>>>0)|(f<>>(l>>>0))&A,A=A&f>>>(l>>>0),i=p<>>(L>>>0))&u|p<>31;break}return s|0&&(t[s>>2]=i&p,t[s+4>>2]=0),(o|0)==1?(L=u|A&0,N=e|0|0,JA(L|0),N|0):(N=pi(o|0)|0,L=f>>>(N>>>0)|0,N=f<<32-N|p>>>(N>>>0)|0,JA(L|0),N|0)}else{if(i)return s|0&&(t[s>>2]=(f>>>0)%(o>>>0),t[s+4>>2]=0),L=0,N=(f>>>0)/(o>>>0)>>>0,JA(L|0),N|0;if(!p)return s|0&&(t[s>>2]=0,t[s+4>>2]=(f>>>0)%(l>>>0)),L=0,N=(f>>>0)/(l>>>0)>>>0,JA(L|0),N|0;if(i=l-1|0,!(i&l))return s|0&&(t[s>>2]=e|0,t[s+4>>2]=i&f|A&0),L=0,N=f>>>((pi(l|0)|0)>>>0),JA(L|0),N|0;if(i=(pt(l|0)|0)-(pt(f|0)|0)|0,i>>>0<=30){A=i+1|0,l=31-i|0,o=A,e=f<>>(A>>>0),A=f>>>(A>>>0),i=0,l=p<>2]=e|0,t[s+4>>2]=u|A&0,L=0,N=0,JA(L|0),N|0):(L=0,N=0,JA(L|0),N|0)}while(!1);if(!o)f=l,u=0,l=0;else{M=r|0|0,p=I|n&0,f=ZA(M|0,p|0,-1,-1)|0,r=S()|0,u=l,l=0;do n=u,u=i>>>31|u<<1,i=l|i<<1,n=e<<1|n>>>31|0,I=e>>>31|A<<1|0,gt(f|0,r|0,n|0,I|0)|0,N=S()|0,L=N>>31|((N|0)<0?-1:0)<<1,l=L&1,e=gt(n|0,I|0,L&M|0,(((N|0)<0?-1:0)>>31|((N|0)<0?-1:0)<<1)&p|0)|0,A=S()|0,o=o-1|0;while((o|0)!=0);f=u,u=0}return o=0,s|0&&(t[s>>2]=e,t[s+4>>2]=A),L=(i|0)>>>31|(f|o)<<1|(o<<1|i>>>31)&0|u,N=(i<<1|0)&-2|l,JA(L|0),N|0}function qr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0;return f=A>>31|((A|0)<0?-1:0)<<1,u=((A|0)<0?-1:0)>>31|((A|0)<0?-1:0)<<1,i=n>>31|((n|0)<0?-1:0)<<1,s=((n|0)<0?-1:0)>>31|((n|0)<0?-1:0)<<1,l=gt(f^e|0,u^A|0,f|0,u|0)|0,o=S()|0,e=i^f,A=s^u,gt((ms(l,o,gt(i^r|0,s^n|0,i|0,s|0)|0,S()|0,0)|0)^e|0,(S()|0)^A|0,e|0,A|0)|0}function ba(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return i=e&65535,s=A&65535,r=ht(s,i)|0,n=e>>>16,e=(r>>>16)+(ht(s,n)|0)|0,s=A>>>16,A=ht(s,i)|0,JA((e>>>16)+(ht(s,n)|0)+(((e&65535)+A|0)>>>16)|0),e+A<<16|r&65535|0|0}function yt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0;return s=e,i=r,r=ba(s,i)|0,e=S()|0,JA((ht(A,i)|0)+(ht(n,s)|0)+e|e&0|0),r|0|0|0}function Nn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,u=0,f=0;return s=C,C=C+16|0,l=s|0,o=A>>31|((A|0)<0?-1:0)<<1,i=((A|0)<0?-1:0)>>31|((A|0)<0?-1:0)<<1,f=n>>31|((n|0)<0?-1:0)<<1,u=((n|0)<0?-1:0)>>31|((n|0)<0?-1:0)<<1,e=gt(o^e|0,i^A|0,o|0,i|0)|0,A=S()|0,ms(e,A,gt(f^r|0,u^n|0,f|0,u|0)|0,S()|0,l)|0,n=gt(t[l>>2]^o|0,t[l+4>>2]^i|0,o|0,i|0)|0,r=S()|0,C=s,JA(r|0),n|0}function Fn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0;return i=C,C=C+16|0,s=i|0,ms(e,A,r,n,s)|0,C=i,JA(t[s+4>>2]|0),t[s>>2]|0|0}function gi(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(JA(A>>r|0),e>>>r|(A&(1<>r-32|0)}function yA(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(JA(A>>>r|0),e>>>r|(A&(1<>>r-32|0)}function CA(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(JA(A<>>32-r|0),e<=0?+$e(e+.5):+Et(e-.5)}function Pn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if((r|0)>=8192)return qe(e|0,A|0,r|0)|0,e|0;if(i=e|0,s=e+r|0,(e&3)==(A&3)){for(;e&3;){if(!r)return i|0;gA[e>>0]=gA[A>>0]|0,e=e+1|0,A=A+1|0,r=r-1|0}for(r=s&-4|0,n=r-64|0;(e|0)<=(n|0);)t[e>>2]=t[A>>2],t[e+4>>2]=t[A+4>>2],t[e+8>>2]=t[A+8>>2],t[e+12>>2]=t[A+12>>2],t[e+16>>2]=t[A+16>>2],t[e+20>>2]=t[A+20>>2],t[e+24>>2]=t[A+24>>2],t[e+28>>2]=t[A+28>>2],t[e+32>>2]=t[A+32>>2],t[e+36>>2]=t[A+36>>2],t[e+40>>2]=t[A+40>>2],t[e+44>>2]=t[A+44>>2],t[e+48>>2]=t[A+48>>2],t[e+52>>2]=t[A+52>>2],t[e+56>>2]=t[A+56>>2],t[e+60>>2]=t[A+60>>2],e=e+64|0,A=A+64|0;for(;(e|0)<(r|0);)t[e>>2]=t[A>>2],e=e+4|0,A=A+4|0}else for(r=s-4|0;(e|0)<(r|0);)gA[e>>0]=gA[A>>0]|0,gA[e+1>>0]=gA[A+1>>0]|0,gA[e+2>>0]=gA[A+2>>0]|0,gA[e+3>>0]=gA[A+3>>0]|0,e=e+4|0,A=A+4|0;for(;(e|0)<(s|0);)gA[e>>0]=gA[A>>0]|0,e=e+1|0,A=A+1|0;return i|0}function Jr(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;if(i=e+r|0,A=A&255,(r|0)>=67){for(;e&3;)gA[e>>0]=A,e=e+1|0;for(n=i&-4|0,o=A|A<<8|A<<16|A<<24,s=n-64|0;(e|0)<=(s|0);)t[e>>2]=o,t[e+4>>2]=o,t[e+8>>2]=o,t[e+12>>2]=o,t[e+16>>2]=o,t[e+20>>2]=o,t[e+24>>2]=o,t[e+28>>2]=o,t[e+32>>2]=o,t[e+36>>2]=o,t[e+40>>2]=o,t[e+44>>2]=o,t[e+48>>2]=o,t[e+52>>2]=o,t[e+56>>2]=o,t[e+60>>2]=o,e=e+64|0;for(;(e|0)<(n|0);)t[e>>2]=o,e=e+4|0}for(;(e|0)<(i|0);)gA[e>>0]=A,e=e+1|0;return i-r|0}function xi(e){return e=+e,e>=0?+$e(e+.5):+Et(e-.5)}function Xr(e){e=e|0;var A=0,r=0,n=0;return n=Gt()|0,r=t[_e>>2]|0,A=r+e|0,(e|0)>0&(A|0)<(r|0)|(A|0)<0?(Lr(A|0)|0,Oe(12),-1):(A|0)>(n|0)&&!(Kt(A|0)|0)?(Oe(12),-1):(t[_e>>2]=A,r|0)}return{___divdi3:qr,___muldi3:yt,___remdi3:Nn,___uremdi3:Fn,_areNeighborCells:rs,_bitshift64Ashr:gi,_bitshift64Lshr:yA,_bitshift64Shl:CA,_calloc:Wt,_cellAreaKm2:Gl,_cellAreaM2:Ul,_cellAreaRads2:cs,_cellToBoundary:In,_cellToCenterChild:qs,_cellToChildPos:Il,_cellToChildren:s0,_cellToChildrenSize:Mr,_cellToLatLng:dn,_cellToLocalIj:ql,_cellToParent:Ft,_cellToVertex:ar,_cellToVertexes:pa,_cellsToDirectedEdge:b0,_cellsToLinkedMultiPolygon:vt,_childPosToCell:Ll,_compactCells:Sl,_constructCell:we,_destroyLinkedMultiPolygon:ti,_directedEdgeToBoundary:fn,_directedEdgeToCells:jn,_edgeLengthKm:Wl,_edgeLengthM:Yl,_edgeLengthRads:Vl,_emscripten_replace_memory:or,_free:$A,_getBaseCellNumber:ne,_getDirectedEdgeDestination:k0,_getDirectedEdgeOrigin:_n,_getHexagonAreaAvgKm2:Ai,_getHexagonAreaAvgM2:Ol,_getHexagonEdgeLengthAvgKm:zl,_getHexagonEdgeLengthAvgM:Hl,_getIcosahedronFaces:Js,_getIndexDigit:Ce,_getNumCells:S0,_getPentagons:ls,_getRes0Cells:$n,_getResolution:DA,_greatCircleDistanceKm:o0,_greatCircleDistanceM:Fl,_greatCircleDistanceRads:Nl,_gridDisk:v,_gridDiskDistances:j,_gridDistance:Xl,_gridPathCells:ea,_gridPathCellsSize:Aa,_gridRing:cA,_gridRingUnsafe:jA,_i64Add:ZA,_i64Subtract:gt,_isPentagon:Qe,_isResClassIII:Dl,_isValidCell:Ue,_isValidDirectedEdge:r0,_isValidIndex:Lt,_isValidVertex:ci,_latLngToCell:is,_llvm_ctlz_i64:ps,_llvm_maxnum_f64:yi,_llvm_minnum_f64:D0,_llvm_round_f64:_0,_localIjToCell:Jl,_malloc:Br,_maxFaceCount:Tl,_maxGridDiskSize:h,_maxPolygonToCellsSize:he,_maxPolygonToCellsSizeExperimental:na,_memcpy:Pn,_memset:Jr,_originToDirectedEdges:Tn,_pentagonCount:Rl,_polygonToCells:jt,_polygonToCellsExperimental:ra,_readInt64AsDoubleFromPointer:fa,_res0CellCount:Zn,_round:xi,_sbrk:Xr,_sizeOfCellBoundary:oa,_sizeOfCoordIJ:ca,_sizeOfGeoLoop:la,_sizeOfGeoPolygon:aa,_sizeOfH3Index:sa,_sizeOfLatLng:ia,_sizeOfLinkedGeoPolygon:ua,_uncompactCells:Ml,_uncompactCellsSize:Bl,_vertexToLatLng:ga,establishStackSpace:kr,stackAlloc:_t,stackRestore:Nr,stackSave:br}})(on,Ur,bA);c.___divdi3=pA.___divdi3,c.___muldi3=pA.___muldi3,c.___remdi3=pA.___remdi3,c.___uremdi3=pA.___uremdi3,c._areNeighborCells=pA._areNeighborCells,c._bitshift64Ashr=pA._bitshift64Ashr,c._bitshift64Lshr=pA._bitshift64Lshr,c._bitshift64Shl=pA._bitshift64Shl,c._calloc=pA._calloc,c._cellAreaKm2=pA._cellAreaKm2,c._cellAreaM2=pA._cellAreaM2,c._cellAreaRads2=pA._cellAreaRads2,c._cellToBoundary=pA._cellToBoundary,c._cellToCenterChild=pA._cellToCenterChild,c._cellToChildPos=pA._cellToChildPos,c._cellToChildren=pA._cellToChildren,c._cellToChildrenSize=pA._cellToChildrenSize,c._cellToLatLng=pA._cellToLatLng,c._cellToLocalIj=pA._cellToLocalIj,c._cellToParent=pA._cellToParent,c._cellToVertex=pA._cellToVertex,c._cellToVertexes=pA._cellToVertexes,c._cellsToDirectedEdge=pA._cellsToDirectedEdge,c._cellsToLinkedMultiPolygon=pA._cellsToLinkedMultiPolygon,c._childPosToCell=pA._childPosToCell,c._compactCells=pA._compactCells,c._constructCell=pA._constructCell,c._destroyLinkedMultiPolygon=pA._destroyLinkedMultiPolygon,c._directedEdgeToBoundary=pA._directedEdgeToBoundary,c._directedEdgeToCells=pA._directedEdgeToCells,c._edgeLengthKm=pA._edgeLengthKm,c._edgeLengthM=pA._edgeLengthM,c._edgeLengthRads=pA._edgeLengthRads;var vr=c._emscripten_replace_memory=pA._emscripten_replace_memory;c._free=pA._free,c._getBaseCellNumber=pA._getBaseCellNumber,c._getDirectedEdgeDestination=pA._getDirectedEdgeDestination,c._getDirectedEdgeOrigin=pA._getDirectedEdgeOrigin,c._getHexagonAreaAvgKm2=pA._getHexagonAreaAvgKm2,c._getHexagonAreaAvgM2=pA._getHexagonAreaAvgM2,c._getHexagonEdgeLengthAvgKm=pA._getHexagonEdgeLengthAvgKm,c._getHexagonEdgeLengthAvgM=pA._getHexagonEdgeLengthAvgM,c._getIcosahedronFaces=pA._getIcosahedronFaces,c._getIndexDigit=pA._getIndexDigit,c._getNumCells=pA._getNumCells,c._getPentagons=pA._getPentagons,c._getRes0Cells=pA._getRes0Cells,c._getResolution=pA._getResolution,c._greatCircleDistanceKm=pA._greatCircleDistanceKm,c._greatCircleDistanceM=pA._greatCircleDistanceM,c._greatCircleDistanceRads=pA._greatCircleDistanceRads,c._gridDisk=pA._gridDisk,c._gridDiskDistances=pA._gridDiskDistances,c._gridDistance=pA._gridDistance,c._gridPathCells=pA._gridPathCells,c._gridPathCellsSize=pA._gridPathCellsSize,c._gridRing=pA._gridRing,c._gridRingUnsafe=pA._gridRingUnsafe,c._i64Add=pA._i64Add,c._i64Subtract=pA._i64Subtract,c._isPentagon=pA._isPentagon,c._isResClassIII=pA._isResClassIII,c._isValidCell=pA._isValidCell,c._isValidDirectedEdge=pA._isValidDirectedEdge,c._isValidIndex=pA._isValidIndex,c._isValidVertex=pA._isValidVertex,c._latLngToCell=pA._latLngToCell,c._llvm_ctlz_i64=pA._llvm_ctlz_i64,c._llvm_maxnum_f64=pA._llvm_maxnum_f64,c._llvm_minnum_f64=pA._llvm_minnum_f64,c._llvm_round_f64=pA._llvm_round_f64,c._localIjToCell=pA._localIjToCell,c._malloc=pA._malloc,c._maxFaceCount=pA._maxFaceCount,c._maxGridDiskSize=pA._maxGridDiskSize,c._maxPolygonToCellsSize=pA._maxPolygonToCellsSize,c._maxPolygonToCellsSizeExperimental=pA._maxPolygonToCellsSizeExperimental,c._memcpy=pA._memcpy,c._memset=pA._memset,c._originToDirectedEdges=pA._originToDirectedEdges,c._pentagonCount=pA._pentagonCount,c._polygonToCells=pA._polygonToCells,c._polygonToCellsExperimental=pA._polygonToCellsExperimental,c._readInt64AsDoubleFromPointer=pA._readInt64AsDoubleFromPointer,c._res0CellCount=pA._res0CellCount,c._round=pA._round,c._sbrk=pA._sbrk,c._sizeOfCellBoundary=pA._sizeOfCellBoundary,c._sizeOfCoordIJ=pA._sizeOfCoordIJ,c._sizeOfGeoLoop=pA._sizeOfGeoLoop,c._sizeOfGeoPolygon=pA._sizeOfGeoPolygon,c._sizeOfH3Index=pA._sizeOfH3Index,c._sizeOfLatLng=pA._sizeOfLatLng,c._sizeOfLinkedGeoPolygon=pA._sizeOfLinkedGeoPolygon,c._uncompactCells=pA._uncompactCells,c._uncompactCellsSize=pA._uncompactCellsSize,c._vertexToLatLng=pA._vertexToLatLng,c.establishStackSpace=pA.establishStackSpace;var rr=c.stackAlloc=pA.stackAlloc,Ne=c.stackRestore=pA.stackRestore,mt=c.stackSave=pA.stackSave;if(c.asm=pA,c.cwrap=fA,c.setValue=U,c.getValue=W,Ke){ye(Ke)||(Ke=b(Ke));{nt();var nr=function(tA){tA.byteLength&&(tA=new Uint8Array(tA)),kA.set(tA,z),c.memoryInitializerRequest&&delete c.memoryInitializerRequest.response,bt()},sr=function(){D(Ke,nr,function(){throw"could not load memory initializer "+Ke})},He=dr(Ke);if(He)nr(He.buffer);else if(c.memoryInitializerRequest){var Bt=function(){var tA=c.memoryInitializerRequest,mA=tA.response;if(tA.status!==200&&tA.status!==0){var RA=dr(c.memoryInitializerRequestURL);if(RA)mA=RA.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+tA.status+", retrying "+Ke),sr();return}}nr(mA)};c.memoryInitializerRequest.response?setTimeout(Bt,0):c.memoryInitializerRequest.addEventListener("load",Bt)}else sr()}}var Ct;At=function tA(){Ct||mr(),Ct||(At=tA)};function mr(tA){if(tt>0||(Ie(),tt>0))return;function mA(){Ct||(Ct=!0,!$&&(ue(),pe(),c.onRuntimeInitialized&&c.onRuntimeInitialized(),ke()))}c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),mA()},1)):mA()}c.run=mr;function Ht(tA){throw c.onAbort&&c.onAbort(tA),tA+="",P(tA),B(tA),$=!0,"abort("+tA+"). Build with -s ASSERTIONS=1 for more info."}if(c.abort=Ht,c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);c.preInit.length>0;)c.preInit.pop()();return mr(),a})(typeof Ot=="object"?Ot:{}),se="number",te=se,Un=se,le=se,ae=se,xt=se,PA=se,t2=[["sizeOfH3Index",se],["sizeOfLatLng",se],["sizeOfCellBoundary",se],["sizeOfGeoLoop",se],["sizeOfGeoPolygon",se],["sizeOfLinkedGeoPolygon",se],["sizeOfCoordIJ",se],["readInt64AsDoubleFromPointer",se],["isValidCell",Un,[le,ae]],["isValidIndex",Un,[le,ae]],["latLngToCell",te,[se,se,xt,PA]],["cellToLatLng",te,[le,ae,PA]],["cellToBoundary",te,[le,ae,PA]],["maxGridDiskSize",te,[se,PA]],["gridDisk",te,[le,ae,se,PA]],["gridDiskDistances",te,[le,ae,se,PA,PA]],["gridRing",te,[le,ae,se,PA]],["gridRingUnsafe",te,[le,ae,se,PA]],["maxPolygonToCellsSize",te,[PA,xt,se,PA]],["polygonToCells",te,[PA,xt,se,PA]],["maxPolygonToCellsSizeExperimental",te,[PA,xt,se,PA]],["polygonToCellsExperimental",te,[PA,xt,se,se,se,PA]],["cellsToLinkedMultiPolygon",te,[PA,se,PA]],["destroyLinkedMultiPolygon",null,[PA]],["compactCells",te,[PA,PA,se,se]],["uncompactCells",te,[PA,se,se,PA,se,xt]],["uncompactCellsSize",te,[PA,se,se,xt,PA]],["isPentagon",Un,[le,ae]],["isResClassIII",Un,[le,ae]],["getBaseCellNumber",se,[le,ae]],["getResolution",se,[le,ae]],["getIndexDigit",se,[le,ae,se]],["constructCell",te,[se,se,PA,PA]],["maxFaceCount",te,[le,ae,PA]],["getIcosahedronFaces",te,[le,ae,PA]],["cellToParent",te,[le,ae,xt,PA]],["cellToChildren",te,[le,ae,xt,PA]],["cellToCenterChild",te,[le,ae,xt,PA]],["cellToChildrenSize",te,[le,ae,xt,PA]],["cellToChildPos",te,[le,ae,xt,PA]],["childPosToCell",te,[se,se,le,ae,xt,PA]],["areNeighborCells",te,[le,ae,le,ae,PA]],["cellsToDirectedEdge",te,[le,ae,le,ae,PA]],["getDirectedEdgeOrigin",te,[le,ae,PA]],["getDirectedEdgeDestination",te,[le,ae,PA]],["isValidDirectedEdge",Un,[le,ae]],["directedEdgeToCells",te,[le,ae,PA]],["originToDirectedEdges",te,[le,ae,PA]],["directedEdgeToBoundary",te,[le,ae,PA]],["gridDistance",te,[le,ae,le,ae,PA]],["gridPathCells",te,[le,ae,le,ae,PA]],["gridPathCellsSize",te,[le,ae,le,ae,PA]],["cellToLocalIj",te,[le,ae,le,ae,se,PA]],["localIjToCell",te,[le,ae,PA,se,PA]],["getHexagonAreaAvgM2",te,[xt,PA]],["getHexagonAreaAvgKm2",te,[xt,PA]],["getHexagonEdgeLengthAvgM",te,[xt,PA]],["getHexagonEdgeLengthAvgKm",te,[xt,PA]],["greatCircleDistanceM",se,[PA,PA]],["greatCircleDistanceKm",se,[PA,PA]],["greatCircleDistanceRads",se,[PA,PA]],["cellAreaM2",te,[le,ae,PA]],["cellAreaKm2",te,[le,ae,PA]],["cellAreaRads2",te,[le,ae,PA]],["edgeLengthM",te,[le,ae,PA]],["edgeLengthKm",te,[le,ae,PA]],["edgeLengthRads",te,[le,ae,PA]],["getNumCells",te,[xt,PA]],["getRes0Cells",te,[PA]],["res0CellCount",se],["getPentagons",te,[se,PA]],["pentagonCount",se],["cellToVertex",te,[le,ae,se,PA]],["cellToVertexes",te,[le,ae,PA]],["vertexToLatLng",te,[le,ae,PA]],["isValidVertex",Un,[le,ae]]],r2=0,n2=1,s2=2,i2=3,o2=4,l2=5,a2=6,u2=7,c2=8,f2=9,h2=10,d2=11,m2=12,p2=13,g2=14,y2=15,x2=16,w2=17,v2=18,b2=19,lt={};lt[r2]="Success";lt[n2]="The operation failed but a more specific error is not available";lt[s2]="Argument was outside of acceptable range";lt[i2]="Latitude or longitude arguments were outside of acceptable range";lt[o2]="Resolution argument was outside of acceptable range";lt[l2]="Cell argument was not valid";lt[a2]="Directed edge argument was not valid";lt[u2]="Undirected edge argument was not valid";lt[c2]="Vertex argument was not valid";lt[f2]="Pentagon distortion was encountered";lt[h2]="Duplicate input";lt[d2]="Cell arguments were not neighbors";lt[m2]="Cell arguments had incompatible resolutions";lt[p2]="Memory allocation failed";lt[g2]="Bounds of provided memory were insufficient";lt[y2]="Mode or flags argument was not valid";lt[x2]="Index argument was not valid";lt[w2]="Base cell number was outside of acceptable range";lt[v2]="Child indexing digits invalid";lt[b2]="Child indexing digits refer to a deleted subsequence";var k2=1e3,C2=1001,yl=1002,ts={};ts[k2]="Unknown unit";ts[C2]="Array length out of bounds";ts[yl]="Got unexpected null value for H3 index";var E2="Unknown error";function xl(a,c,g){var x=g&&"value"in g,y=new Error((a[c]||E2)+" (code: "+c+(x?", value: "+g.value:"")+")");return y.code=c,y}function S2(a,c){var g=arguments.length===2?{value:c}:{};return xl(lt,a,g)}function M2(a,c){var g=arguments.length===2?{value:c}:{};return xl(ts,a,g)}function wl(a){if(a!==0)throw S2(a)}var jr={};t2.forEach(function(c){jr[c[0]]=Ot.cwrap.apply(Ot,c)});var Wn=16,B2=4,$0=8,Fs=jr.sizeOfH3Index(),D2=jr.sizeOfLatLng(),_2=jr.sizeOfCellBoundary();jr.sizeOfGeoPolygon();jr.sizeOfGeoLoop();jr.sizeOfLinkedGeoPolygon();jr.sizeOfCoordIJ();function j2(a){if(!a)throw M2(yl);return a}var T2=/[^0-9a-fA-F]/;function R2(a){if(Array.isArray(a)&&a.length===2&&Number.isInteger(a[0])&&Number.isInteger(a[1]))return a;if(typeof a!="string"||T2.test(a))return[0,0];var c=parseInt(a.substring(0,a.length-8),Wn),g=parseInt(a.substring(a.length-8),Wn);return[g,c]}function Zi(a){if(a>=0)return a.toString(Wn);a=a&2147483647;var c=vl(8,a.toString(Wn)),g=(parseInt(c[0],Wn)+8).toString(Wn);return c=g+c.substring(1),c}function I2(a,c){return Zi(c)+vl(8,Zi(a))}function vl(a,c){for(var g=a-c.length,x="",y=0;y.85?.9+(a-.85)/.15*.1:.1+(a-.15)/.7*.8}function Cl(a,c,g,x){const y=g-c;if(y<.001)return qi(x[12]);const b=Math.max(0,Math.min(1,(a-c)/y)),D=Y2(b),P=Math.min(23,Math.floor(D*24));return qi(x[P])}function K2(a){const c=new Map;for(const b of a){if(typeof b.lat!="number"||typeof b.lon!="number"||isNaN(b.lat)||isNaN(b.lon))continue;const D=P2(b.lat,b.lon,z2),P=c.get(D),B=b.weight;P?(P.count++,P.qualitySum+=B):c.set(D,{count:1,qualitySum:B})}const g=[];let x=1/0,y=-1/0;for(const[b,D]of c.entries()){const P=D.qualitySum/D.count;g.push({hexId:b,count:D.count,avgQuality:P}),x=Math.min(x,P),y=Math.max(y,P)}return{cells:g,minQuality:g.length>0?x:0,maxQuality:g.length>0?y:0}}function Z2(a,c,g,x){const y=[];for(const b of a){const P=bl(b.hexId).map(([E,T])=>[T,E]);P.push(P[0]);const B=Cl(b.avgQuality,c,g,x);y.push({type:"Feature",properties:{color:B,quality:b.avgQuality,count:b.count},geometry:{type:"Polygon",coordinates:[P]}})}return{type:"FeatureCollection",features:y}}async function $2(a,c,g,x,y){const b=[];let D=0;for(;D[U,z]);T.push(T[0]);const Q=Cl(B.avgQuality,c,g,x);b.push({type:"Feature",properties:{color:Q,quality:B.avgQuality,count:B.count},geometry:{type:"Polygon",coordinates:[T]}})}DrequestAnimationFrame(B))}return{type:"FeatureCollection",features:b}}function q2(a,c){const[g,x]=R.useState(a);return R.useEffect(()=>{const y=setTimeout(()=>x(a),c);return()=>clearTimeout(y)},[a,c]),g}function J2(a,c){const g=[];for(const x of a){if(x.timestampS>c)break;const y=x.msgSnr??x.pathSnr??0,b=Math.max(0,Math.min(1,(y+20)/40));g.push({lat:x.lat,lon:x.lon,successRate:1,weight:b,totalSamples:1,ageDays:0,geohash:"",repeaters:x.pathHops??[]})}return g}function X2({coveragePoints:a,visible:c,terrainEnabled:g=!1,brightness:x=H2,basemapMode:y="dark",replaySamples:b,replayTimeS:D}){const P=R.useMemo(()=>b&&b.length>0&&D!=null?J2(b,D):a,[b,D,a]),{current:B}=Gr(),[E,T]=R.useState(null);R.useEffect(()=>{const lA=()=>{var xA;const MA=(xA=B==null?void 0:B.getMap)==null?void 0:xA.call(B);MA&&!E&&T(MA)};lA();const iA=setInterval(lA,50),EA=setTimeout(()=>clearInterval(iA),5e3);return()=>{clearInterval(iA),clearTimeout(EA)}},[B,E]);const[Q,z]=R.useState(null),[U,W]=R.useState(!1),$=R.useRef({aborted:!1}),sA=R.useRef(0),AA=R.useRef(y),fA=q2(P,b?100:G2),uA=R.useMemo(()=>W2(y),[y]);R.useEffect(()=>{if(!fA||!Array.isArray(fA)||fA.length===0){queueMicrotask(()=>{z(null),sA.current=0});return}const lA=AA.current!==y;if(fA.length===sA.current&&Q&&!lA)return;sA.current=fA.length,AA.current=y,$.current.aborted=!0,$.current={aborted:!1};const iA=$.current;W(!0);const{cells:EA,minQuality:MA,maxQuality:xA}=K2(fA);if(EA.length===0){z(null),W(!1);return}if(EA.length{!iA.aborted&&bA&&z(bA)}).finally(()=>{iA.aborted||W(!1)}),()=>{iA.aborted=!0}},[fA,uA]),R.useEffect(()=>{if(!E)return;const lA=()=>{var iA,EA;try{const MA=E.getLayer(xn),xA=E.getSource(yn);if(c&&Q&&Q.features.length>0){if(xA?E.getSource(yn).setData(Q):E.addSource(yn,{type:"geojson",data:Q}),!MA){const bA=E.getLayer("topology-weak-edges-native"),IA=(EA=(iA=E.getStyle())==null?void 0:iA.layers)==null?void 0:EA.find(LA=>LA.type==="symbol"),kA=bA?"topology-weak-edges-native":IA==null?void 0:IA.id;E.addLayer({id:xn,type:"fill",source:yn,paint:{"fill-color":["get","color"],"fill-opacity":x}},kA)}}else MA&&E.removeLayer(xn),xA&&E.removeSource(yn)}catch(MA){console.warn("[WardrivingHexLayerMapLibre] Layer update error:",MA)}};E.isStyleLoaded()?lA():E.once("style.load",lA)},[E,c,Q,g]),R.useEffect(()=>{if(!(!E||!c))try{E.getLayer(xn)&&E.setPaintProperty(xn,"fill-opacity",x)}catch{}},[E,x,c]),R.useEffect(()=>()=>{if(E)try{E.getLayer(xn)&&E.removeLayer(xn),E.getSource(yn)&&E.removeSource(yn)}catch{}},[E]);const TA=(Q==null?void 0:Q.features.length)??0;return TA>0&&c?m.jsx("div",{"data-testid":"wardriving-hexlayer-maplibre-active","data-point-count":(a==null?void 0:a.length)||0,"data-cell-count":TA,"data-terrain-enabled":g,"data-is-processing":U,style:{display:"none"}}):null}const c0="replay-marker",O0="replay-marker-circle",f0="replay-trail",z0="replay-trail-line",h0="replay-trace",Cs="replay-trace-line",d0="replay-marker-icon",Ji=7,A1=2.5,e1=1.5;function t1(){const a=Ji*2*2,c=document.createElement("canvas");c.width=a,c.height=a;const g=c.getContext("2d");if(!g)return c;const x=a/2,y=a/2,b=Ji*2-2;return g.beginPath(),g.arc(x,y,b+2,0,Math.PI*2),g.fillStyle="rgba(59, 130, 246, 0.25)",g.fill(),g.beginPath(),g.arc(x,y,b,0,Math.PI*2),g.fillStyle="#3B82F6",g.fill(),g.lineWidth=2,g.strokeStyle="#1E3A5F",g.stroke(),g.beginPath(),g.arc(x,y,3,0,Math.PI*2),g.fillStyle="#FFFFFF",g.fill(),c}const r1={type:"FeatureCollection",features:[]},m0={type:"FeatureCollection",features:[]};function n1({neighbors:a}){const{current:c}=Gr(),g=Ys(),x=R.useRef(null),y=R.useRef(0),b=R.useRef(!1);return R.useEffect(()=>{const D=c==null?void 0:c.getMap();if(!D||!g)return;const P=()=>{if(!b.current){if(!D.hasImage(d0)){const B=t1(),E=B.getContext("2d");if(E){const T=E.getImageData(0,0,B.width,B.height);D.addImage(d0,T,{pixelRatio:2})}}D.getSource(c0)||D.addSource(c0,{type:"geojson",data:r1}),D.getLayer(O0)||D.addLayer({id:O0,type:"symbol",source:c0,layout:{"icon-image":d0,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}),D.getSource(f0)||D.addSource(f0,{type:"geojson",data:m0}),D.getLayer(z0)||D.addLayer({id:z0,type:"line",source:f0,paint:{"line-color":"rgba(59, 130, 246, 0.4)","line-width":A1},layout:{"line-cap":"round","line-join":"round"}},O0),D.getSource(h0)||D.addSource(h0,{type:"geojson",data:m0}),D.getLayer(Cs)||D.addLayer({id:Cs,type:"line",source:h0,paint:{"line-color":"rgba(251, 191, 36, 0.6)","line-width":e1,"line-dasharray":[4,4]},layout:{"line-cap":"round"}},z0),b.current=!0}};return D.isStyleLoaded()?P():D.once("styledata",P),()=>{if(cancelAnimationFrame(y.current),x.current=null,!D.isStyleLoaded()){b.current=!1;return}for(const B of[O0,z0,Cs])D.getLayer(B)&&D.removeLayer(B);for(const B of[c0,f0,h0])D.getSource(B)&&D.removeSource(B);D.hasImage(d0)&&D.removeImage(d0),b.current=!1}},[c,g]),R.useEffect(()=>{const D=c==null?void 0:c.getMap();if(!D||!g)return;const P=()=>{if(!b.current){y.current=requestAnimationFrame(P);return}const B=Ks.getState();if(!B.isActive)return;const{samples:E,currentTimeS:T}=B,Q=el(),z=D.getSource(c0);z&&Q&&z.setData({type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[Q.lon,Q.lat]},properties:{}}]});const U=D.getSource(f0);if(U){const $=Gu(E,T);$.length>=2?U.setData({type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:$},properties:{}}]}):U.setData(m0)}const W=D.getSource(h0);if(W&&Q){const $=Uu(),sA=($==null?void 0:$[0])??null;if(sA!==x.current||sA)if(x.current=sA,sA&&a){const AA=s1(sA,a);AA?W.setData({type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:[[Q.lon,Q.lat],[AA.lon,AA.lat]]},properties:{}}]}):W.setData(m0)}else W.setData(m0)}y.current=requestAnimationFrame(P)};return y.current=requestAnimationFrame(P),()=>cancelAnimationFrame(y.current)},[c,g,a]),null}function s1(a,c){const g=a.toLowerCase();for(const[x,y]of Object.entries(c))if((x.startsWith("0x")?x.slice(2):x).toLowerCase().startsWith(g)&&y.latitude&&y.longitude&&y.latitude!==0&&y.longitude!==0)return{lat:y.latitude,lon:y.longitude};return null}const Xi="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",Ao="terrarium",eo=256,to=14,p0={shadowColor:"rgba(10, 10, 10, 0.6)",highlightColor:"rgba(245, 240, 230, 0.4)",accentColor:"rgba(90, 75, 65, 0.3)",illuminationDirection:315,exaggeration:.35},An="terrain-dem",Vn="hillshade-dem",H0="terrain-hillshade";function i1({enabled:a,exaggeration:c=4}){const{current:g}=Gr(),[x,y]=R.useState(null),b=R.useRef(null);return R.useEffect(()=>{const D=()=>{var T;const E=(T=g==null?void 0:g.getMap)==null?void 0:T.call(g);E&&!x&&y(E)};D();const P=setInterval(D,50),B=setTimeout(()=>clearInterval(P),5e3);return()=>{clearInterval(P),clearTimeout(B)}},[g,x]),R.useEffect(()=>{if(!x)return;let D=!0;const P=()=>{var B,E;if(D)try{if(x.getSource(Vn)||x.addSource(Vn,{type:"raster-dem",tiles:[Xi],encoding:Ao,tileSize:eo,maxzoom:to}),!x.getLayer(H0)){const T=(E=(B=x.getStyle())==null?void 0:B.layers)==null?void 0:E.find(Q=>Q.type==="symbol");x.addLayer({id:H0,type:"hillshade",source:Vn,paint:{"hillshade-shadow-color":p0.shadowColor,"hillshade-highlight-color":p0.highlightColor,"hillshade-accent-color":p0.accentColor,"hillshade-illumination-direction":p0.illuminationDirection,"hillshade-exaggeration":p0.exaggeration}},T==null?void 0:T.id)}x.getSource(An)||x.addSource(An,{type:"raster-dem",tiles:[Xi],encoding:Ao,tileSize:eo,maxzoom:to})}catch(T){console.error("[TerrainLayer] Source/layer setup error:",T)}};return x.isStyleLoaded()?P():(x.once("style.load",P),x.once("load",()=>{D&&!x.getSource(Vn)&&P()})),()=>{D=!1}},[x]),R.useEffect(()=>{if(!x)return;let D=!0,P=!1;const B=()=>{if(!(!D||!x.getSource(An)))try{a?(x.setCenterClampedToGround(!1),x.setTerrain({source:An,exaggeration:c}),x.setMaxPitch(70),!P&&x.getPitch()<30&&!x.isMoving()&&(P=!0,b.current!==null&&clearTimeout(b.current),b.current=window.setTimeout(()=>{b.current=null,D&&!x.isMoving()&&x.getPitch()<30&&x.easeTo({pitch:45,duration:1e3})},200))):(x.setTerrain(null),x.setCenterClampedToGround(!0),x.getPitch()>0&&!x.isMoving()&&x.easeTo({pitch:0,duration:800}),x.setMaxPitch(60))}catch(E){console.error("[TerrainLayer] Terrain state error:",E)}};if(x.isStyleLoaded()&&x.getSource(An))B();else{const E=()=>{x.getSource(An)&&B()};x.once("idle",E)}return()=>{D=!1,b.current!==null&&(clearTimeout(b.current),b.current=null)}},[x,a,c]),R.useEffect(()=>()=>{var D;try{(D=x==null?void 0:x.getStyle)!=null&&D.call(x)&&x.isStyleLoaded()&&(x.setTerrain(null),x.getLayer(H0)&&x.removeLayer(H0),x.getSource(Vn)&&x.removeSource(Vn),x.getSource(An)&&x.removeSource(An))}catch{}},[x]),null}const o1=.03,l1=.1,a1=2,u1=3,c1=.02,f1=3;function h1(a,c=f1){if(a.length<3||c<=0)return a;let g=a;for(let x=0;x0&&y.push([y[0][0],y[0][1]]),g=y}return g}function d1(a,c){let g=1/0,x=-1/0,y=1/0,b=-1/0;for(const[D,P]of a)Dx&&(x=D),Pb&&(b=P);return g-=c,x+=c,y-=c,b+=c,{minX:g,minY:y,maxX:x,maxY:b,width:x-g,height:b-y}}function m1(a,c={}){if(a.length(AA-b.minX)/b.width*T,U=AA=>(AA-b.minY)/b.height*Q,W=AA=>AA/T*b.width+b.minX,$=AA=>AA/Q*b.height+b.minY,sA=g/b.width*T;try{const J=Fc().x(MA=>z(MA[0])).y(MA=>U(MA[1])).size([T,Q]).bandwidth(Math.max(5,sA)).cellSize(y)(a);if(J.length===0)return{coordinates:[],valid:!1};const uA=Math.max(...J.map(MA=>MA.value))*x;let TA=J[0],lA=1/0;for(const MA of J){const xA=Math.abs(MA.value-uA);xA0){const kA=IA[0],LA=IA[IA.length-1];(kA[0]!==LA[0]||kA[1]!==LA[1])&&IA.push([kA[0],kA[1]])}if(IA.length>=4){const kA=h1(IA);xA.push(kA)}}xA.length>0&&iA.push(xA)}const EA=[];for(const MA of iA)for(const xA of MA)EA.push(xA);return{coordinates:iA,valid:iA.length>0}}catch(AA){return console.warn("[KDE Contour] Failed to generate contour:",AA),{coordinates:[],valid:!1}}}function p1(a,c={}){const g=m1(a,c);return!g.valid||g.coordinates.length===0?null:g.coordinates.length===1?{type:"Polygon",coordinates:g.coordinates[0]}:{type:"MultiPolygon",coordinates:g.coordinates}}const g1="mincut-partition",y1="mincut-partition-fill",x1="mincut-partition-stroke",w1=3,v1=.05,b1=.15,k1=.008,ro=12;function no(a,c,g){return(c[0]-a[0])*(g[1]-a[1])-(c[1]-a[1])*(g[0]-a[0])}function C1(a){if(a.length<3)return a;const c=[...a].sort((y,b)=>y[0]-b[0]||y[1]-b[1]),g=[];for(const y of c){for(;g.length>=2&&no(g[g.length-2],g[g.length-1],y)<=0;)g.pop();g.push(y)}const x=[];for(let y=c.length-1;y>=0;y--){const b=c[y];for(;x.length>=2&&no(x[x.length-2],x[x.length-1],b)<=0;)x.pop();x.push(b)}return g.pop(),x.pop(),g.concat(x)}function E1(a,c){if(a.length<3)return a;let g=0,x=0;for(const[y,b]of a)g+=y,x+=b;return g/=a.length,x/=a.length,a.map(([y,b])=>{const D=y-g,P=b-x,B=Math.sqrt(D*D+P*P);if(B<1e-4)return[y,b];const E=(B+c)/B;return[g+D*E,x+P*E]})}function S1(a,c,g,x,y){const b=y*y,D=b*y;return[.5*(2*c[0]+(-a[0]+g[0])*y+(2*a[0]-5*c[0]+4*g[0]-x[0])*b+(-a[0]+3*c[0]-3*g[0]+x[0])*D),.5*(2*c[1]+(-a[1]+g[1])*y+(2*a[1]-5*c[1]+4*g[1]-x[1])*b+(-a[1]+3*c[1]-3*g[1]+x[1])*D)]}function M1(a){if(a.length<3)return a;const c=[],g=a.length;for(let x=0;xa?D1(a,c,y,b):{type:"FeatureCollection",features:[]},[a,c,y,b]),B=g?x:0,E={"fill-color":["get","color"],"fill-opacity":B},T={"line-color":["get","borderColor"],"line-width":D,"line-opacity":B};return m.jsxs(Hr,{id:g1,type:"geojson",data:P,children:[m.jsx(er,{id:y1,type:"fill",paint:E}),m.jsx(er,{id:x1,type:"line",paint:T})]})}function j1(a,c=!1,g=!1,x=!1,y=.7,b){const D=Do(b);return x?y>=.75?D.restBright:D.rest:y>=.85?D.rest:(y>=.7,D.restDim)}function so(a){return[a[1],a[0]]}function T1(a,c,g,x=12){const[y,b]=a,[D,P]=c,B=[];for(let E=0;E<=x;E++){const T=E/x,Q=b+(P-b)*T,z=y+(D-y)*T,U=4*g*T*(1-T);B.push([Q,z,U])}return B}function io(a,c,g,x,y,b,D,P,B,E,T,Q="dark"){const z=Zs(),U=[];let W=1/0,$=-1/0;const sA=[];for(const J of a){const fA=J.edge.avgConfidence??(c?.7:.5),uA=J.edge.certainCount/Math.max(D,1),TA=fA*.7+uA*.3+(c?.5:0);sA.push({polyline:J,brightnessScore:TA}),W=Math.min(W,TA),$=Math.max($,TA)}if(sA.length===0)return{type:"FeatureCollection",features:[]};const AA=$-W||1;sA.sort((J,fA)=>J.brightnessScore-fA.brightnessScore);for(const{polyline:J,brightnessScore:fA}of sA){const{from:uA,to:TA,edge:lA}=J,iA=g.get(lA.key)??0;if(iA<=0)continue;const EA=P.has(lA.key),MA=B.has(lA.key),xA=lA.avgConfidence??(c?.7:.5),bA=E===lA.key,IA=T[lA.fromHash],kA=T[lA.toHash],LA=(IA==null?void 0:IA.node_name)||(IA==null?void 0:IA.name)||lA.fromHash.slice(0,8),HA=(kA==null?void 0:kA.node_name)||(kA==null?void 0:kA.name)||lA.toHash.slice(0,8),wA=[uA[0]+(TA[0]-uA[0])*iA,uA[1]+(TA[1]-uA[1])*iA];let vA;if(!c)vA=1.5;else{const qA=b.get(lA.key)??Ts(lA.certainCount),XA=y.get(lA.key)??qA;vA=XA+(qA-XA)*x,bA?vA=Math.max(vA*1.6,4.5):MA&&(vA=vA*1.3)}let aA;bA?aA=z.edges.highlight:aA=j1(!1,lA.isDirectPathEdge??!1,EA,MA,xA,Q);let _A;bA?_A=z.edges.highlight:lA.isDirectPathEdge?_A=z.edges.hoverDirect:EA?_A=z.edges.hoverLoop:_A=z.edges.hoverStandard;let FA;if(!c)FA=(.3+xA*.3)*iA;else{const qA=Math.min(iA*1.5,1)*z.edgeOpacity;FA=MA?qA*1.15:qA}bA&&(FA=.95);const zA=(fA-W)/AA;U.push({type:"Feature",properties:{key:lA.key,baseColor:aA,hoverColor:_A,baseWidth:vA,baseOpacity:FA,brightnessScore:zA,isLoopEdge:EA,isBackbone:MA,isDirectPath:lA.isDirectPathEdge??!1,isHubConnection:lA.isHubConnection??!1,isZeroHop:lA.isZeroHop??!1,isValidated:c,certainCount:lA.certainCount,confidence:xA,symmetryRatio:lA.symmetryRatio??1,dominantDirection:lA.dominantDirection??"balanced",fromName:LA,toName:HA,fromHash:lA.fromHash,toHash:lA.toHash},geometry:{type:"LineString",coordinates:[so(uA),so(wA)]}})}return{type:"FeatureCollection",features:U}}const R1=150,I1=8;function oo(a,c){const g=Zs(),x=[];let y=0;for(const b of a){const D=c.get(b.hash);D&&D.blendedScore>y&&(y=D.blendedScore)}for(const b of a){const{from:D,to:P,hash:B,neighbor:E,lastHopData:T}=b,Q=`neighbor-${B}`,z=(T==null?void 0:T.avgRssi)??E.rssi??null,U=(T==null?void 0:T.avgSnr)??E.snr??null,W=(T==null?void 0:T.count)??0,$=(T==null?void 0:T.confidence)??1,sA=c.get(B),AA=(sA==null?void 0:sA.listenerScore)??0,J=(sA==null?void 0:sA.loudScore)??0,fA=(sA==null?void 0:sA.blendedScore)??0,uA=y>0?fA/y:0,TA=b.rxAdvertCount??0,lA=b.txProxyCount??0,iA=TA+lA,EA=iA>0?(lA-TA)/iA:0,MA=T1(D,P,R1,I1);x.push({type:"Feature",properties:{key:Q,hash:B,name:E.node_name||E.name||B.slice(0,8),prefix:B.slice(2,4).toUpperCase(),color:g.neighborColor,width:2.5,opacity:.85,rssi:z,snr:U,packetCount:W,confidence:$,hasAvgRssi:(T==null?void 0:T.avgRssi)!==void 0,hasAvgSnr:(T==null?void 0:T.avgSnr)!==void 0,isNeighborEdge:!0,listenerScore:AA,loudScore:J,blendedScore:fA,trafficWeight:uA,linkAsymmetry:EA,rxAdvertCount:TA,txProxyCount:lA},geometry:{type:"LineString",coordinates:MA}})}return{type:"FeatureCollection",features:x}}function L1({map:a,showTopology:c,validatedPolylines:g,weakPolylines:x,maxCertainCount:y,loopEdgeKeys:b,backboneEdgeKeys:D,highlightedEdgeKey:P,neighbors:B,validatedSourceId:E,weakSourceId:T,neighborPolylines:Q=[],showNeighborLines:z=!0,neighborSourceId:U,neighborLinkScores:W=new Map,basemapMode:$}){const sA=R.useRef(null);R.useEffect(()=>{const ue=a&&"current"in a?a.current:a;sA.current=ue});const AA=R.useRef(new Map),J=R.useRef(1),fA=R.useRef(new Map),uA=R.useRef(new Map),TA=R.useRef(!1),lA=R.useRef(null),iA=R.useRef(c),EA=R.useRef(new Set),MA=R.useRef(""),xA=R.useRef(new Map),bA=R.useRef(""),IA=R.useRef(""),kA=R.useRef(""),LA=R.useRef(g),HA=R.useRef(x),wA=R.useRef(y),vA=R.useRef(b),aA=R.useRef(D),_A=R.useRef(P),FA=R.useRef(B),zA=R.useRef(Q),qA=R.useRef(z),XA=R.useRef(W),VA=R.useRef($);R.useEffect(()=>{LA.current=g,HA.current=x,wA.current=y,vA.current=b,aA.current=D,_A.current=P,FA.current=B,zA.current=Q,qA.current=z,XA.current=W,VA.current=$},[g,x,y,b,D,P,B,Q,z,W,$]);const KA=R.useCallback((ue=!1)=>{var Ee,Me,ge,Le,tt,At,nt,bt,Ke,st;const pe=sA.current;if(!pe)return;const ke=pe.getSource(E),Ye=pe.getSource(T),Te=pe.getSource(U);if(ke){const ye=io(LA.current,!0,AA.current,J.current,fA.current,uA.current,wA.current,vA.current,aA.current,_A.current,FA.current,VA.current),Ze=`${ye.features.length}:${((Me=(Ee=ye.features[0])==null?void 0:Ee.properties)==null?void 0:Me.key)??""}:${((Le=(ge=ye.features[ye.features.length-1])==null?void 0:ge.properties)==null?void 0:Le.key)??""}:${Array.from(AA.current.values()).reduce((zt,kt)=>zt+kt,0).toFixed(2)}`;(ue||Ze!==bA.current)&&(ke.setData(ye),bA.current=Ze)}if(Ye){const ye=io(HA.current,!1,AA.current,J.current,fA.current,uA.current,wA.current,vA.current,aA.current,_A.current,FA.current,VA.current),Ze=`${ye.features.length}:${((At=(tt=ye.features[0])==null?void 0:tt.properties)==null?void 0:At.key)??""}:${((bt=(nt=ye.features[ye.features.length-1])==null?void 0:nt.properties)==null?void 0:bt.key)??""}`;(ue||Ze!==IA.current)&&(Ye.setData(ye),IA.current=Ze)}if(Te&&zA.current.length>0){const ye=oo(zA.current,XA.current),Ze=`${ye.features.length}:${((st=(Ke=ye.features[0])==null?void 0:Ke.properties)==null?void 0:st.hash)??""}`;(ue||Ze!==kA.current)&&(Te.setData(ye),kA.current=Ze)}},[E,T,U]),De=R.useCallback(()=>{lA.current&&(cancelAnimationFrame(lA.current),lA.current=null),AA.current=new Map,J.current=1,fA.current=new Map,uA.current=new Map,TA.current=!1,EA.current=new Set,MA.current="",xA.current=new Map},[]);R.useEffect(()=>{const ue=iA.current,pe=c;if(iA.current=c,!!sA.current){if(lA.current&&(cancelAnimationFrame(lA.current),lA.current=null),ue&&!pe&&!TA.current){TA.current=!0;const Ye=new Map(AA.current);let Te=null;const Ee=Me=>{Te||(Te=Me);const ge=Me-Te,Le=Math.min(ge/Gc,1),tt=rl(Le);for(const[At,nt]of Ye)AA.current.set(At,nt*(1-tt));KA(!0),Le<1?lA.current=requestAnimationFrame(Ee):(TA.current=!1,AA.current=new Map,EA.current=new Set,MA.current="",fA.current=new Map,uA.current=new Map,lA.current=null,KA(!0))};lA.current=requestAnimationFrame(Ee)}!ue&&pe&&(AA.current=new Map,EA.current=new Set,MA.current="")}},[c,KA]),R.useEffect(()=>{const ue=sA.current;if(!c||TA.current||!ue)return;const pe=[...g,...x],ke=pe.map(ge=>`${ge.edge.key}:${ge.edge.certainCount}`).sort().join(","),Ye=EA.current.size===0,Te=MA.current!==""&&MA.current!==ke;if(!Ye&&!Te){KA();return}const Ee=[],Me=[];for(const{edge:ge}of pe)EA.current.has(ge.key)?Me.push(ge.key):Ee.push(ge.key);Te&&Me.length>0&&(fA.current=new Map(xA.current),J.current=0),uA.current=new Map;for(const{edge:ge}of g){const Le=Ts(ge.certainCount);uA.current.set(ge.key,Le)}for(const ge of Ee)AA.current.set(ge,0);for(const ge of Me)AA.current.has(ge)||AA.current.set(ge,1);if(Ee.length>0||Te&&Me.length>0){lA.current&&(cancelAnimationFrame(lA.current),lA.current=null);let ge=null;const Le=Math.min(100,R0/Math.max(Ee.length,1)/2),tt=At=>{ge||(ge=At);const nt=At-ge;for(let Ke=0;Ke0){const Ke=Math.min(nt/R0,1);J.current=_s(Ke)}KA(!0);const bt=R0+(Ee.length-1)*Le;nt{const ue=sA.current;if(!ue||!U)return;const pe=()=>{const Te=ue.getSource(U);if(!Te)return!1;if(Q.length>0){const Ee=oo(Q,W);Te.setData(Ee)}else Te.setData({type:"FeatureCollection",features:[]});return!0};if(pe())return;const ke=Te=>{Te.sourceId===U&&pe()&&ue.off("sourcedata",ke)};ue.on("sourcedata",ke);const Ye=()=>{pe()&&(ue.off("styledata",Ye),ue.off("sourcedata",ke))};return ue.on("styledata",Ye),()=>{ue.off("sourcedata",ke),ue.off("styledata",Ye)}},[U,Q,W]);const Ie=R.useRef($);return R.useEffect(()=>{$!==Ie.current&&(Ie.current=$,bA.current="",IA.current="",kA.current="",KA(!0))},[$,KA]),R.useEffect(()=>()=>{lA.current&&(cancelAnimationFrame(lA.current),lA.current=null)},[]),{isExiting:TA.current,isAnimating:lA.current!==null,resetAnimationState:De,weightAnimProgress:J.current,animStartWeights:fA.current,animTargetWeights:uA.current}}function N1({activeFilters:a,neighborHashes:c,hubConnectedNodes:g,directNodeSet:x,localConnectedNodes:y,nodeTypeMap:b,showTopology:D}){const[P,B]=R.useState(new Map),E=R.useMemo(()=>[...a].sort().join(","),[a]),T=R.useRef(E),Q=R.useRef(!1),z=R.useRef(new Map),U=R.useRef(null),W=R.useRef(g),$=R.useRef(x),sA=R.useRef(y),AA=R.useRef(b),J=R.useRef(D);return R.useEffect(()=>{W.current=g,$.current=x,sA.current=y,AA.current=b,J.current=D},[g,x,y,b,D]),R.useEffect(()=>{const uA=T.current,TA=E;if(T.current=E,uA===TA)return;U.current&&(cancelAnimationFrame(U.current),U.current=null);const lA=new Set(uA?uA.split(",").filter(Boolean):[]),iA=a,EA=W.current,MA=$.current,xA=AA.current;for(const wA of c)z.current.has(wA)||z.current.set(wA,Math.random());const bA=(wA,vA)=>{if(vA.size===0)return!1;const aA=xA.get(wA)??"unknown";return!!(vA.has("repeater")&&aA==="repeater"||vA.has("companion")&&(aA==="companion"||aA==="unknown")||vA.has("room_server")&&aA==="room_server"||vA.has("direct")&&MA.has(wA)||vA.has("hubs")&&EA.has(wA))},IA=[];for(const wA of c){const vA=bA(wA,lA),aA=bA(wA,iA);vA!==aA&&IA.push({hash:wA,startOpacity:vA?1:0,targetOpacity:aA?1:0})}if(IA.length===0)return;Q.current=!0,B(wA=>{const vA=new Map(wA);for(const{hash:aA,startOpacity:_A}of IA)vA.set(aA,_A);return vA});const kA=IA;let LA=null;const HA=wA=>{LA||(LA=wA);const vA=wA-LA;let aA=!0;B(()=>{const FA=new Map;for(const{hash:zA,startOpacity:qA,targetOpacity:XA}of kA){const VA=(z.current.get(zA)??0)*Ri,KA=Math.max(0,vA-VA),De=Math.min(KA/Ti,1),Ie=_s(De),ue=qA+(XA-qA)*Ie;FA.set(zA,ue),De<1&&(aA=!1)}return FA});const _A=Ti+Ri;vA<_A&&!aA?U.current=requestAnimationFrame(HA):(U.current=null,Q.current=!1,B(new Map))};return U.current=requestAnimationFrame(HA),()=>{U.current&&(cancelAnimationFrame(U.current),U.current=null),Q.current=!1}},[E,a,c]),{nodeOpacities:P,getNodeOpacity:(uA,TA)=>Q.current&&P.has(uA)?P.get(uA):TA?1:0}}const Es=240,lo=240;function F1(a,c){if(a[c,c]))}function Q1(a,c,g){const x=g?_r(g):null,y=[];for(const b of a){if(x&&Uo(b.toUpperCase(),x)){g&&y.push(g);continue}const D=c.get(b.toUpperCase());D&&y.push(D)}return y}function O1({neighbors:a,localHash:c,enabled:g=!0}){const[x,y]=R.useState(new Map),b=Rs(),D=R.useRef(b);R.useEffect(()=>{D.current=b},[b]);const P=R.useRef(0),B=R.useRef(null),E=R.useRef(new Map),T=R.useRef(new Map);R.useEffect(()=>{T.current=P1(a)},[a]);const Q=R.useRef(null);return R.useEffect(()=>{const z=()=>{const U=performance.now(),W=E.current;if(W.size===0){B.current=null,y(new Map);return}const $=new Map,sA=[];for(const[AA,{startTime:J,staggerDelay:fA}]of W){const uA=U-J-fA;if(!(uA<0))if(uA>=I0)sA.push(AA);else{const TA=F1(uA,I0);TA>0&&$.set(AA,TA)}}for(const AA of sA)W.delete(AA);y($),W.size>0&&Q.current?B.current=requestAnimationFrame(Q.current):B.current=null};Q.current=z},[]),R.useEffect(()=>{if(!g)return;const z=D.current;if(z.length===0)return;const U=P.current,W=z.filter(J=>(J.timestamp??0)>U);if(U===0){const J=z.reduce((fA,uA)=>Math.max(fA,uA.timestamp??0),0);P.current=J;return}if(W.length===0)return;const $=W.reduce((J,fA)=>Math.max(J,fA.timestamp??0),0);P.current=$;const sA=performance.now();let AA=0;for(const J of W){const fA=Go(J,c);if(!fA||fA.original.length===0)continue;const uA=Q1(fA.original,T.current,c);if(uA.length===0)continue;const TA=I0*.5;for(let lA=0;lA()=>{B.current!==null&&(cancelAnimationFrame(B.current),B.current=null)},[]),{blinkingNodes:x,blinkColor:Hc}}const en="edge-blink-source",kn="edge-blink-layer",Ps=1e3,Qs=1e3,Ss=150,z1=175,H1=3e4,G1=cr.teal,U1="#8B7BAD",V1=2.5,W1=1.875,Y1=.5,q0="node-markers-layer";function K1(a){if(!a.getLayer(kn))return;const c=a.getLayer(q0)?q0:void 0;try{a.moveLayer(kn,c)}catch{}}function Z1(a,c){const g=new Map;for(const x of Object.keys(a)){const y=_r(x);g.has(y)||g.set(y,x)}if(c){const x=_r(c);g.set(x,c)}return g}function $1(a){return a<0||a>=Ps?0:1-a/Ps}function q1(a){if(a<0||a>=Qs)return 0;const c=a/Qs;return Math.pow(1-c,3)}function G0(a){return[a[1],a[0]]}function J1({map:a,nodeCoordinates:c,packets:g,localHash:x,neighbors:y,meshTopology:b,enabled:D=!0}){const P=R.useRef(null),B=a&&"current"in a?a.current:a;R.useEffect(()=>{P.current=B},[B]);const E=R.useRef(!1),T=R.useRef(null),Q=R.useRef([]),z=R.useRef(0),U=R.useRef(!1),[W,$]=R.useState(!1),sA=R.useRef(null),AA=R.useRef([]),J=R.useRef(new Map),fA=R.useRef(c);R.useEffect(()=>{fA.current=c},[c]),R.useEffect(()=>{J.current=Z1(y,x)},[y,x]),R.useEffect(()=>{if(!D){sA.current&&(clearTimeout(sA.current),sA.current=null),AA.current=[],T.current!==null&&(cancelAnimationFrame(T.current),T.current=null),Q.current=[];const iA=P.current;if(iA&&E.current){const EA=iA.getSource(en);EA&&EA.setData({type:"FeatureCollection",features:[]})}U.current=!1,z.current=0}},[D]),R.useEffect(()=>{const iA=B;if(!iA)return;let EA=null,MA=!1;const xA=()=>{if(!MA&&!E.current)try{iA.getLayer(kn)&&iA.removeLayer(kn),iA.getSource(en)&&iA.removeSource(en),iA.addSource(en,{type:"geojson",data:{type:"FeatureCollection",features:[]}});const bA=iA.getLayer(q0)?q0:void 0;iA.addLayer({id:kn,type:"line",source:en,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],U1,G1],"line-width":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],W1,V1],"line-opacity":["*",["get","opacityMult"],["interpolate",["linear"],["get","intensity"],0,0,.1,.8,.5,1,1,1]]}},bA),E.current=!0,$(!0),EA&&(clearInterval(EA),EA=null)}catch{}};return iA.isStyleLoaded()&&xA(),iA.once("style.load",()=>{xA()}),E.current||(EA=setInterval(()=>{if(E.current){EA&&clearInterval(EA);return}xA()},100),setTimeout(()=>{EA&&(clearInterval(EA),EA=null)},5e3)),()=>{MA=!0,EA&&clearInterval(EA),T.current!==null&&(cancelAnimationFrame(T.current),T.current=null);const bA=P.current;if(bA&&E.current){try{bA.getLayer(kn)&&bA.removeLayer(kn),bA.getSource(en)&&bA.removeSource(en)}catch{}E.current=!1,$(!1)}}},[B]);const uA=R.useRef(()=>{});R.useEffect(()=>{uA.current=()=>{const iA=P.current;if(!iA)return;const EA=iA.getSource(en);if(!EA)return;const MA=performance.now(),xA=Q.current,bA=[],IA=[];for(const kA of xA){const LA=MA-kA.startTime-kA.delay,HA=kA.isSpeculative?Qs:Ps;if(LA0&&bA.push({type:"Feature",properties:{intensity:wA,opacityMult:kA.isSpeculative?Y1:1,isSpeculative:kA.isSpeculative??!1},geometry:{type:"LineString",coordinates:[kA.fromCoord,kA.toCoord]}})}}EA.setData({type:"FeatureCollection",features:bA}),Q.current=IA,IA.length>0?T.current=requestAnimationFrame(()=>uA.current()):T.current=null}},[]);const TA=R.useCallback(()=>{const iA=P.current;iA&&K1(iA),T.current===null&&(T.current=requestAnimationFrame(()=>uA.current()))},[]),lA=R.useCallback(()=>{if(!P.current||!E.current)return;const EA=AA.current;if(AA.current=[],sA.current=null,EA.length===0)return;const MA=J.current,xA=fA.current;if(MA.size===0)return;const bA=performance.now();let IA=0,kA=!1;const LA=new Set;for(const HA of EA){const wA=Go(HA,x);if(!wA||wA.original.length<2)continue;const vA=wA.original;let aA=0,_A=null;for(let XA=0;XA0){XA.sort((Ie,ue)=>ue.confidence-Ie.confidence);const VA=Math.max(1,Math.ceil(XA.length*.25)),KA=XA.slice(0,VA),De=IA+aA*Ss;for(const{edgeKey:Ie,otherHash:ue}of KA){const pe=xA.get(_A),ke=xA.get(ue);Q.current.push({edgeKey:Ie,fromCoord:G0(pe),toCoord:G0(ke),startTime:bA,delay:De,isSpeculative:!0}),LA.add(Ie),kA=!0}}}aA>0&&(IA+=aA*Ss*.5)}kA&&TA()},[x,b,TA]);R.useEffect(()=>{const iA=P.current;if(!D||!iA||!W||g.length===0)return;const EA=Date.now(),MA=z.current;if(!U.current){U.current=!0;const IA=(EA-H1)/1e3,kA=g.filter(HA=>(HA.timestamp??0)>=IA);let LA=0;for(const HA of g){const wA=HA.timestamp??0;wA>LA&&(LA=wA)}if(z.current=LA,kA.length>0){kA.sort((wA,vA)=>(wA.timestamp??0)-(vA.timestamp??0));const HA=kA.slice(-20);AA.current.push(...HA),lA()}return}const xA=g.filter(IA=>(IA.timestamp??0)>MA);if(xA.length===0)return;let bA=0;for(const IA of xA){const kA=IA.timestamp??0;kA>bA&&(bA=kA)}z.current=bA,AA.current.push(...xA),sA.current&&clearTimeout(sA.current),sA.current=setTimeout(lA,z1)},[D,g,lA,W]),R.useEffect(()=>()=>{sA.current&&clearTimeout(sA.current)},[])}var tn={},wn={};/** + * @license React + * react-dom-server-legacy.browser.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ao;function X1(){if(ao)return wn;ao=1;var a=Vo();function c(h){for(var v="https://reactjs.org/docs/error-decoder.html?invariant="+h,j=1;j