titan-agent 6.4.0 → 6.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/dist/utils/constants.js +1 -1
  2. package/dist/utils/constants.js.map +1 -1
  3. package/package.json +10 -2
  4. package/ui/dist/assets/AuditPanel-BOIeotPE.js +1 -0
  5. package/ui/dist/assets/{AutonomyPanel-E6arcbAb.js → AutonomyPanel-Dv8ClpL9.js} +1 -1
  6. package/ui/dist/assets/{AutopilotPanel-AhNEPP_2.js → AutopilotPanel-Dv3-_6fZ.js} +1 -1
  7. package/ui/dist/assets/AutoresearchPanel-DdLmfGpC.js +6 -0
  8. package/ui/dist/assets/{BackupPanel-CGQAxeWf.js → BackupPanel-DYr6APwV.js} +1 -1
  9. package/ui/dist/assets/{BrowserPanel-BylOyNpQ.js → BrowserPanel-DMZf6mNn.js} +2 -2
  10. package/ui/dist/assets/{CPActivity-7zS0dXGf.js → CPActivity-B2kmaYR9.js} +1 -1
  11. package/ui/dist/assets/{CPAgentDetail-DUi0ygHI.js → CPAgentDetail--ploJZFv.js} +1 -1
  12. package/ui/dist/assets/{CPAgents-BZYynbga.js → CPAgents-ctC99jCR.js} +1 -1
  13. package/ui/dist/assets/{CPApprovals-CwNTmqzq.js → CPApprovals-BZHaJ6d_.js} +1 -1
  14. package/ui/dist/assets/{CPCosts-5hylxGvH.js → CPCosts--xJmtfEi.js} +1 -1
  15. package/ui/dist/assets/{CPDashboard-5f8qcBKy.js → CPDashboard-rThYnRLi.js} +1 -1
  16. package/ui/dist/assets/CPFiles-IRzbOaxo.js +1 -0
  17. package/ui/dist/assets/{CPGoals-CVSxXk1i.js → CPGoals-BQ4Kasli.js} +1 -1
  18. package/ui/dist/assets/{CPInbox-DD4RYSpf.js → CPInbox-DYvoAJdg.js} +1 -1
  19. package/ui/dist/assets/{CPIssueDetail-Dpuc_wTi.js → CPIssueDetail-D4JUVm7B.js} +1 -1
  20. package/ui/dist/assets/{CPIssues-DsPZLTGm.js → CPIssues-C_K0zuiB.js} +1 -1
  21. package/ui/dist/assets/CPLayout-B3Lr8puc.js +2 -0
  22. package/ui/dist/assets/{CPOrg-C121ZFWy.js → CPOrg-CAKwV8Kr.js} +1 -1
  23. package/ui/dist/assets/{CPRuns-BUdKn-uk.js → CPRuns-COUYpSBB.js} +1 -1
  24. package/ui/dist/assets/{CPSocial-CriG1P45.js → CPSocial-BCTgcO3V.js} +1 -1
  25. package/ui/dist/assets/{CPVoice-BNhgXUE1.js → CPVoice-D-wxXUGf.js} +1 -1
  26. package/ui/dist/assets/{ChannelsPanel-9SjAkSHg.js → ChannelsPanel-Cx3dxaP9.js} +1 -1
  27. package/ui/dist/assets/{CheckpointsPanel-D2sCPz2u.js → CheckpointsPanel-D2ATiPXs.js} +1 -1
  28. package/ui/dist/assets/{CommandPostHub-DHTVn2_E.js → CommandPostHub-DTs1EGm8.js} +4 -4
  29. package/ui/dist/assets/{CronPanel-CLQ0_Z_9.js → CronPanel-D0j9zDVW.js} +1 -1
  30. package/ui/dist/assets/{DataTable-CrBYCT2O.js → DataTable-CgeOprjv.js} +1 -1
  31. package/ui/dist/assets/{DreamPanel-BAkiDqQc.js → DreamPanel-CJAI6Aka.js} +3 -3
  32. package/ui/dist/assets/{EmptyState-DSuZC-Tg.js → EmptyState-NMpt-ODJ.js} +1 -1
  33. package/ui/dist/assets/{EvalHarnessPanel-BykaelQd.js → EvalHarnessPanel-ZPXlKHaK.js} +2 -2
  34. package/ui/dist/assets/{EvalPanel-BlFByCOv.js → EvalPanel-DpmEQQXh.js} +1 -1
  35. package/ui/dist/assets/{FileViewer-B0WedL9k.js → FileViewer-B7Mm4cJL.js} +1 -1
  36. package/ui/dist/assets/{FilesPanel-DwUzP4Hv.js → FilesPanel-CvrGQwh3.js} +2 -2
  37. package/ui/dist/assets/{FleetPanel-JW9Pk1FM.js → FleetPanel-BDf9E7dQ.js} +1 -1
  38. package/ui/dist/assets/{HomelabPanel-DigWCjaM.js → HomelabPanel-CKGR1kGN.js} +1 -1
  39. package/ui/dist/assets/InfraView-CreCQSNl.js +2 -0
  40. package/ui/dist/assets/{InlineEditableField-Car7F635.js → InlineEditableField-JxqorUFO.js} +1 -1
  41. package/ui/dist/assets/{Input-BGGQDAyP.js → Input-rfmX8eLw.js} +1 -1
  42. package/ui/dist/assets/IntegrationsPanel-Ds5KCGUi.js +1 -0
  43. package/ui/dist/assets/IntelligenceView-YcrYQTVO.js +2 -0
  44. package/ui/dist/assets/{LearningPanel-CGENRFnq.js → LearningPanel-CZUd4UsW.js} +1 -1
  45. package/ui/dist/assets/LogsPanel-CmUBA-jG.js +1 -0
  46. package/ui/dist/assets/McpPanel-CVyjQ6H6.js +1 -0
  47. package/ui/dist/assets/{MemoryGraphPanel-FQxiv5x5.js → MemoryGraphPanel-BK-AbsbF.js} +1 -1
  48. package/ui/dist/assets/{MemoryWikiPanel-C1w7xDNl.js → MemoryWikiPanel-DkfHLaje.js} +1 -1
  49. package/ui/dist/assets/MeshPanel-BCDzhBRO.js +11 -0
  50. package/ui/dist/assets/{MissionCanvas-BvbSfN_4.js → MissionCanvas-GvSYEkjz.js} +1 -1
  51. package/ui/dist/assets/{MissionChat-Do8j0nvp.js → MissionChat-DpyGbBhk.js} +1 -1
  52. package/ui/dist/assets/{MissionLibrary-CTzkJFJ7.js → MissionLibrary-Dwn2vP2g.js} +1 -1
  53. package/ui/dist/assets/{MissionStart-_-qlVcRK.js → MissionStart-DIYEotqX.js} +1 -1
  54. package/ui/dist/assets/{Modal-CNnSfYJm.js → Modal-BFii_RIq.js} +1 -1
  55. package/ui/dist/assets/NvidiaPanel-BCmLv4bY.js +1 -0
  56. package/ui/dist/assets/{OrganismPanel-DBy9J7Vl.js → OrganismPanel-CDMC8-yf.js} +1 -1
  57. package/ui/dist/assets/{OverviewPanel-B7JFNH2w.js → OverviewPanel-C9ErRTB1.js} +1 -1
  58. package/ui/dist/assets/{PageHeader-CwcMp_4A.js → PageHeader-CawSrb9E.js} +1 -1
  59. package/ui/dist/assets/{PersonaProfilesPanel-CmZhQC8H.js → PersonaProfilesPanel-B_hx3sLQ.js} +1 -1
  60. package/ui/dist/assets/{PersonasPanel-DSP0tTKz.js → PersonasPanel-BhfAKQWd.js} +1 -1
  61. package/ui/dist/assets/{PhoneDeskPanel-DZSs7aPr.js → PhoneDeskPanel-Cew4jv5F.js} +1 -1
  62. package/ui/dist/assets/{RecipesPanel-BW0hW2sW.js → RecipesPanel-KSNQil0R.js} +1 -1
  63. package/ui/dist/assets/{SecurityPanel-_Saqrvw7.js → SecurityPanel-ojbdvuZR.js} +1 -1
  64. package/ui/dist/assets/SelfImprovePanel-D743Dh0z.js +1 -0
  65. package/ui/dist/assets/{SelfProposalsPanel-D24kB0uM.js → SelfProposalsPanel-DHPrgGsJ.js} +1 -1
  66. package/ui/dist/assets/{SessionsPanel-BCxsCKwr.js → SessionsPanel-Bd8dAJQa.js} +1 -1
  67. package/ui/dist/assets/{SessionsTab-C5fvnjtl.js → SessionsTab-BjyOfaQ9.js} +1 -1
  68. package/ui/dist/assets/SettingsPanel-CWvFc8MJ.js +1 -0
  69. package/ui/dist/assets/SettingsView-Chh-hdRF.js +2 -0
  70. package/ui/dist/assets/{SkeletonLoader-C42HbL9c.js → SkeletonLoader-sjDa7Y96.js} +1 -1
  71. package/ui/dist/assets/{SkillsPanel-DYG8avbV.js → SkillsPanel-B0UwrZGA.js} +1 -1
  72. package/ui/dist/assets/{SomaView-8Rwvw2sJ.js → SomaView-CXfqpdNP.js} +1 -1
  73. package/ui/dist/assets/{StatCard-vp0doZoE.js → StatCard-B4qf3WOB.js} +1 -1
  74. package/ui/dist/assets/{StatusBadge-C4dl4Z7r.js → StatusBadge-BtDtyL5L.js} +1 -1
  75. package/ui/dist/assets/{Tabs-B3hK5PRj.js → Tabs-CeY7i2tk.js} +1 -1
  76. package/ui/dist/assets/{TeamsPanel-Bgc-EYSL.js → TeamsPanel-BxFpHD58.js} +1 -1
  77. package/ui/dist/assets/{TelemetryPanel-DexYjpd5.js → TelemetryPanel-D2L98GwC.js} +1 -1
  78. package/ui/dist/assets/{TitanCanvas-Da6TxxdJ.js → TitanCanvas-D7TL368k.js} +4 -4
  79. package/ui/dist/assets/ToolsView-BiW0mds2.js +2 -0
  80. package/ui/dist/assets/{Tooltip-Chg08x7x.js → Tooltip-C3exOcZa.js} +1 -1
  81. package/ui/dist/assets/{TraceViewer-CojtXASo.js → TraceViewer-z42wYVdE.js} +1 -1
  82. package/ui/dist/assets/{TrainingPanel-tgn1BmiH.js → TrainingPanel-BPVftaSt.js} +1 -1
  83. package/ui/dist/assets/{VoiceOverlay-D_jfyVe9.js → VoiceOverlay-DNzDqitY.js} +1 -1
  84. package/ui/dist/assets/{VramPanel-DXrdQK3J.js → VramPanel-CF4l5fe_.js} +1 -1
  85. package/ui/dist/assets/{WatchView-BitQHsCy.js → WatchView-CewHUoxK.js} +1 -1
  86. package/ui/dist/assets/{WorkTab-6hdXBR7d.js → WorkTab-ByC4niLi.js} +1 -1
  87. package/ui/dist/assets/{WorkflowsPanel-BlB2iBik.js → WorkflowsPanel-Bsyhjv87.js} +1 -1
  88. package/ui/dist/assets/{archive-aaQ0bgj_.js → archive-Cz-kvWW5.js} +1 -1
  89. package/ui/dist/assets/{arrow-left-xxx_FceU.js → arrow-left-CGVxTClf.js} +1 -1
  90. package/ui/dist/assets/{book-open-B00IpKZA.js → book-open-CrOs3smB.js} +1 -1
  91. package/ui/dist/assets/{bot-C4CRICZX.js → bot-C0wiWyCT.js} +1 -1
  92. package/ui/dist/assets/{chart-column-lnilxGq2.js → chart-column-Dcc3a8m5.js} +1 -1
  93. package/ui/dist/assets/{check-BJMHM0tu.js → check-BhmlTEFk.js} +1 -1
  94. package/ui/dist/assets/{chevron-right-CA8HOEP4.js → chevron-right-DJCsUSwz.js} +1 -1
  95. package/ui/dist/assets/{chevron-up-n_3KVmjQ.js → chevron-up-cs3cBR4O.js} +1 -1
  96. package/ui/dist/assets/{circle-check-big-hiNdH5H3.js → circle-check-big-De2k5qVr.js} +1 -1
  97. package/ui/dist/assets/{circle-stop-BlIwj_3n.js → circle-stop-u0L9iQ69.js} +1 -1
  98. package/ui/dist/assets/{clipboard-list-BnOtwHQm.js → clipboard-list-DF1F3Vjf.js} +1 -1
  99. package/ui/dist/assets/{clock-BFgCJnqQ.js → clock-Bc6IrFv8.js} +1 -1
  100. package/ui/dist/assets/{dollar-sign-CBBudQd7.js → dollar-sign-BStL62ws.js} +1 -1
  101. package/ui/dist/assets/{download-C-DdF4cx.js → download-VXqww0Iy.js} +1 -1
  102. package/ui/dist/assets/{external-link-CPAx2HBG.js → external-link-BjN0VrNb.js} +1 -1
  103. package/ui/dist/assets/{file-text-CyC_OxlA.js → file-text-SIULFbzy.js} +1 -1
  104. package/ui/dist/assets/{flask-conical-BKbKUYhz.js → flask-conical-CsShOfpS.js} +1 -1
  105. package/ui/dist/assets/{folder-7bWz46dM.js → folder-DwOkgBGj.js} +1 -1
  106. package/ui/dist/assets/{funnel-C_bR-Dz5.js → funnel-CDnA2Enn.js} +1 -1
  107. package/ui/dist/assets/{git-branch-DGWdkudk.js → git-branch-BAFSlxgi.js} +1 -1
  108. package/ui/dist/assets/{index-CgHHe41p.js → index-BlFxPvdg.js} +5 -5
  109. package/ui/dist/assets/{index-CtD9JOx2.css → index-Dm6zcSTS.css} +1 -1
  110. package/ui/dist/assets/{layers-3BMDaZuk.js → layers-DKKOtsYx.js} +1 -1
  111. package/ui/dist/assets/{legacy-VWR8oDEy.js → legacy-YQ03_WIq.js} +1 -1
  112. package/ui/dist/assets/{lightbulb-CPhcUxli.js → lightbulb-D4Syh7fA.js} +1 -1
  113. package/ui/dist/assets/{link-CfLpUR24.js → link-C_6ueq0o.js} +1 -1
  114. package/ui/dist/assets/{list-todo-DgAmn8ot.js → list-todo-3Me4V-34.js} +1 -1
  115. package/ui/dist/assets/{message-square-WJp1dTaM.js → message-square-Dv6Q3VRO.js} +1 -1
  116. package/ui/dist/assets/{mic-DjXDp1Js.js → mic-BInf3BDE.js} +1 -1
  117. package/ui/dist/assets/{missions-CwDL2FHE.js → missions-BUTRB5Lq.js} +1 -1
  118. package/ui/dist/assets/{network-C_MOo5My.js → network-BsSfc5IE.js} +1 -1
  119. package/ui/dist/assets/{pause-CovS6Xwq.js → pause-CXCmPcHk.js} +1 -1
  120. package/ui/dist/assets/{pencil-C6SVDEUL.js → pencil-DAvceqn3.js} +1 -1
  121. package/ui/dist/assets/{play-D3Nbm1Cz.js → play-MuD1S1C5.js} +1 -1
  122. package/ui/dist/assets/{plug-Dpu9RRBi.js → plug-Chv5y4No.js} +1 -1
  123. package/ui/dist/assets/{plus-CJKkM9fM.js → plus-SBD6A3Qb.js} +1 -1
  124. package/ui/dist/assets/{proxy-CaK_YXZW.js → proxy-C5UuKDtU.js} +1 -1
  125. package/ui/dist/assets/{radio-BTFO9FV9.js → radio-BySzBvYH.js} +1 -1
  126. package/ui/dist/assets/{refresh-cw-_C-4Cd_3.js → refresh-cw-BdcqinTm.js} +1 -1
  127. package/ui/dist/assets/{rotate-ccw-DWyVAH19.js → rotate-ccw-CRA_s5tz.js} +1 -1
  128. package/ui/dist/assets/{save-B02XWwgN.js → save-BWhXC8Tv.js} +1 -1
  129. package/ui/dist/assets/{search-CHteSk-9.js → search-DF7UnWEk.js} +1 -1
  130. package/ui/dist/assets/{send-DkMQeZAz.js → send-CmvPtbvy.js} +1 -1
  131. package/ui/dist/assets/{server-CvEvPDpX.js → server-1PubNLgw.js} +1 -1
  132. package/ui/dist/assets/{shield-check-DQeYCvwF.js → shield-check-BjuAv28a.js} +1 -1
  133. package/ui/dist/assets/{terminal-BVErXh5C.js → terminal-BvDfNOXl.js} +1 -1
  134. package/ui/dist/assets/{test-tube-JSgqEqJs.js → test-tube-CrzRsKdm.js} +1 -1
  135. package/ui/dist/assets/{toggle-right-B3Qz7cQt.js → toggle-right-BRJ_dULZ.js} +1 -1
  136. package/ui/dist/assets/{trash-2-kiHv5iAF.js → trash-2-Dtxmn6GE.js} +1 -1
  137. package/ui/dist/assets/{trending-up-xhvUQXWt.js → trending-up-C7pfwW1S.js} +1 -1
  138. package/ui/dist/assets/{trophy-G3zNxlQS.js → trophy-Dknrgn8P.js} +1 -1
  139. package/ui/dist/assets/{volume-2-CELMZXsT.js → volume-2-ahkfEwxT.js} +1 -1
  140. package/ui/dist/assets/{wifi-off-DKKYhVWL.js → wifi-off-wACQ7wec.js} +1 -1
  141. package/ui/dist/index.html +2 -2
  142. package/ui/dist/sw.js +1 -1
  143. package/ui/dist/assets/AuditPanel-CLc6IVvA.js +0 -1
  144. package/ui/dist/assets/AutoresearchPanel-BJRXdUNa.js +0 -6
  145. package/ui/dist/assets/CPFiles-CR9Nn3_p.js +0 -1
  146. package/ui/dist/assets/CPLayout-CDkrYE-H.js +0 -2
  147. package/ui/dist/assets/InfraView-0iQPmcD1.js +0 -2
  148. package/ui/dist/assets/IntegrationsPanel-BGEkU649.js +0 -1
  149. package/ui/dist/assets/IntelligenceView-wm2Pw46I.js +0 -2
  150. package/ui/dist/assets/LogsPanel-DZ_K2xOL.js +0 -1
  151. package/ui/dist/assets/McpPanel-CNB1BMz-.js +0 -1
  152. package/ui/dist/assets/MeshPanel-DjYZh3P3.js +0 -11
  153. package/ui/dist/assets/NvidiaPanel-CLoX_gD2.js +0 -1
  154. package/ui/dist/assets/SelfImprovePanel-D5s-1XCU.js +0 -1
  155. package/ui/dist/assets/SettingsPanel-B7jrFmeR.js +0 -1
  156. package/ui/dist/assets/SettingsView-CQMHjpN8.js +0 -2
  157. package/ui/dist/assets/ToolsView-DkP9NfCj.js +0 -2
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SomaView-8Rwvw2sJ.js","assets/index-CgHHe41p.js","assets/index-CtD9JOx2.css","assets/Input-BGGQDAyP.js","assets/clsx-B-dksMZM.js","assets/Tooltip-Chg08x7x.js","assets/SomaView-BtCkeWfZ.css","assets/CommandPostHub-DHTVn2_E.js","assets/Modal-CNnSfYJm.js","assets/proxy-CaK_YXZW.js","assets/InlineEditableField-Car7F635.js","assets/check-BJMHM0tu.js","assets/pencil-C6SVDEUL.js","assets/approvalHeadline-DB9SgR-9.js","assets/chevron-right-CA8HOEP4.js","assets/bot-C4CRICZX.js","assets/pause-CovS6Xwq.js","assets/dollar-sign-CBBudQd7.js","assets/git-branch-DGWdkudk.js","assets/chart-column-lnilxGq2.js","assets/clock-BFgCJnqQ.js","assets/message-square-WJp1dTaM.js","assets/file-text-CyC_OxlA.js","assets/terminal-BVErXh5C.js","assets/refresh-cw-_C-4Cd_3.js","assets/circle-stop-BlIwj_3n.js","assets/send-DkMQeZAz.js","assets/plus-CJKkM9fM.js","assets/trash-2-kiHv5iAF.js","assets/IntelligenceView-wm2Pw46I.js","assets/MemoryGraphPanel-FQxiv5x5.js","assets/network-C_MOo5My.js","assets/search-CHteSk-9.js","assets/InfraView-0iQPmcD1.js","assets/ToolsView-DkP9NfCj.js","assets/SettingsView-CQMHjpN8.js","assets/SettingsPanel-B7jrFmeR.js","assets/PageHeader-CwcMp_4A.js","assets/circle-check-big-hiNdH5H3.js","assets/mic-DjXDp1Js.js","assets/wifi-off-DKKYhVWL.js","assets/download-C-DdF4cx.js","assets/play-D3Nbm1Cz.js","assets/save-B02XWwgN.js","assets/SecurityPanel-_Saqrvw7.js","assets/AuditPanel-CLc6IVvA.js","assets/clipboard-list-BnOtwHQm.js","assets/funnel-C_bR-Dz5.js","assets/AutopilotPanel-AhNEPP_2.js","assets/WorkflowsPanel-BlB2iBik.js","assets/toggle-right-B3Qz7cQt.js","assets/book-open-B00IpKZA.js","assets/LearningPanel-CGENRFnq.js","assets/lightbulb-CPhcUxli.js","assets/trending-up-xhvUQXWt.js","assets/chevron-up-n_3KVmjQ.js","assets/server-CvEvPDpX.js","assets/rotate-ccw-DWyVAH19.js","assets/flask-conical-BKbKUYhz.js","assets/archive-aaQ0bgj_.js","assets/radio-BTFO9FV9.js","assets/test-tube-JSgqEqJs.js","assets/VoiceOverlay-D_jfyVe9.js","assets/volume-2-CELMZXsT.js","assets/folder-7bWz46dM.js","assets/shield-check-DQeYCvwF.js","assets/external-link-CPAx2HBG.js","assets/link-CfLpUR24.js","assets/SelfImprovePanel-D5s-1XCU.js","assets/trophy-G3zNxlQS.js","assets/PersonasPanel-DSP0tTKz.js","assets/PersonaProfilesPanel-CmZhQC8H.js","assets/DreamPanel-BAkiDqQc.js","assets/HomelabPanel-DigWCjaM.js","assets/StatCard-vp0doZoE.js","assets/SkeletonLoader-C42HbL9c.js","assets/NvidiaPanel-CLoX_gD2.js","assets/FilesPanel-DwUzP4Hv.js","assets/arrow-left-xxx_FceU.js","assets/LogsPanel-DZ_K2xOL.js","assets/TelemetryPanel-DexYjpd5.js","assets/SkillsPanel-DYG8avbV.js","assets/McpPanel-CNB1BMz-.js","assets/plug-Dpu9RRBi.js","assets/IntegrationsPanel-BGEkU649.js","assets/ChannelsPanel-9SjAkSHg.js","assets/MeshPanel-DjYZh3P3.js","assets/DataTable-CrBYCT2O.js","assets/MemoryWikiPanel-C1w7xDNl.js","assets/AutoresearchPanel-BJRXdUNa.js","assets/SelfProposalsPanel-D24kB0uM.js","assets/OverviewPanel-B7JFNH2w.js","assets/layers-3BMDaZuk.js","assets/SessionsPanel-BCxsCKwr.js","assets/WatchView-BitQHsCy.js","assets/BackupPanel-CGQAxeWf.js","assets/TrainingPanel-tgn1BmiH.js","assets/RecipesPanel-BW0hW2sW.js","assets/VramPanel-DXrdQK3J.js","assets/TeamsPanel-Bgc-EYSL.js","assets/CronPanel-CLQ0_Z_9.js","assets/CheckpointsPanel-D2sCPz2u.js","assets/OrganismPanel-DBy9J7Vl.js","assets/FleetPanel-JW9Pk1FM.js","assets/BrowserPanel-BylOyNpQ.js","assets/EvalPanel-BlFByCOv.js","assets/legacy-VWR8oDEy.js"])))=>i.map(i=>d[i]);
2
- var jl=Object.defineProperty;var El=(t,e,s)=>e in t?jl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var $e=(t,e,s)=>El(t,typeof e!="symbol"?e+"":e,s);import{c as tt,a as st,g as Nl,r as w,b as ge,j as n,S as Cr,W as Tr,B as xt,H as Cl,s as Tl,u as no,d as Rl,e as Al,X as Es,f as mn,E as ro,A as Yt,C as Rr,U as Ar,h as Lr,G as io,R as oe,_ as le,Z as Ll,i as gn,I as fi,k as Il,l as Dl,L as oo,m as Ml,M as Ol,n as Pl,o as Wl,p as Bl,t as Wn}from"./index-CgHHe41p.js";import{C as Ul}from"./chevron-up-n_3KVmjQ.js";import{P as Fl}from"./plus-CJKkM9fM.js";import{F as yn}from"./file-text-CyC_OxlA.js";import{S as Ir}from"./server-CvEvPDpX.js";import{N as ao}from"./network-C_MOo5My.js";import{T as lo}from"./terminal-BVErXh5C.js";import{B as ps}from"./book-open-B00IpKZA.js";import{S as bn}from"./save-B02XWwgN.js";import{P as $l}from"./pencil-C6SVDEUL.js";import{R as co}from"./rotate-ccw-DWyVAH19.js";import{S as uo}from"./search-CHteSk-9.js";import{S as ho}from"./send-DkMQeZAz.js";import{M as xn}from"./message-square-WJp1dTaM.js";import{M as fo}from"./mic-DjXDp1Js.js";import{F as po}from"./flask-conical-BKbKUYhz.js";import{C as ms}from"./clock-BFgCJnqQ.js";import{A as mo}from"./archive-aaQ0bgj_.js";import{R as go}from"./radio-BTFO9FV9.js";import{T as yo,P as pi}from"./test-tube-JSgqEqJs.js";import{VoiceOverlay as zl}from"./VoiceOverlay-D_jfyVe9.js";import{C as Hl}from"./chevron-right-CA8HOEP4.js";import{R as wn}from"./refresh-cw-_C-4Cd_3.js";import{F as Vl}from"./folder-7bWz46dM.js";import{C as mi}from"./check-BJMHM0tu.js";import{S as Gl}from"./shield-check-DQeYCvwF.js";import{E as gi}from"./external-link-CPAx2HBG.js";import{B as Dr}from"./bot-C4CRICZX.js";import{W as ql}from"./wifi-off-DKKYhVWL.js";import{C as Yl}from"./chart-column-lnilxGq2.js";import{L as Kl}from"./link-CfLpUR24.js";import{T as Jl}from"./trash-2-kiHv5iAF.js";/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SomaView-CXfqpdNP.js","assets/index-BlFxPvdg.js","assets/index-Dm6zcSTS.css","assets/Input-rfmX8eLw.js","assets/clsx-B-dksMZM.js","assets/Tooltip-C3exOcZa.js","assets/SomaView-BtCkeWfZ.css","assets/CommandPostHub-DTs1EGm8.js","assets/Modal-BFii_RIq.js","assets/proxy-C5UuKDtU.js","assets/InlineEditableField-JxqorUFO.js","assets/check-BhmlTEFk.js","assets/pencil-DAvceqn3.js","assets/approvalHeadline-DB9SgR-9.js","assets/chevron-right-DJCsUSwz.js","assets/bot-C0wiWyCT.js","assets/pause-CXCmPcHk.js","assets/dollar-sign-BStL62ws.js","assets/git-branch-BAFSlxgi.js","assets/chart-column-Dcc3a8m5.js","assets/clock-Bc6IrFv8.js","assets/message-square-Dv6Q3VRO.js","assets/file-text-SIULFbzy.js","assets/terminal-BvDfNOXl.js","assets/refresh-cw-BdcqinTm.js","assets/circle-stop-u0L9iQ69.js","assets/send-CmvPtbvy.js","assets/plus-SBD6A3Qb.js","assets/trash-2-Dtxmn6GE.js","assets/IntelligenceView-YcrYQTVO.js","assets/MemoryGraphPanel-BK-AbsbF.js","assets/network-BsSfc5IE.js","assets/search-DF7UnWEk.js","assets/InfraView-CreCQSNl.js","assets/ToolsView-BiW0mds2.js","assets/SettingsView-Chh-hdRF.js","assets/SettingsPanel-CWvFc8MJ.js","assets/PageHeader-CawSrb9E.js","assets/circle-check-big-De2k5qVr.js","assets/mic-BInf3BDE.js","assets/wifi-off-wACQ7wec.js","assets/download-VXqww0Iy.js","assets/play-MuD1S1C5.js","assets/save-BWhXC8Tv.js","assets/SecurityPanel-ojbdvuZR.js","assets/AuditPanel-BOIeotPE.js","assets/funnel-CDnA2Enn.js","assets/clipboard-list-DF1F3Vjf.js","assets/AutopilotPanel-Dv3-_6fZ.js","assets/WorkflowsPanel-Bsyhjv87.js","assets/toggle-right-BRJ_dULZ.js","assets/book-open-CrOs3smB.js","assets/LearningPanel-CZUd4UsW.js","assets/lightbulb-D4Syh7fA.js","assets/trending-up-C7pfwW1S.js","assets/chevron-up-cs3cBR4O.js","assets/server-1PubNLgw.js","assets/rotate-ccw-CRA_s5tz.js","assets/flask-conical-CsShOfpS.js","assets/archive-Cz-kvWW5.js","assets/radio-BySzBvYH.js","assets/test-tube-CrzRsKdm.js","assets/VoiceOverlay-DNzDqitY.js","assets/volume-2-ahkfEwxT.js","assets/folder-DwOkgBGj.js","assets/shield-check-BjuAv28a.js","assets/external-link-BjN0VrNb.js","assets/link-C_6ueq0o.js","assets/SelfImprovePanel-D743Dh0z.js","assets/trophy-Dknrgn8P.js","assets/PersonasPanel-BhfAKQWd.js","assets/PersonaProfilesPanel-B_hx3sLQ.js","assets/DreamPanel-CJAI6Aka.js","assets/HomelabPanel-CKGR1kGN.js","assets/StatCard-B4qf3WOB.js","assets/SkeletonLoader-sjDa7Y96.js","assets/NvidiaPanel-BCmLv4bY.js","assets/FilesPanel-CvrGQwh3.js","assets/arrow-left-CGVxTClf.js","assets/LogsPanel-CmUBA-jG.js","assets/TelemetryPanel-D2L98GwC.js","assets/SkillsPanel-B0UwrZGA.js","assets/McpPanel-CVyjQ6H6.js","assets/plug-Chv5y4No.js","assets/IntegrationsPanel-Ds5KCGUi.js","assets/ChannelsPanel-Cx3dxaP9.js","assets/MeshPanel-BCDzhBRO.js","assets/DataTable-CgeOprjv.js","assets/MemoryWikiPanel-DkfHLaje.js","assets/AutoresearchPanel-DdLmfGpC.js","assets/SelfProposalsPanel-DHPrgGsJ.js","assets/OverviewPanel-C9ErRTB1.js","assets/layers-DKKOtsYx.js","assets/SessionsPanel-Bd8dAJQa.js","assets/WatchView-CewHUoxK.js","assets/BackupPanel-DYr6APwV.js","assets/TrainingPanel-BPVftaSt.js","assets/RecipesPanel-KSNQil0R.js","assets/VramPanel-CF4l5fe_.js","assets/TeamsPanel-BxFpHD58.js","assets/CronPanel-D0j9zDVW.js","assets/CheckpointsPanel-D2ATiPXs.js","assets/OrganismPanel-CDMC8-yf.js","assets/FleetPanel-BDf9E7dQ.js","assets/BrowserPanel-DMZf6mNn.js","assets/EvalPanel-DpmEQQXh.js","assets/legacy-YQ03_WIq.js"])))=>i.map(i=>d[i]);
2
+ var jl=Object.defineProperty;var El=(t,e,s)=>e in t?jl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var $e=(t,e,s)=>El(t,typeof e!="symbol"?e+"":e,s);import{c as tt,a as st,g as Nl,r as w,b as ge,j as n,S as Cr,W as Tr,B as xt,H as Cl,s as Tl,u as no,d as Rl,e as Al,X as Es,f as mn,E as ro,A as Yt,C as Rr,U as Ar,h as Lr,G as io,R as oe,_ as le,Z as Ll,i as gn,I as fi,k as Il,l as Dl,L as oo,m as Ml,M as Ol,n as Pl,o as Wl,p as Bl,t as Wn}from"./index-BlFxPvdg.js";import{C as Ul}from"./chevron-up-cs3cBR4O.js";import{P as Fl}from"./plus-SBD6A3Qb.js";import{F as yn}from"./file-text-SIULFbzy.js";import{S as Ir}from"./server-1PubNLgw.js";import{N as ao}from"./network-BsSfc5IE.js";import{T as lo}from"./terminal-BvDfNOXl.js";import{B as ps}from"./book-open-CrOs3smB.js";import{S as bn}from"./save-BWhXC8Tv.js";import{P as $l}from"./pencil-DAvceqn3.js";import{R as co}from"./rotate-ccw-CRA_s5tz.js";import{S as uo}from"./search-DF7UnWEk.js";import{S as ho}from"./send-CmvPtbvy.js";import{M as xn}from"./message-square-Dv6Q3VRO.js";import{M as fo}from"./mic-BInf3BDE.js";import{F as po}from"./flask-conical-CsShOfpS.js";import{C as ms}from"./clock-Bc6IrFv8.js";import{A as mo}from"./archive-Cz-kvWW5.js";import{R as go}from"./radio-BySzBvYH.js";import{T as yo,P as pi}from"./test-tube-CrzRsKdm.js";import{VoiceOverlay as zl}from"./VoiceOverlay-DNzDqitY.js";import{C as Hl}from"./chevron-right-DJCsUSwz.js";import{R as wn}from"./refresh-cw-BdcqinTm.js";import{F as Vl}from"./folder-DwOkgBGj.js";import{C as mi}from"./check-BhmlTEFk.js";import{S as Gl}from"./shield-check-BjuAv28a.js";import{E as gi}from"./external-link-BjN0VrNb.js";import{B as Dr}from"./bot-C0wiWyCT.js";import{W as ql}from"./wifi-off-wACQ7wec.js";import{C as Yl}from"./chart-column-Dcc3a8m5.js";import{L as Kl}from"./link-C_6ueq0o.js";import{T as Jl}from"./trash-2-Dtxmn6GE.js";/**
3
3
  * @license lucide-react v0.513.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
@@ -990,8 +990,8 @@ function Widget({ titan }) {
990
990
  const btn = container.querySelector('button');
991
991
  btn.addEventListener('click', () => btn.textContent = 'Clicked!');
992
992
  }`,html:`<!-- Raw HTML. No scripts run. -->
993
- <div style="padding:16px;color:#e4e4e7">Hello, widget!</div>`,iframe:"",system:""};function qp(t){return String(t||"").startsWith("system:")?"system":"react"}const Yp={productivity:"#a78bfa",finance:"#34d399","health-fitness":"#f472b6","music-dj":"#c084fc",creative:"#fb923c",travel:"#60a5fa",gaming:"#f87171",social:"#38bdf8",cooking:"#fbbf24",vehicle:"#94a3b8",homelab:"#a3e635","ml-ai":"#818cf8",research:"#2dd4bf",document:"#f9a8d4",devops:"#fcd34d","e-commerce":"#fda4af",lifestyle:"#86efac",web:"#67e8f9",data:"#d8b4fe","multi-modal":"#fdba74",automation:"#facc15","smart-home":"#bef264",agents:"#e879f9","software-builder":"#7dd3fc",utilities:"#a5b4fc",media:"#fca5a5",communication:"#5eead4",education:"#c4b5fd",misc:"#9ca3af"};function Kp(t){return t.split(/[-_/]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Jp({open:t,onClose:e}){const[s,r]=w.useState([]),[i,o]=w.useState([]),[c,d]=w.useState("All"),[l,p]=w.useState(""),[g,u]=w.useState(null),[f,x]=w.useState(!1),[y,E]=w.useState(null);w.useEffect(()=>{t&&(x(!0),ge("/api/widget-gallery").then(m=>m.json()).then(m=>{r(m.templates||[]),o(m.categories||[]),x(!1)}).catch(m=>{E(m.message),x(!1)}))},[t]),w.useEffect(()=>{if(!t)return;const m=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t,e]);const L=w.useMemo(()=>{const m=c==="All"?s:s.filter(_=>_.category===c),k=l.trim().toLowerCase();return k?m.filter(_=>[_.name,_.description,_.category,..._.tags||[],..._.triggers||[]].join(" ").toLowerCase().includes(k)):m},[c,l,s]);if(!t)return null;const v=async m=>{var k,_,T,S;u(m.id),E(null);try{const C=await ge(`/api/widget-gallery/${encodeURIComponent(m.id)}`);if(!C.ok)throw new Error(`Could not load template (${C.status})`);const D=await C.json(),j={templateId:m.id,templateName:D.name||m.name,source:D.source,format:qp(D.source),defaultSize:{w:((k=D.defaultSize)==null?void 0:k.w)??((_=m.defaultSize)==null?void 0:_.w)??4,h:((T=D.defaultSize)==null?void 0:T.h)??((S=m.defaultSize)==null?void 0:S.h)??4}};window.dispatchEvent(new CustomEvent("titan:gallery:run-template",{detail:j})),e()}catch(C){E(C.message)}finally{u(null)}},A=["All",...i.map(m=>m.category)];return n.jsx("div",{className:"fixed inset-0 z-[2147483150] flex items-center justify-center p-3 sm:p-4 titan-menu-overlay",onClick:e,children:n.jsxs("div",{className:"w-full max-w-5xl titan-widget-gallery-window flex flex-col",style:{height:"min(760px, 92vh)"},onClick:m=>m.stopPropagation(),children:[n.jsxs("div",{className:"titan-widget-gallery-titlebar",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"titan-window-dot"}),n.jsx("span",{className:"titan-window-dot titan-window-dot--dim"}),n.jsx("span",{className:"titan-window-dot titan-window-dot--dim"}),n.jsx(mn,{className:"w-4 h-4 ml-1",style:{color:"var(--theme-accent)"}}),n.jsx("h3",{className:"font-semibold text-sm",style:{color:"var(--theme-ink)",fontFamily:"var(--theme-font-display)"},children:"Widget gallery"}),n.jsx("span",{className:"text-[10px]",style:{color:"var(--theme-ink-soft)"},children:f?"Loading…":`${s.length} templates`})]}),n.jsx("button",{onClick:e,className:"titan-close-btn",title:"Close (Esc)","aria-label":"Close",children:n.jsx(Es,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"titan-widget-gallery-category-row",children:A.map(m=>{var k;return n.jsxs("button",{onClick:()=>d(m),className:`titan-widget-gallery-category ${c===m?"titan-widget-gallery-category--active":""}`,children:[Kp(m),m!=="All"&&n.jsx("span",{className:"ml-1.5 text-[9px] opacity-70",children:((k=i.find(_=>_.category===m))==null?void 0:k.count)??0})]},m)})}),n.jsx("div",{className:"px-4 sm:px-5 py-2 border-b",style:{borderColor:"var(--theme-menu-border)"},children:n.jsxs("label",{className:"titan-widget-gallery-search",children:[n.jsx(uo,{className:"w-3.5 h-3.5"}),n.jsx("input",{value:l,onChange:m=>p(m.target.value),placeholder:"Search templates...",className:"flex-1 bg-transparent text-xs outline-none"})]})}),n.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[f&&n.jsx("div",{className:"flex items-center justify-center h-full text-sm",style:{color:"var(--theme-ink-soft)"},children:"Loading templates…"}),y&&n.jsxs("div",{className:"flex items-center justify-center h-full text-sm",style:{color:"var(--color-error)"},children:["Error: ",y]}),!f&&!y&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:L.map(m=>n.jsxs("button",{onClick:()=>v(m),disabled:g!==null,className:"titan-widget-gallery-card group",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:Yp[m.category]??"#9ca3af"}}),n.jsx("span",{className:"text-[12px] font-medium truncate",style:{color:"var(--theme-ink)"},children:m.name})]}),n.jsx(ho,{className:"w-3 h-3 transition-colors shrink-0"})]}),n.jsx("div",{className:"text-[11px] leading-relaxed line-clamp-2",style:{color:"var(--theme-ink-soft)"},children:g===m.id?"Adding to canvas...":m.description}),m.tags&&m.tags.length>0&&n.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:m.tags.slice(0,3).map(k=>n.jsx("span",{className:"titan-widget-gallery-tag",children:k},k))})]},m.id))}),L.length===0&&n.jsx("div",{className:"flex items-center justify-center h-40 text-sm",style:{color:"var(--theme-ink-soft)"},children:"No templates in this category."})]}),n.jsxs("div",{className:"titan-widget-gallery-note",children:[n.jsx(xo,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),n.jsxs("div",{className:"text-[11px] leading-relaxed",children:["Don’t see what you want? Open the chat (click the mascot) and describe your widget in plain English. TITAN can build anything that runs inside a sandboxed iframe with access to ",n.jsx("span",{className:"font-mono",children:"titan.fetch"}),","," ",n.jsx("span",{className:"font-mono",children:"titan.api.call"}),", and"," ",n.jsx("span",{className:"font-mono",children:"titan.state"}),"."]})]})]})]})})}const Xp=[{type:"widget",source:"system:nav",name:"Nav Widget",w:3,h:4,icon:n.jsx(xo,{className:"w-4 h-4"})},{type:"widget",source:"system:chat",name:"Chat Widget",w:4,h:5,icon:n.jsx(xn,{className:"w-4 h-4"})},{type:"widget",source:"system:soma",name:"SOMA",w:6,h:6,icon:n.jsx(xt,{className:"w-4 h-4"})},{type:"widget",source:"system:command-post",name:"Command Post",w:8,h:6,icon:n.jsx(lo,{className:"w-4 h-4"})},{type:"widget",source:"system:intelligence",name:"Intelligence",w:6,h:5,icon:n.jsx(ao,{className:"w-4 h-4"})},{type:"widget",source:"system:memory-graph",name:"Memory Graph",w:8,h:7,icon:n.jsx(sc,{className:"w-4 h-4"})},{type:"widget",source:"system:voice",name:"Voice",w:5,h:5,icon:n.jsx(fo,{className:"w-4 h-4"})},{type:"widget",source:"system:infra",name:"Infrastructure",w:6,h:4,icon:n.jsx(Ir,{className:"w-4 h-4"})},{type:"widget",source:"system:tools",name:"Tools",w:5,h:4,icon:n.jsx(Tr,{className:"w-4 h-4"})},{type:"widget",source:"system:settings",name:"Settings",w:5,h:5,icon:n.jsx(Cr,{className:"w-4 h-4"})},{type:"widget",source:"system:files",name:"Files",w:4,h:6,icon:n.jsx(yn,{className:"w-4 h-4"})},{type:"widget",source:"system:memory-wiki",name:"Memory Wiki",w:6,h:6,icon:n.jsx(ps,{className:"w-4 h-4"})},{type:"widget",source:"system:autoresearch",name:"Autoresearch",w:6,h:6,icon:n.jsx(po,{className:"w-4 h-4"})},{type:"widget",source:"system:self-proposals",name:"Self-Proposals",w:6,h:6,icon:n.jsx(bo,{className:"w-4 h-4"})},{type:"widget",source:"system:overview",name:"Overview",w:6,h:5,icon:n.jsx(ro,{className:"w-4 h-4"})},{type:"widget",source:"system:sessions",name:"Sessions",w:6,h:5,icon:n.jsx(ms,{className:"w-4 h-4"})},{type:"widget",source:"system:watch",name:"Watch",w:8,h:7,icon:n.jsx(Yt,{className:"w-4 h-4"})},{type:"widget",source:"system:backup",name:"Backup Manager",w:6,h:6,icon:n.jsx(mo,{className:"w-4 h-4"})},{type:"widget",source:"system:training",name:"Training Dashboard",w:6,h:6,icon:n.jsx(xt,{className:"w-4 h-4"})},{type:"widget",source:"system:recipes",name:"Recipe Kitchen",w:6,h:6,icon:n.jsx(ps,{className:"w-4 h-4"})},{type:"widget",source:"system:vram",name:"VRAM Monitor",w:6,h:6,icon:n.jsx(Rr,{className:"w-4 h-4"})},{type:"widget",source:"system:teams",name:"Team Hub",w:6,h:6,icon:n.jsx(Ar,{className:"w-4 h-4"})},{type:"widget",source:"system:cron",name:"Cron Scheduler",w:6,h:6,icon:n.jsx(ms,{className:"w-4 h-4"})},{type:"widget",source:"system:checkpoints",name:"Checkpoints",w:6,h:5,icon:n.jsx(bn,{className:"w-4 h-4"})},{type:"widget",source:"system:organism",name:"Organism Monitor",w:6,h:6,icon:n.jsx(Lr,{className:"w-4 h-4"})},{type:"widget",source:"system:fleet",name:"Fleet Router",w:6,h:5,icon:n.jsx(go,{className:"w-4 h-4"})},{type:"widget",source:"system:browser",name:"Browser Tools",w:6,h:5,icon:n.jsx(io,{className:"w-4 h-4"})},{type:"widget",source:"system:eval",name:"Test Lab",w:6,h:6,icon:n.jsx(yo,{className:"w-4 h-4"})}];function _l({currentSpaceId:t,onSpaceSelect:e,onAction:s,onClose:r}){const[i,o]=w.useState(""),[c,d]=w.useState(0),l=w.useRef(null),p=ke.list(),g=w.useMemo(()=>{const u=i.toLowerCase(),f=p.filter(y=>y.id!==t&&y.name.toLowerCase().includes(u)).map(y=>({type:"space",id:y.id,name:y.name,color:y.color})),x=Xp.filter(y=>y.name.toLowerCase().includes(u)).map(y=>({type:"action",action:y,name:y.name}));return[...f,...x]},[i,p,t]);return w.useEffect(()=>{var u;(u=l.current)==null||u.focus()},[]),w.useEffect(()=>{d(0)},[i]),w.useEffect(()=>{const u=f=>{if((f.metaKey||f.ctrlKey)&&f.key.toLowerCase()==="k"){f.preventDefault(),r();return}if(f.key==="Escape"){r();return}if(f.key==="ArrowDown"){f.preventDefault(),d(x=>Math.min(x+1,g.length-1));return}if(f.key==="ArrowUp"){f.preventDefault(),d(x=>Math.max(x-1,0));return}if(f.key==="Enter"){f.preventDefault();const x=g[c];if(!x)return;x.type==="space"&&e(x.id),x.type==="action"&&s(x.action)}};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[g,c,e,s,r]),n.jsx("div",{className:"fixed inset-0 z-[2147483200] flex items-start justify-center pt-[20vh]",onClick:r,children:n.jsxs("div",{className:"w-full max-w-lg bg-[#18181b]/98 backdrop-blur-xl border border-[#27272a]/60 rounded-2xl shadow-2xl shadow-black/60 overflow-hidden",onClick:u=>u.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-[#27272a]/40",children:[n.jsx(uo,{className:"w-4 h-4 text-[#3f3f46]"}),n.jsx("input",{ref:l,value:i,onChange:u=>o(u.target.value),placeholder:"Search spaces, widgets, actions...",className:"flex-1 bg-transparent text-sm text-[#e4e4e7] placeholder:text-[#3f3f46] outline-none"}),n.jsx("button",{onClick:r,className:"text-[#3f3f46] hover:text-[#71717a]",children:n.jsx(Es,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"max-h-[50vh] overflow-auto py-1",children:[g.length===0&&n.jsxs("div",{className:"px-4 py-6 text-center text-xs text-[#52525b]",children:['No results for "',i,'"']}),g.map((u,f)=>n.jsxs("button",{onClick:()=>{u.type==="space"&&e(u.id),u.type==="action"&&s(u.action)},className:`w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors ${f===c?"bg-[#6366f1]/10 text-[#818cf8]":"text-[#a1a1aa] hover:bg-[#27272a]/30"}`,children:[u.type==="space"?n.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:u.color||"#52525b"}}):n.jsx("span",{className:"text-[#6366f1]/60",children:u.action.icon}),n.jsx("span",{className:"text-sm",children:u.name}),n.jsx("span",{className:"ml-auto text-[10px] text-[#3f3f46] uppercase tracking-wider",children:u.type==="space"?"Space":"Widget"})]},u.type==="space"?u.id:u.action.source))]}),n.jsxs("div",{className:"px-4 py-2 border-t border-[#27272a]/40 flex items-center gap-3 text-[10px] text-[#3f3f46]",children:[n.jsx("span",{children:"↑↓ Navigate"}),n.jsx("span",{children:"↵ Select"}),n.jsx("span",{children:"ESC Close"})]})]})})}const Qp=oe.lazy(()=>le(()=>import("./SomaView-8Rwvw2sJ.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),Ae={bgBase:"var(--theme-bg-base, var(--color-bg, #09090b))",surface:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-secondary, #18181b)) 82%, transparent)",surfaceSoft:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-tertiary, #27272a)) 62%, transparent)",border:"color-mix(in srgb, var(--theme-metal-dark, var(--color-border, #3f3f46)) 66%, transparent)",ink:"var(--theme-paper-fg, var(--color-text, #fafafa))",inkSoft:"color-mix(in srgb, var(--theme-paper-fg, var(--color-text-secondary, #a1a1aa)) 72%, transparent)",paperFg:"var(--theme-paper-fg, var(--color-text-secondary, #a1a1aa))",accent:"var(--theme-accent, var(--color-accent, #6366f1))",success:"var(--color-success, #22c55e)",error:"var(--color-error, #ef4444)"},or={background:Ae.bgBase,color:Ae.ink};function kl(){const[t,e]=w.useState(null),[s,r]=w.useState(!1),[i,o]=w.useState(null),c=w.useCallback(async()=>{var p;try{const g=await ge("/api/config");if(!g.ok)throw new Error(`HTTP ${g.status}`);const u=await g.json();e(!!((p=u==null?void 0:u.organism)!=null&&p.enabled)),o(null)}catch(g){o(g.message),e(!1)}},[]);w.useEffect(()=>{c()},[c]);const d=w.useRef(0),l=w.useCallback(async p=>{const g=++d.current;r(!0),o(null);try{const u=await ge("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organism:{enabled:p}})});if(g!==d.current)return;if(!u.ok)throw new Error(`HTTP ${u.status}`);e(p),window.dispatchEvent(new CustomEvent("titan:soma:changed",{detail:{enabled:p}}))}catch(u){if(g!==d.current)return;o(u.message)}finally{g===d.current&&r(!1)}},[]);return t===null?n.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs",style:{...or,color:Ae.paperFg},children:"Loading Soma…"}):t?n.jsxs("div",{className:"w-full h-full overflow-auto flex flex-col",style:or,children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b",style:{background:Ae.surface,borderColor:Ae.border},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full animate-pulse",style:{background:Ae.success}}),n.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:Ae.success},children:"Soma active"})]}),n.jsxs("button",{onClick:()=>l(!1),disabled:s,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full border text-[10px] disabled:opacity-60 transition-colors",style:{borderColor:Ae.border,color:Ae.inkSoft,background:Ae.surfaceSoft},title:"Disable Soma",children:[n.jsx(pi,{className:"w-3 h-3"}),s?"saving…":"disable"]})]}),n.jsx("div",{className:"flex-1 overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs",style:{color:Ae.paperFg},children:"Loading Soma dashboard…"}),children:n.jsx(Qp,{})})})]}):n.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-4 p-6 text-center",style:or,children:[n.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center",style:{background:"color-mix(in srgb, var(--theme-accent, var(--color-accent, #6366f1)) 18%, transparent)",border:`1px solid ${Ae.border}`},children:n.jsx(Yt,{className:"w-7 h-7",style:{color:Ae.accent}})}),n.jsxs("div",{className:"space-y-1 max-w-md",children:[n.jsx("h3",{className:"text-lg font-semibold",style:{color:Ae.ink},children:"Soma is off"}),n.jsx("p",{className:"text-xs leading-relaxed",style:{color:Ae.inkSoft},children:"TITAN’s homeostatic drive layer. When enabled, TITAN has a sense of its own state — purpose, curiosity, hunger, safety, social, rest — and will propose work when those drives drift. Every proposal still requires your approval."})]}),n.jsxs("button",{onClick:()=>l(!0),disabled:s,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-full disabled:opacity-60 disabled:cursor-not-allowed text-sm font-medium transition-colors",style:{background:Ae.accent,color:"var(--theme-bg-base, var(--color-bg, #09090b))"},children:[n.jsx(pi,{className:"w-4 h-4"}),s?"Enabling…":"Enable Soma"]}),i&&n.jsx("p",{className:"text-xs",style:{color:Ae.error},children:i}),n.jsx("p",{className:"text-[10px]",style:{color:Ae.paperFg},children:"You can turn this off anytime from the same button."})]})}const Zp={calm:{primary:"#6366f1",glow:"rgba(99,102,241,0.4)",pulse:"rgba(99,102,241,0.15)"},focused:{primary:"#10b981",glow:"rgba(16,185,129,0.4)",pulse:"rgba(16,185,129,0.15)"},excited:{primary:"#f59e0b",glow:"rgba(245,158,11,0.4)",pulse:"rgba(245,158,11,0.15)"},concerned:{primary:"#ef4444",glow:"rgba(239,68,68,0.4)",pulse:"rgba(239,68,68,0.15)"},dreaming:{primary:"#8b5cf6",glow:"rgba(139,92,246,0.4)",pulse:"rgba(139,92,246,0.15)"}},Ee={surface:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-secondary, #18181b)) 90%, transparent)",surfaceSoft:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-tertiary, #27272a)) 62%, transparent)",overlay:"color-mix(in srgb, var(--theme-bg-base, var(--color-bg, #09090b)) 56%, transparent)",border:"color-mix(in srgb, var(--theme-metal-dark, var(--color-border, #3f3f46)) 66%, transparent)",metal:"var(--theme-metal, var(--color-border-light, #52525b))",ink:"var(--theme-paper-fg, var(--color-text, #fafafa))",accent:"var(--theme-accent, var(--color-accent, #6366f1))",warning:"var(--color-warning, #f59e0b)"};function em(t,e,s){if(!s)return{emotion:"dreaming",intensity:.25,activity:"Dormant"};const r=e[0],i=Math.min(1,t/2);switch(r){case"purpose":return{emotion:"focused",intensity:.4+i*.4,activity:"Pursuing purpose"};case"curiosity":return{emotion:"excited",intensity:.4+i*.5,activity:"Exploring"};case"hunger":return{emotion:"focused",intensity:.5+i*.3,activity:"Satiating"};case"safety":return{emotion:"concerned",intensity:.5+i*.4,activity:"Securing"};case"social":return{emotion:"calm",intensity:.3+i*.3,activity:"Connecting"};case"rest":return{emotion:"dreaming",intensity:.2+i*.2,activity:"Recuperating"};default:return t>.5?{emotion:"focused",intensity:i,activity:"Processing"}:{emotion:"calm",intensity:.3,activity:"Observing"}}}function tm(){const[t,e]=w.useState(!1),[s,r]=w.useState({emotion:"calm",intensity:.3,activity:"Observing"}),[i,o]=w.useState(!1),[c,d]=w.useState(()=>sm()),[l,p]=w.useState(!1),g=w.useRef({x:0,y:0}),u=w.useRef(null);w.useEffect(()=>{let v=!1;const A=async()=>{try{const k=await ge("/api/soma/state");if(!k.ok||v)return;const _=await k.json();if(v)return;r(em(Number((_==null?void 0:_.totalPressure)??0),Array.isArray(_==null?void 0:_.dominantDrives)?_.dominantDrives:[],!!(_!=null&&_.enabled)))}catch{}};A();const m=setInterval(A,15e3);return()=>{v=!0,clearInterval(m)}},[]),w.useEffect(()=>{const v=A=>{var m;(m=u.current)!=null&&m.contains(A.target)||o(!1)};return window.addEventListener("mousedown",v),()=>window.removeEventListener("mousedown",v)},[]);const f=v=>{v.button===0&&(g.current={x:v.clientX-c.x,y:v.clientY-c.y},p(!0))},x=v=>{l&&d({x:v.clientX-g.current.x,y:v.clientY-g.current.y})},y=()=>{p(!1)},E=Zp[s.emotion],L=s.activity==="Dormant"?Ee.metal:Ee.accent;return n.jsxs(n.Fragment,{children:[t&&n.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center backdrop-blur-sm",style:{background:Ee.overlay},onClick:()=>e(!1),children:n.jsxs("div",{className:"border rounded-2xl shadow-2xl overflow-hidden",style:{width:"min(900px, 90vw)",height:"min(600px, 80vh)",background:Ee.surface,borderColor:Ee.border,color:Ee.ink,boxShadow:"0 24px 64px color-mix(in srgb, var(--theme-bg-base, var(--color-bg, #09090b)) 72%, transparent)"},onClick:v=>v.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b",style:{borderColor:Ee.border},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(xt,{className:"w-4 h-4",style:{color:L}}),n.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:Ee.ink},children:"SOMA Consciousness"})]}),n.jsx("button",{onClick:()=>e(!1),className:"p-1",style:{color:Ee.metal},children:n.jsx(Es,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"h-[calc(100%-40px)]",children:n.jsx(kl,{})})]})}),n.jsxs("div",{ref:u,className:"fixed z-50 select-none",style:{left:c.x,top:c.y},onMouseDown:f,onMouseMove:x,onMouseUp:y,onMouseLeave:y,children:[i&&n.jsxs("div",{className:"absolute bottom-full left-0 mb-2 backdrop-blur-xl border rounded-xl shadow-2xl overflow-hidden min-w-[160px] py-1",style:{background:Ee.surface,borderColor:Ee.border,boxShadow:"0 18px 40px color-mix(in srgb, var(--theme-bg-base, var(--color-bg, #09090b)) 70%, transparent)"},children:[n.jsxs("button",{onClick:()=>{e(!0),o(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] transition-colors",style:{color:Ee.ink,background:"transparent"},children:[n.jsx(xt,{className:"w-3.5 h-3.5",style:{color:L}}),"Open SOMA"]}),n.jsxs("button",{onClick:()=>{o(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] transition-colors",style:{color:Ee.ink,background:"transparent"},children:[n.jsx(mn,{className:"w-3.5 h-3.5",style:{color:Ee.warning}}),"Summarize Canvas"]}),n.jsxs("button",{onClick:()=>{o(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] transition-colors",style:{color:Ee.ink,background:"transparent"},children:[n.jsx(Ll,{className:"w-3.5 h-3.5",style:{color:Ee.accent}}),"Run Self-Check"]})]}),n.jsxs("div",{className:"relative cursor-pointer group",onClick:()=>!l&&e(!0),onContextMenu:v=>{v.preventDefault(),o(!0)},children:[n.jsx("div",{className:"absolute inset-0 rounded-full animate-ping opacity-20",style:{background:E.pulse,animationDuration:`${3-s.intensity*2}s`}}),n.jsx("div",{className:"absolute -inset-2 rounded-full opacity-30 blur-md transition-all duration-1000",style:{background:E.glow}}),n.jsx("div",{className:"relative w-12 h-12 rounded-full flex items-center justify-center transition-all duration-500 hover:scale-110",style:{background:`radial-gradient(circle at 30% 30%, ${L}, ${Ee.metal})`,boxShadow:`0 0 ${20+s.intensity*30}px ${E.glow}, inset 0 0 10px color-mix(in srgb, var(--theme-ink, var(--color-text, #fafafa)) 12%, transparent)`},children:n.jsx(xt,{className:"w-5 h-5",style:{color:Ee.ink}})}),n.jsx("div",{className:"absolute -bottom-5 left-1/2 -translate-x-1/2 whitespace-nowrap",children:n.jsx("span",{className:"text-[9px] font-medium uppercase tracking-wider px-1.5 py-0.5 rounded border",style:{color:Ee.ink,background:Ee.surfaceSoft,borderColor:Ee.border},children:s.activity})})]})]})]})}function sm(){if(typeof window>"u")return{x:280,y:80};const t=window.innerWidth<640;return{x:t?Math.max(16,window.innerWidth-96):280,y:t?220:80}}const nm=oe.lazy(()=>le(()=>import("./CommandPostHub-DHTVn2_E.js"),__vite__mapDeps([7,1,2,3,4,8,9,10,11,12,5,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28])));function rm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-2",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Command Post..."}),children:n.jsx(nm,{})})})}const im=oe.lazy(()=>le(()=>import("./IntelligenceView-wm2Pw46I.js"),__vite__mapDeps([29,1,2,4])));function om(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Intelligence..."}),children:n.jsx(im,{})})})}const am=oe.lazy(()=>le(()=>import("./MemoryGraphPanel-FQxiv5x5.js"),__vite__mapDeps([30,1,2,31,24,28,32])));function lm(){return n.jsx("div",{className:"w-full h-full overflow-auto bg-[#09090b]",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"w-8 h-8 rounded-full border-2 border-[#6366f1]/20 border-t-[#6366f1] animate-spin mx-auto mb-3"}),n.jsx("p",{className:"text-[11px] text-[#52525b]",children:"Loading memory graph..."})]})}),children:n.jsx("div",{className:"p-4",children:n.jsx(am,{})})})})}function cm(){const[t,e]=w.useState(!1);return t?n.jsx(zl,{onClose:()=>e(!1)}):n.jsx("div",{className:"w-full h-full flex flex-col items-center justify-center bg-[#09090b]",children:n.jsxs("button",{onClick:()=>e(!0),className:"group relative flex flex-col items-center gap-4",children:[n.jsxs("div",{className:"relative w-20 h-20 rounded-full flex items-center justify-center transition-all duration-300 group-hover:scale-110",children:[n.jsx("div",{className:"absolute inset-0 rounded-full bg-[#6366f1]/20 animate-pulse"}),n.jsx("div",{className:"absolute inset-0 rounded-full bg-gradient-to-br from-[#6366f1]/30 to-[#4f46e5]/10 border border-[#6366f1]/30"}),n.jsx(fo,{className:"w-8 h-8 text-[#818cf8] relative z-10"})]}),n.jsxs("div",{className:"text-center",children:[n.jsx("p",{className:"text-sm font-medium text-[#a1a1aa]",children:"Tap to speak"}),n.jsx("p",{className:"text-[10px] text-[#52525b] mt-1",children:"F5-TTS · Voice Cloning"})]})]})})}const dm=oe.lazy(()=>le(()=>import("./InfraView-0iQPmcD1.js"),__vite__mapDeps([33,1,2,4])));function um(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Infrastructure..."}),children:n.jsx(dm,{})})})}const hm=oe.lazy(()=>le(()=>import("./ToolsView-DkP9NfCj.js"),__vite__mapDeps([34,1,2,4])));function fm(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Tools..."}),children:n.jsx(hm,{})})})}const pm=oe.lazy(()=>le(()=>import("./SettingsView-CQMHjpN8.js"),__vite__mapDeps([35,1,2,4])));function mm(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Settings..."}),children:n.jsx(pm,{})})})}function gm(){const[t,e]=w.useState([]),[s,r]=w.useState("/"),[i,o]=w.useState(!1),[c,d]=w.useState(null),l=async()=>{o(!0),d(null);try{const p=await ge(`/api/files?path=${encodeURIComponent(s)}`);if(p.ok){const g=await p.json();e(g.files||[])}else e([]),d(`Couldn't load files (HTTP ${p.status})`)}catch(p){e([]),d(`Couldn't reach /api/files — ${p.message}`)}finally{o(!1)}};return w.useEffect(()=>{l()},[s]),n.jsxs("div",{className:"w-full h-full flex flex-col",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-[#27272a]/40",children:[n.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-[#71717a]",children:[n.jsx("span",{className:"text-[#6366f1]",children:"~"}),n.jsx(Hl,{className:"w-3 h-3"}),n.jsx("span",{children:s})]}),n.jsx("button",{onClick:l,className:"p-1 text-[#3f3f46] hover:text-[#71717a]",children:n.jsx(wn,{className:`w-3 h-3 ${i?"animate-spin":""}`})})]}),n.jsxs("div",{className:"flex-1 overflow-auto",children:[c&&n.jsx("div",{className:"px-3 py-2 text-[11px] text-[#ef4444]/80",children:c}),!c&&!i&&t.length===0&&n.jsx("div",{className:"px-3 py-2 text-[11px] text-[#52525b]",children:"No files"}),t.map(p=>n.jsxs("button",{onClick:()=>p.type==="directory"&&r(p.path),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-[#27272a]/20 transition-colors",children:[p.type==="directory"?n.jsx(Vl,{className:"w-3.5 h-3.5 text-[#f59e0b]"}):n.jsx(yn,{className:"w-3.5 h-3.5 text-[#6366f1]"}),n.jsx("span",{className:"text-[12px] text-[#a1a1aa]",children:p.name})]},p.path))]})]})}const ym=oe.lazy(()=>le(()=>import("./SettingsPanel-B7jrFmeR.js"),__vite__mapDeps([36,1,2,3,4,37,14,5,38,39,24,40,41,42,43])));function bm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ym,{})})})}const xm=oe.lazy(()=>le(()=>import("./SecurityPanel-_Saqrvw7.js"),__vite__mapDeps([44,1,2,37,14])));function wm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(xm,{})})})}const vm=oe.lazy(()=>le(()=>import("./AuditPanel-CLc6IVvA.js"),__vite__mapDeps([45,1,2,46,24,47])));function _m(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(vm,{})})})}const Qi={researcher:"#60a5fa",engineer:"#f87171",manager:"#a78bfa",ceo:"#fbbf24",general:"#9ca3af"},km={Recommended:"bg-[#10b981]/15 text-[#10b981] border-[#10b981]/30",Reasoning:"bg-[#8b5cf6]/15 text-[#8b5cf6] border-[#8b5cf6]/30",Fast:"bg-[#0ea5e9]/15 text-[#0ea5e9] border-[#0ea5e9]/30",Light:"bg-[#f59e0b]/15 text-[#f59e0b] border-[#f59e0b]/30","Long Context":"bg-[#6366f1]/15 text-[#6366f1] border-[#6366f1]/30","High Output":"bg-[#ec4899]/15 text-[#ec4899] border-[#ec4899]/30","Needs Key":"bg-[#ef4444]/15 text-[#ef4444] border-[#ef4444]/30"};function Sm(){const[t,e]=w.useState(null),[s,r]=w.useState({}),[i,o]=w.useState({}),[c,d]=w.useState(null),[l,p]=w.useState({}),[g,u]=w.useState(!0),f=w.useCallback(async()=>{d(null);try{const[E,L]=await Promise.all([ge("/api/specialists"),ge("/api/models")]);if(!E.ok)throw new Error(`Specialists request failed: ${E.status}`);if(!L.ok)throw new Error(`Models request failed: ${L.status}`);const v=await E.json(),A=await L.json();e(v),r(A);const m={};await Promise.all(v.map(async k=>{try{const _=await ge(`/api/specialists/${encodeURIComponent(k.id)}/recommendations`);if(_.ok){const T=await _.json();T.recommendations&&(m[k.id]=T.recommendations)}}catch{}})),o(m)}catch(E){d(E.message)}finally{u(!1)}},[]);w.useEffect(()=>{f()},[f]);const x=w.useCallback(E=>{const L=i[E];if(L&&L.length)return L.map(A=>A.id);const v=new Set;if(s&&typeof s=="object")for(const A of Object.keys(s)){const m=s[A];if(Array.isArray(m))for(const k of m)typeof k=="string"?v.add(k):k&&typeof k=="object"&&"id"in k&&typeof k.id=="string"&&v.add(k.id)}if(Array.isArray(t))for(const A of t)A!=null&&A.activeModel&&v.add(A.activeModel),A!=null&&A.defaultModel&&v.add(A.defaultModel);return Array.from(v).sort((A,m)=>A.localeCompare(m))},[i,s,t]),y=w.useCallback(async(E,L)=>{p(v=>({...v,[E]:"saving"}));try{const v=await ge(`/api/specialists/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:L})});if(!v.ok){const m=await v.text().catch(()=>"");throw new Error(`PATCH failed (${v.status}): ${m||v.statusText}`)}const A=await v.json();e(m=>(m==null?void 0:m.map(k=>k.id===E?{...k,activeModel:A.activeModel??k.defaultModel,overridden:(A.activeModel??k.defaultModel)!==k.defaultModel}:k))??null),p(m=>({...m,[E]:"saved"})),setTimeout(()=>{p(m=>{if(m[E]!=="saved")return m;const k={...m};return delete k[E],k})},1500)}catch(v){p(A=>({...A,[E]:"error"})),d(`${E}: ${v.message}`)}},[]);return g&&!t?n.jsx("div",{className:"h-full w-full flex items-center justify-center text-xs text-[#52525b]",children:"Loading specialists…"}):n.jsxs("div",{className:"w-full h-full flex flex-col bg-[#0a0a0f] text-[#e4e4e7] text-sm",children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[#27272a]/60",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ar,{className:"w-4 h-4 text-[#6366f1]"}),n.jsx("h3",{className:"font-semibold",children:"Specialist Models"}),n.jsxs("span",{className:"text-[10px] text-[#52525b]",children:[(t==null?void 0:t.length)??0," sub-agents"]})]}),n.jsxs("button",{onClick:()=>{u(!0),f()},className:"flex items-center gap-1 px-2 py-1 rounded text-[11px] text-[#71717a] hover:text-[#e4e4e7] hover:bg-[#27272a]/60 transition-colors",title:"Refresh from server",children:[n.jsx(wn,{className:`w-3 h-3 ${g?"animate-spin":""}`}),"Refresh"]})]}),c&&n.jsxs("div",{className:"mx-4 mt-3 flex items-start gap-2 px-3 py-2 rounded bg-[#7f1d1d]/20 border border-[#7f1d1d]/40 text-[11px] text-[#fca5a5]",children:[n.jsx(gn,{className:"w-3 h-3 mt-0.5 shrink-0"}),n.jsx("span",{className:"font-mono",children:c})]}),n.jsxs("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-3",children:[(t==null?void 0:t.length)===0&&n.jsx("div",{className:"text-xs text-[#52525b] italic",children:"No specialists registered."}),t==null?void 0:t.map(E=>n.jsx(jm,{row:E,models:x(E.id),recommendations:i[E.id]??[],state:l[E.id]??"idle",onChange:L=>y(E.id,L),onReset:()=>y(E.id,null)},E.id))]}),n.jsxs("div",{className:"px-4 py-2 border-t border-[#27272a]/60 text-[10px] text-[#52525b]",children:["Overrides write to ",n.jsx("span",{className:"font-mono text-[#71717a]",children:"config.specialists.overrides"}),". Top-scored models are recommended per specialist role."]})]})}function jm({row:t,models:e,recommendations:s,state:r,onChange:i,onReset:o}){var u;const c=Qi[t.role]??Qi.general,d=s.find(f=>f.id===t.activeModel),l=s[0]??null,[p,g]=w.useState(!1);return n.jsxs("div",{className:"rounded-lg border border-[#27272a]/60 bg-[#18181b]/70 hover:border-[#3f3f46]/80 transition-colors",children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-3",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-[180px]",children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:c},title:t.role}),n.jsxs("div",{className:"flex flex-col min-w-0",children:[n.jsx("div",{className:"text-sm font-medium truncate",children:t.name}),n.jsx("div",{className:"text-[10px] text-[#52525b] truncate",children:t.title})]})]}),n.jsxs("div",{className:"flex-1 flex items-center gap-2 min-w-0",children:[n.jsx("select",{value:t.activeModel,onChange:f=>i(f.target.value),disabled:r==="saving",className:"flex-1 min-w-0 px-2 py-1 rounded bg-[#0a0a0f] border border-[#27272a] text-xs font-mono focus:outline-none focus:border-[#6366f1] disabled:opacity-50",title:`default: ${t.defaultModel}`,children:e.map(f=>{const x=s.find(L=>L.id===f),y=(x==null?void 0:x.badges)??[],E=y.length?`${f} [${y.join(", ")}]`:f;return n.jsx("option",{value:f,children:E},f)})}),d&&d.badges.length>0&&n.jsx("div",{className:"hidden sm:flex items-center gap-1 shrink-0",children:d.badges.slice(0,3).map(f=>n.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] border ${km[f]??"bg-[#27272a] text-[#a1a1aa] border-[#27272a]"}`,children:f},f))}),t.overridden&&n.jsxs("button",{onClick:o,disabled:r==="saving",className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] text-[#fbbf24] border border-[#fbbf24]/30 hover:bg-[#fbbf24]/10 transition-colors disabled:opacity-50",title:`Reset to default: ${t.defaultModel}`,children:[n.jsx(co,{className:"w-3 h-3"}),"Reset"]}),n.jsx("button",{onClick:()=>g(f=>!f),className:"flex items-center justify-center w-6 h-6 rounded hover:bg-[#27272a]/60 text-[#52525b] hover:text-[#a1a1aa] transition-colors",title:"Show recommendation details",children:n.jsx(fi,{className:"w-3.5 h-3.5"})}),n.jsxs("div",{className:"w-5 h-5 flex items-center justify-center shrink-0",children:[r==="saving"&&n.jsx(wn,{className:"w-3.5 h-3.5 animate-spin text-[#6366f1]"}),r==="saved"&&n.jsx(mi,{className:"w-3.5 h-3.5 text-[#10b981]"}),r==="error"&&n.jsx(gn,{className:"w-3.5 h-3.5 text-[#ef4444]"})]})]})]}),p&&n.jsxs("div",{className:"px-3 pb-3 space-y-1.5",children:[d&&n.jsxs("div",{className:"flex items-start gap-2 text-[11px] text-[#a1a1aa]",children:[n.jsx(fi,{className:"w-3 h-3 mt-0.5 shrink-0 text-[#6366f1]"}),n.jsx("span",{children:d.rationale})]}),l&&l.id!==t.activeModel&&n.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[#10b981]",children:[n.jsx(mi,{className:"w-3 h-3 shrink-0"}),n.jsxs("span",{children:["Recommended upgrade: ",n.jsx("span",{className:"font-mono",children:l.id})," (score ",l.score,"/100)",l.badges.length>0&&n.jsxs("span",{className:"ml-1 text-[#71717a]",children:["[",l.badges.join(", "),"]"]})]})]}),d&&n.jsxs("div",{className:"grid grid-cols-3 gap-2 text-[10px] text-[#52525b]",children:[n.jsxs("div",{children:["Capability: ",n.jsxs("span",{className:"text-[#a1a1aa]",children:[d.breakdown.capabilityScore,"/40"]})]}),n.jsxs("div",{children:["Fit: ",n.jsxs("span",{className:"text-[#a1a1aa]",children:[d.breakdown.specialistFit,"/40"]})]}),n.jsxs("div",{children:["Availability: ",n.jsxs("span",{className:"text-[#a1a1aa]",children:[d.breakdown.availability,"/20"]})]})]})]}),n.jsxs("div",{className:"px-3 pb-2 flex items-center gap-2 text-[10px] text-[#52525b]",children:[n.jsxs("span",{children:["id: ",n.jsx("span",{className:"font-mono text-[#71717a]",children:t.id})]}),n.jsx("span",{children:"•"}),n.jsxs("span",{children:["role: ",n.jsx("span",{className:"font-mono",style:{color:c},children:t.role})]}),((u=t.templateMatches)==null?void 0:u.length)>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"•"}),n.jsxs("span",{className:"truncate",children:["templates: ",n.jsx("span",{className:"font-mono text-[#71717a]",children:t.templateMatches.join(", ")})]})]})]})]})}function Em(){const[t,e]=w.useState(null),[s,r]=w.useState(null),[i,o]=w.useState(null),[c,d]=w.useState(!1),[l,p]=w.useState(null),[g,u]=w.useState(null),f=w.useCallback(async()=>{p(null);try{const[L,v,A]=await Promise.all([ge("/api/telemetry/consent").then(m=>m.ok?m.json():Promise.reject(new Error(`consent ${m.status}`))),ge("/api/analytics/profile").then(m=>m.ok?m.json():null),ge("/api/telemetry/status").then(m=>m.ok?m.json():null)]);e(L),r(v),A!=null&&A.remote&&o(A.remote)}catch(L){p(L.message)}},[]);w.useEffect(()=>{const L=setInterval(()=>{ge("/api/telemetry/status").then(v=>v.ok?v.json():null).then(v=>{v!=null&&v.remote&&o(v.remote)}).catch(()=>{})},15e3);return()=>clearInterval(L)},[]),w.useEffect(()=>{f()},[f]);const x=w.useCallback(async L=>{d(!0),p(null);try{const v=await ge("/api/telemetry/consent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L)});if(!v.ok)throw new Error(`save failed: ${v.status}`);const A=await v.json();e(m=>m?{...m,...A,consentedAt:A.enabled?new Date().toISOString():void 0}:null),u(Date.now()),setTimeout(()=>u(null),2e3)}catch(v){p(v.message)}finally{d(!1)}},[]),y=!!(t!=null&&t.enabled),E=!!(t!=null&&t.crashReports);return n.jsxs("div",{className:"w-full h-full overflow-auto bg-[#0a0a0f] text-[#e4e4e7] text-sm p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[y?n.jsx(Gl,{className:"w-5 h-5 text-[#10b981]"}):n.jsx(Lr,{className:"w-5 h-5 text-[#71717a]"}),n.jsx("h3",{className:"font-semibold text-base",children:"Privacy & Telemetry"}),n.jsx("span",{className:`ml-2 text-[10px] px-2 py-0.5 rounded-full border ${y?"border-[#10b981]/40 bg-[#10b981]/10 text-[#10b981]":"border-[#3f3f46] bg-[#18181b] text-[#71717a]"}`,children:y?"ENABLED":"OFF"}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[g&&n.jsxs("span",{className:"text-[11px] text-[#10b981] flex items-center gap-1",children:[n.jsx(Il,{className:"w-3 h-3"})," Saved"]}),l&&n.jsxs("span",{className:"text-[11px] text-[#ef4444] flex items-center gap-1",children:[n.jsx(Dl,{className:"w-3 h-3"})," ",l]}),n.jsxs("button",{onClick:()=>{f()},className:"flex items-center gap-1 px-2 py-1 rounded text-[11px] text-[#71717a] hover:text-[#e4e4e7] hover:bg-[#27272a]/60 transition-colors",children:[n.jsx(wn,{className:"w-3 h-3"})," Refresh"]})]})]}),n.jsx("div",{className:"mb-4 p-4 rounded-lg border border-[#27272a]/60 bg-[#18181b]/70",children:n.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:y,disabled:c,onChange:L=>x({enabled:L.target.checked,crashReports:E}),className:"mt-1 w-4 h-4 accent-[#6366f1] disabled:opacity-50"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"font-medium",children:"Send anonymous usage stats"}),n.jsx("div",{className:"text-xs text-[#a1a1aa] mt-1 leading-relaxed",children:"OS, Node version, CPU/GPU model + VRAM, RAM, TITAN version, and install method. A heartbeat every 5 minutes so we see uptime + concurrent-session counts. Never sends: prompts, file contents, credentials, IP address, or conversations."}),(t==null?void 0:t.consentedAt)&&n.jsxs("div",{className:"text-[10px] text-[#71717a] mt-2",children:["Consented ",n.jsx("span",{className:"font-mono",children:new Date(t.consentedAt).toLocaleString()}),t.consentedVersion&&n.jsxs(n.Fragment,{children:[" on TITAN v",n.jsx("span",{className:"font-mono",children:t.consentedVersion})]})]})]})]})}),n.jsx("div",{className:`mb-4 p-4 rounded-lg border transition-opacity ${y?"border-[#27272a]/60 bg-[#18181b]/70":"border-[#27272a]/30 bg-[#18181b]/30 opacity-60"}`,children:n.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:E,disabled:c||!y,onChange:L=>x({enabled:y,crashReports:L.target.checked}),className:"mt-1 w-4 h-4 accent-[#6366f1] disabled:opacity-50"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"font-medium",children:"Send crash reports"}),n.jsxs("div",{className:"text-xs text-[#a1a1aa] mt-1 leading-relaxed",children:["When TITAN throws an uncaught exception or unhandled promise rejection, send the error class, message, and stack trace. ",n.jsxs("span",{className:"text-[#fbbf24]",children:["Your $HOME path is replaced with the string ",n.jsx("span",{className:"font-mono",children:'"$HOME"'})," before sending."]})]})]})]})}),n.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-[#27272a]/60 bg-[#18181b]/40",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(gn,{className:"w-4 h-4 text-[#6366f1]"}),n.jsx("div",{className:"text-sm font-medium",children:"What would be sent right now"})]}),s?n.jsxs("dl",{className:"grid grid-cols-[160px_1fr] gap-y-1 text-xs",children:[n.jsx("dt",{className:"text-[#71717a]",children:"installId"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.installId.slice(0,32),"…"]}),n.jsx("dt",{className:"text-[#71717a]",children:"os / arch"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.os," / ",s.arch," (",s.osRelease,")"]}),n.jsx("dt",{className:"text-[#71717a]",children:"cpu"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.cpuModel," · ",s.cpuCores,"c"]}),n.jsx("dt",{className:"text-[#71717a]",children:"ram"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[(s.ramTotalMB/1024).toFixed(1)," GB"]}),n.jsx("dt",{className:"text-[#71717a]",children:"gpu"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.gpuVendor,"/",s.gpuName," · ",(s.gpuVramMB/1024).toFixed(1)," GB VRAM"]}),n.jsx("dt",{className:"text-[#71717a]",children:"disk"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.diskTotalGB," GB"]}),n.jsx("dt",{className:"text-[#71717a]",children:"version / node"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.version," · ",s.nodeVersion]}),n.jsx("dt",{className:"text-[#71717a]",children:"install method"}),n.jsx("dd",{className:"font-mono text-[#e4e4e7]",children:s.installMethod})]}):n.jsx("div",{className:"text-xs text-[#71717a]",children:"Loading profile preview…"})]}),n.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-[#27272a]/60 bg-[#18181b]/50",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(ho,{className:"w-4 h-4 text-[#6366f1]"}),n.jsx("div",{className:"text-sm font-medium",children:"Delivery status"}),(i==null?void 0:i.lastSuccessAt)&&!i.lastError&&n.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full border border-[#10b981]/40 bg-[#10b981]/10 text-[#10b981]",children:"FLOWING"}),(i==null?void 0:i.lastError)&&n.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full border border-[#ef4444]/40 bg-[#ef4444]/10 text-[#ef4444]",children:"ERROR"}),!(i!=null&&i.configured)&&n.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full border border-[#71717a]/40 bg-[#71717a]/10 text-[#71717a]",children:"NO REMOTE"})]}),i?n.jsxs("dl",{className:"grid grid-cols-[160px_1fr] gap-y-1 text-xs",children:[n.jsx("dt",{className:"text-[#71717a]",children:"remote URL"}),n.jsx("dd",{className:"font-mono text-[#e4e4e7] break-all",children:i.remoteUrl||"—"}),n.jsx("dt",{className:"text-[#71717a]",children:"sent / failed"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[n.jsx("span",{className:"text-[#10b981]",children:i.sentCount})," / ",n.jsx("span",{className:i.failedCount>0?"text-[#ef4444]":"text-[#71717a]",children:i.failedCount}),i.lastEventType&&n.jsxs("span",{className:"text-[#71717a]",children:[" · last event: ",n.jsx("span",{className:"text-[#a1a1aa]",children:i.lastEventType})]})]}),n.jsx("dt",{className:"text-[#71717a]",children:"last attempt"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7] flex items-center gap-1",children:[n.jsx(ms,{className:"w-3 h-3 text-[#71717a]"}),i.lastAttemptAt?new Date(i.lastAttemptAt).toLocaleString():"—"]}),n.jsx("dt",{className:"text-[#71717a]",children:"last success"}),n.jsx("dd",{className:"font-mono text-[#e4e4e7]",children:i.lastSuccessAt?new Date(i.lastSuccessAt).toLocaleString():"—"}),i.lastError&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"text-[#ef4444]",children:"last error"}),n.jsx("dd",{className:"font-mono text-[#fca5a5] break-all",children:i.lastError})]})]}):n.jsx("div",{className:"text-xs text-[#71717a]",children:"Checking collector reachability…"})]}),n.jsxs("div",{className:"mb-4 p-3 rounded-lg border border-[#27272a]/60 bg-[#0a0a0f]",children:[n.jsx("div",{className:"text-[10px] text-[#71717a] uppercase tracking-wider mb-1",children:"Collector"}),n.jsx("div",{className:"font-mono text-[11px] text-[#a1a1aa] break-all",children:(t==null?void 0:t.remoteUrl)||"—"})]}),n.jsxs("div",{className:"flex items-center gap-3 text-[11px]",children:[n.jsxs("a",{href:"https://github.com/Djtony707/TITAN/blob/main/PRIVACY.md",target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-[#6366f1] hover:underline",children:[n.jsx(gi,{className:"w-3 h-3"})," Read the full PRIVACY.md"]}),n.jsx("span",{className:"text-[#52525b]",children:"·"}),n.jsxs("a",{href:"https://github.com/Djtony707/TITAN/blob/main/src/analytics/collector.ts",target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-[#6366f1] hover:underline",children:[n.jsx(gi,{className:"w-3 h-3"})," See the collector source"]})]})]})}const Nm=oe.lazy(()=>le(()=>import("./AutopilotPanel-AhNEPP_2.js"),__vite__mapDeps([48,1,2,37,14])));function Cm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Nm,{})})})}const Tm=oe.lazy(()=>le(()=>import("./WorkflowsPanel-BlB2iBik.js"),__vite__mapDeps([49,1,2,37,14,3,4,10,11,12,24,27,42,16,28,20,50,51])));function Rm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Tm,{})})})}const Am=oe.lazy(()=>le(()=>import("./LearningPanel-CGENRFnq.js"),__vite__mapDeps([52,1,2,37,14,24,51,53,54,55,27,22,56,31,23,43,12,57,32,26,21,39,58,20,59,60,61,62,63,64,11,65,66,15,40,19,67,28])));function Lm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Am,{})})})}const Im=oe.lazy(()=>le(()=>import("./SelfImprovePanel-D5s-1XCU.js"),__vite__mapDeps([68,1,2,24,38,20,69,54,15,14,42,23,60,28])));function Dm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Im,{})})})}const Mm=oe.lazy(()=>le(()=>import("./PersonasPanel-DSP0tTKz.js"),__vite__mapDeps([70,1,2])));function Om(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Mm,{})})})}const Pm=oe.lazy(()=>le(()=>import("./PersonaProfilesPanel-CmZhQC8H.js"),__vite__mapDeps([71,1,2,37,14,24,11,16,63,20])));function Wm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Pm,{})})})}const Bm=oe.lazy(()=>le(()=>import("./DreamPanel-BAkiDqQc.js"),__vite__mapDeps([72,1,2,37,14,24])));function Um(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Bm,{})})})}const Fm=oe.lazy(()=>le(()=>import("./HomelabPanel-DigWCjaM.js"),__vite__mapDeps([73,1,2,37,14,74,75,4,24,20,21,56,19,31,38,40,17])));function $m(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Fm,{})})})}const zm=oe.lazy(()=>le(()=>import("./NvidiaPanel-CLoX_gD2.js"),__vite__mapDeps([76,1,2,24,43,38,66,32])));function Hm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(zm,{})})})}const Vm=oe.lazy(()=>le(()=>import("./FilesPanel-DwUzP4Hv.js"),__vite__mapDeps([77,1,2,27,24,14,78,20,12,28,43,41,11,22,55,56,31,23,51,57,32,26,21,39,58,59,60,61,62,63,64,65,66,15,40,19,67])));function Gm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Vm,{})})})}const qm=oe.lazy(()=>le(()=>import("./LogsPanel-DZ_K2xOL.js"),__vite__mapDeps([79,1,2,24])));function Ym(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(qm,{})})})}const Km=oe.lazy(()=>le(()=>import("./TelemetryPanel-DexYjpd5.js"),__vite__mapDeps([80,1,2,74,20,18,19,56])));function Jm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Km,{})})})}const Xm=oe.lazy(()=>le(()=>import("./SkillsPanel-DYG8avbV.js"),__vite__mapDeps([81,1,2,37,14,32,28,41])));function Qm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Xm,{})})})}const Zm=oe.lazy(()=>le(()=>import("./McpPanel-CNB1BMz-.js"),__vite__mapDeps([82,1,2,83,24,27,56,61,28])));function eg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Zm,{})})})}const tg=oe.lazy(()=>le(()=>import("./IntegrationsPanel-BGEkU649.js"),__vite__mapDeps([84,1,2,83,38,43,14])));function sg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(tg,{})})})}const ng=oe.lazy(()=>le(()=>import("./ChannelsPanel-9SjAkSHg.js"),__vite__mapDeps([85,1,2,37,14,24,38,43])));function rg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ng,{})})})}const ig=oe.lazy(()=>le(()=>import("./MeshPanel-DjYZh3P3.js"),__vite__mapDeps([86,1,2,87,24,65])));function og(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ig,{})})})}const ag=oe.lazy(()=>le(()=>import("./MemoryWikiPanel-C1w7xDNl.js"),__vite__mapDeps([88,1,2,37,14,78,67,20,32,51])));function lg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ag,{})})})}const cg=oe.lazy(()=>le(()=>import("./AutoresearchPanel-BJRXdUNa.js"),__vite__mapDeps([89,1,2,58,42,16,24,69,54,20,14])));function dg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(cg,{})})})}const ug=oe.lazy(()=>le(()=>import("./SelfProposalsPanel-D24kB0uM.js"),__vite__mapDeps([90,1,2,37,14,20,55,27,22,56,31,23,51,43,12,57,32,26,21,39,58,59,60,61,62,63,24,64,11,65,66,15,40,19,67,28])));function hg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ug,{})})})}const fg=oe.lazy(()=>le(()=>import("./OverviewPanel-B7JFNH2w.js"),__vite__mapDeps([91,1,2,74,37,14,75,4,20,21,56,92])));function pg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(fg,{})})})}const mg=oe.lazy(()=>le(()=>import("./SessionsPanel-BCxsCKwr.js"),__vite__mapDeps([93,1,2,37,14,3,4,87,10,11,12,32,28])));function gg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(mg,{})})})}const yg=oe.lazy(()=>le(()=>import("./WatchView-BitQHsCy.js"),__vite__mapDeps([94,1,2,9])));function bg(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(yg,{})})})}const xg=oe.lazy(()=>le(()=>import("./BackupPanel-CGQAxeWf.js"),__vite__mapDeps([95,1,2,37,14,27,24,59,38])));function wg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(xg,{})})})}const vg=oe.lazy(()=>le(()=>import("./TrainingPanel-tgn1BmiH.js"),__vite__mapDeps([96,1,2,37,14,24,41])));function _g(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(vg,{})})})}const kg=oe.lazy(()=>le(()=>import("./RecipesPanel-BW0hW2sW.js"),__vite__mapDeps([97,1,2,37,14,24,51,42,28])));function Sg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(kg,{})})})}const jg=oe.lazy(()=>le(()=>import("./VramPanel-DXrdQK3J.js"),__vite__mapDeps([98,1,2,37,14,24])));function Eg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(jg,{})})})}const Ng=oe.lazy(()=>le(()=>import("./TeamsPanel-Bgc-EYSL.js"),__vite__mapDeps([99,1,2,37,14,24,28])));function Cg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Ng,{})})})}const Tg=oe.lazy(()=>le(()=>import("./CronPanel-CLQ0_Z_9.js"),__vite__mapDeps([100,1,2,37,14,24,20,50,28])));function Rg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Tg,{})})})}const Ag=oe.lazy(()=>le(()=>import("./CheckpointsPanel-D2sCPz2u.js"),__vite__mapDeps([101,1,2,37,14,24,43,28])));function Lg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Ag,{})})})}const Ig=oe.lazy(()=>le(()=>import("./OrganismPanel-DBy9J7Vl.js"),__vite__mapDeps([102,1,2,37,14,24,38])));function Dg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Ig,{})})})}const Mg=oe.lazy(()=>le(()=>import("./FleetPanel-JW9Pk1FM.js"),__vite__mapDeps([103,1,2,37,14,24,60])));function Og(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Mg,{})})})}const Pg=oe.lazy(()=>le(()=>import("./BrowserPanel-BylOyNpQ.js"),__vite__mapDeps([104,1,2,37,14])));function Wg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Pg,{})})})}const Bg=oe.lazy(()=>le(()=>import("./EvalPanel-BlFByCOv.js"),__vite__mapDeps([105,1,2,37,14,24,42])));function Ug(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Bg,{})})})}function Fg(t){const e=Date.now()-new Date(t).getTime();if(!Number.isFinite(e)||e<0)return t;const s=Math.floor(e/1e3);if(s<60)return`${s}s ago`;const r=Math.floor(s/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function $g(t){const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>=0?t.slice(e+1):t}function zg(){const[t,e]=w.useState([]),[s,r]=w.useState(!0),[i,o]=w.useState(""),[c,d]=w.useState(null),[l,p]=w.useState(""),[g,u]=w.useState(!1),[f,x]=w.useState(null),[y,E]=w.useState(null),[L,v]=w.useState(null),A=w.useCallback(async()=>{r(!0),x(null);try{const C=await ge("/api/time-travel/checkpoints?limit=100");if(!C.ok)throw new Error(`${C.status} ${C.statusText}`);const D=await C.json();e(D.checkpoints||[])}catch(C){x(C.message||"Failed to load")}finally{r(!1)}},[]);w.useEffect(()=>{A()},[A]);const m=w.useCallback((C,D)=>{v({kind:C,message:D}),setTimeout(()=>v(null),4e3)},[]),k=w.useCallback(async C=>{d(C),p(""),u(!0);try{const D=await ge(`/api/time-travel/diff/${encodeURIComponent(C)}`);if(!D.ok)throw new Error(`${D.status} ${D.statusText}`);const j=await D.json();p(j.diff||"(no diff returned)")}catch(D){p(`Failed to load diff: ${D.message}`)}finally{u(!1)}},[]),_=w.useCallback(C=>{E(C)},[]),T=w.useCallback(async()=>{if(!y)return;const C=y;E(null);try{const D=await ge(`/api/time-travel/restore/${encodeURIComponent(C)}`,{method:"POST"});if(!D.ok)throw new Error(`${D.status} ${D.statusText}`);const j=await D.json();j.ok?(m("ok",j.message||`Restored to ${C.slice(0,8)}.`),A()):m("err",j.message||"Restore failed.")}catch(D){m("err",D.message||"Restore failed.")}},[y,A,m]),S=w.useMemo(()=>{const C=i.trim().toLowerCase();return C?t.filter(D=>D.filePath.toLowerCase().includes(C)||D.toolName.toLowerCase().includes(C)||D.id.toLowerCase().includes(C)):t},[t,i]);return n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",fontSize:12,background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Time Travel"}),n.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:[t.length," file checkpoints · newest first"]})]}),n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("input",{type:"text",value:i,onChange:C=>o(C.target.value),placeholder:"Filter by file or tool…",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:6,color:"#fff",fontSize:11,padding:"4px 8px",outline:"none",width:180}}),n.jsx("button",{onClick:A,disabled:s,title:"Refresh checkpoint list",style:{background:"rgba(99,102,241,0.15)",border:"1px solid rgba(99,102,241,0.35)",borderRadius:6,color:"#c7d2fe",fontSize:11,padding:"4px 10px",cursor:s?"wait":"pointer"},children:s?"…":"Refresh"})]})]}),L&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,background:L.kind==="ok"?"rgba(34,197,94,0.12)":"rgba(239,68,68,0.12)",border:`1px solid ${L.kind==="ok"?"rgba(34,197,94,0.3)":"rgba(239,68,68,0.3)"}`,color:L.kind==="ok"?"#86efac":"#fca5a5",fontSize:11},children:L.message}),f&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,background:"rgba(239,68,68,0.12)",border:"1px solid rgba(239,68,68,0.3)",color:"#fca5a5",fontSize:11},children:f}),n.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[n.jsx("div",{style:{flex:1,overflow:"auto",borderRight:"1px solid rgba(255,255,255,0.06)"},children:s&&t.length===0?n.jsx("div",{style:{padding:16,color:"rgba(255,255,255,0.4)"},children:"Loading checkpoints…"}):S.length===0?n.jsx("div",{style:{padding:16,color:"rgba(255,255,255,0.4)"},children:i?"No matches for that filter.":"No file checkpoints yet. They're created automatically whenever TITAN writes or edits a file."}):S.map(C=>n.jsxs("div",{onClick:()=>k(C.id),style:{padding:"8px 14px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:c===C.id?"rgba(99,102,241,0.08)":"transparent",borderLeft:c===C.id?"2px solid #818cf8":"2px solid transparent"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:2},children:[n.jsx("span",{style:{fontSize:11,fontFamily:"ui-monospace, monospace",color:"#a5b4fc"},children:C.commitHash.slice(0,8)}),n.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.5)"},children:Fg(C.timestamp)})]}),n.jsx("div",{style:{fontSize:12,color:"#e2e8f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:C.filePath,children:$g(C.filePath)}),n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:4},children:[n.jsxs("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)"},children:["before ",n.jsx("code",{style:{color:"#fbbf24"},children:C.toolName})]}),n.jsx("button",{onClick:D=>{D.stopPropagation(),_(C.id)},title:"Restore this file to the state it was in at this checkpoint",style:{fontSize:10,padding:"2px 8px",borderRadius:999,background:"rgba(34,197,94,0.12)",border:"1px solid rgba(34,197,94,0.3)",color:"#86efac",cursor:"pointer"},children:"Restore"})]})]},C.id))}),n.jsx("div",{style:{flex:1,overflow:"auto",padding:14},children:c?g?n.jsx("div",{style:{color:"rgba(255,255,255,0.4)"},children:"Loading diff…"}):n.jsx("pre",{style:{margin:0,fontFamily:'ui-monospace, "SF Mono", Menlo, monospace',fontSize:11,lineHeight:1.5,color:"#e2e8f5",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:(l||"").split(`
994
- `).map((C,D)=>{let j="rgba(255,255,255,0.7)";return C.startsWith("+")&&!C.startsWith("+++")?j="#86efac":C.startsWith("-")&&!C.startsWith("---")?j="#fca5a5":C.startsWith("@@")?j="#a5b4fc":(C.startsWith("diff")||C.startsWith("index")||C.startsWith("+++")||C.startsWith("---"))&&(j="rgba(255,255,255,0.45)"),n.jsx("div",{style:{color:j},children:C||" "},D)})}):n.jsx("div",{style:{color:"rgba(255,255,255,0.4)"},children:"Select a checkpoint on the left to see its diff vs the current file."})})]}),y&&n.jsx("div",{onClick:()=>E(null),style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10},children:n.jsxs("div",{onClick:C=>C.stopPropagation(),style:{background:"#0d0f1d",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:18,maxWidth:380,color:"#e2e8f5"},children:[n.jsx("div",{style:{fontSize:14,fontWeight:600,marginBottom:8},children:"Restore this checkpoint?"}),n.jsxs("div",{style:{fontSize:12,color:"rgba(255,255,255,0.7)",marginBottom:12},children:["The file will be overwritten with its state at ",n.jsx("code",{children:y.slice(0,8)}),". A NEW checkpoint of the current state is taken first, so you can always come back."]}),n.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[n.jsx("button",{onClick:()=>E(null),style:{background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"#e2e8f5",borderRadius:6,padding:"6px 12px",fontSize:12,cursor:"pointer"},children:"Cancel"}),n.jsx("button",{onClick:T,style:{background:"rgba(34,197,94,0.18)",border:"1px solid rgba(34,197,94,0.4)",color:"#86efac",borderRadius:6,padding:"6px 12px",fontSize:12,cursor:"pointer"},children:"Restore"})]})]})})]})}const Zi=5e3,eo={planning:"#a5b4fc",delegating:"#60a5fa",observing:"#22d3ee",iterating:"#f59e0b",verifying:"#a78bfa",reporting:"#34d399",blocked:"#facc15",escalated:"#fb7185",done:"#34d399",failed:"#ef4444",cancelled:"#737373"};function Hg(t){if(!Number.isFinite(t)||t<0)return"—";const e=Math.floor(t/1e3);if(e<60)return`${e}s`;const s=Math.floor(e/60);if(s<60)return`${s}m`;const r=Math.floor(s/60),i=s%60;return`${r}h ${i}m`}function Vg(t){return t===0?"$0":t<.01?"$<0.01":`$${t.toFixed(2)}`}function Gg(){const[t,e]=w.useState([]),[s,r]=w.useState(!0),[i,o]=w.useState(null),[c,d]=w.useState(!1),[l,p]=w.useState(""),[g,u]=w.useState(2),[f,x]=w.useState(!1),[y,E]=w.useState(null),L=w.useCallback(async()=>{try{const _=await ge("/api/missions/active");if(!_.ok)throw new Error(`${_.status} ${_.statusText}`);const T=await _.json();e(T.missions||[]),o(null)}catch(_){o(_.message||"failed to load")}finally{r(!1)}},[]);w.useEffect(()=>{L();const _=setInterval(L,Zi);return()=>clearInterval(_)},[L]);const v=w.useCallback((_,T)=>{E({kind:_,message:T}),setTimeout(()=>E(null),5e3)},[]),A=w.useCallback(async()=>{var T;const _=l.trim();if(_.length<10){v("err","Describe the mission (>=10 chars).");return}x(!0);try{const S=await ge("/api/mission/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:_,budgetUsd:g})});if(!S.ok)throw new Error(`${S.status} ${S.statusText}`);const C=await S.json();v("ok",C.message||`Mission "${((T=C.goal)==null?void 0:T.title)??"?"}" launched.`),p(""),d(!1),L()}catch(S){v("err",S.message||"launch failed")}finally{x(!1)}},[l,g,L,v]),m=w.useCallback(async _=>{try{const T=await ge(`/api/mission/${encodeURIComponent(_)}/cancel`,{method:"POST"});if(!T.ok)throw new Error(`${T.status} ${T.statusText}`);v("ok","Mission marked for cancellation."),L()}catch(T){v("err",T.message||"cancel failed")}},[L,v]),k=w.useMemo(()=>{const _={delegating:0,observing:1,iterating:2,verifying:3,planning:4,reporting:5,blocked:6,escalated:7};return[...t].sort((T,S)=>(_[T.phase]??99)-(_[S.phase]??99))},[t]);return n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Mission Driver"}),n.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:[t.length," active · polling every ",Zi/1e3,"s"]})]}),n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("button",{onClick:()=>d(_=>!_),title:"Launch a new autonomous mission",style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:"1px solid rgba(99,102,241,0.4)",background:c?"rgba(99,102,241,0.25)":"rgba(99,102,241,0.12)",color:"#c7d2fe",cursor:"pointer"},children:c?"× Close":"+ New mission"}),n.jsx("button",{onClick:L,title:"Refresh",style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.04)",color:"#e2e8f5",cursor:"pointer"},children:"↻"})]})]}),y&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,fontSize:11,background:y.kind==="ok"?"rgba(34,197,94,0.12)":"rgba(239,68,68,0.12)",border:`1px solid ${y.kind==="ok"?"rgba(34,197,94,0.3)":"rgba(239,68,68,0.3)"}`,color:y.kind==="ok"?"#86efac":"#fca5a5"},children:y.message}),c&&n.jsxs("div",{style:{padding:12,borderBottom:"1px solid rgba(255,255,255,0.06)",background:"rgba(99,102,241,0.04)"},children:[n.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:.6,color:"#a5b4fc",marginBottom:6},children:"Describe the mission"}),n.jsx("textarea",{value:l,onChange:_=>p(_.target.value),placeholder:"e.g. 'Research the top 5 AI agent frameworks for 2026, summarize their differentiation in a markdown report, and save to ~/Documents/agent-research.md'",rows:3,style:{width:"100%",background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"#fff",fontSize:12,padding:"6px 10px",resize:"vertical",fontFamily:"inherit",boxSizing:"border-box"}}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:8,gap:8},children:[n.jsxs("label",{style:{fontSize:11,color:"rgba(255,255,255,0.6)"},children:["Budget cap: $",n.jsx("input",{type:"number",value:g,onChange:_=>u(Math.max(.05,Math.min(50,Number(_.target.value)||2))),step:"0.5",min:"0.05",max:"50",style:{width:60,marginLeft:4,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:4,color:"#fff",fontSize:11,padding:"2px 6px"}})]}),n.jsx("button",{onClick:A,disabled:f||l.trim().length<10,style:{fontSize:12,padding:"6px 14px",borderRadius:6,border:"none",background:f?"rgba(255,255,255,0.05)":"rgba(34,197,94,0.18)",color:"#86efac",cursor:f?"wait":"pointer",fontWeight:600},children:f?"Decomposing…":"🚀 Launch"})]})]}),n.jsxs("div",{style:{flex:1,overflow:"auto",padding:8},children:[i&&n.jsx("div",{style:{padding:10,color:"#fca5a5",fontSize:11},children:i}),s&&t.length===0?n.jsx("div",{style:{padding:16,color:"rgba(255,255,255,0.4)",fontSize:12},children:"Loading missions…"}):k.length===0?n.jsxs("div",{style:{padding:24,color:"rgba(255,255,255,0.45)",fontSize:12,textAlign:"center"},children:["No active missions.",n.jsx("br",{}),n.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.35)"},children:'Click "+ New mission" to launch one.'})]}):k.map(_=>{const T=eo[_.phase]??"#94a3b8",S=_.subtasks.total>0?Math.round(_.subtasks.completed/_.subtasks.total*100):0;return n.jsxs("div",{style:{padding:"10px 12px",marginBottom:6,borderRadius:8,background:"rgba(255,255,255,0.025)",border:`1px solid ${_.phase==="blocked"?"rgba(250,204,21,0.4)":"rgba(255,255,255,0.06)"}`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[n.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#fafafa",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:_.title,children:_.title}),n.jsx("button",{onClick:()=>m(_.goalId),title:"Cancel this mission",style:{fontSize:10,padding:"2px 8px",borderRadius:999,background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.3)",color:"#fca5a5",cursor:"pointer",marginLeft:6},children:"Cancel"})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:10,color:"rgba(255,255,255,0.7)"},children:[n.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"1px 6px",borderRadius:4,background:`${T}22`,border:`1px solid ${T}55`,color:T,textTransform:"uppercase",letterSpacing:.5,fontWeight:600,fontSize:9},children:_.phase}),n.jsxs("span",{children:[_.subtasks.completed,"/",_.subtasks.total," subtasks (",S,"%)"]}),n.jsx("span",{children:"·"}),n.jsx("span",{children:Vg(_.budget.costUsd)}),n.jsx("span",{children:"·"}),n.jsx("span",{children:Hg(Date.now()-new Date(_.startedAt).getTime())})]}),_.blockedReason&&n.jsxs("div",{style:{marginTop:6,padding:"6px 8px",borderRadius:4,background:"rgba(250,204,21,0.08)",border:"1px solid rgba(250,204,21,0.25)",fontSize:11,color:"#fde68a"},children:[n.jsx("strong",{children:"Blocked:"})," ",_.blockedReason.question??"(no reason)"]}),_.lastHistory.length>0&&n.jsx("div",{style:{marginTop:6,fontSize:10,color:"rgba(255,255,255,0.45)",display:"flex",flexDirection:"column",gap:1},children:_.lastHistory.slice(-3).map((C,D)=>n.jsxs("div",{style:{display:"flex",gap:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[n.jsx("span",{style:{color:eo[C.phase]??"rgba(255,255,255,0.6)",minWidth:70,fontFamily:"ui-monospace, monospace",fontSize:9},children:C.phase}),n.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.note??""})]},D))})]},_.goalId)})]})]})}const qg=6e4,Yg=[{label:"6h",hours:6},{label:"24h",hours:24},{label:"7d",hours:168}];function Kg(t){return t===0?"$0":t<.01?"$<0.01":`$${t.toFixed(2)}`}function Jg(t){return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(1)}k`:`${(t/1e6).toFixed(2)}M`}function Xg(){const[t,e]=w.useState(24),[s,r]=w.useState(null),[i,o]=w.useState(!0),[c,d]=w.useState(null),l=w.useCallback(async()=>{o(!0);try{const p=await ge(`/api/missions/digest?hours=${t}`);if(!p.ok)throw new Error(`${p.status} ${p.statusText}`);const g=await p.json();r(g),d(null)}catch(p){d(p.message||"failed")}finally{o(!1)}},[t]);return w.useEffect(()=>{l();const p=setInterval(l,qg);return()=>clearInterval(p)},[l]),n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Daily digest"}),n.jsx("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:"what TITAN did while you were away"})]}),n.jsx("div",{style:{display:"flex",gap:4},children:Yg.map(p=>n.jsx("button",{onClick:()=>e(p.hours),style:{fontSize:10,padding:"3px 8px",borderRadius:4,border:"1px solid rgba(255,255,255,0.1)",background:t===p.hours?"rgba(99,102,241,0.25)":"rgba(255,255,255,0.03)",color:t===p.hours?"#c7d2fe":"rgba(255,255,255,0.65)",cursor:"pointer"},children:p.label},p.label))})]}),s&&n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.04)",display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8},children:[n.jsx(Us,{label:"Done",value:s.stats.completed,color:"#34d399"}),n.jsx(Us,{label:"Failed",value:s.stats.failed,color:s.stats.failed>0?"#fca5a5":"rgba(255,255,255,0.5)"}),n.jsx(Us,{label:"Active",value:s.stats.active,color:"#60a5fa"}),n.jsx(Us,{label:"Blocked",value:s.stats.blocked,color:s.stats.blocked>0?"#facc15":"rgba(255,255,255,0.5)"})]}),s&&(s.stats.totalCostUsd>0||s.stats.totalTokens>0)&&n.jsxs("div",{style:{padding:"6px 14px",borderBottom:"1px solid rgba(255,255,255,0.04)",fontSize:10,color:"rgba(255,255,255,0.55)",display:"flex",justifyContent:"space-between"},children:[n.jsxs("span",{children:["Spend: ",n.jsx("strong",{style:{color:"#e2e8f5"},children:Kg(s.stats.totalCostUsd)})]}),n.jsxs("span",{children:["Tokens: ",n.jsx("strong",{style:{color:"#e2e8f5"},children:Jg(s.stats.totalTokens)})]})]}),n.jsxs("div",{style:{flex:1,overflow:"auto",padding:14},children:[i&&!s&&n.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:11},children:"Loading…"}),c&&n.jsx("div",{style:{color:"#fca5a5",fontSize:11},children:c}),s&&n.jsxs(n.Fragment,{children:[n.jsx("pre",{style:{margin:0,fontFamily:'ui-monospace, "SF Mono", Menlo, monospace',fontSize:11,lineHeight:1.55,color:"#e2e8f5",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.summaryText||"(no activity in this window)"}),s.recentLessons.length>0&&n.jsxs("div",{style:{marginTop:16,paddingTop:12,borderTop:"1px solid rgba(255,255,255,0.06)"},children:[n.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:.6,color:"#a5b4fc",marginBottom:6},children:"Lessons learned (Reflexion)"}),s.recentLessons.map((p,g)=>n.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.8)",padding:"4px 0",borderBottom:"1px dashed rgba(255,255,255,0.04)"},children:["• ",p]},g))]})]})]})]})}function Us({label:t,value:e,color:s}){return n.jsxs("div",{style:{textAlign:"center",padding:"6px 4px",borderRadius:6,background:"rgba(255,255,255,0.02)"},children:[n.jsx("div",{style:{fontSize:18,fontWeight:700,color:s,lineHeight:1},children:e}),n.jsx("div",{style:{fontSize:9,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:.5,marginTop:4},children:t})]})}const Fs={pending:"#737373",running:"#60a5fa",done:"#34d399",failed:"#ef4444",skipped:"#a78bfa"},to=6e3,St=180,ar=64,so=96,$s=24;function Qg(t){const e=new Map,s=new Map(t.map(i=>[i.id,i])),r=(i,o)=>{if(e.has(i))return e.get(i);if(o.has(i))return 0;const c=s.get(i);if(!c)return 0;o.add(i);const d=(c.dependsOn??[]).filter(p=>s.has(p)),l=d.length===0?0:Math.max(...d.map(p=>r(p,o)))+1;return o.delete(i),e.set(i,l),l};for(const i of t)r(i.id,new Set);return e}function Zg(){const[t,e]=w.useState([]),[s,r]=w.useState(null),[i,o]=w.useState(null),[c,d]=w.useState(null),[l,p]=w.useState(null),g=w.useCallback(async()=>{try{const v=await ge("/api/missions/active");if(!v.ok)throw new Error(`${v.status} ${v.statusText}`);const m=(await v.json()).missions||[];e(m),!s&&m.length>0&&r(m[0].goalId)}catch(v){d(v.message||"failed")}},[s]),u=w.useCallback(async v=>{try{const A=await ge(`/api/mission/${encodeURIComponent(v)}`);if(!A.ok)throw new Error(`${A.status} ${A.statusText}`);const m=await A.json();o(m),d(null)}catch(A){d(A.message||"failed to load mission"),o(null)}},[]);w.useEffect(()=>{g();const v=setInterval(g,to);return()=>clearInterval(v)},[g]),w.useEffect(()=>{if(!s){o(null);return}u(s);const v=setInterval(()=>u(s),to);return()=>clearInterval(v)},[s,u]);const{layout:f,edges:x,viewBox:y}=w.useMemo(()=>{if(!(i!=null&&i.goal.subtasks))return{layout:[],edges:[],viewBox:"0 0 600 200"};const v=i.goal.subtasks,A=Qg(v),m=new Map;for(const R of v){const P=A.get(R.id)??0;m.has(P)||m.set(P,[]),m.get(P).push(R)}const k=Array.from(m.keys()).sort((R,P)=>R-P),_=Math.max(...Array.from(m.values()).map(R=>R.length),1),T=Math.max(640,_*(St+$s)+$s),S=k.length*so+ar+40,C=new Map,D=[];for(const R of k){const P=m.get(R),B=P.length*St+(P.length-1)*$s,z=(T-B)/2,J=R*so+20;for(let H=0;H<P.length;H++){const K=z+H*(St+$s);C.set(P[H].id,{x:K,y:J}),D.push({...P[H],x:K,y:J})}}const j=[];for(const R of v){const P=C.get(R.id);if(P)for(const B of R.dependsOn??[]){const z=C.get(B);z&&j.push({from:B,to:R.id,x1:z.x+St/2,y1:z.y+ar,x2:P.x+St/2,y2:P.y})}}return{layout:D,edges:j,viewBox:`0 0 ${T} ${S}`}},[i]),E=w.useMemo(()=>new Map(((i==null?void 0:i.goal.subtasks)??[]).map(v=>[v.id,v])),[i]),L=l?E.get(l):null;return n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:10},children:[n.jsxs("div",{style:{flex:1},children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Mission graph"}),n.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:[t.length," active mission(s) · subtask DAG"]})]}),t.length>0&&n.jsx("select",{value:s??"",onChange:v=>r(v.target.value||null),style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"#fff",fontSize:11,padding:"4px 8px",maxWidth:240},children:t.map(v=>n.jsxs("option",{value:v.goalId,children:[v.title," [",v.phase,"]"]},v.goalId))})]}),c&&n.jsx("div",{style:{padding:10,color:"#fca5a5",fontSize:11},children:c}),n.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[n.jsx("div",{style:{flex:1,overflow:"auto",padding:14},children:i?f.length===0?n.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.45)",fontSize:12,textAlign:"center"},children:"This mission has no subtasks yet."}):n.jsxs("svg",{viewBox:y,style:{width:"100%",height:"auto"},role:"img","aria-label":"Mission subtask DAG",children:[n.jsx("defs",{children:n.jsx("marker",{id:"mg-arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:n.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"rgba(255,255,255,0.35)"})})}),x.map((v,A)=>n.jsx("line",{x1:v.x1,y1:v.y1,x2:v.x2,y2:v.y2,stroke:"rgba(255,255,255,0.25)",strokeWidth:"1.4",markerEnd:"url(#mg-arrow)"},`e-${A}`)),f.map(v=>{var _;const A=((_=i.driver)==null?void 0:_.currentSubtaskId)===v.id,m=Fs[v.status],k=l===v.id;return n.jsxs("g",{transform:`translate(${v.x}, ${v.y})`,onClick:()=>p(v.id),style:{cursor:"pointer"},children:[n.jsx("rect",{width:St,height:ar,rx:"8",fill:A?`${m}22`:"rgba(255,255,255,0.04)",stroke:k||A?m:`${m}55`,strokeWidth:A||k?2:1}),n.jsx("circle",{cx:14,cy:14,r:"5",fill:m,children:v.status==="running"&&n.jsx("animate",{attributeName:"r",values:"4;6;4",dur:"1.2s",repeatCount:"indefinite"})}),n.jsx("text",{x:28,y:18,fontSize:"11",fontWeight:"600",fill:"#fafafa",children:v.title.length>22?v.title.slice(0,21)+"…":v.title}),n.jsxs("text",{x:28,y:34,fontSize:"9",fill:"rgba(255,255,255,0.55)",letterSpacing:"0.5",style:{textTransform:"uppercase"},children:[v.status,v.retries>0?` · ${v.retries} retr${v.retries===1?"y":"ies"}`:""]}),n.jsxs("text",{x:14,y:52,fontSize:"9",fill:"rgba(255,255,255,0.45)",children:[(v.description||"").slice(0,30),(v.description||"").length>30?"…":""]}),A&&n.jsx("text",{x:St-8,y:14,fontSize:"8",fill:m,textAnchor:"end",fontWeight:"700",children:"NOW"})]},v.id)})]}):n.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.45)",fontSize:12,textAlign:"center"},children:t.length===0?"No active missions. Launch one via the Mission Driver widget.":"Select a mission to view its graph."})}),L&&n.jsxs("div",{style:{width:260,borderLeft:"1px solid rgba(255,255,255,0.06)",padding:14,overflow:"auto",fontSize:11},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#fafafa",flex:1},children:L.title}),n.jsx("button",{onClick:()=>p(null),style:{background:"transparent",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:14,padding:0,marginLeft:6},children:"×"})]}),n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("span",{style:{padding:"2px 8px",borderRadius:4,fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,background:`${Fs[L.status]}22`,border:`1px solid ${Fs[L.status]}55`,color:Fs[L.status]},children:L.status}),L.retries>0&&n.jsxs("span",{style:{marginLeft:6,color:"rgba(255,255,255,0.5)"},children:[L.retries," retries"]})]}),n.jsx("div",{style:{color:"rgba(255,255,255,0.85)",lineHeight:1.5,marginBottom:10},children:L.description}),L.dependsOn.length>0&&n.jsxs("div",{style:{color:"rgba(255,255,255,0.55)",fontSize:10,marginBottom:6},children:[n.jsx("strong",{children:"Depends on:"})," ",L.dependsOn.map(v=>{var A;return((A=E.get(v))==null?void 0:A.title)||v}).join(", ")]}),L.completedAt&&n.jsxs("div",{style:{color:"rgba(255,255,255,0.45)",fontSize:10},children:["Completed: ",new Date(L.completedAt).toLocaleString()]})]})]}),i&&n.jsxs("div",{style:{padding:"6px 14px",borderTop:"1px solid rgba(255,255,255,0.06)",display:"flex",justifyContent:"space-between",fontSize:10,color:"rgba(255,255,255,0.55)"},children:[n.jsxs("span",{children:[i.goal.subtasks.length," subtasks · ",i.goal.progress,"% progress"]}),i.driver&&n.jsxs("span",{children:[i.driver.phase," · $",i.driver.budget.costUsd.toFixed(2)," spent"]})]})]})}function ey(){const[t,e]=w.useState([]),[s,r]=w.useState(!0),[i,o]=w.useState(null),c=async()=>{try{const d=await fetch("/api/agents");if(!d.ok)throw new Error(`HTTP ${d.status}`);const l=await d.json();e(Array.isArray(l)?l:l.agents||[]),o(null)}catch(d){o(d.message)}finally{r(!1)}};return w.useEffect(()=>{c();const d=setInterval(c,1e4);return()=>clearInterval(d)},[]),s?n.jsx("div",{className:"w-full h-full flex items-center justify-center",children:n.jsx(oo,{className:"w-4 h-4 text-[#6366f1] animate-spin"})}):i?n.jsx("div",{className:"w-full h-full flex items-center justify-center p-4",children:n.jsxs("div",{className:"text-center",children:[n.jsx(gn,{className:"w-4 h-4 text-red-400 mx-auto mb-1"}),n.jsx("span",{className:"text-[10px] text-red-400",children:i})]})}):t.length===0?n.jsx("div",{className:"w-full h-full flex items-center justify-center p-4",children:n.jsx("span",{className:"text-[10px] text-[#52525b]",children:"No active agents"})}):n.jsx("div",{className:"w-full h-full p-3 overflow-auto",children:n.jsx("div",{className:"space-y-2",children:t.map(d=>n.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsx(Dr,{className:`w-3.5 h-3.5 ${d.status==="busy"?"text-[#f59e0b]":d.status==="error"?"text-red-400":"text-[#6366f1]"}`}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-[11px] text-[#a1a1aa] truncate",children:d.name}),n.jsxs("div",{className:"text-[10px] text-[#52525b] truncate",children:[d.role,d.model?` · ${d.model}`:""]})]}),n.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase ${d.status==="busy"?"bg-[#f59e0b]/10 text-[#f59e0b]":d.status==="error"?"bg-red-400/10 text-red-400":"bg-[#6366f1]/10 text-[#818cf8]"}`,children:d.status})]},d.id))})})}function ty(){const[t,e]=w.useState(null),[s,r]=w.useState(!0),i=async()=>{try{const[c,d]=await Promise.allSettled([fetch("/api/health").then(g=>g.ok?g.json():null),fetch("/ollama/api/tags").then(g=>g.ok)]),l=c.status==="fulfilled"&&c.value,p=d.status==="fulfilled"&&d.value;e({gateway:l,ollama:p,version:(l==null?void 0:l.version)||"unknown",uptime:(l==null?void 0:l.uptime)||0})}catch{e({gateway:!1,ollama:!1,version:"unknown",uptime:0})}finally{r(!1)}};if(w.useEffect(()=>{i();const c=setInterval(i,3e4);return()=>clearInterval(c)},[]),s)return n.jsx("div",{className:"w-full h-full flex items-center justify-center",children:n.jsx(oo,{className:"w-4 h-4 text-[#6366f1] animate-spin"})});const o=c=>{const d=Math.floor(c/3600),l=Math.floor(c%3600/60);return`${d}h ${l}m`};return n.jsx("div",{className:"w-full h-full p-3 overflow-auto",children:n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[t!=null&&t.gateway?n.jsx(Ml,{className:"w-3.5 h-3.5 text-emerald-400"}):n.jsx(ql,{className:"w-3.5 h-3.5 text-red-400"}),n.jsx("span",{className:"text-[11px] text-[#a1a1aa]",children:"TITAN Gateway"})]}),n.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase ${t!=null&&t.gateway?"bg-emerald-400/10 text-emerald-400":"bg-red-400/10 text-red-400"}`,children:t!=null&&t.gateway?"Online":"Offline"})]}),n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Yt,{className:`w-3.5 h-3.5 ${t!=null&&t.ollama?"text-emerald-400":"text-red-400"}`}),n.jsx("span",{className:"text-[11px] text-[#a1a1aa]",children:"Ollama"})]}),n.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase ${t!=null&&t.ollama?"bg-emerald-400/10 text-emerald-400":"bg-red-400/10 text-red-400"}`,children:t!=null&&t.ollama?"Online":"Offline"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsx("div",{className:"text-[9px] text-[#52525b] uppercase tracking-wider",children:"Version"}),n.jsx("div",{className:"text-[11px] text-[#a1a1aa] font-mono mt-0.5",children:t==null?void 0:t.version})]}),n.jsxs("div",{className:"px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsx("div",{className:"text-[9px] text-[#52525b] uppercase tracking-wider",children:"Uptime"}),n.jsx("div",{className:"text-[11px] text-[#a1a1aa] font-mono mt-0.5",children:o((t==null?void 0:t.uptime)||0)})]})]})]})})}function zs({label:t,value:e,icon:s,color:r,unknown:i}){const o=Math.max(0,Math.min(100,Math.round(e)));return n.jsxs("div",{className:"px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[s,n.jsx("span",{className:"text-[10px] text-[#52525b] uppercase tracking-wider",children:t})]}),n.jsx("span",{className:"text-[11px] text-[#a1a1aa] font-mono",children:i?"—":`${o}%`})]}),n.jsx("div",{className:"h-1.5 rounded-full bg-[#27272a] overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:i?"0%":`${o}%`,backgroundColor:r}})})]})}function sy(){const[t,e]=w.useState({cpu:0,memory:0,disk:0,load:0,loaded:!1,error:null,diskAvailable:!0});w.useEffect(()=>{let r=!1;async function i(){try{const c=await ge("/api/stats");if(!c.ok){const y=`HTTP ${c.status}`;r||e(E=>({...E,loaded:!0,error:y}));return}const d=await c.json();if(r)return;const l=d.host;if(!l){e(y=>({...y,loaded:!0,error:"no host metrics"}));return}const p=typeof l.cpuPercent=="number"?l.cpuPercent:0,g=typeof l.memPercent=="number"?l.memPercent:0,u=typeof l.diskPercent=="number"?l.diskPercent:0,f=l.cores||1,x=typeof l.loadAvg1=="number"?Math.min(100,l.loadAvg1/f*100):0;e({cpu:p,memory:g,disk:u,load:x,loaded:!0,error:null,diskAvailable:!l.diskError})}catch(c){r||e(d=>({...d,loaded:!0,error:c.message}))}}i();const o=setInterval(i,3e3);return()=>{r=!0,clearInterval(o)}},[]);const s=!t.loaded||!!t.error;return n.jsxs("div",{className:"w-full h-full p-3 overflow-auto",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(zs,{label:"CPU",value:t.cpu,icon:n.jsx(Rr,{className:"w-3 h-3 text-[#6366f1]"}),color:"#6366f1",unknown:s}),n.jsx(zs,{label:"Memory",value:t.memory,icon:n.jsx(Ol,{className:"w-3 h-3 text-[#a78bfa]"}),color:"#a78bfa",unknown:s}),n.jsx(zs,{label:"Disk",value:t.disk,icon:n.jsx(Pl,{className:"w-3 h-3 text-[#10b981]"}),color:"#10b981",unknown:s||!t.diskAvailable}),n.jsx(zs,{label:"Load",value:t.load,icon:n.jsx(Yt,{className:"w-3 h-3 text-[#f59e0b]"}),color:"#f59e0b",unknown:s})]}),t.error&&n.jsx("div",{className:"mt-2 text-[10px] text-[#ef4444]/80",children:t.error})]})}const ny=[{label:"Nav",source:"system:nav",w:3,h:4,icon:n.jsx(ec,{className:"w-3.5 h-3.5"})},{label:"Agents",source:"system:agents",w:3,h:4,icon:n.jsx(Dr,{className:"w-3.5 h-3.5"})},{label:"Health",source:"system:health",w:3,h:3,icon:n.jsx(Yt,{className:"w-3.5 h-3.5"})},{label:"Stats",source:"system:stats",w:3,h:4,icon:n.jsx(oc,{className:"w-3.5 h-3.5"})},{label:"Chat",source:"system:chat",w:4,h:5,icon:n.jsx(xn,{className:"w-3.5 h-3.5"})},{label:"Files",source:"system:files",w:4,h:6,icon:n.jsx(yn,{className:"w-3.5 h-3.5"})},{label:"Skills",source:"system:tools",w:5,h:4,icon:n.jsx(mn,{className:"w-3.5 h-3.5"})},{label:"Soma",source:"system:soma",w:6,h:6,icon:n.jsx(Wl,{className:"w-3.5 h-3.5"})},{label:"Intel",source:"system:intelligence",w:6,h:5,icon:n.jsx(xt,{className:"w-3.5 h-3.5"})},{label:"Infra",source:"system:infra",w:6,h:4,icon:n.jsx(Ir,{className:"w-3.5 h-3.5"})},{label:"Tools",source:"system:tools",w:5,h:4,icon:n.jsx(Tr,{className:"w-3.5 h-3.5"})},{label:"Settings",source:"system:settings",w:4,h:6,icon:n.jsx(Cr,{className:"w-3.5 h-3.5"})},{label:"Wiki",source:"system:memory-wiki",w:5,h:5,icon:n.jsx(ps,{className:"w-3.5 h-3.5"})},{label:"Research",source:"system:autoresearch",w:5,h:5,icon:n.jsx(po,{className:"w-3.5 h-3.5"})},{label:"Proposals",source:"system:self-proposals",w:5,h:5,icon:n.jsx(bo,{className:"w-3.5 h-3.5"})},{label:"Overview",source:"system:overview",w:5,h:4,icon:n.jsx(ro,{className:"w-3.5 h-3.5"})},{label:"Sessions",source:"system:sessions",w:5,h:4,icon:n.jsx(ms,{className:"w-3.5 h-3.5"})},{label:"Watch",source:"system:watch",w:6,h:5,icon:n.jsx(Yt,{className:"w-3.5 h-3.5"})},{label:"Backup",source:"system:backup",w:5,h:5,icon:n.jsx(mo,{className:"w-3.5 h-3.5"})},{label:"Training",source:"system:training",w:5,h:5,icon:n.jsx(xt,{className:"w-3.5 h-3.5"})},{label:"Recipes",source:"system:recipes",w:5,h:5,icon:n.jsx(ps,{className:"w-3.5 h-3.5"})},{label:"VRAM",source:"system:vram",w:5,h:5,icon:n.jsx(Rr,{className:"w-3.5 h-3.5"})},{label:"Teams",source:"system:teams",w:5,h:5,icon:n.jsx(Ar,{className:"w-3.5 h-3.5"})},{label:"Cron",source:"system:cron",w:5,h:5,icon:n.jsx(ms,{className:"w-3.5 h-3.5"})},{label:"Checkpoints",source:"system:checkpoints",w:5,h:5,icon:n.jsx(bn,{className:"w-3.5 h-3.5"})},{label:"Organism",source:"system:organism",w:5,h:5,icon:n.jsx(Lr,{className:"w-3.5 h-3.5"})},{label:"Fleet",source:"system:fleet",w:5,h:5,icon:n.jsx(go,{className:"w-3.5 h-3.5"})},{label:"Browser",source:"system:browser",w:5,h:5,icon:n.jsx(io,{className:"w-3.5 h-3.5"})},{label:"Eval",source:"system:eval",w:5,h:5,icon:n.jsx(yo,{className:"w-3.5 h-3.5"})}];function ry(){const t=(e,s,r)=>{window.dispatchEvent(new CustomEvent("titan:widget:add",{detail:{source:e,w:s,h:r}}))};return n.jsx("div",{className:"w-full h-full p-3 overflow-auto",children:n.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:ny.map(e=>n.jsxs("button",{onClick:()=>t(e.source,e.w,e.h),className:"flex items-center gap-2 px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a] text-[#71717a] hover:text-[#a1a1aa] hover:border-[#3f3f46] hover:bg-[#27272a]/30 transition-all text-left",children:[n.jsx("span",{className:"text-[#6366f1]",children:e.icon}),n.jsx("span",{className:"text-[10px] font-medium",children:e.label})]},e.source))})})}class iy extends oe.Component{componentDidCatch(e){this.props.onError(e.message)}render(){return this.props.children}}function oy({name:t,children:e}){const[s,r]=oe.useState(null);return s?n.jsx("div",{className:"w-full h-full flex items-center justify-center p-4",children:n.jsxs("span",{className:"text-xs text-red-400",children:[t,": ",s]})}):n.jsx(iy,{onError:r,children:e})}const ay=oe.lazy(()=>le(()=>import("./legacy-VWR8oDEy.js"),__vite__mapDeps([106,1,2,4])).then(t=>({default:t.Responsive}))),ly={"system:nav":$f,"system:chat":fl,"system:cmd":_l,"system:soma":kl,"system:command-post":rm,"system:intelligence":om,"system:memory-graph":lm,"system:voice":cm,"system:infra":um,"system:tools":fm,"system:settings":mm,"system:files":gm,"system:settings-general":bm,"system:settings-security":wm,"system:settings-audit":_m,"system:settings-specialists":Sm,"system:settings-privacy":Em,"system:intelligence-autopilot":Cm,"system:intelligence-workflows":Rm,"system:intelligence-learning":Lm,"system:intelligence-self-improve":Dm,"system:intelligence-personas":Om,"system:intelligence-persona-profiles":Wm,"system:intelligence-dream":Um,"system:infra-homelab":$m,"system:infra-gpu":Hm,"system:infra-files":Gm,"system:infra-logs":Ym,"system:infra-telemetry":Jm,"system:tools-skills":Qm,"system:tools-mcp":eg,"system:tools-integrations":sg,"system:tools-channels":rg,"system:tools-mesh":og,"system:agents":ey,"system:health":ty,"system:stats":sy,"system:quick-links":ry,"system:memory-wiki":lg,"system:autoresearch":dg,"system:self-proposals":hg,"system:overview":pg,"system:sessions":gg,"system:watch":bg,"system:backup":wg,"system:training":_g,"system:recipes":Sg,"system:vram":Eg,"system:teams":Cg,"system:cron":Rg,"system:checkpoints":Lg,"system:organism":Dg,"system:fleet":Og,"system:browser":Wg,"system:eval":Ug,"system:time-travel":zg,"system:mission-driver":Gg,"system:daily-digest":Xg,"system:mission-graph":Zg},cy={lg:12,md:10,sm:6,xs:4,xxs:2},dy=60,uy={lg:1200,md:996,sm:768,xs:480,xxs:0},hy=[12,12],fy=["se","sw","ne","nw","e","w","n","s"],py=[{source:"system:nav",name:"Nav",w:3,h:4,label:"Navigation",icon:pc},{source:"system:agents",name:"Agents",w:3,h:4,label:"Agents",icon:Dr},{source:"system:health",name:"Health",w:3,h:3,label:"Health",icon:cc},{source:"system:stats",name:"Stats",w:3,h:4,label:"Stats",icon:Yl},{source:"system:quick-links",name:"Quick Links",w:3,h:4,label:"Links",icon:Kl},{source:"system:chat",name:"Chat",w:4,h:5,label:"Chat",icon:xn}],Sl=oe.forwardRef(({widget:t,space:e,onRemove:s,style:r,className:i,onMouseDown:o,onMouseUp:c,onTouchStart:d,onTouchEnd:l,children:p},g)=>{const u=w.useCallback(()=>s(t.id),[t.id,s]);return n.jsxs("div",{ref:g,style:r,className:i,onMouseDown:o,onMouseUp:c,onTouchStart:d,onTouchEnd:l,children:[n.jsx(yy,{widget:t,space:e,onRemove:u}),p]})});Sl.displayName="MemoWidgetItem";const my=oe.memo(Sl);function gy({widget:t,space:e,onRemove:s}){const r=w.useRef(null),i=w.useRef(null),o=w.useRef(e),[c,d]=w.useState(null),[l,p]=w.useState(!0);if(w.useEffect(()=>{o.current=e},[e]),w.useEffect(()=>{if(t.format==="system"||!r.current)return;if(!t.source||t.source.trim()===""){d("Empty widget — no source code"),p(!1);return}p(!0),d(null),i.current=new cl(r.current,{onLog:u=>console.log(`[Widget ${t.id}]`,u)}),i.current.setMessageHandler(u=>{var x,y,E,L;const f=o.current;if(u.type==="canvas"&&((x=u.payload)==null?void 0:x.action)==="createWidget"){const v=u.payload.def;if(!v)return{ok:!1,error:"createWidget requires a `def` object"};const A=Number.isFinite(v.w)?v.w:4,m=Number.isFinite(v.h)?v.h:4,k=Number.isFinite(v.x)&&Number.isFinite(v.y)?{x:v.x,y:v.y}:Ys(f.widgets||[],A,m);try{const _=ke.addWidget(f.id,{name:v.name||"Agent Widget",format:v.format||"react",source:v.source||"",x:k.x,y:k.y,w:A,h:m});return window.dispatchEvent(new CustomEvent("titan:space:refresh",{detail:{spaceId:f.id}})),{ok:!0,widgetId:_.id}}catch(_){return{ok:!1,error:_.message}}}if(u.type==="canvas"&&((y=u.payload)==null?void 0:y.action)==="updateWidget"){const{id:v,patch:A}=u.payload;return v?(ke.updateWidget(f.id,v,A||{}),window.dispatchEvent(new CustomEvent("titan:space:refresh",{detail:{spaceId:f.id}})),{ok:!0,id:v}):{ok:!1,error:"updateWidget requires an `id`"}}if(u.type==="canvas"&&((E=u.payload)==null?void 0:E.action)==="listWidgets")return{ok:!0,widgets:f.widgets||[]};if(u.type==="canvas"&&((L=u.payload)==null?void 0:L.action)==="removeWidget"){const v=u.payload.id;return v?(ke.removeWidget(f.id,v),window.dispatchEvent(new CustomEvent("titan:space:refresh",{detail:{spaceId:f.id}})),{ok:!0}):{ok:!1,error:"removeWidget requires an `id`"}}return{ok:!1,error:"Unknown message type"}});const g=setTimeout(()=>{p(!1),d("Sandbox timeout: widget took longer than 30s to render. The widget source may have an infinite loop or an unhandled exception. Open DevTools (F12) → Console to see the iframe-side error.")},3e4);return i.current.render(t.format,t.source).then(()=>{clearTimeout(g),p(!1)}).catch(u=>{clearTimeout(g),p(!1),d(String(u))}),()=>{var u;clearTimeout(g),(u=i.current)==null||u.destroy()}},[t.format,t.source,t.id]),t.format==="system"){const g=ly[t.source];return g?n.jsxs("div",{className:"w-full h-full rounded-xl overflow-hidden flex flex-col group transition-colors shadow-md",style:{background:"var(--color-desk-widget-bg)",border:"1px solid var(--color-desk-border)",boxShadow:"0 4px 12px var(--theme-shadow, rgba(60,40,15,0.15))"},children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b panel-drag-handle cursor-move",style:{borderColor:"var(--color-desk-border-light)",background:"var(--theme-leather, rgba(58,37,24,0.05))"},children:[n.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--color-desk-accent)"},children:t.name}),n.jsx("button",{onClick:s,className:"opacity-0 group-hover:opacity-100 text-xs px-1 transition-opacity",style:{color:"var(--color-desk-text-muted)"},children:"×"})]}),n.jsx("div",{className:"flex-1 overflow-auto relative",children:n.jsx(oy,{name:t.name,children:n.jsx(g,{space:e,widget:t,onRemove:s})})})]}):n.jsxs("div",{className:"w-full h-full flex items-center justify-center text-xs text-red-400",children:["Unknown system widget: ",t.source]})}return n.jsxs("div",{className:"w-full h-full rounded-xl overflow-hidden flex flex-col shadow-md",style:{background:"var(--color-desk-widget-bg)",border:"1px solid var(--color-desk-border)",boxShadow:"0 4px 12px var(--theme-shadow, rgba(60,40,15,0.15))"},children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b panel-drag-handle cursor-move",style:{borderColor:"var(--color-desk-border-light)",background:"var(--theme-leather, rgba(58,37,24,0.05))"},children:[n.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--color-desk-accent)"},children:t.name}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{onClick:g=>{g.stopPropagation(),window.dispatchEvent(new CustomEvent("titan:widget:edit",{detail:{spaceId:e.id,widgetId:t.id}}))},onMouseDown:g=>g.stopPropagation(),className:"px-1",style:{color:"var(--color-desk-text-muted)"},title:"Edit widget",children:n.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"m18 2 4 4-14 14H4v-4L18 2z"})})}),n.jsx("button",{onClick:s,className:"text-xs px-1",style:{color:"var(--color-desk-text-muted)"},children:"×"})]})]}),n.jsx("div",{className:"flex-1 relative",children:c?n.jsx("div",{className:"p-3 text-xs text-red-400 font-mono whitespace-pre-wrap",children:c}):n.jsxs(n.Fragment,{children:[n.jsx("iframe",{ref:r,className:"w-full h-full border-0",sandbox:"allow-scripts",title:t.name}),l&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-xs",style:{background:"var(--theme-paper, rgba(253,246,227,0.85))",color:"var(--color-desk-text-muted)",fontFamily:"var(--theme-font-display, 'Georgia', serif)"},children:n.jsx("span",{className:"animate-pulse",children:"Loading widget…"})})]})})]})}const yy=oe.memo(gy);function Ft({label:t,onClick:e,children:s,variant:r="default",disabled:i}){return n.jsx("button",{type:"button",onClick:e,disabled:i,className:`titan-canvas-icon-button titan-canvas-icon-button--${r}`,title:t,"aria-label":t,children:s})}function by(){const{spaceId:t}=Bl(),e=no(),[s,r]=w.useState(null),[i]=w.useState(!1),[o,c]=w.useState(!1),[d,l]=w.useState(null),[p,g]=w.useState(!1),[u,f]=w.useState(!1),[x,y]=w.useState(!1),[E,L]=w.useState(1200),v=w.useRef(null),A=w.useRef(null),{info:m,triggerUpdate:k,waitForReload:_}=Pf(),[T,S]=w.useState(!1);w.useEffect(()=>{const $=t||"home",F=ke.get($);F?r(F):e("/space/home",{replace:!0})},[t,e]),w.useEffect(()=>{const $=()=>{const se=A.current;if(!se)return null;const q=new ResizeObserver(te=>{for(const Q of te)L(Q.contentRect.width)});return q.observe(se),L(se.getBoundingClientRect().width||1200),q};let F=$();const V=setInterval(()=>{F||(F=$()),F&&clearInterval(V)},200);return()=>{F==null||F.disconnect(),clearInterval(V)}},[s==null?void 0:s.id]),w.useEffect(()=>{const $=F=>{(F.metaKey||F.ctrlKey)&&F.key==="k"&&(F.preventDefault(),f(V=>!V)),(F.metaKey||F.ctrlKey)&&F.key==="j"&&(F.preventDefault(),window.dispatchEvent(new CustomEvent("titan:chat:toggle")))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[]),Wf([{key:"?",action:()=>y(!0),description:"Show keyboard shortcuts help"},{key:"g",shift:!0,action:()=>e("/space/command"),description:"Go to Command Post space"},{key:"h",shift:!0,action:()=>e("/space/home"),description:"Go to Home space"},{key:"s",shift:!0,action:()=>e("/space/settings"),description:"Go to Settings space"},{key:"i",shift:!0,action:()=>e("/space/intelligence"),description:"Go to Intelligence space"}]);const C=w.useCallback(()=>{},[]),D=w.useRef(null),j=w.useRef(null),R=w.useCallback($=>{s&&(j.current=$,D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{const F=j.current;!F||!s||(ke.updateLayout(s.id,F.map(V=>({i:V.i,x:V.x,y:V.y,w:V.w,h:V.h}))),j.current=null,D.current=null)},50))},[s]),P=w.useCallback($=>{var se;if(!s)return;const F=(se=s.widgets)==null?void 0:se.find(q=>q.id===$);Wn("canvas_panel_removed",{widgetId:$,format:F==null?void 0:F.format,source:F==null?void 0:F.source}),ke.removeWidget(s.id,$);const V=Array.isArray(s.widgets)?s.widgets:[];r({...s,widgets:V.filter(q=>q.id!==$)})},[s]),B=w.useCallback($=>{if(!s)return;const F=ke.addWidget(s.id,$),V=Array.isArray(s.widgets)?s.widgets:[];return r({...s,widgets:[...V,F]}),Wn($.format==="system"?"canvas_system_panel_created":"canvas_panel_created",{source:$.source,name:$.name,format:$.format}),F},[s]),z=w.useCallback(($,F)=>{if(!s||!Array.isArray(s.widgets)||s.widgets.length===0)return{x:0,y:0};const V=12,se=new Set;for(const q of s.widgets)for(let te=0;te<q.w;te++)for(let Q=0;Q<q.h;Q++)se.add(`${q.x+te},${q.y+Q}`);for(let q=0;q<200;q++)for(let te=0;te<=V-$;te++){let Q=!0;for(let be=0;be<$;be++){for(let Ce=0;Ce<F;Ce++)if(se.has(`${te+be},${q+Ce}`)){Q=!1;break}if(!Q)break}if(Q)return{x:te,y:q}}return{x:0,y:0}},[s]),J=w.useCallback(($,F,V=4,se=4)=>{const q=z(V,se);B({name:F,format:"system",source:$,x:q.x,y:q.y,w:V,h:se})},[B,z]);w.useEffect(()=>{const $=F=>{const V=F.detail;if(console.log("[TitanCanvas] titan:space:refresh received:",V),!!s&&(V==null?void 0:V.spaceId)===s.id){const se=ke.get(s.id);se&&(console.log("[TitanCanvas] Refreshing space, widget count:",se.widgets.length),r(se))}};return window.addEventListener("titan:space:refresh",$),()=>window.removeEventListener("titan:space:refresh",$)},[s]),w.useEffect(()=>{const $=F=>{const V=F.detail;if(s&&V!=null&&V.source){const se=Number.isFinite(V.w)?V.w:4,q=Number.isFinite(V.h)?V.h:4,te=typeof V.name=="string"&&V.name.trim()?V.name.trim():String(V.source).replace("system:","").replace(/-/g," "),Q=V.format==="react"||V.format==="vanilla"||V.format==="html"||V.format==="system"?V.format:String(V.source).startsWith("system:")?"system":"react",be=z(se,q);B({name:te,format:Q,source:String(V.source),x:be.x,y:be.y,w:se,h:q})}};return window.addEventListener("titan:widget:add",$),()=>window.removeEventListener("titan:widget:add",$)},[s,B,z]),w.useEffect(()=>{const $=F=>{const V=F.detail;s&&(V==null?void 0:V.spaceId)===s.id&&typeof(V==null?void 0:V.widgetId)=="string"&&l(V.widgetId)};return window.addEventListener("titan:widget:edit",$),()=>window.removeEventListener("titan:widget:edit",$)},[s]),w.useEffect(()=>s?ke.observe(s.id,F=>{console.log("[TitanCanvas] CRDT observer fired, widgets:",F.length),r(V=>V&&{...V,widgets:F})}):void 0,[s==null?void 0:s.id]);const H=w.useMemo(()=>{const $=s==null?void 0:s.widgets;return Array.isArray($)?$.filter(Boolean):[]},[s]),K=w.useMemo(()=>H.map(($,F)=>({i:$.id,x:Number.isFinite($.x)?$.x:F%3*4,y:Number.isFinite($.y)?$.y:Math.floor(F/3)*4,w:Number.isFinite($.w)?$.w:4,h:Number.isFinite($.h)?$.h:4,minW:2,minH:2,maxW:12,maxH:40})),[H]);return s?n.jsxs("div",{className:"h-full w-full flex",children:[n.jsx(Bp,{}),n.jsxs("div",{ref:v,className:"flex-1 relative overflow-auto",children:[n.jsx("style",{children:`
993
+ <div style="padding:16px;color:#e4e4e7">Hello, widget!</div>`,iframe:"",system:""};function qp(t){return String(t||"").startsWith("system:")?"system":"react"}const Yp={productivity:"#a78bfa",finance:"#34d399","health-fitness":"#f472b6","music-dj":"#c084fc",creative:"#fb923c",travel:"#60a5fa",gaming:"#f87171",social:"#38bdf8",cooking:"#fbbf24",vehicle:"#94a3b8",homelab:"#a3e635","ml-ai":"#818cf8",research:"#2dd4bf",document:"#f9a8d4",devops:"#fcd34d","e-commerce":"#fda4af",lifestyle:"#86efac",web:"#67e8f9",data:"#d8b4fe","multi-modal":"#fdba74",automation:"#facc15","smart-home":"#bef264",agents:"#e879f9","software-builder":"#7dd3fc",utilities:"#a5b4fc",media:"#fca5a5",communication:"#5eead4",education:"#c4b5fd",misc:"#9ca3af"};function Kp(t){return t.split(/[-_/]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Jp({open:t,onClose:e}){const[s,r]=w.useState([]),[i,o]=w.useState([]),[c,d]=w.useState("All"),[l,p]=w.useState(""),[g,u]=w.useState(null),[f,x]=w.useState(!1),[y,E]=w.useState(null);w.useEffect(()=>{t&&(x(!0),ge("/api/widget-gallery").then(m=>m.json()).then(m=>{r(m.templates||[]),o(m.categories||[]),x(!1)}).catch(m=>{E(m.message),x(!1)}))},[t]),w.useEffect(()=>{if(!t)return;const m=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t,e]);const L=w.useMemo(()=>{const m=c==="All"?s:s.filter(_=>_.category===c),k=l.trim().toLowerCase();return k?m.filter(_=>[_.name,_.description,_.category,..._.tags||[],..._.triggers||[]].join(" ").toLowerCase().includes(k)):m},[c,l,s]);if(!t)return null;const v=async m=>{var k,_,T,S;u(m.id),E(null);try{const C=await ge(`/api/widget-gallery/${encodeURIComponent(m.id)}`);if(!C.ok)throw new Error(`Could not load template (${C.status})`);const D=await C.json(),j={templateId:m.id,templateName:D.name||m.name,source:D.source,format:qp(D.source),defaultSize:{w:((k=D.defaultSize)==null?void 0:k.w)??((_=m.defaultSize)==null?void 0:_.w)??4,h:((T=D.defaultSize)==null?void 0:T.h)??((S=m.defaultSize)==null?void 0:S.h)??4}};window.dispatchEvent(new CustomEvent("titan:gallery:run-template",{detail:j})),e()}catch(C){E(C.message)}finally{u(null)}},A=["All",...i.map(m=>m.category)];return n.jsx("div",{className:"fixed inset-0 z-[2147483150] flex items-center justify-center p-3 sm:p-4 titan-menu-overlay",onClick:e,children:n.jsxs("div",{className:"w-full max-w-5xl titan-widget-gallery-window flex flex-col",style:{height:"min(760px, 92vh)"},onClick:m=>m.stopPropagation(),children:[n.jsxs("div",{className:"titan-widget-gallery-titlebar",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"titan-window-dot"}),n.jsx("span",{className:"titan-window-dot titan-window-dot--dim"}),n.jsx("span",{className:"titan-window-dot titan-window-dot--dim"}),n.jsx(mn,{className:"w-4 h-4 ml-1",style:{color:"var(--theme-accent)"}}),n.jsx("h3",{className:"font-semibold text-sm",style:{color:"var(--theme-ink)",fontFamily:"var(--theme-font-display)"},children:"Widget gallery"}),n.jsx("span",{className:"text-[10px]",style:{color:"var(--theme-ink-soft)"},children:f?"Loading…":`${s.length} templates`})]}),n.jsx("button",{onClick:e,className:"titan-close-btn",title:"Close (Esc)","aria-label":"Close",children:n.jsx(Es,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"titan-widget-gallery-category-row",children:A.map(m=>{var k;return n.jsxs("button",{onClick:()=>d(m),className:`titan-widget-gallery-category ${c===m?"titan-widget-gallery-category--active":""}`,children:[Kp(m),m!=="All"&&n.jsx("span",{className:"ml-1.5 text-[9px] opacity-70",children:((k=i.find(_=>_.category===m))==null?void 0:k.count)??0})]},m)})}),n.jsx("div",{className:"px-4 sm:px-5 py-2 border-b",style:{borderColor:"var(--theme-menu-border)"},children:n.jsxs("label",{className:"titan-widget-gallery-search",children:[n.jsx(uo,{className:"w-3.5 h-3.5"}),n.jsx("input",{value:l,onChange:m=>p(m.target.value),placeholder:"Search templates...",className:"flex-1 bg-transparent text-xs outline-none"})]})}),n.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[f&&n.jsx("div",{className:"flex items-center justify-center h-full text-sm",style:{color:"var(--theme-ink-soft)"},children:"Loading templates…"}),y&&n.jsxs("div",{className:"flex items-center justify-center h-full text-sm",style:{color:"var(--color-error)"},children:["Error: ",y]}),!f&&!y&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:L.map(m=>n.jsxs("button",{onClick:()=>v(m),disabled:g!==null,className:"titan-widget-gallery-card group",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:Yp[m.category]??"#9ca3af"}}),n.jsx("span",{className:"text-[12px] font-medium truncate",style:{color:"var(--theme-ink)"},children:m.name})]}),n.jsx(ho,{className:"w-3 h-3 transition-colors shrink-0"})]}),n.jsx("div",{className:"text-[11px] leading-relaxed line-clamp-2",style:{color:"var(--theme-ink-soft)"},children:g===m.id?"Adding to canvas...":m.description}),m.tags&&m.tags.length>0&&n.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:m.tags.slice(0,3).map(k=>n.jsx("span",{className:"titan-widget-gallery-tag",children:k},k))})]},m.id))}),L.length===0&&n.jsx("div",{className:"flex items-center justify-center h-40 text-sm",style:{color:"var(--theme-ink-soft)"},children:"No templates in this category."})]}),n.jsxs("div",{className:"titan-widget-gallery-note",children:[n.jsx(xo,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),n.jsxs("div",{className:"text-[11px] leading-relaxed",children:["Don’t see what you want? Open the chat (click the mascot) and describe your widget in plain English. TITAN can build anything that runs inside a sandboxed iframe with access to ",n.jsx("span",{className:"font-mono",children:"titan.fetch"}),","," ",n.jsx("span",{className:"font-mono",children:"titan.api.call"}),", and"," ",n.jsx("span",{className:"font-mono",children:"titan.state"}),"."]})]})]})]})})}const Xp=[{type:"widget",source:"system:nav",name:"Nav Widget",w:3,h:4,icon:n.jsx(xo,{className:"w-4 h-4"})},{type:"widget",source:"system:chat",name:"Chat Widget",w:4,h:5,icon:n.jsx(xn,{className:"w-4 h-4"})},{type:"widget",source:"system:soma",name:"SOMA",w:6,h:6,icon:n.jsx(xt,{className:"w-4 h-4"})},{type:"widget",source:"system:command-post",name:"Command Post",w:8,h:6,icon:n.jsx(lo,{className:"w-4 h-4"})},{type:"widget",source:"system:intelligence",name:"Intelligence",w:6,h:5,icon:n.jsx(ao,{className:"w-4 h-4"})},{type:"widget",source:"system:memory-graph",name:"Memory Graph",w:8,h:7,icon:n.jsx(sc,{className:"w-4 h-4"})},{type:"widget",source:"system:voice",name:"Voice",w:5,h:5,icon:n.jsx(fo,{className:"w-4 h-4"})},{type:"widget",source:"system:infra",name:"Infrastructure",w:6,h:4,icon:n.jsx(Ir,{className:"w-4 h-4"})},{type:"widget",source:"system:tools",name:"Tools",w:5,h:4,icon:n.jsx(Tr,{className:"w-4 h-4"})},{type:"widget",source:"system:settings",name:"Settings",w:5,h:5,icon:n.jsx(Cr,{className:"w-4 h-4"})},{type:"widget",source:"system:files",name:"Files",w:4,h:6,icon:n.jsx(yn,{className:"w-4 h-4"})},{type:"widget",source:"system:memory-wiki",name:"Memory Wiki",w:6,h:6,icon:n.jsx(ps,{className:"w-4 h-4"})},{type:"widget",source:"system:autoresearch",name:"Autoresearch",w:6,h:6,icon:n.jsx(po,{className:"w-4 h-4"})},{type:"widget",source:"system:self-proposals",name:"Self-Proposals",w:6,h:6,icon:n.jsx(bo,{className:"w-4 h-4"})},{type:"widget",source:"system:overview",name:"Overview",w:6,h:5,icon:n.jsx(ro,{className:"w-4 h-4"})},{type:"widget",source:"system:sessions",name:"Sessions",w:6,h:5,icon:n.jsx(ms,{className:"w-4 h-4"})},{type:"widget",source:"system:watch",name:"Watch",w:8,h:7,icon:n.jsx(Yt,{className:"w-4 h-4"})},{type:"widget",source:"system:backup",name:"Backup Manager",w:6,h:6,icon:n.jsx(mo,{className:"w-4 h-4"})},{type:"widget",source:"system:training",name:"Training Dashboard",w:6,h:6,icon:n.jsx(xt,{className:"w-4 h-4"})},{type:"widget",source:"system:recipes",name:"Recipe Kitchen",w:6,h:6,icon:n.jsx(ps,{className:"w-4 h-4"})},{type:"widget",source:"system:vram",name:"VRAM Monitor",w:6,h:6,icon:n.jsx(Rr,{className:"w-4 h-4"})},{type:"widget",source:"system:teams",name:"Team Hub",w:6,h:6,icon:n.jsx(Ar,{className:"w-4 h-4"})},{type:"widget",source:"system:cron",name:"Cron Scheduler",w:6,h:6,icon:n.jsx(ms,{className:"w-4 h-4"})},{type:"widget",source:"system:checkpoints",name:"Checkpoints",w:6,h:5,icon:n.jsx(bn,{className:"w-4 h-4"})},{type:"widget",source:"system:organism",name:"Organism Monitor",w:6,h:6,icon:n.jsx(Lr,{className:"w-4 h-4"})},{type:"widget",source:"system:fleet",name:"Fleet Router",w:6,h:5,icon:n.jsx(go,{className:"w-4 h-4"})},{type:"widget",source:"system:browser",name:"Browser Tools",w:6,h:5,icon:n.jsx(io,{className:"w-4 h-4"})},{type:"widget",source:"system:eval",name:"Test Lab",w:6,h:6,icon:n.jsx(yo,{className:"w-4 h-4"})}];function _l({currentSpaceId:t,onSpaceSelect:e,onAction:s,onClose:r}){const[i,o]=w.useState(""),[c,d]=w.useState(0),l=w.useRef(null),p=ke.list(),g=w.useMemo(()=>{const u=i.toLowerCase(),f=p.filter(y=>y.id!==t&&y.name.toLowerCase().includes(u)).map(y=>({type:"space",id:y.id,name:y.name,color:y.color})),x=Xp.filter(y=>y.name.toLowerCase().includes(u)).map(y=>({type:"action",action:y,name:y.name}));return[...f,...x]},[i,p,t]);return w.useEffect(()=>{var u;(u=l.current)==null||u.focus()},[]),w.useEffect(()=>{d(0)},[i]),w.useEffect(()=>{const u=f=>{if((f.metaKey||f.ctrlKey)&&f.key.toLowerCase()==="k"){f.preventDefault(),r();return}if(f.key==="Escape"){r();return}if(f.key==="ArrowDown"){f.preventDefault(),d(x=>Math.min(x+1,g.length-1));return}if(f.key==="ArrowUp"){f.preventDefault(),d(x=>Math.max(x-1,0));return}if(f.key==="Enter"){f.preventDefault();const x=g[c];if(!x)return;x.type==="space"&&e(x.id),x.type==="action"&&s(x.action)}};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[g,c,e,s,r]),n.jsx("div",{className:"fixed inset-0 z-[2147483200] flex items-start justify-center pt-[20vh]",onClick:r,children:n.jsxs("div",{className:"w-full max-w-lg bg-[#18181b]/98 backdrop-blur-xl border border-[#27272a]/60 rounded-2xl shadow-2xl shadow-black/60 overflow-hidden",onClick:u=>u.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-[#27272a]/40",children:[n.jsx(uo,{className:"w-4 h-4 text-[#3f3f46]"}),n.jsx("input",{ref:l,value:i,onChange:u=>o(u.target.value),placeholder:"Search spaces, widgets, actions...",className:"flex-1 bg-transparent text-sm text-[#e4e4e7] placeholder:text-[#3f3f46] outline-none"}),n.jsx("button",{onClick:r,className:"text-[#3f3f46] hover:text-[#71717a]",children:n.jsx(Es,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"max-h-[50vh] overflow-auto py-1",children:[g.length===0&&n.jsxs("div",{className:"px-4 py-6 text-center text-xs text-[#52525b]",children:['No results for "',i,'"']}),g.map((u,f)=>n.jsxs("button",{onClick:()=>{u.type==="space"&&e(u.id),u.type==="action"&&s(u.action)},className:`w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors ${f===c?"bg-[#6366f1]/10 text-[#818cf8]":"text-[#a1a1aa] hover:bg-[#27272a]/30"}`,children:[u.type==="space"?n.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:u.color||"#52525b"}}):n.jsx("span",{className:"text-[#6366f1]/60",children:u.action.icon}),n.jsx("span",{className:"text-sm",children:u.name}),n.jsx("span",{className:"ml-auto text-[10px] text-[#3f3f46] uppercase tracking-wider",children:u.type==="space"?"Space":"Widget"})]},u.type==="space"?u.id:u.action.source))]}),n.jsxs("div",{className:"px-4 py-2 border-t border-[#27272a]/40 flex items-center gap-3 text-[10px] text-[#3f3f46]",children:[n.jsx("span",{children:"↑↓ Navigate"}),n.jsx("span",{children:"↵ Select"}),n.jsx("span",{children:"ESC Close"})]})]})})}const Qp=oe.lazy(()=>le(()=>import("./SomaView-CXfqpdNP.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),Ae={bgBase:"var(--theme-bg-base, var(--color-bg, #09090b))",surface:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-secondary, #18181b)) 82%, transparent)",surfaceSoft:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-tertiary, #27272a)) 62%, transparent)",border:"color-mix(in srgb, var(--theme-metal-dark, var(--color-border, #3f3f46)) 66%, transparent)",ink:"var(--theme-paper-fg, var(--color-text, #fafafa))",inkSoft:"color-mix(in srgb, var(--theme-paper-fg, var(--color-text-secondary, #a1a1aa)) 72%, transparent)",paperFg:"var(--theme-paper-fg, var(--color-text-secondary, #a1a1aa))",accent:"var(--theme-accent, var(--color-accent, #6366f1))",success:"var(--color-success, #22c55e)",error:"var(--color-error, #ef4444)"},or={background:Ae.bgBase,color:Ae.ink};function kl(){const[t,e]=w.useState(null),[s,r]=w.useState(!1),[i,o]=w.useState(null),c=w.useCallback(async()=>{var p;try{const g=await ge("/api/config");if(!g.ok)throw new Error(`HTTP ${g.status}`);const u=await g.json();e(!!((p=u==null?void 0:u.organism)!=null&&p.enabled)),o(null)}catch(g){o(g.message),e(!1)}},[]);w.useEffect(()=>{c()},[c]);const d=w.useRef(0),l=w.useCallback(async p=>{const g=++d.current;r(!0),o(null);try{const u=await ge("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organism:{enabled:p}})});if(g!==d.current)return;if(!u.ok)throw new Error(`HTTP ${u.status}`);e(p),window.dispatchEvent(new CustomEvent("titan:soma:changed",{detail:{enabled:p}}))}catch(u){if(g!==d.current)return;o(u.message)}finally{g===d.current&&r(!1)}},[]);return t===null?n.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs",style:{...or,color:Ae.paperFg},children:"Loading Soma…"}):t?n.jsxs("div",{className:"w-full h-full overflow-auto flex flex-col",style:or,children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b",style:{background:Ae.surface,borderColor:Ae.border},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full animate-pulse",style:{background:Ae.success}}),n.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:Ae.success},children:"Soma active"})]}),n.jsxs("button",{onClick:()=>l(!1),disabled:s,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full border text-[10px] disabled:opacity-60 transition-colors",style:{borderColor:Ae.border,color:Ae.inkSoft,background:Ae.surfaceSoft},title:"Disable Soma",children:[n.jsx(pi,{className:"w-3 h-3"}),s?"saving…":"disable"]})]}),n.jsx("div",{className:"flex-1 overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs",style:{color:Ae.paperFg},children:"Loading Soma dashboard…"}),children:n.jsx(Qp,{})})})]}):n.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-4 p-6 text-center",style:or,children:[n.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center",style:{background:"color-mix(in srgb, var(--theme-accent, var(--color-accent, #6366f1)) 18%, transparent)",border:`1px solid ${Ae.border}`},children:n.jsx(Yt,{className:"w-7 h-7",style:{color:Ae.accent}})}),n.jsxs("div",{className:"space-y-1 max-w-md",children:[n.jsx("h3",{className:"text-lg font-semibold",style:{color:Ae.ink},children:"Soma is off"}),n.jsx("p",{className:"text-xs leading-relaxed",style:{color:Ae.inkSoft},children:"TITAN’s homeostatic drive layer. When enabled, TITAN has a sense of its own state — purpose, curiosity, hunger, safety, social, rest — and will propose work when those drives drift. Every proposal still requires your approval."})]}),n.jsxs("button",{onClick:()=>l(!0),disabled:s,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-full disabled:opacity-60 disabled:cursor-not-allowed text-sm font-medium transition-colors",style:{background:Ae.accent,color:"var(--theme-bg-base, var(--color-bg, #09090b))"},children:[n.jsx(pi,{className:"w-4 h-4"}),s?"Enabling…":"Enable Soma"]}),i&&n.jsx("p",{className:"text-xs",style:{color:Ae.error},children:i}),n.jsx("p",{className:"text-[10px]",style:{color:Ae.paperFg},children:"You can turn this off anytime from the same button."})]})}const Zp={calm:{primary:"#6366f1",glow:"rgba(99,102,241,0.4)",pulse:"rgba(99,102,241,0.15)"},focused:{primary:"#10b981",glow:"rgba(16,185,129,0.4)",pulse:"rgba(16,185,129,0.15)"},excited:{primary:"#f59e0b",glow:"rgba(245,158,11,0.4)",pulse:"rgba(245,158,11,0.15)"},concerned:{primary:"#ef4444",glow:"rgba(239,68,68,0.4)",pulse:"rgba(239,68,68,0.15)"},dreaming:{primary:"#8b5cf6",glow:"rgba(139,92,246,0.4)",pulse:"rgba(139,92,246,0.15)"}},Ee={surface:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-secondary, #18181b)) 90%, transparent)",surfaceSoft:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-tertiary, #27272a)) 62%, transparent)",overlay:"color-mix(in srgb, var(--theme-bg-base, var(--color-bg, #09090b)) 56%, transparent)",border:"color-mix(in srgb, var(--theme-metal-dark, var(--color-border, #3f3f46)) 66%, transparent)",metal:"var(--theme-metal, var(--color-border-light, #52525b))",ink:"var(--theme-paper-fg, var(--color-text, #fafafa))",accent:"var(--theme-accent, var(--color-accent, #6366f1))",warning:"var(--color-warning, #f59e0b)"};function em(t,e,s){if(!s)return{emotion:"dreaming",intensity:.25,activity:"Dormant"};const r=e[0],i=Math.min(1,t/2);switch(r){case"purpose":return{emotion:"focused",intensity:.4+i*.4,activity:"Pursuing purpose"};case"curiosity":return{emotion:"excited",intensity:.4+i*.5,activity:"Exploring"};case"hunger":return{emotion:"focused",intensity:.5+i*.3,activity:"Satiating"};case"safety":return{emotion:"concerned",intensity:.5+i*.4,activity:"Securing"};case"social":return{emotion:"calm",intensity:.3+i*.3,activity:"Connecting"};case"rest":return{emotion:"dreaming",intensity:.2+i*.2,activity:"Recuperating"};default:return t>.5?{emotion:"focused",intensity:i,activity:"Processing"}:{emotion:"calm",intensity:.3,activity:"Observing"}}}function tm(){const[t,e]=w.useState(!1),[s,r]=w.useState({emotion:"calm",intensity:.3,activity:"Observing"}),[i,o]=w.useState(!1),[c,d]=w.useState(()=>sm()),[l,p]=w.useState(!1),g=w.useRef({x:0,y:0}),u=w.useRef(null);w.useEffect(()=>{let v=!1;const A=async()=>{try{const k=await ge("/api/soma/state");if(!k.ok||v)return;const _=await k.json();if(v)return;r(em(Number((_==null?void 0:_.totalPressure)??0),Array.isArray(_==null?void 0:_.dominantDrives)?_.dominantDrives:[],!!(_!=null&&_.enabled)))}catch{}};A();const m=setInterval(A,15e3);return()=>{v=!0,clearInterval(m)}},[]),w.useEffect(()=>{const v=A=>{var m;(m=u.current)!=null&&m.contains(A.target)||o(!1)};return window.addEventListener("mousedown",v),()=>window.removeEventListener("mousedown",v)},[]);const f=v=>{v.button===0&&(g.current={x:v.clientX-c.x,y:v.clientY-c.y},p(!0))},x=v=>{l&&d({x:v.clientX-g.current.x,y:v.clientY-g.current.y})},y=()=>{p(!1)},E=Zp[s.emotion],L=s.activity==="Dormant"?Ee.metal:Ee.accent;return n.jsxs(n.Fragment,{children:[t&&n.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center backdrop-blur-sm",style:{background:Ee.overlay},onClick:()=>e(!1),children:n.jsxs("div",{className:"border rounded-2xl shadow-2xl overflow-hidden",style:{width:"min(900px, 90vw)",height:"min(600px, 80vh)",background:Ee.surface,borderColor:Ee.border,color:Ee.ink,boxShadow:"0 24px 64px color-mix(in srgb, var(--theme-bg-base, var(--color-bg, #09090b)) 72%, transparent)"},onClick:v=>v.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b",style:{borderColor:Ee.border},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(xt,{className:"w-4 h-4",style:{color:L}}),n.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:Ee.ink},children:"SOMA Consciousness"})]}),n.jsx("button",{onClick:()=>e(!1),className:"p-1",style:{color:Ee.metal},children:n.jsx(Es,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"h-[calc(100%-40px)]",children:n.jsx(kl,{})})]})}),n.jsxs("div",{ref:u,className:"fixed z-50 select-none",style:{left:c.x,top:c.y},onMouseDown:f,onMouseMove:x,onMouseUp:y,onMouseLeave:y,children:[i&&n.jsxs("div",{className:"absolute bottom-full left-0 mb-2 backdrop-blur-xl border rounded-xl shadow-2xl overflow-hidden min-w-[160px] py-1",style:{background:Ee.surface,borderColor:Ee.border,boxShadow:"0 18px 40px color-mix(in srgb, var(--theme-bg-base, var(--color-bg, #09090b)) 70%, transparent)"},children:[n.jsxs("button",{onClick:()=>{e(!0),o(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] transition-colors",style:{color:Ee.ink,background:"transparent"},children:[n.jsx(xt,{className:"w-3.5 h-3.5",style:{color:L}}),"Open SOMA"]}),n.jsxs("button",{onClick:()=>{o(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] transition-colors",style:{color:Ee.ink,background:"transparent"},children:[n.jsx(mn,{className:"w-3.5 h-3.5",style:{color:Ee.warning}}),"Summarize Canvas"]}),n.jsxs("button",{onClick:()=>{o(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] transition-colors",style:{color:Ee.ink,background:"transparent"},children:[n.jsx(Ll,{className:"w-3.5 h-3.5",style:{color:Ee.accent}}),"Run Self-Check"]})]}),n.jsxs("div",{className:"relative cursor-pointer group",onClick:()=>!l&&e(!0),onContextMenu:v=>{v.preventDefault(),o(!0)},children:[n.jsx("div",{className:"absolute inset-0 rounded-full animate-ping opacity-20",style:{background:E.pulse,animationDuration:`${3-s.intensity*2}s`}}),n.jsx("div",{className:"absolute -inset-2 rounded-full opacity-30 blur-md transition-all duration-1000",style:{background:E.glow}}),n.jsx("div",{className:"relative w-12 h-12 rounded-full flex items-center justify-center transition-all duration-500 hover:scale-110",style:{background:`radial-gradient(circle at 30% 30%, ${L}, ${Ee.metal})`,boxShadow:`0 0 ${20+s.intensity*30}px ${E.glow}, inset 0 0 10px color-mix(in srgb, var(--theme-ink, var(--color-text, #fafafa)) 12%, transparent)`},children:n.jsx(xt,{className:"w-5 h-5",style:{color:Ee.ink}})}),n.jsx("div",{className:"absolute -bottom-5 left-1/2 -translate-x-1/2 whitespace-nowrap",children:n.jsx("span",{className:"text-[9px] font-medium uppercase tracking-wider px-1.5 py-0.5 rounded border",style:{color:Ee.ink,background:Ee.surfaceSoft,borderColor:Ee.border},children:s.activity})})]})]})]})}function sm(){if(typeof window>"u")return{x:280,y:80};const t=window.innerWidth<640;return{x:t?Math.max(16,window.innerWidth-96):280,y:t?220:80}}const nm=oe.lazy(()=>le(()=>import("./CommandPostHub-DTs1EGm8.js"),__vite__mapDeps([7,1,2,3,4,8,9,10,11,12,5,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28])));function rm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-2",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Command Post..."}),children:n.jsx(nm,{})})})}const im=oe.lazy(()=>le(()=>import("./IntelligenceView-YcrYQTVO.js"),__vite__mapDeps([29,1,2,4])));function om(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Intelligence..."}),children:n.jsx(im,{})})})}const am=oe.lazy(()=>le(()=>import("./MemoryGraphPanel-BK-AbsbF.js"),__vite__mapDeps([30,1,2,31,24,28,32])));function lm(){return n.jsx("div",{className:"w-full h-full overflow-auto bg-[#09090b]",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"w-8 h-8 rounded-full border-2 border-[#6366f1]/20 border-t-[#6366f1] animate-spin mx-auto mb-3"}),n.jsx("p",{className:"text-[11px] text-[#52525b]",children:"Loading memory graph..."})]})}),children:n.jsx("div",{className:"p-4",children:n.jsx(am,{})})})})}function cm(){const[t,e]=w.useState(!1);return t?n.jsx(zl,{onClose:()=>e(!1)}):n.jsx("div",{className:"w-full h-full flex flex-col items-center justify-center bg-[#09090b]",children:n.jsxs("button",{onClick:()=>e(!0),className:"group relative flex flex-col items-center gap-4",children:[n.jsxs("div",{className:"relative w-20 h-20 rounded-full flex items-center justify-center transition-all duration-300 group-hover:scale-110",children:[n.jsx("div",{className:"absolute inset-0 rounded-full bg-[#6366f1]/20 animate-pulse"}),n.jsx("div",{className:"absolute inset-0 rounded-full bg-gradient-to-br from-[#6366f1]/30 to-[#4f46e5]/10 border border-[#6366f1]/30"}),n.jsx(fo,{className:"w-8 h-8 text-[#818cf8] relative z-10"})]}),n.jsxs("div",{className:"text-center",children:[n.jsx("p",{className:"text-sm font-medium text-[#a1a1aa]",children:"Tap to speak"}),n.jsx("p",{className:"text-[10px] text-[#52525b] mt-1",children:"F5-TTS · Voice Cloning"})]})]})})}const dm=oe.lazy(()=>le(()=>import("./InfraView-CreCQSNl.js"),__vite__mapDeps([33,1,2,4])));function um(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Infrastructure..."}),children:n.jsx(dm,{})})})}const hm=oe.lazy(()=>le(()=>import("./ToolsView-BiW0mds2.js"),__vite__mapDeps([34,1,2,4])));function fm(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Tools..."}),children:n.jsx(hm,{})})})}const pm=oe.lazy(()=>le(()=>import("./SettingsView-Chh-hdRF.js"),__vite__mapDeps([35,1,2,4])));function mm(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Settings..."}),children:n.jsx(pm,{})})})}function gm(){const[t,e]=w.useState([]),[s,r]=w.useState("/"),[i,o]=w.useState(!1),[c,d]=w.useState(null),l=async()=>{o(!0),d(null);try{const p=await ge(`/api/files?path=${encodeURIComponent(s)}`);if(p.ok){const g=await p.json();e(g.files||[])}else e([]),d(`Couldn't load files (HTTP ${p.status})`)}catch(p){e([]),d(`Couldn't reach /api/files — ${p.message}`)}finally{o(!1)}};return w.useEffect(()=>{l()},[s]),n.jsxs("div",{className:"w-full h-full flex flex-col",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-[#27272a]/40",children:[n.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-[#71717a]",children:[n.jsx("span",{className:"text-[#6366f1]",children:"~"}),n.jsx(Hl,{className:"w-3 h-3"}),n.jsx("span",{children:s})]}),n.jsx("button",{onClick:l,className:"p-1 text-[#3f3f46] hover:text-[#71717a]",children:n.jsx(wn,{className:`w-3 h-3 ${i?"animate-spin":""}`})})]}),n.jsxs("div",{className:"flex-1 overflow-auto",children:[c&&n.jsx("div",{className:"px-3 py-2 text-[11px] text-[#ef4444]/80",children:c}),!c&&!i&&t.length===0&&n.jsx("div",{className:"px-3 py-2 text-[11px] text-[#52525b]",children:"No files"}),t.map(p=>n.jsxs("button",{onClick:()=>p.type==="directory"&&r(p.path),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-[#27272a]/20 transition-colors",children:[p.type==="directory"?n.jsx(Vl,{className:"w-3.5 h-3.5 text-[#f59e0b]"}):n.jsx(yn,{className:"w-3.5 h-3.5 text-[#6366f1]"}),n.jsx("span",{className:"text-[12px] text-[#a1a1aa]",children:p.name})]},p.path))]})]})}const ym=oe.lazy(()=>le(()=>import("./SettingsPanel-CWvFc8MJ.js"),__vite__mapDeps([36,1,2,3,4,37,14,5,38,39,24,40,41,42,43])));function bm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ym,{})})})}const xm=oe.lazy(()=>le(()=>import("./SecurityPanel-ojbdvuZR.js"),__vite__mapDeps([44,1,2,37,14])));function wm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(xm,{})})})}const vm=oe.lazy(()=>le(()=>import("./AuditPanel-BOIeotPE.js"),__vite__mapDeps([45,1,2,37,14,24,46,47])));function _m(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(vm,{})})})}const Qi={researcher:"#60a5fa",engineer:"#f87171",manager:"#a78bfa",ceo:"#fbbf24",general:"#9ca3af"},km={Recommended:"bg-[#10b981]/15 text-[#10b981] border-[#10b981]/30",Reasoning:"bg-[#8b5cf6]/15 text-[#8b5cf6] border-[#8b5cf6]/30",Fast:"bg-[#0ea5e9]/15 text-[#0ea5e9] border-[#0ea5e9]/30",Light:"bg-[#f59e0b]/15 text-[#f59e0b] border-[#f59e0b]/30","Long Context":"bg-[#6366f1]/15 text-[#6366f1] border-[#6366f1]/30","High Output":"bg-[#ec4899]/15 text-[#ec4899] border-[#ec4899]/30","Needs Key":"bg-[#ef4444]/15 text-[#ef4444] border-[#ef4444]/30"};function Sm(){const[t,e]=w.useState(null),[s,r]=w.useState({}),[i,o]=w.useState({}),[c,d]=w.useState(null),[l,p]=w.useState({}),[g,u]=w.useState(!0),f=w.useCallback(async()=>{d(null);try{const[E,L]=await Promise.all([ge("/api/specialists"),ge("/api/models")]);if(!E.ok)throw new Error(`Specialists request failed: ${E.status}`);if(!L.ok)throw new Error(`Models request failed: ${L.status}`);const v=await E.json(),A=await L.json();e(v),r(A);const m={};await Promise.all(v.map(async k=>{try{const _=await ge(`/api/specialists/${encodeURIComponent(k.id)}/recommendations`);if(_.ok){const T=await _.json();T.recommendations&&(m[k.id]=T.recommendations)}}catch{}})),o(m)}catch(E){d(E.message)}finally{u(!1)}},[]);w.useEffect(()=>{f()},[f]);const x=w.useCallback(E=>{const L=i[E];if(L&&L.length)return L.map(A=>A.id);const v=new Set;if(s&&typeof s=="object")for(const A of Object.keys(s)){const m=s[A];if(Array.isArray(m))for(const k of m)typeof k=="string"?v.add(k):k&&typeof k=="object"&&"id"in k&&typeof k.id=="string"&&v.add(k.id)}if(Array.isArray(t))for(const A of t)A!=null&&A.activeModel&&v.add(A.activeModel),A!=null&&A.defaultModel&&v.add(A.defaultModel);return Array.from(v).sort((A,m)=>A.localeCompare(m))},[i,s,t]),y=w.useCallback(async(E,L)=>{p(v=>({...v,[E]:"saving"}));try{const v=await ge(`/api/specialists/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:L})});if(!v.ok){const m=await v.text().catch(()=>"");throw new Error(`PATCH failed (${v.status}): ${m||v.statusText}`)}const A=await v.json();e(m=>(m==null?void 0:m.map(k=>k.id===E?{...k,activeModel:A.activeModel??k.defaultModel,overridden:(A.activeModel??k.defaultModel)!==k.defaultModel}:k))??null),p(m=>({...m,[E]:"saved"})),setTimeout(()=>{p(m=>{if(m[E]!=="saved")return m;const k={...m};return delete k[E],k})},1500)}catch(v){p(A=>({...A,[E]:"error"})),d(`${E}: ${v.message}`)}},[]);return g&&!t?n.jsx("div",{className:"h-full w-full flex items-center justify-center text-xs text-[#52525b]",children:"Loading specialists…"}):n.jsxs("div",{className:"w-full h-full flex flex-col bg-[#0a0a0f] text-[#e4e4e7] text-sm",children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[#27272a]/60",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ar,{className:"w-4 h-4 text-[#6366f1]"}),n.jsx("h3",{className:"font-semibold",children:"Specialist Models"}),n.jsxs("span",{className:"text-[10px] text-[#52525b]",children:[(t==null?void 0:t.length)??0," sub-agents"]})]}),n.jsxs("button",{onClick:()=>{u(!0),f()},className:"flex items-center gap-1 px-2 py-1 rounded text-[11px] text-[#71717a] hover:text-[#e4e4e7] hover:bg-[#27272a]/60 transition-colors",title:"Refresh from server",children:[n.jsx(wn,{className:`w-3 h-3 ${g?"animate-spin":""}`}),"Refresh"]})]}),c&&n.jsxs("div",{className:"mx-4 mt-3 flex items-start gap-2 px-3 py-2 rounded bg-[#7f1d1d]/20 border border-[#7f1d1d]/40 text-[11px] text-[#fca5a5]",children:[n.jsx(gn,{className:"w-3 h-3 mt-0.5 shrink-0"}),n.jsx("span",{className:"font-mono",children:c})]}),n.jsxs("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-3",children:[(t==null?void 0:t.length)===0&&n.jsx("div",{className:"text-xs text-[#52525b] italic",children:"No specialists registered."}),t==null?void 0:t.map(E=>n.jsx(jm,{row:E,models:x(E.id),recommendations:i[E.id]??[],state:l[E.id]??"idle",onChange:L=>y(E.id,L),onReset:()=>y(E.id,null)},E.id))]}),n.jsxs("div",{className:"px-4 py-2 border-t border-[#27272a]/60 text-[10px] text-[#52525b]",children:["Overrides write to ",n.jsx("span",{className:"font-mono text-[#71717a]",children:"config.specialists.overrides"}),". Top-scored models are recommended per specialist role."]})]})}function jm({row:t,models:e,recommendations:s,state:r,onChange:i,onReset:o}){var u;const c=Qi[t.role]??Qi.general,d=s.find(f=>f.id===t.activeModel),l=s[0]??null,[p,g]=w.useState(!1);return n.jsxs("div",{className:"rounded-lg border border-[#27272a]/60 bg-[#18181b]/70 hover:border-[#3f3f46]/80 transition-colors",children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-3",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-[180px]",children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:c},title:t.role}),n.jsxs("div",{className:"flex flex-col min-w-0",children:[n.jsx("div",{className:"text-sm font-medium truncate",children:t.name}),n.jsx("div",{className:"text-[10px] text-[#52525b] truncate",children:t.title})]})]}),n.jsxs("div",{className:"flex-1 flex items-center gap-2 min-w-0",children:[n.jsx("select",{value:t.activeModel,onChange:f=>i(f.target.value),disabled:r==="saving",className:"flex-1 min-w-0 px-2 py-1 rounded bg-[#0a0a0f] border border-[#27272a] text-xs font-mono focus:outline-none focus:border-[#6366f1] disabled:opacity-50",title:`default: ${t.defaultModel}`,children:e.map(f=>{const x=s.find(L=>L.id===f),y=(x==null?void 0:x.badges)??[],E=y.length?`${f} [${y.join(", ")}]`:f;return n.jsx("option",{value:f,children:E},f)})}),d&&d.badges.length>0&&n.jsx("div",{className:"hidden sm:flex items-center gap-1 shrink-0",children:d.badges.slice(0,3).map(f=>n.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] border ${km[f]??"bg-[#27272a] text-[#a1a1aa] border-[#27272a]"}`,children:f},f))}),t.overridden&&n.jsxs("button",{onClick:o,disabled:r==="saving",className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] text-[#fbbf24] border border-[#fbbf24]/30 hover:bg-[#fbbf24]/10 transition-colors disabled:opacity-50",title:`Reset to default: ${t.defaultModel}`,children:[n.jsx(co,{className:"w-3 h-3"}),"Reset"]}),n.jsx("button",{onClick:()=>g(f=>!f),className:"flex items-center justify-center w-6 h-6 rounded hover:bg-[#27272a]/60 text-[#52525b] hover:text-[#a1a1aa] transition-colors",title:"Show recommendation details",children:n.jsx(fi,{className:"w-3.5 h-3.5"})}),n.jsxs("div",{className:"w-5 h-5 flex items-center justify-center shrink-0",children:[r==="saving"&&n.jsx(wn,{className:"w-3.5 h-3.5 animate-spin text-[#6366f1]"}),r==="saved"&&n.jsx(mi,{className:"w-3.5 h-3.5 text-[#10b981]"}),r==="error"&&n.jsx(gn,{className:"w-3.5 h-3.5 text-[#ef4444]"})]})]})]}),p&&n.jsxs("div",{className:"px-3 pb-3 space-y-1.5",children:[d&&n.jsxs("div",{className:"flex items-start gap-2 text-[11px] text-[#a1a1aa]",children:[n.jsx(fi,{className:"w-3 h-3 mt-0.5 shrink-0 text-[#6366f1]"}),n.jsx("span",{children:d.rationale})]}),l&&l.id!==t.activeModel&&n.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[#10b981]",children:[n.jsx(mi,{className:"w-3 h-3 shrink-0"}),n.jsxs("span",{children:["Recommended upgrade: ",n.jsx("span",{className:"font-mono",children:l.id})," (score ",l.score,"/100)",l.badges.length>0&&n.jsxs("span",{className:"ml-1 text-[#71717a]",children:["[",l.badges.join(", "),"]"]})]})]}),d&&n.jsxs("div",{className:"grid grid-cols-3 gap-2 text-[10px] text-[#52525b]",children:[n.jsxs("div",{children:["Capability: ",n.jsxs("span",{className:"text-[#a1a1aa]",children:[d.breakdown.capabilityScore,"/40"]})]}),n.jsxs("div",{children:["Fit: ",n.jsxs("span",{className:"text-[#a1a1aa]",children:[d.breakdown.specialistFit,"/40"]})]}),n.jsxs("div",{children:["Availability: ",n.jsxs("span",{className:"text-[#a1a1aa]",children:[d.breakdown.availability,"/20"]})]})]})]}),n.jsxs("div",{className:"px-3 pb-2 flex items-center gap-2 text-[10px] text-[#52525b]",children:[n.jsxs("span",{children:["id: ",n.jsx("span",{className:"font-mono text-[#71717a]",children:t.id})]}),n.jsx("span",{children:"•"}),n.jsxs("span",{children:["role: ",n.jsx("span",{className:"font-mono",style:{color:c},children:t.role})]}),((u=t.templateMatches)==null?void 0:u.length)>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"•"}),n.jsxs("span",{className:"truncate",children:["templates: ",n.jsx("span",{className:"font-mono text-[#71717a]",children:t.templateMatches.join(", ")})]})]})]})]})}function Em(){const[t,e]=w.useState(null),[s,r]=w.useState(null),[i,o]=w.useState(null),[c,d]=w.useState(!1),[l,p]=w.useState(null),[g,u]=w.useState(null),f=w.useCallback(async()=>{p(null);try{const[L,v,A]=await Promise.all([ge("/api/telemetry/consent").then(m=>m.ok?m.json():Promise.reject(new Error(`consent ${m.status}`))),ge("/api/analytics/profile").then(m=>m.ok?m.json():null),ge("/api/telemetry/status").then(m=>m.ok?m.json():null)]);e(L),r(v),A!=null&&A.remote&&o(A.remote)}catch(L){p(L.message)}},[]);w.useEffect(()=>{const L=setInterval(()=>{ge("/api/telemetry/status").then(v=>v.ok?v.json():null).then(v=>{v!=null&&v.remote&&o(v.remote)}).catch(()=>{})},15e3);return()=>clearInterval(L)},[]),w.useEffect(()=>{f()},[f]);const x=w.useCallback(async L=>{d(!0),p(null);try{const v=await ge("/api/telemetry/consent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L)});if(!v.ok)throw new Error(`save failed: ${v.status}`);const A=await v.json();e(m=>m?{...m,...A,consentedAt:A.enabled?new Date().toISOString():void 0}:null),u(Date.now()),setTimeout(()=>u(null),2e3)}catch(v){p(v.message)}finally{d(!1)}},[]),y=!!(t!=null&&t.enabled),E=!!(t!=null&&t.crashReports);return n.jsxs("div",{className:"w-full h-full overflow-auto bg-[#0a0a0f] text-[#e4e4e7] text-sm p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[y?n.jsx(Gl,{className:"w-5 h-5 text-[#10b981]"}):n.jsx(Lr,{className:"w-5 h-5 text-[#71717a]"}),n.jsx("h3",{className:"font-semibold text-base",children:"Privacy & Telemetry"}),n.jsx("span",{className:`ml-2 text-[10px] px-2 py-0.5 rounded-full border ${y?"border-[#10b981]/40 bg-[#10b981]/10 text-[#10b981]":"border-[#3f3f46] bg-[#18181b] text-[#71717a]"}`,children:y?"ENABLED":"OFF"}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[g&&n.jsxs("span",{className:"text-[11px] text-[#10b981] flex items-center gap-1",children:[n.jsx(Il,{className:"w-3 h-3"})," Saved"]}),l&&n.jsxs("span",{className:"text-[11px] text-[#ef4444] flex items-center gap-1",children:[n.jsx(Dl,{className:"w-3 h-3"})," ",l]}),n.jsxs("button",{onClick:()=>{f()},className:"flex items-center gap-1 px-2 py-1 rounded text-[11px] text-[#71717a] hover:text-[#e4e4e7] hover:bg-[#27272a]/60 transition-colors",children:[n.jsx(wn,{className:"w-3 h-3"})," Refresh"]})]})]}),n.jsx("div",{className:"mb-4 p-4 rounded-lg border border-[#27272a]/60 bg-[#18181b]/70",children:n.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:y,disabled:c,onChange:L=>x({enabled:L.target.checked,crashReports:E}),className:"mt-1 w-4 h-4 accent-[#6366f1] disabled:opacity-50"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"font-medium",children:"Send anonymous usage stats"}),n.jsx("div",{className:"text-xs text-[#a1a1aa] mt-1 leading-relaxed",children:"OS, Node version, CPU/GPU model + VRAM, RAM, TITAN version, and install method. A heartbeat every 5 minutes so we see uptime + concurrent-session counts. Never sends: prompts, file contents, credentials, IP address, or conversations."}),(t==null?void 0:t.consentedAt)&&n.jsxs("div",{className:"text-[10px] text-[#71717a] mt-2",children:["Consented ",n.jsx("span",{className:"font-mono",children:new Date(t.consentedAt).toLocaleString()}),t.consentedVersion&&n.jsxs(n.Fragment,{children:[" on TITAN v",n.jsx("span",{className:"font-mono",children:t.consentedVersion})]})]})]})]})}),n.jsx("div",{className:`mb-4 p-4 rounded-lg border transition-opacity ${y?"border-[#27272a]/60 bg-[#18181b]/70":"border-[#27272a]/30 bg-[#18181b]/30 opacity-60"}`,children:n.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:E,disabled:c||!y,onChange:L=>x({enabled:y,crashReports:L.target.checked}),className:"mt-1 w-4 h-4 accent-[#6366f1] disabled:opacity-50"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"font-medium",children:"Send crash reports"}),n.jsxs("div",{className:"text-xs text-[#a1a1aa] mt-1 leading-relaxed",children:["When TITAN throws an uncaught exception or unhandled promise rejection, send the error class, message, and stack trace. ",n.jsxs("span",{className:"text-[#fbbf24]",children:["Your $HOME path is replaced with the string ",n.jsx("span",{className:"font-mono",children:'"$HOME"'})," before sending."]})]})]})]})}),n.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-[#27272a]/60 bg-[#18181b]/40",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(gn,{className:"w-4 h-4 text-[#6366f1]"}),n.jsx("div",{className:"text-sm font-medium",children:"What would be sent right now"})]}),s?n.jsxs("dl",{className:"grid grid-cols-[160px_1fr] gap-y-1 text-xs",children:[n.jsx("dt",{className:"text-[#71717a]",children:"installId"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.installId.slice(0,32),"…"]}),n.jsx("dt",{className:"text-[#71717a]",children:"os / arch"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.os," / ",s.arch," (",s.osRelease,")"]}),n.jsx("dt",{className:"text-[#71717a]",children:"cpu"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.cpuModel," · ",s.cpuCores,"c"]}),n.jsx("dt",{className:"text-[#71717a]",children:"ram"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[(s.ramTotalMB/1024).toFixed(1)," GB"]}),n.jsx("dt",{className:"text-[#71717a]",children:"gpu"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.gpuVendor,"/",s.gpuName," · ",(s.gpuVramMB/1024).toFixed(1)," GB VRAM"]}),n.jsx("dt",{className:"text-[#71717a]",children:"disk"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.diskTotalGB," GB"]}),n.jsx("dt",{className:"text-[#71717a]",children:"version / node"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.version," · ",s.nodeVersion]}),n.jsx("dt",{className:"text-[#71717a]",children:"install method"}),n.jsx("dd",{className:"font-mono text-[#e4e4e7]",children:s.installMethod})]}):n.jsx("div",{className:"text-xs text-[#71717a]",children:"Loading profile preview…"})]}),n.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-[#27272a]/60 bg-[#18181b]/50",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(ho,{className:"w-4 h-4 text-[#6366f1]"}),n.jsx("div",{className:"text-sm font-medium",children:"Delivery status"}),(i==null?void 0:i.lastSuccessAt)&&!i.lastError&&n.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full border border-[#10b981]/40 bg-[#10b981]/10 text-[#10b981]",children:"FLOWING"}),(i==null?void 0:i.lastError)&&n.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full border border-[#ef4444]/40 bg-[#ef4444]/10 text-[#ef4444]",children:"ERROR"}),!(i!=null&&i.configured)&&n.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full border border-[#71717a]/40 bg-[#71717a]/10 text-[#71717a]",children:"NO REMOTE"})]}),i?n.jsxs("dl",{className:"grid grid-cols-[160px_1fr] gap-y-1 text-xs",children:[n.jsx("dt",{className:"text-[#71717a]",children:"remote URL"}),n.jsx("dd",{className:"font-mono text-[#e4e4e7] break-all",children:i.remoteUrl||"—"}),n.jsx("dt",{className:"text-[#71717a]",children:"sent / failed"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[n.jsx("span",{className:"text-[#10b981]",children:i.sentCount})," / ",n.jsx("span",{className:i.failedCount>0?"text-[#ef4444]":"text-[#71717a]",children:i.failedCount}),i.lastEventType&&n.jsxs("span",{className:"text-[#71717a]",children:[" · last event: ",n.jsx("span",{className:"text-[#a1a1aa]",children:i.lastEventType})]})]}),n.jsx("dt",{className:"text-[#71717a]",children:"last attempt"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7] flex items-center gap-1",children:[n.jsx(ms,{className:"w-3 h-3 text-[#71717a]"}),i.lastAttemptAt?new Date(i.lastAttemptAt).toLocaleString():"—"]}),n.jsx("dt",{className:"text-[#71717a]",children:"last success"}),n.jsx("dd",{className:"font-mono text-[#e4e4e7]",children:i.lastSuccessAt?new Date(i.lastSuccessAt).toLocaleString():"—"}),i.lastError&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"text-[#ef4444]",children:"last error"}),n.jsx("dd",{className:"font-mono text-[#fca5a5] break-all",children:i.lastError})]})]}):n.jsx("div",{className:"text-xs text-[#71717a]",children:"Checking collector reachability…"})]}),n.jsxs("div",{className:"mb-4 p-3 rounded-lg border border-[#27272a]/60 bg-[#0a0a0f]",children:[n.jsx("div",{className:"text-[10px] text-[#71717a] uppercase tracking-wider mb-1",children:"Collector"}),n.jsx("div",{className:"font-mono text-[11px] text-[#a1a1aa] break-all",children:(t==null?void 0:t.remoteUrl)||"—"})]}),n.jsxs("div",{className:"flex items-center gap-3 text-[11px]",children:[n.jsxs("a",{href:"https://github.com/Djtony707/TITAN/blob/main/PRIVACY.md",target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-[#6366f1] hover:underline",children:[n.jsx(gi,{className:"w-3 h-3"})," Read the full PRIVACY.md"]}),n.jsx("span",{className:"text-[#52525b]",children:"·"}),n.jsxs("a",{href:"https://github.com/Djtony707/TITAN/blob/main/src/analytics/collector.ts",target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-[#6366f1] hover:underline",children:[n.jsx(gi,{className:"w-3 h-3"})," See the collector source"]})]})]})}const Nm=oe.lazy(()=>le(()=>import("./AutopilotPanel-Dv3-_6fZ.js"),__vite__mapDeps([48,1,2,37,14])));function Cm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Nm,{})})})}const Tm=oe.lazy(()=>le(()=>import("./WorkflowsPanel-Bsyhjv87.js"),__vite__mapDeps([49,1,2,37,14,3,4,10,11,12,24,27,42,16,28,20,50,51])));function Rm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Tm,{})})})}const Am=oe.lazy(()=>le(()=>import("./LearningPanel-CZUd4UsW.js"),__vite__mapDeps([52,1,2,37,14,24,51,53,54,55,27,22,56,31,23,43,12,57,32,26,21,39,58,20,59,60,61,62,63,64,11,65,66,15,40,19,67,28])));function Lm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Am,{})})})}const Im=oe.lazy(()=>le(()=>import("./SelfImprovePanel-D743Dh0z.js"),__vite__mapDeps([68,1,2,37,14,24,38,20,69,54,15,42,23,60,28])));function Dm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Im,{})})})}const Mm=oe.lazy(()=>le(()=>import("./PersonasPanel-BhfAKQWd.js"),__vite__mapDeps([70,1,2])));function Om(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Mm,{})})})}const Pm=oe.lazy(()=>le(()=>import("./PersonaProfilesPanel-B_hx3sLQ.js"),__vite__mapDeps([71,1,2,37,14,24,11,16,63,20])));function Wm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Pm,{})})})}const Bm=oe.lazy(()=>le(()=>import("./DreamPanel-CJAI6Aka.js"),__vite__mapDeps([72,1,2,37,14,24])));function Um(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Bm,{})})})}const Fm=oe.lazy(()=>le(()=>import("./HomelabPanel-CKGR1kGN.js"),__vite__mapDeps([73,1,2,37,14,74,75,4,24,20,21,56,19,31,38,40,17])));function $m(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Fm,{})})})}const zm=oe.lazy(()=>le(()=>import("./NvidiaPanel-BCmLv4bY.js"),__vite__mapDeps([76,1,2,37,14,24,43,38,66,32])));function Hm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(zm,{})})})}const Vm=oe.lazy(()=>le(()=>import("./FilesPanel-CvrGQwh3.js"),__vite__mapDeps([77,1,2,27,24,14,78,20,12,28,43,41,11,22,55,56,31,23,51,57,32,26,21,39,58,59,60,61,62,63,64,65,66,15,40,19,67])));function Gm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Vm,{})})})}const qm=oe.lazy(()=>le(()=>import("./LogsPanel-CmUBA-jG.js"),__vite__mapDeps([79,1,2,37,14,24])));function Ym(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(qm,{})})})}const Km=oe.lazy(()=>le(()=>import("./TelemetryPanel-D2L98GwC.js"),__vite__mapDeps([80,1,2,74,20,18,19,56])));function Jm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Km,{})})})}const Xm=oe.lazy(()=>le(()=>import("./SkillsPanel-B0UwrZGA.js"),__vite__mapDeps([81,1,2,37,14,32,28,41])));function Qm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Xm,{})})})}const Zm=oe.lazy(()=>le(()=>import("./McpPanel-CVyjQ6H6.js"),__vite__mapDeps([82,1,2,37,14,24,27,56,83,61,28])));function eg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Zm,{})})})}const tg=oe.lazy(()=>le(()=>import("./IntegrationsPanel-Ds5KCGUi.js"),__vite__mapDeps([84,1,2,37,14,38,83,43])));function sg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(tg,{})})})}const ng=oe.lazy(()=>le(()=>import("./ChannelsPanel-Cx3dxaP9.js"),__vite__mapDeps([85,1,2,37,14,24,38,43])));function rg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ng,{})})})}const ig=oe.lazy(()=>le(()=>import("./MeshPanel-BCDzhBRO.js"),__vite__mapDeps([86,1,2,87,37,14,24,65])));function og(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ig,{})})})}const ag=oe.lazy(()=>le(()=>import("./MemoryWikiPanel-DkfHLaje.js"),__vite__mapDeps([88,1,2,37,14,78,67,20,32,51])));function lg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ag,{})})})}const cg=oe.lazy(()=>le(()=>import("./AutoresearchPanel-DdLmfGpC.js"),__vite__mapDeps([89,1,2,37,14,42,16,24,58,69,54,20])));function dg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(cg,{})})})}const ug=oe.lazy(()=>le(()=>import("./SelfProposalsPanel-DHPrgGsJ.js"),__vite__mapDeps([90,1,2,37,14,20,55,27,22,56,31,23,51,43,12,57,32,26,21,39,58,59,60,61,62,63,24,64,11,65,66,15,40,19,67,28])));function hg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ug,{})})})}const fg=oe.lazy(()=>le(()=>import("./OverviewPanel-C9ErRTB1.js"),__vite__mapDeps([91,1,2,74,37,14,75,4,20,21,56,92])));function pg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(fg,{})})})}const mg=oe.lazy(()=>le(()=>import("./SessionsPanel-Bd8dAJQa.js"),__vite__mapDeps([93,1,2,37,14,3,4,87,10,11,12,32,28])));function gg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(mg,{})})})}const yg=oe.lazy(()=>le(()=>import("./WatchView-CewHUoxK.js"),__vite__mapDeps([94,1,2,9])));function bg(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(yg,{})})})}const xg=oe.lazy(()=>le(()=>import("./BackupPanel-DYr6APwV.js"),__vite__mapDeps([95,1,2,37,14,27,24,59,38])));function wg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(xg,{})})})}const vg=oe.lazy(()=>le(()=>import("./TrainingPanel-BPVftaSt.js"),__vite__mapDeps([96,1,2,37,14,24,41])));function _g(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(vg,{})})})}const kg=oe.lazy(()=>le(()=>import("./RecipesPanel-KSNQil0R.js"),__vite__mapDeps([97,1,2,37,14,24,51,42,28])));function Sg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(kg,{})})})}const jg=oe.lazy(()=>le(()=>import("./VramPanel-CF4l5fe_.js"),__vite__mapDeps([98,1,2,37,14,24])));function Eg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(jg,{})})})}const Ng=oe.lazy(()=>le(()=>import("./TeamsPanel-BxFpHD58.js"),__vite__mapDeps([99,1,2,37,14,24,28])));function Cg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Ng,{})})})}const Tg=oe.lazy(()=>le(()=>import("./CronPanel-D0j9zDVW.js"),__vite__mapDeps([100,1,2,37,14,24,20,50,28])));function Rg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Tg,{})})})}const Ag=oe.lazy(()=>le(()=>import("./CheckpointsPanel-D2ATiPXs.js"),__vite__mapDeps([101,1,2,37,14,24,43,28])));function Lg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Ag,{})})})}const Ig=oe.lazy(()=>le(()=>import("./OrganismPanel-CDMC8-yf.js"),__vite__mapDeps([102,1,2,37,14,24,38])));function Dg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Ig,{})})})}const Mg=oe.lazy(()=>le(()=>import("./FleetPanel-BDf9E7dQ.js"),__vite__mapDeps([103,1,2,37,14,24,60])));function Og(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Mg,{})})})}const Pg=oe.lazy(()=>le(()=>import("./BrowserPanel-DMZf6mNn.js"),__vite__mapDeps([104,1,2,37,14])));function Wg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Pg,{})})})}const Bg=oe.lazy(()=>le(()=>import("./EvalPanel-DpmEQQXh.js"),__vite__mapDeps([105,1,2,37,14,24,42])));function Ug(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Bg,{})})})}function Fg(t){const e=Date.now()-new Date(t).getTime();if(!Number.isFinite(e)||e<0)return t;const s=Math.floor(e/1e3);if(s<60)return`${s}s ago`;const r=Math.floor(s/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function $g(t){const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>=0?t.slice(e+1):t}function zg(){const[t,e]=w.useState([]),[s,r]=w.useState(!0),[i,o]=w.useState(""),[c,d]=w.useState(null),[l,p]=w.useState(""),[g,u]=w.useState(!1),[f,x]=w.useState(null),[y,E]=w.useState(null),[L,v]=w.useState(null),A=w.useCallback(async()=>{r(!0),x(null);try{const C=await ge("/api/time-travel/checkpoints?limit=100");if(!C.ok)throw new Error(`${C.status} ${C.statusText}`);const D=await C.json();e(D.checkpoints||[])}catch(C){x(C.message||"Failed to load")}finally{r(!1)}},[]);w.useEffect(()=>{A()},[A]);const m=w.useCallback((C,D)=>{v({kind:C,message:D}),setTimeout(()=>v(null),4e3)},[]),k=w.useCallback(async C=>{d(C),p(""),u(!0);try{const D=await ge(`/api/time-travel/diff/${encodeURIComponent(C)}`);if(!D.ok)throw new Error(`${D.status} ${D.statusText}`);const j=await D.json();p(j.diff||"(no diff returned)")}catch(D){p(`Failed to load diff: ${D.message}`)}finally{u(!1)}},[]),_=w.useCallback(C=>{E(C)},[]),T=w.useCallback(async()=>{if(!y)return;const C=y;E(null);try{const D=await ge(`/api/time-travel/restore/${encodeURIComponent(C)}`,{method:"POST"});if(!D.ok)throw new Error(`${D.status} ${D.statusText}`);const j=await D.json();j.ok?(m("ok",j.message||`Restored to ${C.slice(0,8)}.`),A()):m("err",j.message||"Restore failed.")}catch(D){m("err",D.message||"Restore failed.")}},[y,A,m]),S=w.useMemo(()=>{const C=i.trim().toLowerCase();return C?t.filter(D=>D.filePath.toLowerCase().includes(C)||D.toolName.toLowerCase().includes(C)||D.id.toLowerCase().includes(C)):t},[t,i]);return n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",fontSize:12,background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Time Travel"}),n.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:[t.length," file checkpoints · newest first"]})]}),n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("input",{type:"text",value:i,onChange:C=>o(C.target.value),placeholder:"Filter by file or tool…",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:6,color:"#fff",fontSize:11,padding:"4px 8px",outline:"none",width:180}}),n.jsx("button",{onClick:A,disabled:s,title:"Refresh checkpoint list",style:{background:"rgba(99,102,241,0.15)",border:"1px solid rgba(99,102,241,0.35)",borderRadius:6,color:"#c7d2fe",fontSize:11,padding:"4px 10px",cursor:s?"wait":"pointer"},children:s?"…":"Refresh"})]})]}),L&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,background:L.kind==="ok"?"rgba(34,197,94,0.12)":"rgba(239,68,68,0.12)",border:`1px solid ${L.kind==="ok"?"rgba(34,197,94,0.3)":"rgba(239,68,68,0.3)"}`,color:L.kind==="ok"?"#86efac":"#fca5a5",fontSize:11},children:L.message}),f&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,background:"rgba(239,68,68,0.12)",border:"1px solid rgba(239,68,68,0.3)",color:"#fca5a5",fontSize:11},children:f}),n.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[n.jsx("div",{style:{flex:1,overflow:"auto",borderRight:"1px solid rgba(255,255,255,0.06)"},children:s&&t.length===0?n.jsx("div",{style:{padding:16,color:"rgba(255,255,255,0.4)"},children:"Loading checkpoints…"}):S.length===0?n.jsx("div",{style:{padding:16,color:"rgba(255,255,255,0.4)"},children:i?"No matches for that filter.":"No file checkpoints yet. They're created automatically whenever TITAN writes or edits a file."}):S.map(C=>n.jsxs("div",{onClick:()=>k(C.id),style:{padding:"8px 14px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:c===C.id?"rgba(99,102,241,0.08)":"transparent",borderLeft:c===C.id?"2px solid #818cf8":"2px solid transparent"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:2},children:[n.jsx("span",{style:{fontSize:11,fontFamily:"ui-monospace, monospace",color:"#a5b4fc"},children:C.commitHash.slice(0,8)}),n.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.5)"},children:Fg(C.timestamp)})]}),n.jsx("div",{style:{fontSize:12,color:"#e2e8f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:C.filePath,children:$g(C.filePath)}),n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:4},children:[n.jsxs("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)"},children:["before ",n.jsx("code",{style:{color:"#fbbf24"},children:C.toolName})]}),n.jsx("button",{onClick:D=>{D.stopPropagation(),_(C.id)},title:"Restore this file to the state it was in at this checkpoint",style:{fontSize:10,padding:"2px 8px",borderRadius:999,background:"rgba(34,197,94,0.12)",border:"1px solid rgba(34,197,94,0.3)",color:"#86efac",cursor:"pointer"},children:"Restore"})]})]},C.id))}),n.jsx("div",{style:{flex:1,overflow:"auto",padding:14},children:c?g?n.jsx("div",{style:{color:"rgba(255,255,255,0.4)"},children:"Loading diff…"}):n.jsx("pre",{style:{margin:0,fontFamily:'ui-monospace, "SF Mono", Menlo, monospace',fontSize:11,lineHeight:1.5,color:"#e2e8f5",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:(l||"").split(`
994
+ `).map((C,D)=>{let j="rgba(255,255,255,0.7)";return C.startsWith("+")&&!C.startsWith("+++")?j="#86efac":C.startsWith("-")&&!C.startsWith("---")?j="#fca5a5":C.startsWith("@@")?j="#a5b4fc":(C.startsWith("diff")||C.startsWith("index")||C.startsWith("+++")||C.startsWith("---"))&&(j="rgba(255,255,255,0.45)"),n.jsx("div",{style:{color:j},children:C||" "},D)})}):n.jsx("div",{style:{color:"rgba(255,255,255,0.4)"},children:"Select a checkpoint on the left to see its diff vs the current file."})})]}),y&&n.jsx("div",{onClick:()=>E(null),style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10},children:n.jsxs("div",{onClick:C=>C.stopPropagation(),style:{background:"#0d0f1d",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:18,maxWidth:380,color:"#e2e8f5"},children:[n.jsx("div",{style:{fontSize:14,fontWeight:600,marginBottom:8},children:"Restore this checkpoint?"}),n.jsxs("div",{style:{fontSize:12,color:"rgba(255,255,255,0.7)",marginBottom:12},children:["The file will be overwritten with its state at ",n.jsx("code",{children:y.slice(0,8)}),". A NEW checkpoint of the current state is taken first, so you can always come back."]}),n.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[n.jsx("button",{onClick:()=>E(null),style:{background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"#e2e8f5",borderRadius:6,padding:"6px 12px",fontSize:12,cursor:"pointer"},children:"Cancel"}),n.jsx("button",{onClick:T,style:{background:"rgba(34,197,94,0.18)",border:"1px solid rgba(34,197,94,0.4)",color:"#86efac",borderRadius:6,padding:"6px 12px",fontSize:12,cursor:"pointer"},children:"Restore"})]})]})})]})}const Zi=5e3,eo={planning:"#a5b4fc",delegating:"#60a5fa",observing:"#22d3ee",iterating:"#f59e0b",verifying:"#a78bfa",reporting:"#34d399",blocked:"#facc15",escalated:"#fb7185",done:"#34d399",failed:"#ef4444",cancelled:"#737373"};function Hg(t){if(!Number.isFinite(t)||t<0)return"—";const e=Math.floor(t/1e3);if(e<60)return`${e}s`;const s=Math.floor(e/60);if(s<60)return`${s}m`;const r=Math.floor(s/60),i=s%60;return`${r}h ${i}m`}function Vg(t){return t===0?"$0":t<.01?"$<0.01":`$${t.toFixed(2)}`}function Gg(){const[t,e]=w.useState([]),[s,r]=w.useState(!0),[i,o]=w.useState(null),[c,d]=w.useState(!1),[l,p]=w.useState(""),[g,u]=w.useState(2),[f,x]=w.useState(!1),[y,E]=w.useState(null),L=w.useCallback(async()=>{try{const _=await ge("/api/missions/active");if(!_.ok)throw new Error(`${_.status} ${_.statusText}`);const T=await _.json();e(T.missions||[]),o(null)}catch(_){o(_.message||"failed to load")}finally{r(!1)}},[]);w.useEffect(()=>{L();const _=setInterval(L,Zi);return()=>clearInterval(_)},[L]);const v=w.useCallback((_,T)=>{E({kind:_,message:T}),setTimeout(()=>E(null),5e3)},[]),A=w.useCallback(async()=>{var T;const _=l.trim();if(_.length<10){v("err","Describe the mission (>=10 chars).");return}x(!0);try{const S=await ge("/api/mission/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:_,budgetUsd:g})});if(!S.ok)throw new Error(`${S.status} ${S.statusText}`);const C=await S.json();v("ok",C.message||`Mission "${((T=C.goal)==null?void 0:T.title)??"?"}" launched.`),p(""),d(!1),L()}catch(S){v("err",S.message||"launch failed")}finally{x(!1)}},[l,g,L,v]),m=w.useCallback(async _=>{try{const T=await ge(`/api/mission/${encodeURIComponent(_)}/cancel`,{method:"POST"});if(!T.ok)throw new Error(`${T.status} ${T.statusText}`);v("ok","Mission marked for cancellation."),L()}catch(T){v("err",T.message||"cancel failed")}},[L,v]),k=w.useMemo(()=>{const _={delegating:0,observing:1,iterating:2,verifying:3,planning:4,reporting:5,blocked:6,escalated:7};return[...t].sort((T,S)=>(_[T.phase]??99)-(_[S.phase]??99))},[t]);return n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Mission Driver"}),n.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:[t.length," active · polling every ",Zi/1e3,"s"]})]}),n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("button",{onClick:()=>d(_=>!_),title:"Launch a new autonomous mission",style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:"1px solid rgba(99,102,241,0.4)",background:c?"rgba(99,102,241,0.25)":"rgba(99,102,241,0.12)",color:"#c7d2fe",cursor:"pointer"},children:c?"× Close":"+ New mission"}),n.jsx("button",{onClick:L,title:"Refresh",style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.04)",color:"#e2e8f5",cursor:"pointer"},children:"↻"})]})]}),y&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,fontSize:11,background:y.kind==="ok"?"rgba(34,197,94,0.12)":"rgba(239,68,68,0.12)",border:`1px solid ${y.kind==="ok"?"rgba(34,197,94,0.3)":"rgba(239,68,68,0.3)"}`,color:y.kind==="ok"?"#86efac":"#fca5a5"},children:y.message}),c&&n.jsxs("div",{style:{padding:12,borderBottom:"1px solid rgba(255,255,255,0.06)",background:"rgba(99,102,241,0.04)"},children:[n.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:.6,color:"#a5b4fc",marginBottom:6},children:"Describe the mission"}),n.jsx("textarea",{value:l,onChange:_=>p(_.target.value),placeholder:"e.g. 'Research the top 5 AI agent frameworks for 2026, summarize their differentiation in a markdown report, and save to ~/Documents/agent-research.md'",rows:3,style:{width:"100%",background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"#fff",fontSize:12,padding:"6px 10px",resize:"vertical",fontFamily:"inherit",boxSizing:"border-box"}}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:8,gap:8},children:[n.jsxs("label",{style:{fontSize:11,color:"rgba(255,255,255,0.6)"},children:["Budget cap: $",n.jsx("input",{type:"number",value:g,onChange:_=>u(Math.max(.05,Math.min(50,Number(_.target.value)||2))),step:"0.5",min:"0.05",max:"50",style:{width:60,marginLeft:4,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:4,color:"#fff",fontSize:11,padding:"2px 6px"}})]}),n.jsx("button",{onClick:A,disabled:f||l.trim().length<10,style:{fontSize:12,padding:"6px 14px",borderRadius:6,border:"none",background:f?"rgba(255,255,255,0.05)":"rgba(34,197,94,0.18)",color:"#86efac",cursor:f?"wait":"pointer",fontWeight:600},children:f?"Decomposing…":"🚀 Launch"})]})]}),n.jsxs("div",{style:{flex:1,overflow:"auto",padding:8},children:[i&&n.jsx("div",{style:{padding:10,color:"#fca5a5",fontSize:11},children:i}),s&&t.length===0?n.jsx("div",{style:{padding:16,color:"rgba(255,255,255,0.4)",fontSize:12},children:"Loading missions…"}):k.length===0?n.jsxs("div",{style:{padding:24,color:"rgba(255,255,255,0.45)",fontSize:12,textAlign:"center"},children:["No active missions.",n.jsx("br",{}),n.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.35)"},children:'Click "+ New mission" to launch one.'})]}):k.map(_=>{const T=eo[_.phase]??"#94a3b8",S=_.subtasks.total>0?Math.round(_.subtasks.completed/_.subtasks.total*100):0;return n.jsxs("div",{style:{padding:"10px 12px",marginBottom:6,borderRadius:8,background:"rgba(255,255,255,0.025)",border:`1px solid ${_.phase==="blocked"?"rgba(250,204,21,0.4)":"rgba(255,255,255,0.06)"}`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[n.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#fafafa",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:_.title,children:_.title}),n.jsx("button",{onClick:()=>m(_.goalId),title:"Cancel this mission",style:{fontSize:10,padding:"2px 8px",borderRadius:999,background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.3)",color:"#fca5a5",cursor:"pointer",marginLeft:6},children:"Cancel"})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:10,color:"rgba(255,255,255,0.7)"},children:[n.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"1px 6px",borderRadius:4,background:`${T}22`,border:`1px solid ${T}55`,color:T,textTransform:"uppercase",letterSpacing:.5,fontWeight:600,fontSize:9},children:_.phase}),n.jsxs("span",{children:[_.subtasks.completed,"/",_.subtasks.total," subtasks (",S,"%)"]}),n.jsx("span",{children:"·"}),n.jsx("span",{children:Vg(_.budget.costUsd)}),n.jsx("span",{children:"·"}),n.jsx("span",{children:Hg(Date.now()-new Date(_.startedAt).getTime())})]}),_.blockedReason&&n.jsxs("div",{style:{marginTop:6,padding:"6px 8px",borderRadius:4,background:"rgba(250,204,21,0.08)",border:"1px solid rgba(250,204,21,0.25)",fontSize:11,color:"#fde68a"},children:[n.jsx("strong",{children:"Blocked:"})," ",_.blockedReason.question??"(no reason)"]}),_.lastHistory.length>0&&n.jsx("div",{style:{marginTop:6,fontSize:10,color:"rgba(255,255,255,0.45)",display:"flex",flexDirection:"column",gap:1},children:_.lastHistory.slice(-3).map((C,D)=>n.jsxs("div",{style:{display:"flex",gap:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[n.jsx("span",{style:{color:eo[C.phase]??"rgba(255,255,255,0.6)",minWidth:70,fontFamily:"ui-monospace, monospace",fontSize:9},children:C.phase}),n.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.note??""})]},D))})]},_.goalId)})]})]})}const qg=6e4,Yg=[{label:"6h",hours:6},{label:"24h",hours:24},{label:"7d",hours:168}];function Kg(t){return t===0?"$0":t<.01?"$<0.01":`$${t.toFixed(2)}`}function Jg(t){return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(1)}k`:`${(t/1e6).toFixed(2)}M`}function Xg(){const[t,e]=w.useState(24),[s,r]=w.useState(null),[i,o]=w.useState(!0),[c,d]=w.useState(null),l=w.useCallback(async()=>{o(!0);try{const p=await ge(`/api/missions/digest?hours=${t}`);if(!p.ok)throw new Error(`${p.status} ${p.statusText}`);const g=await p.json();r(g),d(null)}catch(p){d(p.message||"failed")}finally{o(!1)}},[t]);return w.useEffect(()=>{l();const p=setInterval(l,qg);return()=>clearInterval(p)},[l]),n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Daily digest"}),n.jsx("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:"what TITAN did while you were away"})]}),n.jsx("div",{style:{display:"flex",gap:4},children:Yg.map(p=>n.jsx("button",{onClick:()=>e(p.hours),style:{fontSize:10,padding:"3px 8px",borderRadius:4,border:"1px solid rgba(255,255,255,0.1)",background:t===p.hours?"rgba(99,102,241,0.25)":"rgba(255,255,255,0.03)",color:t===p.hours?"#c7d2fe":"rgba(255,255,255,0.65)",cursor:"pointer"},children:p.label},p.label))})]}),s&&n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.04)",display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8},children:[n.jsx(Us,{label:"Done",value:s.stats.completed,color:"#34d399"}),n.jsx(Us,{label:"Failed",value:s.stats.failed,color:s.stats.failed>0?"#fca5a5":"rgba(255,255,255,0.5)"}),n.jsx(Us,{label:"Active",value:s.stats.active,color:"#60a5fa"}),n.jsx(Us,{label:"Blocked",value:s.stats.blocked,color:s.stats.blocked>0?"#facc15":"rgba(255,255,255,0.5)"})]}),s&&(s.stats.totalCostUsd>0||s.stats.totalTokens>0)&&n.jsxs("div",{style:{padding:"6px 14px",borderBottom:"1px solid rgba(255,255,255,0.04)",fontSize:10,color:"rgba(255,255,255,0.55)",display:"flex",justifyContent:"space-between"},children:[n.jsxs("span",{children:["Spend: ",n.jsx("strong",{style:{color:"#e2e8f5"},children:Kg(s.stats.totalCostUsd)})]}),n.jsxs("span",{children:["Tokens: ",n.jsx("strong",{style:{color:"#e2e8f5"},children:Jg(s.stats.totalTokens)})]})]}),n.jsxs("div",{style:{flex:1,overflow:"auto",padding:14},children:[i&&!s&&n.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:11},children:"Loading…"}),c&&n.jsx("div",{style:{color:"#fca5a5",fontSize:11},children:c}),s&&n.jsxs(n.Fragment,{children:[n.jsx("pre",{style:{margin:0,fontFamily:'ui-monospace, "SF Mono", Menlo, monospace',fontSize:11,lineHeight:1.55,color:"#e2e8f5",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.summaryText||"(no activity in this window)"}),s.recentLessons.length>0&&n.jsxs("div",{style:{marginTop:16,paddingTop:12,borderTop:"1px solid rgba(255,255,255,0.06)"},children:[n.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:.6,color:"#a5b4fc",marginBottom:6},children:"Lessons learned (Reflexion)"}),s.recentLessons.map((p,g)=>n.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.8)",padding:"4px 0",borderBottom:"1px dashed rgba(255,255,255,0.04)"},children:["• ",p]},g))]})]})]})]})}function Us({label:t,value:e,color:s}){return n.jsxs("div",{style:{textAlign:"center",padding:"6px 4px",borderRadius:6,background:"rgba(255,255,255,0.02)"},children:[n.jsx("div",{style:{fontSize:18,fontWeight:700,color:s,lineHeight:1},children:e}),n.jsx("div",{style:{fontSize:9,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:.5,marginTop:4},children:t})]})}const Fs={pending:"#737373",running:"#60a5fa",done:"#34d399",failed:"#ef4444",skipped:"#a78bfa"},to=6e3,St=180,ar=64,so=96,$s=24;function Qg(t){const e=new Map,s=new Map(t.map(i=>[i.id,i])),r=(i,o)=>{if(e.has(i))return e.get(i);if(o.has(i))return 0;const c=s.get(i);if(!c)return 0;o.add(i);const d=(c.dependsOn??[]).filter(p=>s.has(p)),l=d.length===0?0:Math.max(...d.map(p=>r(p,o)))+1;return o.delete(i),e.set(i,l),l};for(const i of t)r(i.id,new Set);return e}function Zg(){const[t,e]=w.useState([]),[s,r]=w.useState(null),[i,o]=w.useState(null),[c,d]=w.useState(null),[l,p]=w.useState(null),g=w.useCallback(async()=>{try{const v=await ge("/api/missions/active");if(!v.ok)throw new Error(`${v.status} ${v.statusText}`);const m=(await v.json()).missions||[];e(m),!s&&m.length>0&&r(m[0].goalId)}catch(v){d(v.message||"failed")}},[s]),u=w.useCallback(async v=>{try{const A=await ge(`/api/mission/${encodeURIComponent(v)}`);if(!A.ok)throw new Error(`${A.status} ${A.statusText}`);const m=await A.json();o(m),d(null)}catch(A){d(A.message||"failed to load mission"),o(null)}},[]);w.useEffect(()=>{g();const v=setInterval(g,to);return()=>clearInterval(v)},[g]),w.useEffect(()=>{if(!s){o(null);return}u(s);const v=setInterval(()=>u(s),to);return()=>clearInterval(v)},[s,u]);const{layout:f,edges:x,viewBox:y}=w.useMemo(()=>{if(!(i!=null&&i.goal.subtasks))return{layout:[],edges:[],viewBox:"0 0 600 200"};const v=i.goal.subtasks,A=Qg(v),m=new Map;for(const R of v){const P=A.get(R.id)??0;m.has(P)||m.set(P,[]),m.get(P).push(R)}const k=Array.from(m.keys()).sort((R,P)=>R-P),_=Math.max(...Array.from(m.values()).map(R=>R.length),1),T=Math.max(640,_*(St+$s)+$s),S=k.length*so+ar+40,C=new Map,D=[];for(const R of k){const P=m.get(R),B=P.length*St+(P.length-1)*$s,z=(T-B)/2,J=R*so+20;for(let H=0;H<P.length;H++){const K=z+H*(St+$s);C.set(P[H].id,{x:K,y:J}),D.push({...P[H],x:K,y:J})}}const j=[];for(const R of v){const P=C.get(R.id);if(P)for(const B of R.dependsOn??[]){const z=C.get(B);z&&j.push({from:B,to:R.id,x1:z.x+St/2,y1:z.y+ar,x2:P.x+St/2,y2:P.y})}}return{layout:D,edges:j,viewBox:`0 0 ${T} ${S}`}},[i]),E=w.useMemo(()=>new Map(((i==null?void 0:i.goal.subtasks)??[]).map(v=>[v.id,v])),[i]),L=l?E.get(l):null;return n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:10},children:[n.jsxs("div",{style:{flex:1},children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Mission graph"}),n.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:[t.length," active mission(s) · subtask DAG"]})]}),t.length>0&&n.jsx("select",{value:s??"",onChange:v=>r(v.target.value||null),style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"#fff",fontSize:11,padding:"4px 8px",maxWidth:240},children:t.map(v=>n.jsxs("option",{value:v.goalId,children:[v.title," [",v.phase,"]"]},v.goalId))})]}),c&&n.jsx("div",{style:{padding:10,color:"#fca5a5",fontSize:11},children:c}),n.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[n.jsx("div",{style:{flex:1,overflow:"auto",padding:14},children:i?f.length===0?n.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.45)",fontSize:12,textAlign:"center"},children:"This mission has no subtasks yet."}):n.jsxs("svg",{viewBox:y,style:{width:"100%",height:"auto"},role:"img","aria-label":"Mission subtask DAG",children:[n.jsx("defs",{children:n.jsx("marker",{id:"mg-arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:n.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"rgba(255,255,255,0.35)"})})}),x.map((v,A)=>n.jsx("line",{x1:v.x1,y1:v.y1,x2:v.x2,y2:v.y2,stroke:"rgba(255,255,255,0.25)",strokeWidth:"1.4",markerEnd:"url(#mg-arrow)"},`e-${A}`)),f.map(v=>{var _;const A=((_=i.driver)==null?void 0:_.currentSubtaskId)===v.id,m=Fs[v.status],k=l===v.id;return n.jsxs("g",{transform:`translate(${v.x}, ${v.y})`,onClick:()=>p(v.id),style:{cursor:"pointer"},children:[n.jsx("rect",{width:St,height:ar,rx:"8",fill:A?`${m}22`:"rgba(255,255,255,0.04)",stroke:k||A?m:`${m}55`,strokeWidth:A||k?2:1}),n.jsx("circle",{cx:14,cy:14,r:"5",fill:m,children:v.status==="running"&&n.jsx("animate",{attributeName:"r",values:"4;6;4",dur:"1.2s",repeatCount:"indefinite"})}),n.jsx("text",{x:28,y:18,fontSize:"11",fontWeight:"600",fill:"#fafafa",children:v.title.length>22?v.title.slice(0,21)+"…":v.title}),n.jsxs("text",{x:28,y:34,fontSize:"9",fill:"rgba(255,255,255,0.55)",letterSpacing:"0.5",style:{textTransform:"uppercase"},children:[v.status,v.retries>0?` · ${v.retries} retr${v.retries===1?"y":"ies"}`:""]}),n.jsxs("text",{x:14,y:52,fontSize:"9",fill:"rgba(255,255,255,0.45)",children:[(v.description||"").slice(0,30),(v.description||"").length>30?"…":""]}),A&&n.jsx("text",{x:St-8,y:14,fontSize:"8",fill:m,textAnchor:"end",fontWeight:"700",children:"NOW"})]},v.id)})]}):n.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.45)",fontSize:12,textAlign:"center"},children:t.length===0?"No active missions. Launch one via the Mission Driver widget.":"Select a mission to view its graph."})}),L&&n.jsxs("div",{style:{width:260,borderLeft:"1px solid rgba(255,255,255,0.06)",padding:14,overflow:"auto",fontSize:11},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#fafafa",flex:1},children:L.title}),n.jsx("button",{onClick:()=>p(null),style:{background:"transparent",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:14,padding:0,marginLeft:6},children:"×"})]}),n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("span",{style:{padding:"2px 8px",borderRadius:4,fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,background:`${Fs[L.status]}22`,border:`1px solid ${Fs[L.status]}55`,color:Fs[L.status]},children:L.status}),L.retries>0&&n.jsxs("span",{style:{marginLeft:6,color:"rgba(255,255,255,0.5)"},children:[L.retries," retries"]})]}),n.jsx("div",{style:{color:"rgba(255,255,255,0.85)",lineHeight:1.5,marginBottom:10},children:L.description}),L.dependsOn.length>0&&n.jsxs("div",{style:{color:"rgba(255,255,255,0.55)",fontSize:10,marginBottom:6},children:[n.jsx("strong",{children:"Depends on:"})," ",L.dependsOn.map(v=>{var A;return((A=E.get(v))==null?void 0:A.title)||v}).join(", ")]}),L.completedAt&&n.jsxs("div",{style:{color:"rgba(255,255,255,0.45)",fontSize:10},children:["Completed: ",new Date(L.completedAt).toLocaleString()]})]})]}),i&&n.jsxs("div",{style:{padding:"6px 14px",borderTop:"1px solid rgba(255,255,255,0.06)",display:"flex",justifyContent:"space-between",fontSize:10,color:"rgba(255,255,255,0.55)"},children:[n.jsxs("span",{children:[i.goal.subtasks.length," subtasks · ",i.goal.progress,"% progress"]}),i.driver&&n.jsxs("span",{children:[i.driver.phase," · $",i.driver.budget.costUsd.toFixed(2)," spent"]})]})]})}function ey(){const[t,e]=w.useState([]),[s,r]=w.useState(!0),[i,o]=w.useState(null),c=async()=>{try{const d=await fetch("/api/agents");if(!d.ok)throw new Error(`HTTP ${d.status}`);const l=await d.json();e(Array.isArray(l)?l:l.agents||[]),o(null)}catch(d){o(d.message)}finally{r(!1)}};return w.useEffect(()=>{c();const d=setInterval(c,1e4);return()=>clearInterval(d)},[]),s?n.jsx("div",{className:"w-full h-full flex items-center justify-center",children:n.jsx(oo,{className:"w-4 h-4 text-[#6366f1] animate-spin"})}):i?n.jsx("div",{className:"w-full h-full flex items-center justify-center p-4",children:n.jsxs("div",{className:"text-center",children:[n.jsx(gn,{className:"w-4 h-4 text-red-400 mx-auto mb-1"}),n.jsx("span",{className:"text-[10px] text-red-400",children:i})]})}):t.length===0?n.jsx("div",{className:"w-full h-full flex items-center justify-center p-4",children:n.jsx("span",{className:"text-[10px] text-[#52525b]",children:"No active agents"})}):n.jsx("div",{className:"w-full h-full p-3 overflow-auto",children:n.jsx("div",{className:"space-y-2",children:t.map(d=>n.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsx(Dr,{className:`w-3.5 h-3.5 ${d.status==="busy"?"text-[#f59e0b]":d.status==="error"?"text-red-400":"text-[#6366f1]"}`}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-[11px] text-[#a1a1aa] truncate",children:d.name}),n.jsxs("div",{className:"text-[10px] text-[#52525b] truncate",children:[d.role,d.model?` · ${d.model}`:""]})]}),n.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase ${d.status==="busy"?"bg-[#f59e0b]/10 text-[#f59e0b]":d.status==="error"?"bg-red-400/10 text-red-400":"bg-[#6366f1]/10 text-[#818cf8]"}`,children:d.status})]},d.id))})})}function ty(){const[t,e]=w.useState(null),[s,r]=w.useState(!0),i=async()=>{try{const[c,d]=await Promise.allSettled([fetch("/api/health").then(g=>g.ok?g.json():null),fetch("/ollama/api/tags").then(g=>g.ok)]),l=c.status==="fulfilled"&&c.value,p=d.status==="fulfilled"&&d.value;e({gateway:l,ollama:p,version:(l==null?void 0:l.version)||"unknown",uptime:(l==null?void 0:l.uptime)||0})}catch{e({gateway:!1,ollama:!1,version:"unknown",uptime:0})}finally{r(!1)}};if(w.useEffect(()=>{i();const c=setInterval(i,3e4);return()=>clearInterval(c)},[]),s)return n.jsx("div",{className:"w-full h-full flex items-center justify-center",children:n.jsx(oo,{className:"w-4 h-4 text-[#6366f1] animate-spin"})});const o=c=>{const d=Math.floor(c/3600),l=Math.floor(c%3600/60);return`${d}h ${l}m`};return n.jsx("div",{className:"w-full h-full p-3 overflow-auto",children:n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[t!=null&&t.gateway?n.jsx(Ml,{className:"w-3.5 h-3.5 text-emerald-400"}):n.jsx(ql,{className:"w-3.5 h-3.5 text-red-400"}),n.jsx("span",{className:"text-[11px] text-[#a1a1aa]",children:"TITAN Gateway"})]}),n.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase ${t!=null&&t.gateway?"bg-emerald-400/10 text-emerald-400":"bg-red-400/10 text-red-400"}`,children:t!=null&&t.gateway?"Online":"Offline"})]}),n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Yt,{className:`w-3.5 h-3.5 ${t!=null&&t.ollama?"text-emerald-400":"text-red-400"}`}),n.jsx("span",{className:"text-[11px] text-[#a1a1aa]",children:"Ollama"})]}),n.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase ${t!=null&&t.ollama?"bg-emerald-400/10 text-emerald-400":"bg-red-400/10 text-red-400"}`,children:t!=null&&t.ollama?"Online":"Offline"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsx("div",{className:"text-[9px] text-[#52525b] uppercase tracking-wider",children:"Version"}),n.jsx("div",{className:"text-[11px] text-[#a1a1aa] font-mono mt-0.5",children:t==null?void 0:t.version})]}),n.jsxs("div",{className:"px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsx("div",{className:"text-[9px] text-[#52525b] uppercase tracking-wider",children:"Uptime"}),n.jsx("div",{className:"text-[11px] text-[#a1a1aa] font-mono mt-0.5",children:o((t==null?void 0:t.uptime)||0)})]})]})]})})}function zs({label:t,value:e,icon:s,color:r,unknown:i}){const o=Math.max(0,Math.min(100,Math.round(e)));return n.jsxs("div",{className:"px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[s,n.jsx("span",{className:"text-[10px] text-[#52525b] uppercase tracking-wider",children:t})]}),n.jsx("span",{className:"text-[11px] text-[#a1a1aa] font-mono",children:i?"—":`${o}%`})]}),n.jsx("div",{className:"h-1.5 rounded-full bg-[#27272a] overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:i?"0%":`${o}%`,backgroundColor:r}})})]})}function sy(){const[t,e]=w.useState({cpu:0,memory:0,disk:0,load:0,loaded:!1,error:null,diskAvailable:!0});w.useEffect(()=>{let r=!1;async function i(){try{const c=await ge("/api/stats");if(!c.ok){const y=`HTTP ${c.status}`;r||e(E=>({...E,loaded:!0,error:y}));return}const d=await c.json();if(r)return;const l=d.host;if(!l){e(y=>({...y,loaded:!0,error:"no host metrics"}));return}const p=typeof l.cpuPercent=="number"?l.cpuPercent:0,g=typeof l.memPercent=="number"?l.memPercent:0,u=typeof l.diskPercent=="number"?l.diskPercent:0,f=l.cores||1,x=typeof l.loadAvg1=="number"?Math.min(100,l.loadAvg1/f*100):0;e({cpu:p,memory:g,disk:u,load:x,loaded:!0,error:null,diskAvailable:!l.diskError})}catch(c){r||e(d=>({...d,loaded:!0,error:c.message}))}}i();const o=setInterval(i,3e3);return()=>{r=!0,clearInterval(o)}},[]);const s=!t.loaded||!!t.error;return n.jsxs("div",{className:"w-full h-full p-3 overflow-auto",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(zs,{label:"CPU",value:t.cpu,icon:n.jsx(Rr,{className:"w-3 h-3 text-[#6366f1]"}),color:"#6366f1",unknown:s}),n.jsx(zs,{label:"Memory",value:t.memory,icon:n.jsx(Ol,{className:"w-3 h-3 text-[#a78bfa]"}),color:"#a78bfa",unknown:s}),n.jsx(zs,{label:"Disk",value:t.disk,icon:n.jsx(Pl,{className:"w-3 h-3 text-[#10b981]"}),color:"#10b981",unknown:s||!t.diskAvailable}),n.jsx(zs,{label:"Load",value:t.load,icon:n.jsx(Yt,{className:"w-3 h-3 text-[#f59e0b]"}),color:"#f59e0b",unknown:s})]}),t.error&&n.jsx("div",{className:"mt-2 text-[10px] text-[#ef4444]/80",children:t.error})]})}const ny=[{label:"Nav",source:"system:nav",w:3,h:4,icon:n.jsx(ec,{className:"w-3.5 h-3.5"})},{label:"Agents",source:"system:agents",w:3,h:4,icon:n.jsx(Dr,{className:"w-3.5 h-3.5"})},{label:"Health",source:"system:health",w:3,h:3,icon:n.jsx(Yt,{className:"w-3.5 h-3.5"})},{label:"Stats",source:"system:stats",w:3,h:4,icon:n.jsx(oc,{className:"w-3.5 h-3.5"})},{label:"Chat",source:"system:chat",w:4,h:5,icon:n.jsx(xn,{className:"w-3.5 h-3.5"})},{label:"Files",source:"system:files",w:4,h:6,icon:n.jsx(yn,{className:"w-3.5 h-3.5"})},{label:"Skills",source:"system:tools",w:5,h:4,icon:n.jsx(mn,{className:"w-3.5 h-3.5"})},{label:"Soma",source:"system:soma",w:6,h:6,icon:n.jsx(Wl,{className:"w-3.5 h-3.5"})},{label:"Intel",source:"system:intelligence",w:6,h:5,icon:n.jsx(xt,{className:"w-3.5 h-3.5"})},{label:"Infra",source:"system:infra",w:6,h:4,icon:n.jsx(Ir,{className:"w-3.5 h-3.5"})},{label:"Tools",source:"system:tools",w:5,h:4,icon:n.jsx(Tr,{className:"w-3.5 h-3.5"})},{label:"Settings",source:"system:settings",w:4,h:6,icon:n.jsx(Cr,{className:"w-3.5 h-3.5"})},{label:"Wiki",source:"system:memory-wiki",w:5,h:5,icon:n.jsx(ps,{className:"w-3.5 h-3.5"})},{label:"Research",source:"system:autoresearch",w:5,h:5,icon:n.jsx(po,{className:"w-3.5 h-3.5"})},{label:"Proposals",source:"system:self-proposals",w:5,h:5,icon:n.jsx(bo,{className:"w-3.5 h-3.5"})},{label:"Overview",source:"system:overview",w:5,h:4,icon:n.jsx(ro,{className:"w-3.5 h-3.5"})},{label:"Sessions",source:"system:sessions",w:5,h:4,icon:n.jsx(ms,{className:"w-3.5 h-3.5"})},{label:"Watch",source:"system:watch",w:6,h:5,icon:n.jsx(Yt,{className:"w-3.5 h-3.5"})},{label:"Backup",source:"system:backup",w:5,h:5,icon:n.jsx(mo,{className:"w-3.5 h-3.5"})},{label:"Training",source:"system:training",w:5,h:5,icon:n.jsx(xt,{className:"w-3.5 h-3.5"})},{label:"Recipes",source:"system:recipes",w:5,h:5,icon:n.jsx(ps,{className:"w-3.5 h-3.5"})},{label:"VRAM",source:"system:vram",w:5,h:5,icon:n.jsx(Rr,{className:"w-3.5 h-3.5"})},{label:"Teams",source:"system:teams",w:5,h:5,icon:n.jsx(Ar,{className:"w-3.5 h-3.5"})},{label:"Cron",source:"system:cron",w:5,h:5,icon:n.jsx(ms,{className:"w-3.5 h-3.5"})},{label:"Checkpoints",source:"system:checkpoints",w:5,h:5,icon:n.jsx(bn,{className:"w-3.5 h-3.5"})},{label:"Organism",source:"system:organism",w:5,h:5,icon:n.jsx(Lr,{className:"w-3.5 h-3.5"})},{label:"Fleet",source:"system:fleet",w:5,h:5,icon:n.jsx(go,{className:"w-3.5 h-3.5"})},{label:"Browser",source:"system:browser",w:5,h:5,icon:n.jsx(io,{className:"w-3.5 h-3.5"})},{label:"Eval",source:"system:eval",w:5,h:5,icon:n.jsx(yo,{className:"w-3.5 h-3.5"})}];function ry(){const t=(e,s,r)=>{window.dispatchEvent(new CustomEvent("titan:widget:add",{detail:{source:e,w:s,h:r}}))};return n.jsx("div",{className:"w-full h-full p-3 overflow-auto",children:n.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:ny.map(e=>n.jsxs("button",{onClick:()=>t(e.source,e.w,e.h),className:"flex items-center gap-2 px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a] text-[#71717a] hover:text-[#a1a1aa] hover:border-[#3f3f46] hover:bg-[#27272a]/30 transition-all text-left",children:[n.jsx("span",{className:"text-[#6366f1]",children:e.icon}),n.jsx("span",{className:"text-[10px] font-medium",children:e.label})]},e.source))})})}class iy extends oe.Component{componentDidCatch(e){this.props.onError(e.message)}render(){return this.props.children}}function oy({name:t,children:e}){const[s,r]=oe.useState(null);return s?n.jsx("div",{className:"w-full h-full flex items-center justify-center p-4",children:n.jsxs("span",{className:"text-xs text-red-400",children:[t,": ",s]})}):n.jsx(iy,{onError:r,children:e})}const ay=oe.lazy(()=>le(()=>import("./legacy-YQ03_WIq.js"),__vite__mapDeps([106,1,2,4])).then(t=>({default:t.Responsive}))),ly={"system:nav":$f,"system:chat":fl,"system:cmd":_l,"system:soma":kl,"system:command-post":rm,"system:intelligence":om,"system:memory-graph":lm,"system:voice":cm,"system:infra":um,"system:tools":fm,"system:settings":mm,"system:files":gm,"system:settings-general":bm,"system:settings-security":wm,"system:settings-audit":_m,"system:settings-specialists":Sm,"system:settings-privacy":Em,"system:intelligence-autopilot":Cm,"system:intelligence-workflows":Rm,"system:intelligence-learning":Lm,"system:intelligence-self-improve":Dm,"system:intelligence-personas":Om,"system:intelligence-persona-profiles":Wm,"system:intelligence-dream":Um,"system:infra-homelab":$m,"system:infra-gpu":Hm,"system:infra-files":Gm,"system:infra-logs":Ym,"system:infra-telemetry":Jm,"system:tools-skills":Qm,"system:tools-mcp":eg,"system:tools-integrations":sg,"system:tools-channels":rg,"system:tools-mesh":og,"system:agents":ey,"system:health":ty,"system:stats":sy,"system:quick-links":ry,"system:memory-wiki":lg,"system:autoresearch":dg,"system:self-proposals":hg,"system:overview":pg,"system:sessions":gg,"system:watch":bg,"system:backup":wg,"system:training":_g,"system:recipes":Sg,"system:vram":Eg,"system:teams":Cg,"system:cron":Rg,"system:checkpoints":Lg,"system:organism":Dg,"system:fleet":Og,"system:browser":Wg,"system:eval":Ug,"system:time-travel":zg,"system:mission-driver":Gg,"system:daily-digest":Xg,"system:mission-graph":Zg},cy={lg:12,md:10,sm:6,xs:4,xxs:2},dy=60,uy={lg:1200,md:996,sm:768,xs:480,xxs:0},hy=[12,12],fy=["se","sw","ne","nw","e","w","n","s"],py=[{source:"system:nav",name:"Nav",w:3,h:4,label:"Navigation",icon:pc},{source:"system:agents",name:"Agents",w:3,h:4,label:"Agents",icon:Dr},{source:"system:health",name:"Health",w:3,h:3,label:"Health",icon:cc},{source:"system:stats",name:"Stats",w:3,h:4,label:"Stats",icon:Yl},{source:"system:quick-links",name:"Quick Links",w:3,h:4,label:"Links",icon:Kl},{source:"system:chat",name:"Chat",w:4,h:5,label:"Chat",icon:xn}],Sl=oe.forwardRef(({widget:t,space:e,onRemove:s,style:r,className:i,onMouseDown:o,onMouseUp:c,onTouchStart:d,onTouchEnd:l,children:p},g)=>{const u=w.useCallback(()=>s(t.id),[t.id,s]);return n.jsxs("div",{ref:g,style:r,className:i,onMouseDown:o,onMouseUp:c,onTouchStart:d,onTouchEnd:l,children:[n.jsx(yy,{widget:t,space:e,onRemove:u}),p]})});Sl.displayName="MemoWidgetItem";const my=oe.memo(Sl);function gy({widget:t,space:e,onRemove:s}){const r=w.useRef(null),i=w.useRef(null),o=w.useRef(e),[c,d]=w.useState(null),[l,p]=w.useState(!0);if(w.useEffect(()=>{o.current=e},[e]),w.useEffect(()=>{if(t.format==="system"||!r.current)return;if(!t.source||t.source.trim()===""){d("Empty widget — no source code"),p(!1);return}p(!0),d(null),i.current=new cl(r.current,{onLog:u=>console.log(`[Widget ${t.id}]`,u)}),i.current.setMessageHandler(u=>{var x,y,E,L;const f=o.current;if(u.type==="canvas"&&((x=u.payload)==null?void 0:x.action)==="createWidget"){const v=u.payload.def;if(!v)return{ok:!1,error:"createWidget requires a `def` object"};const A=Number.isFinite(v.w)?v.w:4,m=Number.isFinite(v.h)?v.h:4,k=Number.isFinite(v.x)&&Number.isFinite(v.y)?{x:v.x,y:v.y}:Ys(f.widgets||[],A,m);try{const _=ke.addWidget(f.id,{name:v.name||"Agent Widget",format:v.format||"react",source:v.source||"",x:k.x,y:k.y,w:A,h:m});return window.dispatchEvent(new CustomEvent("titan:space:refresh",{detail:{spaceId:f.id}})),{ok:!0,widgetId:_.id}}catch(_){return{ok:!1,error:_.message}}}if(u.type==="canvas"&&((y=u.payload)==null?void 0:y.action)==="updateWidget"){const{id:v,patch:A}=u.payload;return v?(ke.updateWidget(f.id,v,A||{}),window.dispatchEvent(new CustomEvent("titan:space:refresh",{detail:{spaceId:f.id}})),{ok:!0,id:v}):{ok:!1,error:"updateWidget requires an `id`"}}if(u.type==="canvas"&&((E=u.payload)==null?void 0:E.action)==="listWidgets")return{ok:!0,widgets:f.widgets||[]};if(u.type==="canvas"&&((L=u.payload)==null?void 0:L.action)==="removeWidget"){const v=u.payload.id;return v?(ke.removeWidget(f.id,v),window.dispatchEvent(new CustomEvent("titan:space:refresh",{detail:{spaceId:f.id}})),{ok:!0}):{ok:!1,error:"removeWidget requires an `id`"}}return{ok:!1,error:"Unknown message type"}});const g=setTimeout(()=>{p(!1),d("Sandbox timeout: widget took longer than 30s to render. The widget source may have an infinite loop or an unhandled exception. Open DevTools (F12) → Console to see the iframe-side error.")},3e4);return i.current.render(t.format,t.source).then(()=>{clearTimeout(g),p(!1)}).catch(u=>{clearTimeout(g),p(!1),d(String(u))}),()=>{var u;clearTimeout(g),(u=i.current)==null||u.destroy()}},[t.format,t.source,t.id]),t.format==="system"){const g=ly[t.source];return g?n.jsxs("div",{className:"w-full h-full rounded-xl overflow-hidden flex flex-col group transition-colors shadow-md",style:{background:"var(--color-desk-widget-bg)",border:"1px solid var(--color-desk-border)",boxShadow:"0 4px 12px var(--theme-shadow, rgba(60,40,15,0.15))"},children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b panel-drag-handle cursor-move",style:{borderColor:"var(--color-desk-border-light)",background:"var(--theme-leather, rgba(58,37,24,0.05))"},children:[n.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--color-desk-accent)"},children:t.name}),n.jsx("button",{onClick:s,className:"opacity-0 group-hover:opacity-100 text-xs px-1 transition-opacity",style:{color:"var(--color-desk-text-muted)"},children:"×"})]}),n.jsx("div",{className:"flex-1 overflow-auto relative",children:n.jsx(oy,{name:t.name,children:n.jsx(g,{space:e,widget:t,onRemove:s})})})]}):n.jsxs("div",{className:"w-full h-full flex items-center justify-center text-xs text-red-400",children:["Unknown system widget: ",t.source]})}return n.jsxs("div",{className:"w-full h-full rounded-xl overflow-hidden flex flex-col shadow-md",style:{background:"var(--color-desk-widget-bg)",border:"1px solid var(--color-desk-border)",boxShadow:"0 4px 12px var(--theme-shadow, rgba(60,40,15,0.15))"},children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b panel-drag-handle cursor-move",style:{borderColor:"var(--color-desk-border-light)",background:"var(--theme-leather, rgba(58,37,24,0.05))"},children:[n.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--color-desk-accent)"},children:t.name}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{onClick:g=>{g.stopPropagation(),window.dispatchEvent(new CustomEvent("titan:widget:edit",{detail:{spaceId:e.id,widgetId:t.id}}))},onMouseDown:g=>g.stopPropagation(),className:"px-1",style:{color:"var(--color-desk-text-muted)"},title:"Edit widget",children:n.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"m18 2 4 4-14 14H4v-4L18 2z"})})}),n.jsx("button",{onClick:s,className:"text-xs px-1",style:{color:"var(--color-desk-text-muted)"},children:"×"})]})]}),n.jsx("div",{className:"flex-1 relative",children:c?n.jsx("div",{className:"p-3 text-xs text-red-400 font-mono whitespace-pre-wrap",children:c}):n.jsxs(n.Fragment,{children:[n.jsx("iframe",{ref:r,className:"w-full h-full border-0",sandbox:"allow-scripts",title:t.name}),l&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-xs",style:{background:"var(--theme-paper, rgba(253,246,227,0.85))",color:"var(--color-desk-text-muted)",fontFamily:"var(--theme-font-display, 'Georgia', serif)"},children:n.jsx("span",{className:"animate-pulse",children:"Loading widget…"})})]})})]})}const yy=oe.memo(gy);function Ft({label:t,onClick:e,children:s,variant:r="default",disabled:i}){return n.jsx("button",{type:"button",onClick:e,disabled:i,className:`titan-canvas-icon-button titan-canvas-icon-button--${r}`,title:t,"aria-label":t,children:s})}function by(){const{spaceId:t}=Bl(),e=no(),[s,r]=w.useState(null),[i]=w.useState(!1),[o,c]=w.useState(!1),[d,l]=w.useState(null),[p,g]=w.useState(!1),[u,f]=w.useState(!1),[x,y]=w.useState(!1),[E,L]=w.useState(1200),v=w.useRef(null),A=w.useRef(null),{info:m,triggerUpdate:k,waitForReload:_}=Pf(),[T,S]=w.useState(!1);w.useEffect(()=>{const $=t||"home",F=ke.get($);F?r(F):e("/space/home",{replace:!0})},[t,e]),w.useEffect(()=>{const $=()=>{const se=A.current;if(!se)return null;const q=new ResizeObserver(te=>{for(const Q of te)L(Q.contentRect.width)});return q.observe(se),L(se.getBoundingClientRect().width||1200),q};let F=$();const V=setInterval(()=>{F||(F=$()),F&&clearInterval(V)},200);return()=>{F==null||F.disconnect(),clearInterval(V)}},[s==null?void 0:s.id]),w.useEffect(()=>{const $=F=>{(F.metaKey||F.ctrlKey)&&F.key==="k"&&(F.preventDefault(),f(V=>!V)),(F.metaKey||F.ctrlKey)&&F.key==="j"&&(F.preventDefault(),window.dispatchEvent(new CustomEvent("titan:chat:toggle")))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[]),Wf([{key:"?",action:()=>y(!0),description:"Show keyboard shortcuts help"},{key:"g",shift:!0,action:()=>e("/space/command"),description:"Go to Command Post space"},{key:"h",shift:!0,action:()=>e("/space/home"),description:"Go to Home space"},{key:"s",shift:!0,action:()=>e("/space/settings"),description:"Go to Settings space"},{key:"i",shift:!0,action:()=>e("/space/intelligence"),description:"Go to Intelligence space"}]);const C=w.useCallback(()=>{},[]),D=w.useRef(null),j=w.useRef(null),R=w.useCallback($=>{s&&(j.current=$,D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{const F=j.current;!F||!s||(ke.updateLayout(s.id,F.map(V=>({i:V.i,x:V.x,y:V.y,w:V.w,h:V.h}))),j.current=null,D.current=null)},50))},[s]),P=w.useCallback($=>{var se;if(!s)return;const F=(se=s.widgets)==null?void 0:se.find(q=>q.id===$);Wn("canvas_panel_removed",{widgetId:$,format:F==null?void 0:F.format,source:F==null?void 0:F.source}),ke.removeWidget(s.id,$);const V=Array.isArray(s.widgets)?s.widgets:[];r({...s,widgets:V.filter(q=>q.id!==$)})},[s]),B=w.useCallback($=>{if(!s)return;const F=ke.addWidget(s.id,$),V=Array.isArray(s.widgets)?s.widgets:[];return r({...s,widgets:[...V,F]}),Wn($.format==="system"?"canvas_system_panel_created":"canvas_panel_created",{source:$.source,name:$.name,format:$.format}),F},[s]),z=w.useCallback(($,F)=>{if(!s||!Array.isArray(s.widgets)||s.widgets.length===0)return{x:0,y:0};const V=12,se=new Set;for(const q of s.widgets)for(let te=0;te<q.w;te++)for(let Q=0;Q<q.h;Q++)se.add(`${q.x+te},${q.y+Q}`);for(let q=0;q<200;q++)for(let te=0;te<=V-$;te++){let Q=!0;for(let be=0;be<$;be++){for(let Ce=0;Ce<F;Ce++)if(se.has(`${te+be},${q+Ce}`)){Q=!1;break}if(!Q)break}if(Q)return{x:te,y:q}}return{x:0,y:0}},[s]),J=w.useCallback(($,F,V=4,se=4)=>{const q=z(V,se);B({name:F,format:"system",source:$,x:q.x,y:q.y,w:V,h:se})},[B,z]);w.useEffect(()=>{const $=F=>{const V=F.detail;if(console.log("[TitanCanvas] titan:space:refresh received:",V),!!s&&(V==null?void 0:V.spaceId)===s.id){const se=ke.get(s.id);se&&(console.log("[TitanCanvas] Refreshing space, widget count:",se.widgets.length),r(se))}};return window.addEventListener("titan:space:refresh",$),()=>window.removeEventListener("titan:space:refresh",$)},[s]),w.useEffect(()=>{const $=F=>{const V=F.detail;if(s&&V!=null&&V.source){const se=Number.isFinite(V.w)?V.w:4,q=Number.isFinite(V.h)?V.h:4,te=typeof V.name=="string"&&V.name.trim()?V.name.trim():String(V.source).replace("system:","").replace(/-/g," "),Q=V.format==="react"||V.format==="vanilla"||V.format==="html"||V.format==="system"?V.format:String(V.source).startsWith("system:")?"system":"react",be=z(se,q);B({name:te,format:Q,source:String(V.source),x:be.x,y:be.y,w:se,h:q})}};return window.addEventListener("titan:widget:add",$),()=>window.removeEventListener("titan:widget:add",$)},[s,B,z]),w.useEffect(()=>{const $=F=>{const V=F.detail;s&&(V==null?void 0:V.spaceId)===s.id&&typeof(V==null?void 0:V.widgetId)=="string"&&l(V.widgetId)};return window.addEventListener("titan:widget:edit",$),()=>window.removeEventListener("titan:widget:edit",$)},[s]),w.useEffect(()=>s?ke.observe(s.id,F=>{console.log("[TitanCanvas] CRDT observer fired, widgets:",F.length),r(V=>V&&{...V,widgets:F})}):void 0,[s==null?void 0:s.id]);const H=w.useMemo(()=>{const $=s==null?void 0:s.widgets;return Array.isArray($)?$.filter(Boolean):[]},[s]),K=w.useMemo(()=>H.map(($,F)=>({i:$.id,x:Number.isFinite($.x)?$.x:F%3*4,y:Number.isFinite($.y)?$.y:Math.floor(F/3)*4,w:Number.isFinite($.w)?$.w:4,h:Number.isFinite($.h)?$.h:4,minW:2,minH:2,maxW:12,maxH:40})),[H]);return s?n.jsxs("div",{className:"h-full w-full flex",children:[n.jsx(Bp,{}),n.jsxs("div",{ref:v,className:"flex-1 relative overflow-auto",children:[n.jsx("style",{children:`
995
995
  .titan-canvas-grid .react-grid-item > .react-resizable-handle {
996
996
  background: none;
997
997
  padding: 0;