titan-agent 6.3.2 → 6.3.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 (144) hide show
  1. package/dist/utils/constants.js +1 -1
  2. package/dist/utils/constants.js.map +1 -1
  3. package/package.json +1 -1
  4. package/ui/dist/assets/{AuditPanel-6hTX-30T.js → AuditPanel-srKuRJBx.js} +1 -1
  5. package/ui/dist/assets/{AutonomyPanel-bEolzW0c.js → AutonomyPanel-DTOg92_8.js} +1 -1
  6. package/ui/dist/assets/{AutopilotPanel-BBhP6EEw.js → AutopilotPanel-C-XlExji.js} +1 -1
  7. package/ui/dist/assets/{AutoresearchPanel-CmSoFu9c.js → AutoresearchPanel-BYffkknO.js} +1 -1
  8. package/ui/dist/assets/{BackupPanel-BMqXOM64.js → BackupPanel-BpqVqS2y.js} +1 -1
  9. package/ui/dist/assets/{BrowserPanel-DqpJBtZO.js → BrowserPanel-CpcHkt_q.js} +1 -1
  10. package/ui/dist/assets/{CPActivity-kjPVmtna.js → CPActivity-BDsBsGAV.js} +1 -1
  11. package/ui/dist/assets/{CPAgentDetail-DJVqWbIz.js → CPAgentDetail-C8kfr8IG.js} +1 -1
  12. package/ui/dist/assets/{CPAgents-DvoKU7K3.js → CPAgents-DO7kdGWL.js} +1 -1
  13. package/ui/dist/assets/{CPApprovals-CgkIcjKy.js → CPApprovals-UJ-Rs0IT.js} +1 -1
  14. package/ui/dist/assets/{CPCosts-Dh2-rKBQ.js → CPCosts-C7ZevZP2.js} +1 -1
  15. package/ui/dist/assets/{CPDashboard-Bk5ehnOo.js → CPDashboard-BZN7lJ4t.js} +1 -1
  16. package/ui/dist/assets/{CPFiles-85DnmiZ9.js → CPFiles-Bx4ttNJ8.js} +1 -1
  17. package/ui/dist/assets/{CPGoals-CmaEWa0s.js → CPGoals-Bvzkk8W6.js} +1 -1
  18. package/ui/dist/assets/{CPInbox-DyrwUxsn.js → CPInbox-BczZjFbO.js} +1 -1
  19. package/ui/dist/assets/{CPIssueDetail-tuKkMZU0.js → CPIssueDetail-DRVr_aqu.js} +1 -1
  20. package/ui/dist/assets/{CPIssues-CRkGwoU7.js → CPIssues-DpeO_37Y.js} +1 -1
  21. package/ui/dist/assets/CPLayout-B2Odh1We.js +2 -0
  22. package/ui/dist/assets/{CPOrg-BiYIRMSl.js → CPOrg-CZaFupL_.js} +1 -1
  23. package/ui/dist/assets/{CPRuns-_2GvItJv.js → CPRuns-LfgKZcY5.js} +1 -1
  24. package/ui/dist/assets/{CPSocial-BBdyKNyq.js → CPSocial-aV6eplfG.js} +1 -1
  25. package/ui/dist/assets/{CPVoice-BnYo-G04.js → CPVoice-CJfW9Rmi.js} +1 -1
  26. package/ui/dist/assets/{ChannelsPanel-e1nT5QcW.js → ChannelsPanel-C2BO3kax.js} +1 -1
  27. package/ui/dist/assets/{CheckpointsPanel-BixKyU53.js → CheckpointsPanel-CBcHZncd.js} +1 -1
  28. package/ui/dist/assets/{CommandPostHub-Ckh7LlWG.js → CommandPostHub-CLnqGM62.js} +3 -3
  29. package/ui/dist/assets/{CronPanel-BMneWRHA.js → CronPanel-DGraqIbo.js} +1 -1
  30. package/ui/dist/assets/{DataTable-CEjOtKUe.js → DataTable-BJlvWF1y.js} +1 -1
  31. package/ui/dist/assets/{DreamPanel-BJO5hRUh.js → DreamPanel-DfczImsZ.js} +1 -1
  32. package/ui/dist/assets/{EmptyState-CB9me2NW.js → EmptyState-D_fRWCXx.js} +1 -1
  33. package/ui/dist/assets/{EvalHarnessPanel-Dg_ghVTz.js → EvalHarnessPanel-Benn3gFG.js} +1 -1
  34. package/ui/dist/assets/{EvalPanel-j3fHE-k4.js → EvalPanel-DDDTr1W8.js} +1 -1
  35. package/ui/dist/assets/{FileViewer-C7fgbngf.js → FileViewer-CFDLpbl3.js} +1 -1
  36. package/ui/dist/assets/{FilesPanel-Cimj2Z8k.js → FilesPanel-g8k7Z_ea.js} +1 -1
  37. package/ui/dist/assets/{FleetPanel-zzprw7Ro.js → FleetPanel-01gxZlxR.js} +1 -1
  38. package/ui/dist/assets/{HomelabPanel-C658fL2z.js → HomelabPanel-C_Kpp-jq.js} +1 -1
  39. package/ui/dist/assets/InfraView-DLhemt3r.js +2 -0
  40. package/ui/dist/assets/{InlineEditableField-ChiCaepw.js → InlineEditableField-zyYfa5Jl.js} +1 -1
  41. package/ui/dist/assets/{Input-DoWIY9i3.js → Input-Cm4ppgbt.js} +1 -1
  42. package/ui/dist/assets/{IntegrationsPanel-Xy3HlXti.js → IntegrationsPanel-DLfYHy7-.js} +1 -1
  43. package/ui/dist/assets/IntelligenceView-I7i3t8kE.js +2 -0
  44. package/ui/dist/assets/{LearningPanel-Ka17sHxK.js → LearningPanel-2LcS5Vqm.js} +1 -1
  45. package/ui/dist/assets/{LogsPanel-BiELvlMC.js → LogsPanel-YDE1-OQU.js} +1 -1
  46. package/ui/dist/assets/{McpPanel-BW2r8V3m.js → McpPanel-D1v3LwyX.js} +1 -1
  47. package/ui/dist/assets/{MemoryGraphPanel-DZTQIsys.js → MemoryGraphPanel-CtWA8YuJ.js} +1 -1
  48. package/ui/dist/assets/{MemoryWikiPanel-BSbG8c80.js → MemoryWikiPanel-Cqps7hGG.js} +1 -1
  49. package/ui/dist/assets/{MeshPanel-Ch_uGo4a.js → MeshPanel-BNBI60Kh.js} +1 -1
  50. package/ui/dist/assets/{MissionCanvas-BMv0c-RX.js → MissionCanvas-CPmsOHNs.js} +1 -1
  51. package/ui/dist/assets/{MissionChat-CFwKDVc8.js → MissionChat-BhdcG_8G.js} +1 -1
  52. package/ui/dist/assets/{MissionLibrary-D2LfLlm2.js → MissionLibrary-Deks4dm7.js} +1 -1
  53. package/ui/dist/assets/{MissionStart-CTyqZWBT.js → MissionStart-ClQzNvvk.js} +1 -1
  54. package/ui/dist/assets/{Modal-BS3rireW.js → Modal-D3kmdSBW.js} +1 -1
  55. package/ui/dist/assets/{NvidiaPanel-53CiSPrh.js → NvidiaPanel-BhSsBbMG.js} +1 -1
  56. package/ui/dist/assets/{OrganismPanel-BRbiiY5k.js → OrganismPanel-5eKj-u5O.js} +1 -1
  57. package/ui/dist/assets/{OverviewPanel-CmRVwkE7.js → OverviewPanel-C7YJgjIS.js} +1 -1
  58. package/ui/dist/assets/{PageHeader-Cx4DHJXy.js → PageHeader-0FZrM9sX.js} +1 -1
  59. package/ui/dist/assets/{PersonaProfilesPanel-hmUdUabW.js → PersonaProfilesPanel-Kbyz2S3M.js} +1 -1
  60. package/ui/dist/assets/{PersonasPanel-VfvknF9L.js → PersonasPanel-DzJFmfaz.js} +1 -1
  61. package/ui/dist/assets/{PhoneDeskPanel-DX_6zrt5.js → PhoneDeskPanel-DZDPkVmm.js} +1 -1
  62. package/ui/dist/assets/{RecipesPanel-B7NygJvl.js → RecipesPanel-sG2wIUOY.js} +1 -1
  63. package/ui/dist/assets/{SecurityPanel-DRZu6PRV.js → SecurityPanel-R8QcTvYn.js} +1 -1
  64. package/ui/dist/assets/{SelfImprovePanel-CgJG9v1W.js → SelfImprovePanel-Burrv2Jw.js} +1 -1
  65. package/ui/dist/assets/{SelfProposalsPanel-BenuzEGo.js → SelfProposalsPanel-DdHyA7M7.js} +1 -1
  66. package/ui/dist/assets/{SessionsPanel-CFdsWt2W.js → SessionsPanel-ByV8dYnL.js} +1 -1
  67. package/ui/dist/assets/{SessionsTab-8Qtu9BMv.js → SessionsTab-BRpcK3SC.js} +1 -1
  68. package/ui/dist/assets/{SettingsPanel-CmIAAw_T.js → SettingsPanel-E5WyEqka.js} +1 -1
  69. package/ui/dist/assets/SettingsView-BPVPhIUK.js +2 -0
  70. package/ui/dist/assets/{SkeletonLoader-crWOfBFq.js → SkeletonLoader-BxTaQoW_.js} +1 -1
  71. package/ui/dist/assets/{SkillsPanel-BINP41r2.js → SkillsPanel-BXyiyd7F.js} +1 -1
  72. package/ui/dist/assets/{SomaView-CzZ6SCuw.js → SomaView-w865kZBc.js} +1 -1
  73. package/ui/dist/assets/{StatCard-DfoksLmM.js → StatCard-D2OzXAEF.js} +1 -1
  74. package/ui/dist/assets/{StatusBadge-FyqmZDG0.js → StatusBadge-9A-LF8XO.js} +1 -1
  75. package/ui/dist/assets/{Tabs-BMzVMYab.js → Tabs-C7UF63vs.js} +1 -1
  76. package/ui/dist/assets/{TeamsPanel-CwVNzD77.js → TeamsPanel-BeNA1P-k.js} +1 -1
  77. package/ui/dist/assets/{TelemetryPanel-C3JTWWQO.js → TelemetryPanel-D8gu25aT.js} +1 -1
  78. package/ui/dist/assets/{TitanCanvas-CmVs4TFr.js → TitanCanvas-D7KEvDFz.js} +4 -4
  79. package/ui/dist/assets/{ToolsView-C3m7TbnX.js → ToolsView-CDeB3RtS.js} +2 -2
  80. package/ui/dist/assets/{Tooltip-DZJl8UaT.js → Tooltip-1mExUZjj.js} +1 -1
  81. package/ui/dist/assets/{TraceViewer-CfFZQJ3K.js → TraceViewer-MDRjeVoy.js} +1 -1
  82. package/ui/dist/assets/{TrainingPanel-BMunX3EV.js → TrainingPanel-CS9oWB58.js} +1 -1
  83. package/ui/dist/assets/{VoiceOverlay-DRjTeQgq.js → VoiceOverlay-BeQ9oiym.js} +1 -1
  84. package/ui/dist/assets/{VramPanel-C4nG82nu.js → VramPanel-BNOFAvif.js} +1 -1
  85. package/ui/dist/assets/{WatchView-Cflz1FfL.js → WatchView-COyUaBza.js} +1 -1
  86. package/ui/dist/assets/{WorkTab-BglKN8Uf.js → WorkTab-BFYrzFcn.js} +1 -1
  87. package/ui/dist/assets/{WorkflowsPanel-BZQu93gE.js → WorkflowsPanel-DEz8opv0.js} +1 -1
  88. package/ui/dist/assets/{archive-C10aphzL.js → archive-D0TMs-ec.js} +1 -1
  89. package/ui/dist/assets/{arrow-left-CLTerrT5.js → arrow-left-BflMGFJr.js} +1 -1
  90. package/ui/dist/assets/{book-open-DQ4VpfMq.js → book-open-DucGf6Ry.js} +1 -1
  91. package/ui/dist/assets/{bot-DNI_W-iH.js → bot-DlZ9827e.js} +1 -1
  92. package/ui/dist/assets/{chart-column-COymYluE.js → chart-column-Dva45R9X.js} +1 -1
  93. package/ui/dist/assets/{check-Dq1bBdnM.js → check-o_c7GSUi.js} +1 -1
  94. package/ui/dist/assets/{chevron-right-Dz0EiJIX.js → chevron-right-B2xN7vZr.js} +1 -1
  95. package/ui/dist/assets/{chevron-up-CaJdgiQv.js → chevron-up-DNehgPl9.js} +1 -1
  96. package/ui/dist/assets/{circle-check-big-Bi688_yD.js → circle-check-big-BTui49nQ.js} +1 -1
  97. package/ui/dist/assets/{circle-stop-BKeZMLyT.js → circle-stop-GEGv_qUQ.js} +1 -1
  98. package/ui/dist/assets/{clipboard-list-BvhH8UZ-.js → clipboard-list-Dy-3UtJn.js} +1 -1
  99. package/ui/dist/assets/{clock-BiDhhRG4.js → clock-DSVWc_hS.js} +1 -1
  100. package/ui/dist/assets/{dollar-sign-XvC0BdrI.js → dollar-sign-B57wYnbN.js} +1 -1
  101. package/ui/dist/assets/{download-BUv-3ow-.js → download-BYoF2I2k.js} +1 -1
  102. package/ui/dist/assets/{external-link-6i_dEGHo.js → external-link-BbZ5ZMbT.js} +1 -1
  103. package/ui/dist/assets/{file-text-CMteaHPb.js → file-text-BsTFGmBj.js} +1 -1
  104. package/ui/dist/assets/{flask-conical-DOupoJs-.js → flask-conical-D8gouq57.js} +1 -1
  105. package/ui/dist/assets/{folder-Heg9X62R.js → folder-C0s6yhdf.js} +1 -1
  106. package/ui/dist/assets/{funnel-C1qSeehb.js → funnel-CYj9F_J0.js} +1 -1
  107. package/ui/dist/assets/{git-branch-BgrSzLGu.js → git-branch-BFjAPkNq.js} +1 -1
  108. package/ui/dist/assets/{index-CfeeNofL.js → index-Dnvk3jCu.js} +61 -61
  109. package/ui/dist/assets/{layers-BXjHgthV.js → layers-7OM7j4xy.js} +1 -1
  110. package/ui/dist/assets/{legacy-CMWeVEm-.js → legacy-DWFG28eD.js} +1 -1
  111. package/ui/dist/assets/{lightbulb-CaU3yf0V.js → lightbulb-KE9dVLJ1.js} +1 -1
  112. package/ui/dist/assets/{list-todo-DIH1DDut.js → list-todo-I7S4ILfX.js} +1 -1
  113. package/ui/dist/assets/{message-square-CAJnwIi8.js → message-square-BktXdPkG.js} +1 -1
  114. package/ui/dist/assets/{mic-a150MaF_.js → mic-CQcJXVlD.js} +1 -1
  115. package/ui/dist/assets/{missions-BCmxIqis.js → missions-DoFF2JOc.js} +1 -1
  116. package/ui/dist/assets/{network-DpJozzT9.js → network-CxR7yDrR.js} +1 -1
  117. package/ui/dist/assets/{pause-B7pXF6wS.js → pause-CoNV7lxb.js} +1 -1
  118. package/ui/dist/assets/{pencil-DNQZmkMU.js → pencil-BfcTfeAV.js} +1 -1
  119. package/ui/dist/assets/{play-CB_hciEJ.js → play-BQj0nGq2.js} +1 -1
  120. package/ui/dist/assets/{plug-UdiCBZ6I.js → plug-Bt3RMNci.js} +1 -1
  121. package/ui/dist/assets/{plus-BNliIo_L.js → plus-D3aWFzy1.js} +1 -1
  122. package/ui/dist/assets/{proxy-tgCU20-X.js → proxy-Dxc39wKi.js} +1 -1
  123. package/ui/dist/assets/{radio-KEVgfxWk.js → radio-DwaUeLWj.js} +1 -1
  124. package/ui/dist/assets/{refresh-cw-C4BAymqq.js → refresh-cw-pV7an3cE.js} +1 -1
  125. package/ui/dist/assets/{rotate-ccw-CyT1wcCY.js → rotate-ccw-DQ2_e6Ey.js} +1 -1
  126. package/ui/dist/assets/{save-ICOKiEQf.js → save-Bc5LT98_.js} +1 -1
  127. package/ui/dist/assets/{search-qz2VMyBQ.js → search-5DwwxYyL.js} +1 -1
  128. package/ui/dist/assets/{send-AYGyxY6d.js → send-D1b4UjEx.js} +1 -1
  129. package/ui/dist/assets/{server-DMkFokTU.js → server-DjUE1pG1.js} +1 -1
  130. package/ui/dist/assets/{shield-check-Dtr3ujKk.js → shield-check-CFFgZVUJ.js} +1 -1
  131. package/ui/dist/assets/{terminal-ucriUmF-.js → terminal-BgivA6PX.js} +1 -1
  132. package/ui/dist/assets/{test-tube-Co4Kjj0G.js → test-tube-dYWRJTXm.js} +1 -1
  133. package/ui/dist/assets/{toggle-right-NKDEGJdm.js → toggle-right-C0WDq8zW.js} +1 -1
  134. package/ui/dist/assets/{trash-2-CJjOlqMp.js → trash-2-BYDarYfk.js} +1 -1
  135. package/ui/dist/assets/{trending-up-CC4itzlz.js → trending-up-gomnMzHI.js} +1 -1
  136. package/ui/dist/assets/{trophy-BP9FY35i.js → trophy-BdGosdNp.js} +1 -1
  137. package/ui/dist/assets/{volume-2-CAQ1nA-B.js → volume-2-UXO66-b3.js} +1 -1
  138. package/ui/dist/assets/{wifi-off-jrnDcc0y.js → wifi-off-BBMJbZvM.js} +1 -1
  139. package/ui/dist/index.html +1 -1
  140. package/ui/dist/sw.js +1 -1
  141. package/ui/dist/assets/CPLayout-BUN7FasU.js +0 -2
  142. package/ui/dist/assets/InfraView-DAwJClAs.js +0 -2
  143. package/ui/dist/assets/IntelligenceView-CJ2r76hu.js +0 -2
  144. package/ui/dist/assets/SettingsView-ByyjhwLz.js +0 -2
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SomaView-CzZ6SCuw.js","assets/index-CfeeNofL.js","assets/index-DmgXt1oB.css","assets/Input-DoWIY9i3.js","assets/clsx-B-dksMZM.js","assets/Tooltip-DZJl8UaT.js","assets/SomaView-BtCkeWfZ.css","assets/CommandPostHub-Ckh7LlWG.js","assets/Modal-BS3rireW.js","assets/proxy-tgCU20-X.js","assets/InlineEditableField-ChiCaepw.js","assets/check-Dq1bBdnM.js","assets/pencil-DNQZmkMU.js","assets/approvalHeadline-DB9SgR-9.js","assets/chevron-right-Dz0EiJIX.js","assets/bot-DNI_W-iH.js","assets/pause-B7pXF6wS.js","assets/dollar-sign-XvC0BdrI.js","assets/git-branch-BgrSzLGu.js","assets/chart-column-COymYluE.js","assets/clock-BiDhhRG4.js","assets/message-square-CAJnwIi8.js","assets/file-text-CMteaHPb.js","assets/terminal-ucriUmF-.js","assets/refresh-cw-C4BAymqq.js","assets/circle-stop-BKeZMLyT.js","assets/send-AYGyxY6d.js","assets/plus-BNliIo_L.js","assets/trash-2-CJjOlqMp.js","assets/IntelligenceView-CJ2r76hu.js","assets/MemoryGraphPanel-DZTQIsys.js","assets/network-DpJozzT9.js","assets/search-qz2VMyBQ.js","assets/InfraView-DAwJClAs.js","assets/ToolsView-C3m7TbnX.js","assets/SettingsView-ByyjhwLz.js","assets/SettingsPanel-CmIAAw_T.js","assets/PageHeader-Cx4DHJXy.js","assets/circle-check-big-Bi688_yD.js","assets/mic-a150MaF_.js","assets/wifi-off-jrnDcc0y.js","assets/download-BUv-3ow-.js","assets/play-CB_hciEJ.js","assets/save-ICOKiEQf.js","assets/SecurityPanel-DRZu6PRV.js","assets/AuditPanel-6hTX-30T.js","assets/clipboard-list-BvhH8UZ-.js","assets/funnel-C1qSeehb.js","assets/AutopilotPanel-BBhP6EEw.js","assets/WorkflowsPanel-BZQu93gE.js","assets/toggle-right-NKDEGJdm.js","assets/book-open-DQ4VpfMq.js","assets/LearningPanel-Ka17sHxK.js","assets/lightbulb-CaU3yf0V.js","assets/trending-up-CC4itzlz.js","assets/chevron-up-CaJdgiQv.js","assets/server-DMkFokTU.js","assets/rotate-ccw-CyT1wcCY.js","assets/flask-conical-DOupoJs-.js","assets/archive-C10aphzL.js","assets/radio-KEVgfxWk.js","assets/test-tube-Co4Kjj0G.js","assets/VoiceOverlay-DRjTeQgq.js","assets/volume-2-CAQ1nA-B.js","assets/folder-Heg9X62R.js","assets/shield-check-Dtr3ujKk.js","assets/external-link-6i_dEGHo.js","assets/SelfImprovePanel-CgJG9v1W.js","assets/trophy-BP9FY35i.js","assets/PersonasPanel-VfvknF9L.js","assets/PersonaProfilesPanel-hmUdUabW.js","assets/DreamPanel-BJO5hRUh.js","assets/HomelabPanel-C658fL2z.js","assets/StatCard-DfoksLmM.js","assets/SkeletonLoader-crWOfBFq.js","assets/NvidiaPanel-53CiSPrh.js","assets/FilesPanel-Cimj2Z8k.js","assets/arrow-left-CLTerrT5.js","assets/LogsPanel-BiELvlMC.js","assets/TelemetryPanel-C3JTWWQO.js","assets/SkillsPanel-BINP41r2.js","assets/McpPanel-BW2r8V3m.js","assets/plug-UdiCBZ6I.js","assets/IntegrationsPanel-Xy3HlXti.js","assets/ChannelsPanel-e1nT5QcW.js","assets/MeshPanel-Ch_uGo4a.js","assets/DataTable-CEjOtKUe.js","assets/MemoryWikiPanel-BSbG8c80.js","assets/AutoresearchPanel-CmSoFu9c.js","assets/SelfProposalsPanel-BenuzEGo.js","assets/OverviewPanel-CmRVwkE7.js","assets/layers-BXjHgthV.js","assets/SessionsPanel-CFdsWt2W.js","assets/WatchView-Cflz1FfL.js","assets/BackupPanel-BMqXOM64.js","assets/TrainingPanel-BMunX3EV.js","assets/RecipesPanel-B7NygJvl.js","assets/VramPanel-C4nG82nu.js","assets/TeamsPanel-CwVNzD77.js","assets/CronPanel-BMneWRHA.js","assets/CheckpointsPanel-BixKyU53.js","assets/OrganismPanel-BRbiiY5k.js","assets/FleetPanel-zzprw7Ro.js","assets/BrowserPanel-DqpJBtZO.js","assets/EvalPanel-j3fHE-k4.js","assets/legacy-CMWeVEm-.js"])))=>i.map(i=>d[i]);
2
- var vl=Object.defineProperty;var _l=(t,e,s)=>e in t?vl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var $e=(t,e,s)=>_l(t,typeof e!="symbol"?e+"":e,s);import{c as ts,a as et,g as kl,r as w,b as ge,j as n,S as Sr,W as jr,B as yt,H as Sl,s as jl,u as Zi,d as El,e as Nl,X as js,f as Er,E as eo,A as Vt,C as Nr,U as Cr,h as Tr,G as to,R as oe,_ as le,Z as Cl,i as fn,I as ci,k as Tl,l as Rl,L as so,m as Al,M as Ll,n as Il,o as Dl,p as Ml,t as Dn}from"./index-CfeeNofL.js";import{C as Ol}from"./chevron-up-CaJdgiQv.js";import{P as Pl}from"./plus-BNliIo_L.js";import{F as pn}from"./file-text-CMteaHPb.js";import{S as Rr}from"./server-DMkFokTU.js";import{N as no}from"./network-DpJozzT9.js";import{T as ro}from"./terminal-ucriUmF-.js";import{B as fs}from"./book-open-DQ4VpfMq.js";import{S as mn}from"./save-ICOKiEQf.js";import{P as Wl}from"./pencil-DNQZmkMU.js";import{R as io}from"./rotate-ccw-CyT1wcCY.js";import{S as oo}from"./search-qz2VMyBQ.js";import{S as ao}from"./send-AYGyxY6d.js";import{M as lo}from"./message-square-CAJnwIi8.js";import{M as co}from"./mic-a150MaF_.js";import{F as uo}from"./flask-conical-DOupoJs-.js";import{C as ps}from"./clock-BiDhhRG4.js";import{A as ho}from"./archive-C10aphzL.js";import{R as fo}from"./radio-KEVgfxWk.js";import{T as po,P as di}from"./test-tube-Co4Kjj0G.js";import{VoiceOverlay as Bl}from"./VoiceOverlay-DRjTeQgq.js";import{C as Ul}from"./chevron-right-Dz0EiJIX.js";import{R as gn}from"./refresh-cw-C4BAymqq.js";import{F as Fl}from"./folder-Heg9X62R.js";import{C as ui}from"./check-Dq1bBdnM.js";import{S as $l}from"./shield-check-Dtr3ujKk.js";import{E as hi}from"./external-link-6i_dEGHo.js";import{B as mo}from"./bot-DNI_W-iH.js";import{W as zl}from"./wifi-off-jrnDcc0y.js";/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SomaView-w865kZBc.js","assets/index-Dnvk3jCu.js","assets/index-DmgXt1oB.css","assets/Input-Cm4ppgbt.js","assets/clsx-B-dksMZM.js","assets/Tooltip-1mExUZjj.js","assets/SomaView-BtCkeWfZ.css","assets/CommandPostHub-CLnqGM62.js","assets/Modal-D3kmdSBW.js","assets/proxy-Dxc39wKi.js","assets/InlineEditableField-zyYfa5Jl.js","assets/check-o_c7GSUi.js","assets/pencil-BfcTfeAV.js","assets/approvalHeadline-DB9SgR-9.js","assets/chevron-right-B2xN7vZr.js","assets/bot-DlZ9827e.js","assets/pause-CoNV7lxb.js","assets/dollar-sign-B57wYnbN.js","assets/git-branch-BFjAPkNq.js","assets/chart-column-Dva45R9X.js","assets/clock-DSVWc_hS.js","assets/message-square-BktXdPkG.js","assets/file-text-BsTFGmBj.js","assets/terminal-BgivA6PX.js","assets/refresh-cw-pV7an3cE.js","assets/circle-stop-GEGv_qUQ.js","assets/send-D1b4UjEx.js","assets/plus-D3aWFzy1.js","assets/trash-2-BYDarYfk.js","assets/IntelligenceView-I7i3t8kE.js","assets/MemoryGraphPanel-CtWA8YuJ.js","assets/network-CxR7yDrR.js","assets/search-5DwwxYyL.js","assets/InfraView-DLhemt3r.js","assets/ToolsView-CDeB3RtS.js","assets/SettingsView-BPVPhIUK.js","assets/SettingsPanel-E5WyEqka.js","assets/PageHeader-0FZrM9sX.js","assets/circle-check-big-BTui49nQ.js","assets/mic-CQcJXVlD.js","assets/wifi-off-BBMJbZvM.js","assets/download-BYoF2I2k.js","assets/play-BQj0nGq2.js","assets/save-Bc5LT98_.js","assets/SecurityPanel-R8QcTvYn.js","assets/AuditPanel-srKuRJBx.js","assets/clipboard-list-Dy-3UtJn.js","assets/funnel-CYj9F_J0.js","assets/AutopilotPanel-C-XlExji.js","assets/WorkflowsPanel-DEz8opv0.js","assets/toggle-right-C0WDq8zW.js","assets/book-open-DucGf6Ry.js","assets/LearningPanel-2LcS5Vqm.js","assets/lightbulb-KE9dVLJ1.js","assets/trending-up-gomnMzHI.js","assets/chevron-up-DNehgPl9.js","assets/server-DjUE1pG1.js","assets/rotate-ccw-DQ2_e6Ey.js","assets/flask-conical-D8gouq57.js","assets/archive-D0TMs-ec.js","assets/radio-DwaUeLWj.js","assets/test-tube-dYWRJTXm.js","assets/VoiceOverlay-BeQ9oiym.js","assets/volume-2-UXO66-b3.js","assets/folder-C0s6yhdf.js","assets/shield-check-CFFgZVUJ.js","assets/external-link-BbZ5ZMbT.js","assets/SelfImprovePanel-Burrv2Jw.js","assets/trophy-BdGosdNp.js","assets/PersonasPanel-DzJFmfaz.js","assets/PersonaProfilesPanel-Kbyz2S3M.js","assets/DreamPanel-DfczImsZ.js","assets/HomelabPanel-C_Kpp-jq.js","assets/StatCard-D2OzXAEF.js","assets/SkeletonLoader-BxTaQoW_.js","assets/NvidiaPanel-BhSsBbMG.js","assets/FilesPanel-g8k7Z_ea.js","assets/arrow-left-BflMGFJr.js","assets/LogsPanel-YDE1-OQU.js","assets/TelemetryPanel-D8gu25aT.js","assets/SkillsPanel-BXyiyd7F.js","assets/McpPanel-D1v3LwyX.js","assets/plug-Bt3RMNci.js","assets/IntegrationsPanel-DLfYHy7-.js","assets/ChannelsPanel-C2BO3kax.js","assets/MeshPanel-BNBI60Kh.js","assets/DataTable-BJlvWF1y.js","assets/MemoryWikiPanel-Cqps7hGG.js","assets/AutoresearchPanel-BYffkknO.js","assets/SelfProposalsPanel-DdHyA7M7.js","assets/OverviewPanel-C7YJgjIS.js","assets/layers-7OM7j4xy.js","assets/SessionsPanel-ByV8dYnL.js","assets/WatchView-COyUaBza.js","assets/BackupPanel-BpqVqS2y.js","assets/TrainingPanel-CS9oWB58.js","assets/RecipesPanel-sG2wIUOY.js","assets/VramPanel-BNOFAvif.js","assets/TeamsPanel-BeNA1P-k.js","assets/CronPanel-DGraqIbo.js","assets/CheckpointsPanel-CBcHZncd.js","assets/OrganismPanel-5eKj-u5O.js","assets/FleetPanel-01gxZlxR.js","assets/BrowserPanel-CpcHkt_q.js","assets/EvalPanel-DDDTr1W8.js","assets/legacy-DWFG28eD.js"])))=>i.map(i=>d[i]);
2
+ var vl=Object.defineProperty;var _l=(t,e,s)=>e in t?vl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var $e=(t,e,s)=>_l(t,typeof e!="symbol"?e+"":e,s);import{c as ts,a as et,g as kl,r as w,b as ge,j as n,S as Sr,W as jr,B as yt,H as Sl,s as jl,u as Zi,d as El,e as Nl,X as js,f as Er,E as eo,A as Vt,C as Nr,U as Cr,h as Tr,G as to,R as oe,_ as le,Z as Cl,i as fn,I as ci,k as Tl,l as Rl,L as so,m as Al,M as Ll,n as Il,o as Dl,p as Ml,t as Dn}from"./index-Dnvk3jCu.js";import{C as Ol}from"./chevron-up-DNehgPl9.js";import{P as Pl}from"./plus-D3aWFzy1.js";import{F as pn}from"./file-text-BsTFGmBj.js";import{S as Rr}from"./server-DjUE1pG1.js";import{N as no}from"./network-CxR7yDrR.js";import{T as ro}from"./terminal-BgivA6PX.js";import{B as fs}from"./book-open-DucGf6Ry.js";import{S as mn}from"./save-Bc5LT98_.js";import{P as Wl}from"./pencil-BfcTfeAV.js";import{R as io}from"./rotate-ccw-DQ2_e6Ey.js";import{S as oo}from"./search-5DwwxYyL.js";import{S as ao}from"./send-D1b4UjEx.js";import{M as lo}from"./message-square-BktXdPkG.js";import{M as co}from"./mic-CQcJXVlD.js";import{F as uo}from"./flask-conical-D8gouq57.js";import{C as ps}from"./clock-DSVWc_hS.js";import{A as ho}from"./archive-D0TMs-ec.js";import{R as fo}from"./radio-DwaUeLWj.js";import{T as po,P as di}from"./test-tube-dYWRJTXm.js";import{VoiceOverlay as Bl}from"./VoiceOverlay-BeQ9oiym.js";import{C as Ul}from"./chevron-right-B2xN7vZr.js";import{R as gn}from"./refresh-cw-pV7an3cE.js";import{F as Fl}from"./folder-C0s6yhdf.js";import{C as ui}from"./check-o_c7GSUi.js";import{S as $l}from"./shield-check-CFFgZVUJ.js";import{E as hi}from"./external-link-BbZ5ZMbT.js";import{B as mo}from"./bot-DlZ9827e.js";import{W as zl}from"./wifi-off-BBMJbZvM.js";/**
3
3
  * @license lucide-react v0.513.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
@@ -965,8 +965,8 @@ function Widget({ titan }) {
965
965
  const btn = container.querySelector('button');
966
966
  btn.addEventListener('click', () => btn.textContent = 'Clicked!');
967
967
  }`,html:`<!-- Raw HTML. No scripts run. -->
968
- <div style="padding:16px;color:#e4e4e7">Hello, widget!</div>`,iframe:"",system:""};function Np(t){return String(t||"").startsWith("system:")?"system":"react"}const Cp={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 Tp(t){return t.split(/[-_/]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Rp({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 I=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:Np(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-4 titan-menu-overlay",onClick:e,children:n.jsxs("div",{className:"w-full max-w-4xl titan-modal-surface flex flex-col",style:{height:"min(720px, 90vh)",borderRadius:12},onClick:m=>m.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:"1px solid var(--theme-menu-border)"},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Er,{className:"w-4 h-4",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(js,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"flex items-center gap-1.5 px-5 py-2 border-b border-[#27272a] text-[11px] overflow-x-auto",children:A.map(m=>{var k;return n.jsxs("button",{onClick:()=>d(m),className:`px-2.5 py-1 rounded-full border transition-colors whitespace-nowrap ${c===m?"border-[#6366f1] bg-[#6366f1]/15 text-white":"border-[#27272a] bg-transparent text-[#a1a1aa] hover:border-[#3f3f46] hover:text-white"}`,children:[Tp(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-5 py-2 border-b border-[#27272a]",children:n.jsxs("label",{className:"flex items-center gap-2 rounded-lg border border-[#27272a] bg-[#18181b]/60 px-3 py-2",children:[n.jsx(oo,{className:"w-3.5 h-3.5 text-[#71717a]"}),n.jsx("input",{value:l,onChange:m=>p(m.target.value),placeholder:"Search templates...",className:"flex-1 bg-transparent text-xs text-white placeholder:text-[#71717a] 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-[#a1a1aa] text-sm",children:"Loading templates…"}),y&&n.jsxs("div",{className:"flex items-center justify-center h-full text-[#f87171] text-sm",children:["Error: ",y]}),!f&&!y&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:I.map(m=>n.jsxs("button",{onClick:()=>v(m),disabled:g!==null,className:"text-left p-3 rounded-lg border border-[#27272a] bg-[#18181b]/60 hover:border-[#6366f1]/50 hover:bg-[#18181b] transition-colors 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:Cp[m.category]??"#9ca3af"}}),n.jsx("span",{className:"text-[12px] font-medium text-white truncate",children:m.name})]}),n.jsx(ao,{className:"w-3 h-3 text-[#52525b] group-hover:text-[#a5b4fc] transition-colors shrink-0"})]}),n.jsx("div",{className:"text-[11px] text-[#a1a1aa] leading-relaxed line-clamp-2",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:"text-[9px] px-1.5 py-0.5 rounded bg-[#27272a] text-[#71717a]",children:k},k))})]},m.id))}),I.length===0&&n.jsx("div",{className:"flex items-center justify-center h-40 text-[#a1a1aa] text-sm",children:"No templates in this category."})]}),n.jsxs("div",{className:"mt-4 p-3 rounded-lg border border-dashed border-[#27272a] bg-[#0a0a0e] flex items-start gap-2",children:[n.jsx(yo,{className:"w-3.5 h-3.5 text-[#71717a] mt-0.5 shrink-0"}),n.jsxs("div",{className:"text-[11px] text-[#a1a1aa] 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 text-[#d4d4d8]",children:"titan.fetch"}),","," ",n.jsx("span",{className:"font-mono text-[#d4d4d8]",children:"titan.api.call"}),", and"," ",n.jsx("span",{className:"font-mono text-[#d4d4d8]",children:"titan.state"}),"."]})]})]})]})})}const Ap=[{type:"widget",source:"system:nav",name:"Nav Widget",w:3,h:4,icon:n.jsx(yo,{className:"w-4 h-4"})},{type:"widget",source:"system:chat",name:"Chat Widget",w:4,h:5,icon:n.jsx(lo,{className:"w-4 h-4"})},{type:"widget",source:"system:soma",name:"SOMA",w:6,h:6,icon:n.jsx(yt,{className:"w-4 h-4"})},{type:"widget",source:"system:command-post",name:"Command Post",w:8,h:6,icon:n.jsx(ro,{className:"w-4 h-4"})},{type:"widget",source:"system:intelligence",name:"Intelligence",w:6,h:5,icon:n.jsx(no,{className:"w-4 h-4"})},{type:"widget",source:"system:memory-graph",name:"Memory Graph",w:8,h:7,icon:n.jsx(ql,{className:"w-4 h-4"})},{type:"widget",source:"system:voice",name:"Voice",w:5,h:5,icon:n.jsx(co,{className:"w-4 h-4"})},{type:"widget",source:"system:infra",name:"Infrastructure",w:6,h:4,icon:n.jsx(Rr,{className:"w-4 h-4"})},{type:"widget",source:"system:tools",name:"Tools",w:5,h:4,icon:n.jsx(jr,{className:"w-4 h-4"})},{type:"widget",source:"system:settings",name:"Settings",w:5,h:5,icon:n.jsx(Sr,{className:"w-4 h-4"})},{type:"widget",source:"system:files",name:"Files",w:4,h:6,icon:n.jsx(pn,{className:"w-4 h-4"})},{type:"widget",source:"system:memory-wiki",name:"Memory Wiki",w:6,h:6,icon:n.jsx(fs,{className:"w-4 h-4"})},{type:"widget",source:"system:autoresearch",name:"Autoresearch",w:6,h:6,icon:n.jsx(uo,{className:"w-4 h-4"})},{type:"widget",source:"system:self-proposals",name:"Self-Proposals",w:6,h:6,icon:n.jsx(go,{className:"w-4 h-4"})},{type:"widget",source:"system:overview",name:"Overview",w:6,h:5,icon:n.jsx(eo,{className:"w-4 h-4"})},{type:"widget",source:"system:sessions",name:"Sessions",w:6,h:5,icon:n.jsx(ps,{className:"w-4 h-4"})},{type:"widget",source:"system:watch",name:"Watch",w:8,h:7,icon:n.jsx(Vt,{className:"w-4 h-4"})},{type:"widget",source:"system:backup",name:"Backup Manager",w:6,h:6,icon:n.jsx(ho,{className:"w-4 h-4"})},{type:"widget",source:"system:training",name:"Training Dashboard",w:6,h:6,icon:n.jsx(yt,{className:"w-4 h-4"})},{type:"widget",source:"system:recipes",name:"Recipe Kitchen",w:6,h:6,icon:n.jsx(fs,{className:"w-4 h-4"})},{type:"widget",source:"system:vram",name:"VRAM Monitor",w:6,h:6,icon:n.jsx(Nr,{className:"w-4 h-4"})},{type:"widget",source:"system:teams",name:"Team Hub",w:6,h:6,icon:n.jsx(Cr,{className:"w-4 h-4"})},{type:"widget",source:"system:cron",name:"Cron Scheduler",w:6,h:6,icon:n.jsx(ps,{className:"w-4 h-4"})},{type:"widget",source:"system:checkpoints",name:"Checkpoints",w:6,h:5,icon:n.jsx(mn,{className:"w-4 h-4"})},{type:"widget",source:"system:organism",name:"Organism Monitor",w:6,h:6,icon:n.jsx(Tr,{className:"w-4 h-4"})},{type:"widget",source:"system:fleet",name:"Fleet Router",w:6,h:5,icon:n.jsx(fo,{className:"w-4 h-4"})},{type:"widget",source:"system:browser",name:"Browser Tools",w:6,h:5,icon:n.jsx(to,{className:"w-4 h-4"})},{type:"widget",source:"system:eval",name:"Test Lab",w:6,h:6,icon:n.jsx(po,{className:"w-4 h-4"})}];function bl({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=Ap.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(oo,{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(js,{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 Lp=oe.lazy(()=>le(()=>import("./SomaView-CzZ6SCuw.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)"},sr={background:Ae.bgBase,color:Ae.ink};function xl(){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:{...sr,color:Ae.paperFg},children:"Loading Soma…"}):t?n.jsxs("div",{className:"w-full h-full overflow-auto flex flex-col",style:sr,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(di,{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(Lp,{})})})]}):n.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-4 p-6 text-center",style:sr,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(Vt,{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(di,{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 Ip={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 Dp(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 Mp(){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({x:280,y:80}),[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(Dp(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=Ip[s.emotion],I=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(yt,{className:"w-4 h-4",style:{color:I}}),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(js,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"h-[calc(100%-40px)]",children:n.jsx(xl,{})})]})}),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(yt,{className:"w-3.5 h-3.5",style:{color:I}}),"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(Er,{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(Cl,{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%, ${I}, ${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(yt,{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})})]})]})]})}const Op=oe.lazy(()=>le(()=>import("./CommandPostHub-Ckh7LlWG.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 Pp(){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(Op,{})})})}const Wp=oe.lazy(()=>le(()=>import("./IntelligenceView-CJ2r76hu.js"),__vite__mapDeps([29,1,2,4])));function Bp(){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(Wp,{})})})}const Up=oe.lazy(()=>le(()=>import("./MemoryGraphPanel-DZTQIsys.js"),__vite__mapDeps([30,1,2,31,24,28,32])));function Fp(){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(Up,{})})})})}function $p(){const[t,e]=w.useState(!1);return t?n.jsx(Bl,{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(co,{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 zp=oe.lazy(()=>le(()=>import("./InfraView-DAwJClAs.js"),__vite__mapDeps([33,1,2,4])));function Hp(){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(zp,{})})})}const Vp=oe.lazy(()=>le(()=>import("./ToolsView-C3m7TbnX.js"),__vite__mapDeps([34,1,2,4])));function Gp(){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(Vp,{})})})}const qp=oe.lazy(()=>le(()=>import("./SettingsView-ByyjhwLz.js"),__vite__mapDeps([35,1,2,4])));function Yp(){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(qp,{})})})}function Kp(){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(Ul,{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(gn,{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(Fl,{className:"w-3.5 h-3.5 text-[#f59e0b]"}):n.jsx(pn,{className:"w-3.5 h-3.5 text-[#6366f1]"}),n.jsx("span",{className:"text-[12px] text-[#a1a1aa]",children:p.name})]},p.path))]})]})}const Jp=oe.lazy(()=>le(()=>import("./SettingsPanel-CmIAAw_T.js"),__vite__mapDeps([36,1,2,3,4,37,14,5,38,39,24,40,41,42,43])));function Xp(){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(Jp,{})})})}const Qp=oe.lazy(()=>le(()=>import("./SecurityPanel-DRZu6PRV.js"),__vite__mapDeps([44,1,2,37,14])));function Zp(){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(Qp,{})})})}const em=oe.lazy(()=>le(()=>import("./AuditPanel-6hTX-30T.js"),__vite__mapDeps([45,1,2,46,24,47])));function tm(){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(em,{})})})}const Yi={researcher:"#60a5fa",engineer:"#f87171",manager:"#a78bfa",ceo:"#fbbf24",general:"#9ca3af"},sm={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 nm(){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,I]=await Promise.all([ge("/api/specialists"),ge("/api/models")]);if(!E.ok)throw new Error(`Specialists request failed: ${E.status}`);if(!I.ok)throw new Error(`Models request failed: ${I.status}`);const v=await E.json(),A=await I.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 I=i[E];if(I&&I.length)return I.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,I)=>{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:I})});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(Cr,{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(gn,{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(fn,{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(rm,{row:E,models:x(E.id),recommendations:i[E.id]??[],state:l[E.id]??"idle",onChange:I=>y(E.id,I),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 rm({row:t,models:e,recommendations:s,state:r,onChange:i,onReset:o}){var u;const c=Yi[t.role]??Yi.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(I=>I.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 ${sm[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(io,{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(ci,{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(gn,{className:"w-3.5 h-3.5 animate-spin text-[#6366f1]"}),r==="saved"&&n.jsx(ui,{className:"w-3.5 h-3.5 text-[#10b981]"}),r==="error"&&n.jsx(fn,{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(ci,{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(ui,{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 im(){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[I,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(I),r(v),A!=null&&A.remote&&o(A.remote)}catch(I){p(I.message)}},[]);w.useEffect(()=>{const I=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(I)},[]),w.useEffect(()=>{f()},[f]);const x=w.useCallback(async I=>{d(!0),p(null);try{const v=await ge("/api/telemetry/consent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)});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($l,{className:"w-5 h-5 text-[#10b981]"}):n.jsx(Tr,{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(Tl,{className:"w-3 h-3"})," Saved"]}),l&&n.jsxs("span",{className:"text-[11px] text-[#ef4444] flex items-center gap-1",children:[n.jsx(Rl,{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(gn,{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:I=>x({enabled:I.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:I=>x({enabled:y,crashReports:I.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(fn,{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(ao,{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(ps,{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(hi,{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(hi,{className:"w-3 h-3"})," See the collector source"]})]})]})}const om=oe.lazy(()=>le(()=>import("./AutopilotPanel-BBhP6EEw.js"),__vite__mapDeps([48,1,2,37,14])));function am(){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(om,{})})})}const lm=oe.lazy(()=>le(()=>import("./WorkflowsPanel-BZQu93gE.js"),__vite__mapDeps([49,1,2,37,14,3,4,10,11,12,24,27,42,16,28,20,50,51])));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(lm,{})})})}const dm=oe.lazy(()=>le(()=>import("./LearningPanel-Ka17sHxK.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])));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(dm,{})})})}const hm=oe.lazy(()=>le(()=>import("./SelfImprovePanel-CgJG9v1W.js"),__vite__mapDeps([67,1,2,24,38,20,68,54,15,14,42,23,60,28])));function fm(){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(hm,{})})})}const pm=oe.lazy(()=>le(()=>import("./PersonasPanel-VfvknF9L.js"),__vite__mapDeps([69,1,2])));function mm(){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 gm=oe.lazy(()=>le(()=>import("./PersonaProfilesPanel-hmUdUabW.js"),__vite__mapDeps([70,1,2,37,14,24,11,16,63,20])));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(gm,{})})})}const bm=oe.lazy(()=>le(()=>import("./DreamPanel-BJO5hRUh.js"),__vite__mapDeps([71,1,2,37,14,24])));function xm(){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 wm=oe.lazy(()=>le(()=>import("./HomelabPanel-C658fL2z.js"),__vite__mapDeps([72,1,2,37,14,73,74,4,24,20,21,56,19,31,38,40,17])));function vm(){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(wm,{})})})}const _m=oe.lazy(()=>le(()=>import("./NvidiaPanel-53CiSPrh.js"),__vite__mapDeps([75,1,2,24,43,38,66,32])));function km(){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(_m,{})})})}const Sm=oe.lazy(()=>le(()=>import("./FilesPanel-Cimj2Z8k.js"),__vite__mapDeps([76,1,2,27,24,14,77,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])));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(Sm,{})})})}const Em=oe.lazy(()=>le(()=>import("./LogsPanel-BiELvlMC.js"),__vite__mapDeps([78,1,2,24])));function Nm(){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(Em,{})})})}const Cm=oe.lazy(()=>le(()=>import("./TelemetryPanel-C3JTWWQO.js"),__vite__mapDeps([79,1,2,73,20,18,19,56])));function Tm(){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(Cm,{})})})}const Rm=oe.lazy(()=>le(()=>import("./SkillsPanel-BINP41r2.js"),__vite__mapDeps([80,1,2,37,14,32,28,41])));function Am(){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(Rm,{})})})}const Lm=oe.lazy(()=>le(()=>import("./McpPanel-BW2r8V3m.js"),__vite__mapDeps([81,1,2,82,24,27,56,61,28])));function Im(){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(Lm,{})})})}const Dm=oe.lazy(()=>le(()=>import("./IntegrationsPanel-Xy3HlXti.js"),__vite__mapDeps([83,1,2,82,38,43,14])));function Mm(){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(Dm,{})})})}const Om=oe.lazy(()=>le(()=>import("./ChannelsPanel-e1nT5QcW.js"),__vite__mapDeps([84,1,2,37,14,24,38,43])));function Pm(){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(Om,{})})})}const Wm=oe.lazy(()=>le(()=>import("./MeshPanel-Ch_uGo4a.js"),__vite__mapDeps([85,1,2,86,24,65])));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(Wm,{})})})}const Um=oe.lazy(()=>le(()=>import("./MemoryWikiPanel-BSbG8c80.js"),__vite__mapDeps([87,1,2,37,14,77,20,32,51])));function Fm(){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(Um,{})})})}const $m=oe.lazy(()=>le(()=>import("./AutoresearchPanel-CmSoFu9c.js"),__vite__mapDeps([88,1,2,58,42,16,24,68,54,20,14])));function zm(){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($m,{})})})}const Hm=oe.lazy(()=>le(()=>import("./SelfProposalsPanel-BenuzEGo.js"),__vite__mapDeps([89,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])));function Vm(){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(Hm,{})})})}const Gm=oe.lazy(()=>le(()=>import("./OverviewPanel-CmRVwkE7.js"),__vite__mapDeps([90,1,2,73,37,14,74,4,20,21,56,91])));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(Gm,{})})})}const Ym=oe.lazy(()=>le(()=>import("./SessionsPanel-CFdsWt2W.js"),__vite__mapDeps([92,1,2,37,14,3,4,86,10,11,12,32,28])));function Km(){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 Jm=oe.lazy(()=>le(()=>import("./WatchView-Cflz1FfL.js"),__vite__mapDeps([93,1,2,9])));function Xm(){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(Jm,{})})})}const Qm=oe.lazy(()=>le(()=>import("./BackupPanel-BMqXOM64.js"),__vite__mapDeps([94,1,2,37,14,27,24,59,38])));function Zm(){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 eg=oe.lazy(()=>le(()=>import("./TrainingPanel-BMunX3EV.js"),__vite__mapDeps([95,1,2,37,14,24,41])));function tg(){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(eg,{})})})}const sg=oe.lazy(()=>le(()=>import("./RecipesPanel-B7NygJvl.js"),__vite__mapDeps([96,1,2,37,14,24,51,42,28])));function ng(){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(sg,{})})})}const rg=oe.lazy(()=>le(()=>import("./VramPanel-C4nG82nu.js"),__vite__mapDeps([97,1,2,37,14,24])));function ig(){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(rg,{})})})}const og=oe.lazy(()=>le(()=>import("./TeamsPanel-CwVNzD77.js"),__vite__mapDeps([98,1,2,37,14,24,28])));function ag(){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(og,{})})})}const lg=oe.lazy(()=>le(()=>import("./CronPanel-BMneWRHA.js"),__vite__mapDeps([99,1,2,37,14,24,20,50,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(lg,{})})})}const dg=oe.lazy(()=>le(()=>import("./CheckpointsPanel-BixKyU53.js"),__vite__mapDeps([100,1,2,37,14,24,43,28])));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(dg,{})})})}const hg=oe.lazy(()=>le(()=>import("./OrganismPanel-BRbiiY5k.js"),__vite__mapDeps([101,1,2,37,14,24,38])));function fg(){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(hg,{})})})}const pg=oe.lazy(()=>le(()=>import("./FleetPanel-zzprw7Ro.js"),__vite__mapDeps([102,1,2,37,14,24,60])));function mg(){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 gg=oe.lazy(()=>le(()=>import("./BrowserPanel-DqpJBtZO.js"),__vite__mapDeps([103,1,2,37,14])));function yg(){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(gg,{})})})}const bg=oe.lazy(()=>le(()=>import("./EvalPanel-j3fHE-k4.js"),__vite__mapDeps([104,1,2,37,14,24,42])));function xg(){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 wg(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 vg(t){const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>=0?t.slice(e+1):t}function _g(){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),[I,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"})]})]}),I&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,background:I.kind==="ok"?"rgba(34,197,94,0.12)":"rgba(239,68,68,0.12)",border:`1px solid ${I.kind==="ok"?"rgba(34,197,94,0.3)":"rgba(239,68,68,0.3)"}`,color:I.kind==="ok"?"#86efac":"#fca5a5",fontSize:11},children:I.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:wg(C.timestamp)})]}),n.jsx("div",{style:{fontSize:12,color:"#e2e8f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:C.filePath,children:vg(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(`
969
- `).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 Ki=5e3,Ji={planning:"#a5b4fc",delegating:"#60a5fa",observing:"#22d3ee",iterating:"#f59e0b",verifying:"#a78bfa",reporting:"#34d399",blocked:"#facc15",escalated:"#fb7185",done:"#34d399",failed:"#ef4444",cancelled:"#737373"};function kg(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 Sg(t){return t===0?"$0":t<.01?"$<0.01":`$${t.toFixed(2)}`}function jg(){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),I=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(()=>{I();const _=setInterval(I,Ki);return()=>clearInterval(_)},[I]);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),I()}catch(S){v("err",S.message||"launch failed")}finally{x(!1)}},[l,g,I,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."),I()}catch(T){v("err",T.message||"cancel failed")}},[I,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 ",Ki/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:I,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=Ji[_.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:Sg(_.budget.costUsd)}),n.jsx("span",{children:"·"}),n.jsx("span",{children:kg(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:Ji[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 Eg=6e4,Ng=[{label:"6h",hours:6},{label:"24h",hours:24},{label:"7d",hours:168}];function Cg(t){return t===0?"$0":t<.01?"$<0.01":`$${t.toFixed(2)}`}function Tg(t){return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(1)}k`:`${(t/1e6).toFixed(2)}M`}function Rg(){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,Eg);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:Ng.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(Ws,{label:"Done",value:s.stats.completed,color:"#34d399"}),n.jsx(Ws,{label:"Failed",value:s.stats.failed,color:s.stats.failed>0?"#fca5a5":"rgba(255,255,255,0.5)"}),n.jsx(Ws,{label:"Active",value:s.stats.active,color:"#60a5fa"}),n.jsx(Ws,{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:Cg(s.stats.totalCostUsd)})]}),n.jsxs("span",{children:["Tokens: ",n.jsx("strong",{style:{color:"#e2e8f5"},children:Tg(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 Ws({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 Bs={pending:"#737373",running:"#60a5fa",done:"#34d399",failed:"#ef4444",skipped:"#a78bfa"},Xi=6e3,_t=180,nr=64,Qi=96,Us=24;function Ag(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 Lg(){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,Xi);return()=>clearInterval(v)},[g]),w.useEffect(()=>{if(!s){o(null);return}u(s);const v=setInterval(()=>u(s),Xi);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=Ag(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,_*(_t+Us)+Us),S=k.length*Qi+nr+40,C=new Map,D=[];for(const R of k){const P=m.get(R),B=P.length*_t+(P.length-1)*Us,z=(T-B)/2,q=R*Qi+20;for(let H=0;H<P.length;H++){const J=z+H*(_t+Us);C.set(P[H].id,{x:J,y:q}),D.push({...P[H],x:J,y:q})}}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+_t/2,y1:z.y+nr,x2:P.x+_t/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]),I=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=Bs[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:_t,height:nr,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:_t-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."})}),I&&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:I.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:`${Bs[I.status]}22`,border:`1px solid ${Bs[I.status]}55`,color:Bs[I.status]},children:I.status}),I.retries>0&&n.jsxs("span",{style:{marginLeft:6,color:"rgba(255,255,255,0.5)"},children:[I.retries," retries"]})]}),n.jsx("div",{style:{color:"rgba(255,255,255,0.85)",lineHeight:1.5,marginBottom:10},children:I.description}),I.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:"})," ",I.dependsOn.map(v=>{var A;return((A=E.get(v))==null?void 0:A.title)||v}).join(", ")]}),I.completedAt&&n.jsxs("div",{style:{color:"rgba(255,255,255,0.45)",fontSize:10},children:["Completed: ",new Date(I.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 Ig(){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(so,{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(fn,{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(mo,{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 Dg(){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(so,{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(Al,{className:"w-3.5 h-3.5 text-emerald-400"}):n.jsx(zl,{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(Vt,{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 Fs({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 Mg(){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(Fs,{label:"CPU",value:t.cpu,icon:n.jsx(Nr,{className:"w-3 h-3 text-[#6366f1]"}),color:"#6366f1",unknown:s}),n.jsx(Fs,{label:"Memory",value:t.memory,icon:n.jsx(Ll,{className:"w-3 h-3 text-[#a78bfa]"}),color:"#a78bfa",unknown:s}),n.jsx(Fs,{label:"Disk",value:t.disk,icon:n.jsx(Il,{className:"w-3 h-3 text-[#10b981]"}),color:"#10b981",unknown:s||!t.diskAvailable}),n.jsx(Fs,{label:"Load",value:t.load,icon:n.jsx(Vt,{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 Og=[{label:"Nav",source:"system:nav",w:3,h:4,icon:n.jsx(Vl,{className:"w-3.5 h-3.5"})},{label:"Agents",source:"system:agents",w:3,h:4,icon:n.jsx(mo,{className:"w-3.5 h-3.5"})},{label:"Health",source:"system:health",w:3,h:3,icon:n.jsx(Vt,{className:"w-3.5 h-3.5"})},{label:"Stats",source:"system:stats",w:3,h:4,icon:n.jsx(Kl,{className:"w-3.5 h-3.5"})},{label:"Chat",source:"system:chat",w:4,h:5,icon:n.jsx(lo,{className:"w-3.5 h-3.5"})},{label:"Files",source:"system:files",w:4,h:6,icon:n.jsx(pn,{className:"w-3.5 h-3.5"})},{label:"Skills",source:"system:tools",w:5,h:4,icon:n.jsx(Er,{className:"w-3.5 h-3.5"})},{label:"Soma",source:"system:soma",w:6,h:6,icon:n.jsx(Dl,{className:"w-3.5 h-3.5"})},{label:"Intel",source:"system:intelligence",w:6,h:5,icon:n.jsx(yt,{className:"w-3.5 h-3.5"})},{label:"Infra",source:"system:infra",w:6,h:4,icon:n.jsx(Rr,{className:"w-3.5 h-3.5"})},{label:"Tools",source:"system:tools",w:5,h:4,icon:n.jsx(jr,{className:"w-3.5 h-3.5"})},{label:"Settings",source:"system:settings",w:4,h:6,icon:n.jsx(Sr,{className:"w-3.5 h-3.5"})},{label:"Wiki",source:"system:memory-wiki",w:5,h:5,icon:n.jsx(fs,{className:"w-3.5 h-3.5"})},{label:"Research",source:"system:autoresearch",w:5,h:5,icon:n.jsx(uo,{className:"w-3.5 h-3.5"})},{label:"Proposals",source:"system:self-proposals",w:5,h:5,icon:n.jsx(go,{className:"w-3.5 h-3.5"})},{label:"Overview",source:"system:overview",w:5,h:4,icon:n.jsx(eo,{className:"w-3.5 h-3.5"})},{label:"Sessions",source:"system:sessions",w:5,h:4,icon:n.jsx(ps,{className:"w-3.5 h-3.5"})},{label:"Watch",source:"system:watch",w:6,h:5,icon:n.jsx(Vt,{className:"w-3.5 h-3.5"})},{label:"Backup",source:"system:backup",w:5,h:5,icon:n.jsx(ho,{className:"w-3.5 h-3.5"})},{label:"Training",source:"system:training",w:5,h:5,icon:n.jsx(yt,{className:"w-3.5 h-3.5"})},{label:"Recipes",source:"system:recipes",w:5,h:5,icon:n.jsx(fs,{className:"w-3.5 h-3.5"})},{label:"VRAM",source:"system:vram",w:5,h:5,icon:n.jsx(Nr,{className:"w-3.5 h-3.5"})},{label:"Teams",source:"system:teams",w:5,h:5,icon:n.jsx(Cr,{className:"w-3.5 h-3.5"})},{label:"Cron",source:"system:cron",w:5,h:5,icon:n.jsx(ps,{className:"w-3.5 h-3.5"})},{label:"Checkpoints",source:"system:checkpoints",w:5,h:5,icon:n.jsx(mn,{className:"w-3.5 h-3.5"})},{label:"Organism",source:"system:organism",w:5,h:5,icon:n.jsx(Tr,{className:"w-3.5 h-3.5"})},{label:"Fleet",source:"system:fleet",w:5,h:5,icon:n.jsx(fo,{className:"w-3.5 h-3.5"})},{label:"Browser",source:"system:browser",w:5,h:5,icon:n.jsx(to,{className:"w-3.5 h-3.5"})},{label:"Eval",source:"system:eval",w:5,h:5,icon:n.jsx(po,{className:"w-3.5 h-3.5"})}];function Pg(){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:Og.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 Wg extends oe.Component{componentDidCatch(e){this.props.onError(e.message)}render(){return this.props.children}}function Bg({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(Wg,{onError:r,children:e})}const Ug=oe.lazy(()=>le(()=>import("./legacy-CMWeVEm-.js"),__vite__mapDeps([105,1,2,4])).then(t=>({default:t.Responsive}))),Fg={"system:nav":ll,"system:chat":hl,"system:cmd":bl,"system:soma":xl,"system:command-post":Pp,"system:intelligence":Bp,"system:memory-graph":Fp,"system:voice":$p,"system:infra":Hp,"system:tools":Gp,"system:settings":Yp,"system:files":Kp,"system:settings-general":Xp,"system:settings-security":Zp,"system:settings-audit":tm,"system:settings-specialists":nm,"system:settings-privacy":im,"system:intelligence-autopilot":am,"system:intelligence-workflows":cm,"system:intelligence-learning":um,"system:intelligence-self-improve":fm,"system:intelligence-personas":mm,"system:intelligence-persona-profiles":ym,"system:intelligence-dream":xm,"system:infra-homelab":vm,"system:infra-gpu":km,"system:infra-files":jm,"system:infra-logs":Nm,"system:infra-telemetry":Tm,"system:tools-skills":Am,"system:tools-mcp":Im,"system:tools-integrations":Mm,"system:tools-channels":Pm,"system:tools-mesh":Bm,"system:agents":Ig,"system:health":Dg,"system:stats":Mg,"system:quick-links":Pg,"system:memory-wiki":Fm,"system:autoresearch":zm,"system:self-proposals":Vm,"system:overview":qm,"system:sessions":Km,"system:watch":Xm,"system:backup":Zm,"system:training":tg,"system:recipes":ng,"system:vram":ig,"system:teams":ag,"system:cron":cg,"system:checkpoints":ug,"system:organism":fg,"system:fleet":mg,"system:browser":yg,"system:eval":xg,"system:time-travel":_g,"system:mission-driver":jg,"system:daily-digest":Rg,"system:mission-graph":Lg},$g={lg:12,md:10,sm:6,xs:4,xxs:2},zg=60,Hg={lg:1200,md:996,sm:768,xs:480,xxs:0},Vg=[12,12],Gg=["se","sw","ne","nw","e","w","n","s"],wl=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(Kg,{widget:t,space:e,onRemove:u}),p]})});wl.displayName="MemoWidgetItem";const qg=oe.memo(wl);function Yg({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 al(r.current,{onLog:u=>console.log(`[Widget ${t.id}]`,u)}),i.current.setMessageHandler(u=>{var x,y,E,I;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}:Gs(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"&&((I=u.payload)==null?void 0:I.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=Fg[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(Bg,{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 Kg=oe.memo(Yg);function Jg(){const{spaceId:t}=Ml(),e=Zi(),[s,r]=w.useState(null),[i]=w.useState(!0),[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,I]=w.useState(1200),v=w.useRef(null),A=w.useRef(null),{info:m,triggerUpdate:k,waitForReload:_}=wf(),[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 Y=new ResizeObserver(te=>{for(const Q of te)I(Q.contentRect.width)});return Y.observe(se),I(se.getBoundingClientRect().width||1200),Y};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",$)},[]),vf([{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(Y=>Y.id===$);Dn("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(Y=>Y.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]}),Dn($.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 Y of s.widgets)for(let te=0;te<Y.w;te++)for(let Q=0;Q<Y.h;Q++)se.add(`${Y.x+te},${Y.y+Q}`);for(let Y=0;Y<200;Y++)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},${Y+Ce}`)){Q=!1;break}if(!Q)break}if(Q)return{x:te,y:Y}}return{x:0,y:0}},[s]),q=w.useCallback(($,F,V=4,se=4)=>{const Y=z(V,se);B({name:F,format:"system",source:$,x:Y.x,y:Y.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,Y=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,Y);B({name:te,format:Q,source:String(V.source),x:be.x,y:be.y,w:se,h:Y})}};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]),J=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(xp,{}),n.jsxs("div",{ref:v,className:"flex-1 relative overflow-auto",children:[n.jsx("style",{children:`
968
+ <div style="padding:16px;color:#e4e4e7">Hello, widget!</div>`,iframe:"",system:""};function Np(t){return String(t||"").startsWith("system:")?"system":"react"}const Cp={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 Tp(t){return t.split(/[-_/]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Rp({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 I=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:Np(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-4 titan-menu-overlay",onClick:e,children:n.jsxs("div",{className:"w-full max-w-4xl titan-modal-surface flex flex-col",style:{height:"min(720px, 90vh)",borderRadius:12},onClick:m=>m.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:"1px solid var(--theme-menu-border)"},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Er,{className:"w-4 h-4",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(js,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"flex items-center gap-1.5 px-5 py-2 border-b border-[#27272a] text-[11px] overflow-x-auto",children:A.map(m=>{var k;return n.jsxs("button",{onClick:()=>d(m),className:`px-2.5 py-1 rounded-full border transition-colors whitespace-nowrap ${c===m?"border-[#6366f1] bg-[#6366f1]/15 text-white":"border-[#27272a] bg-transparent text-[#a1a1aa] hover:border-[#3f3f46] hover:text-white"}`,children:[Tp(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-5 py-2 border-b border-[#27272a]",children:n.jsxs("label",{className:"flex items-center gap-2 rounded-lg border border-[#27272a] bg-[#18181b]/60 px-3 py-2",children:[n.jsx(oo,{className:"w-3.5 h-3.5 text-[#71717a]"}),n.jsx("input",{value:l,onChange:m=>p(m.target.value),placeholder:"Search templates...",className:"flex-1 bg-transparent text-xs text-white placeholder:text-[#71717a] 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-[#a1a1aa] text-sm",children:"Loading templates…"}),y&&n.jsxs("div",{className:"flex items-center justify-center h-full text-[#f87171] text-sm",children:["Error: ",y]}),!f&&!y&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:I.map(m=>n.jsxs("button",{onClick:()=>v(m),disabled:g!==null,className:"text-left p-3 rounded-lg border border-[#27272a] bg-[#18181b]/60 hover:border-[#6366f1]/50 hover:bg-[#18181b] transition-colors 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:Cp[m.category]??"#9ca3af"}}),n.jsx("span",{className:"text-[12px] font-medium text-white truncate",children:m.name})]}),n.jsx(ao,{className:"w-3 h-3 text-[#52525b] group-hover:text-[#a5b4fc] transition-colors shrink-0"})]}),n.jsx("div",{className:"text-[11px] text-[#a1a1aa] leading-relaxed line-clamp-2",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:"text-[9px] px-1.5 py-0.5 rounded bg-[#27272a] text-[#71717a]",children:k},k))})]},m.id))}),I.length===0&&n.jsx("div",{className:"flex items-center justify-center h-40 text-[#a1a1aa] text-sm",children:"No templates in this category."})]}),n.jsxs("div",{className:"mt-4 p-3 rounded-lg border border-dashed border-[#27272a] bg-[#0a0a0e] flex items-start gap-2",children:[n.jsx(yo,{className:"w-3.5 h-3.5 text-[#71717a] mt-0.5 shrink-0"}),n.jsxs("div",{className:"text-[11px] text-[#a1a1aa] 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 text-[#d4d4d8]",children:"titan.fetch"}),","," ",n.jsx("span",{className:"font-mono text-[#d4d4d8]",children:"titan.api.call"}),", and"," ",n.jsx("span",{className:"font-mono text-[#d4d4d8]",children:"titan.state"}),"."]})]})]})]})})}const Ap=[{type:"widget",source:"system:nav",name:"Nav Widget",w:3,h:4,icon:n.jsx(yo,{className:"w-4 h-4"})},{type:"widget",source:"system:chat",name:"Chat Widget",w:4,h:5,icon:n.jsx(lo,{className:"w-4 h-4"})},{type:"widget",source:"system:soma",name:"SOMA",w:6,h:6,icon:n.jsx(yt,{className:"w-4 h-4"})},{type:"widget",source:"system:command-post",name:"Command Post",w:8,h:6,icon:n.jsx(ro,{className:"w-4 h-4"})},{type:"widget",source:"system:intelligence",name:"Intelligence",w:6,h:5,icon:n.jsx(no,{className:"w-4 h-4"})},{type:"widget",source:"system:memory-graph",name:"Memory Graph",w:8,h:7,icon:n.jsx(ql,{className:"w-4 h-4"})},{type:"widget",source:"system:voice",name:"Voice",w:5,h:5,icon:n.jsx(co,{className:"w-4 h-4"})},{type:"widget",source:"system:infra",name:"Infrastructure",w:6,h:4,icon:n.jsx(Rr,{className:"w-4 h-4"})},{type:"widget",source:"system:tools",name:"Tools",w:5,h:4,icon:n.jsx(jr,{className:"w-4 h-4"})},{type:"widget",source:"system:settings",name:"Settings",w:5,h:5,icon:n.jsx(Sr,{className:"w-4 h-4"})},{type:"widget",source:"system:files",name:"Files",w:4,h:6,icon:n.jsx(pn,{className:"w-4 h-4"})},{type:"widget",source:"system:memory-wiki",name:"Memory Wiki",w:6,h:6,icon:n.jsx(fs,{className:"w-4 h-4"})},{type:"widget",source:"system:autoresearch",name:"Autoresearch",w:6,h:6,icon:n.jsx(uo,{className:"w-4 h-4"})},{type:"widget",source:"system:self-proposals",name:"Self-Proposals",w:6,h:6,icon:n.jsx(go,{className:"w-4 h-4"})},{type:"widget",source:"system:overview",name:"Overview",w:6,h:5,icon:n.jsx(eo,{className:"w-4 h-4"})},{type:"widget",source:"system:sessions",name:"Sessions",w:6,h:5,icon:n.jsx(ps,{className:"w-4 h-4"})},{type:"widget",source:"system:watch",name:"Watch",w:8,h:7,icon:n.jsx(Vt,{className:"w-4 h-4"})},{type:"widget",source:"system:backup",name:"Backup Manager",w:6,h:6,icon:n.jsx(ho,{className:"w-4 h-4"})},{type:"widget",source:"system:training",name:"Training Dashboard",w:6,h:6,icon:n.jsx(yt,{className:"w-4 h-4"})},{type:"widget",source:"system:recipes",name:"Recipe Kitchen",w:6,h:6,icon:n.jsx(fs,{className:"w-4 h-4"})},{type:"widget",source:"system:vram",name:"VRAM Monitor",w:6,h:6,icon:n.jsx(Nr,{className:"w-4 h-4"})},{type:"widget",source:"system:teams",name:"Team Hub",w:6,h:6,icon:n.jsx(Cr,{className:"w-4 h-4"})},{type:"widget",source:"system:cron",name:"Cron Scheduler",w:6,h:6,icon:n.jsx(ps,{className:"w-4 h-4"})},{type:"widget",source:"system:checkpoints",name:"Checkpoints",w:6,h:5,icon:n.jsx(mn,{className:"w-4 h-4"})},{type:"widget",source:"system:organism",name:"Organism Monitor",w:6,h:6,icon:n.jsx(Tr,{className:"w-4 h-4"})},{type:"widget",source:"system:fleet",name:"Fleet Router",w:6,h:5,icon:n.jsx(fo,{className:"w-4 h-4"})},{type:"widget",source:"system:browser",name:"Browser Tools",w:6,h:5,icon:n.jsx(to,{className:"w-4 h-4"})},{type:"widget",source:"system:eval",name:"Test Lab",w:6,h:6,icon:n.jsx(po,{className:"w-4 h-4"})}];function bl({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=Ap.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(oo,{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(js,{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 Lp=oe.lazy(()=>le(()=>import("./SomaView-w865kZBc.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)"},sr={background:Ae.bgBase,color:Ae.ink};function xl(){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:{...sr,color:Ae.paperFg},children:"Loading Soma…"}):t?n.jsxs("div",{className:"w-full h-full overflow-auto flex flex-col",style:sr,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(di,{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(Lp,{})})})]}):n.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-4 p-6 text-center",style:sr,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(Vt,{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(di,{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 Ip={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 Dp(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 Mp(){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({x:280,y:80}),[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(Dp(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=Ip[s.emotion],I=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(yt,{className:"w-4 h-4",style:{color:I}}),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(js,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"h-[calc(100%-40px)]",children:n.jsx(xl,{})})]})}),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(yt,{className:"w-3.5 h-3.5",style:{color:I}}),"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(Er,{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(Cl,{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%, ${I}, ${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(yt,{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})})]})]})]})}const Op=oe.lazy(()=>le(()=>import("./CommandPostHub-CLnqGM62.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 Pp(){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(Op,{})})})}const Wp=oe.lazy(()=>le(()=>import("./IntelligenceView-I7i3t8kE.js"),__vite__mapDeps([29,1,2,4])));function Bp(){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(Wp,{})})})}const Up=oe.lazy(()=>le(()=>import("./MemoryGraphPanel-CtWA8YuJ.js"),__vite__mapDeps([30,1,2,31,24,28,32])));function Fp(){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(Up,{})})})})}function $p(){const[t,e]=w.useState(!1);return t?n.jsx(Bl,{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(co,{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 zp=oe.lazy(()=>le(()=>import("./InfraView-DLhemt3r.js"),__vite__mapDeps([33,1,2,4])));function Hp(){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(zp,{})})})}const Vp=oe.lazy(()=>le(()=>import("./ToolsView-CDeB3RtS.js"),__vite__mapDeps([34,1,2,4])));function Gp(){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(Vp,{})})})}const qp=oe.lazy(()=>le(()=>import("./SettingsView-BPVPhIUK.js"),__vite__mapDeps([35,1,2,4])));function Yp(){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(qp,{})})})}function Kp(){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(Ul,{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(gn,{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(Fl,{className:"w-3.5 h-3.5 text-[#f59e0b]"}):n.jsx(pn,{className:"w-3.5 h-3.5 text-[#6366f1]"}),n.jsx("span",{className:"text-[12px] text-[#a1a1aa]",children:p.name})]},p.path))]})]})}const Jp=oe.lazy(()=>le(()=>import("./SettingsPanel-E5WyEqka.js"),__vite__mapDeps([36,1,2,3,4,37,14,5,38,39,24,40,41,42,43])));function Xp(){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(Jp,{})})})}const Qp=oe.lazy(()=>le(()=>import("./SecurityPanel-R8QcTvYn.js"),__vite__mapDeps([44,1,2,37,14])));function Zp(){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(Qp,{})})})}const em=oe.lazy(()=>le(()=>import("./AuditPanel-srKuRJBx.js"),__vite__mapDeps([45,1,2,46,24,47])));function tm(){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(em,{})})})}const Yi={researcher:"#60a5fa",engineer:"#f87171",manager:"#a78bfa",ceo:"#fbbf24",general:"#9ca3af"},sm={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 nm(){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,I]=await Promise.all([ge("/api/specialists"),ge("/api/models")]);if(!E.ok)throw new Error(`Specialists request failed: ${E.status}`);if(!I.ok)throw new Error(`Models request failed: ${I.status}`);const v=await E.json(),A=await I.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 I=i[E];if(I&&I.length)return I.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,I)=>{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:I})});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(Cr,{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(gn,{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(fn,{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(rm,{row:E,models:x(E.id),recommendations:i[E.id]??[],state:l[E.id]??"idle",onChange:I=>y(E.id,I),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 rm({row:t,models:e,recommendations:s,state:r,onChange:i,onReset:o}){var u;const c=Yi[t.role]??Yi.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(I=>I.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 ${sm[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(io,{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(ci,{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(gn,{className:"w-3.5 h-3.5 animate-spin text-[#6366f1]"}),r==="saved"&&n.jsx(ui,{className:"w-3.5 h-3.5 text-[#10b981]"}),r==="error"&&n.jsx(fn,{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(ci,{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(ui,{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 im(){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[I,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(I),r(v),A!=null&&A.remote&&o(A.remote)}catch(I){p(I.message)}},[]);w.useEffect(()=>{const I=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(I)},[]),w.useEffect(()=>{f()},[f]);const x=w.useCallback(async I=>{d(!0),p(null);try{const v=await ge("/api/telemetry/consent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)});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($l,{className:"w-5 h-5 text-[#10b981]"}):n.jsx(Tr,{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(Tl,{className:"w-3 h-3"})," Saved"]}),l&&n.jsxs("span",{className:"text-[11px] text-[#ef4444] flex items-center gap-1",children:[n.jsx(Rl,{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(gn,{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:I=>x({enabled:I.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:I=>x({enabled:y,crashReports:I.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(fn,{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(ao,{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(ps,{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(hi,{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(hi,{className:"w-3 h-3"})," See the collector source"]})]})]})}const om=oe.lazy(()=>le(()=>import("./AutopilotPanel-C-XlExji.js"),__vite__mapDeps([48,1,2,37,14])));function am(){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(om,{})})})}const lm=oe.lazy(()=>le(()=>import("./WorkflowsPanel-DEz8opv0.js"),__vite__mapDeps([49,1,2,37,14,3,4,10,11,12,24,27,42,16,28,20,50,51])));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(lm,{})})})}const dm=oe.lazy(()=>le(()=>import("./LearningPanel-2LcS5Vqm.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])));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(dm,{})})})}const hm=oe.lazy(()=>le(()=>import("./SelfImprovePanel-Burrv2Jw.js"),__vite__mapDeps([67,1,2,24,38,20,68,54,15,14,42,23,60,28])));function fm(){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(hm,{})})})}const pm=oe.lazy(()=>le(()=>import("./PersonasPanel-DzJFmfaz.js"),__vite__mapDeps([69,1,2])));function mm(){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 gm=oe.lazy(()=>le(()=>import("./PersonaProfilesPanel-Kbyz2S3M.js"),__vite__mapDeps([70,1,2,37,14,24,11,16,63,20])));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(gm,{})})})}const bm=oe.lazy(()=>le(()=>import("./DreamPanel-DfczImsZ.js"),__vite__mapDeps([71,1,2,37,14,24])));function xm(){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 wm=oe.lazy(()=>le(()=>import("./HomelabPanel-C_Kpp-jq.js"),__vite__mapDeps([72,1,2,37,14,73,74,4,24,20,21,56,19,31,38,40,17])));function vm(){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(wm,{})})})}const _m=oe.lazy(()=>le(()=>import("./NvidiaPanel-BhSsBbMG.js"),__vite__mapDeps([75,1,2,24,43,38,66,32])));function km(){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(_m,{})})})}const Sm=oe.lazy(()=>le(()=>import("./FilesPanel-g8k7Z_ea.js"),__vite__mapDeps([76,1,2,27,24,14,77,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])));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(Sm,{})})})}const Em=oe.lazy(()=>le(()=>import("./LogsPanel-YDE1-OQU.js"),__vite__mapDeps([78,1,2,24])));function Nm(){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(Em,{})})})}const Cm=oe.lazy(()=>le(()=>import("./TelemetryPanel-D8gu25aT.js"),__vite__mapDeps([79,1,2,73,20,18,19,56])));function Tm(){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(Cm,{})})})}const Rm=oe.lazy(()=>le(()=>import("./SkillsPanel-BXyiyd7F.js"),__vite__mapDeps([80,1,2,37,14,32,28,41])));function Am(){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(Rm,{})})})}const Lm=oe.lazy(()=>le(()=>import("./McpPanel-D1v3LwyX.js"),__vite__mapDeps([81,1,2,82,24,27,56,61,28])));function Im(){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(Lm,{})})})}const Dm=oe.lazy(()=>le(()=>import("./IntegrationsPanel-DLfYHy7-.js"),__vite__mapDeps([83,1,2,82,38,43,14])));function Mm(){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(Dm,{})})})}const Om=oe.lazy(()=>le(()=>import("./ChannelsPanel-C2BO3kax.js"),__vite__mapDeps([84,1,2,37,14,24,38,43])));function Pm(){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(Om,{})})})}const Wm=oe.lazy(()=>le(()=>import("./MeshPanel-BNBI60Kh.js"),__vite__mapDeps([85,1,2,86,24,65])));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(Wm,{})})})}const Um=oe.lazy(()=>le(()=>import("./MemoryWikiPanel-Cqps7hGG.js"),__vite__mapDeps([87,1,2,37,14,77,20,32,51])));function Fm(){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(Um,{})})})}const $m=oe.lazy(()=>le(()=>import("./AutoresearchPanel-BYffkknO.js"),__vite__mapDeps([88,1,2,58,42,16,24,68,54,20,14])));function zm(){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($m,{})})})}const Hm=oe.lazy(()=>le(()=>import("./SelfProposalsPanel-DdHyA7M7.js"),__vite__mapDeps([89,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])));function Vm(){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(Hm,{})})})}const Gm=oe.lazy(()=>le(()=>import("./OverviewPanel-C7YJgjIS.js"),__vite__mapDeps([90,1,2,73,37,14,74,4,20,21,56,91])));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(Gm,{})})})}const Ym=oe.lazy(()=>le(()=>import("./SessionsPanel-ByV8dYnL.js"),__vite__mapDeps([92,1,2,37,14,3,4,86,10,11,12,32,28])));function Km(){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 Jm=oe.lazy(()=>le(()=>import("./WatchView-COyUaBza.js"),__vite__mapDeps([93,1,2,9])));function Xm(){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(Jm,{})})})}const Qm=oe.lazy(()=>le(()=>import("./BackupPanel-BpqVqS2y.js"),__vite__mapDeps([94,1,2,37,14,27,24,59,38])));function Zm(){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 eg=oe.lazy(()=>le(()=>import("./TrainingPanel-CS9oWB58.js"),__vite__mapDeps([95,1,2,37,14,24,41])));function tg(){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(eg,{})})})}const sg=oe.lazy(()=>le(()=>import("./RecipesPanel-sG2wIUOY.js"),__vite__mapDeps([96,1,2,37,14,24,51,42,28])));function ng(){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(sg,{})})})}const rg=oe.lazy(()=>le(()=>import("./VramPanel-BNOFAvif.js"),__vite__mapDeps([97,1,2,37,14,24])));function ig(){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(rg,{})})})}const og=oe.lazy(()=>le(()=>import("./TeamsPanel-BeNA1P-k.js"),__vite__mapDeps([98,1,2,37,14,24,28])));function ag(){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(og,{})})})}const lg=oe.lazy(()=>le(()=>import("./CronPanel-DGraqIbo.js"),__vite__mapDeps([99,1,2,37,14,24,20,50,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(lg,{})})})}const dg=oe.lazy(()=>le(()=>import("./CheckpointsPanel-CBcHZncd.js"),__vite__mapDeps([100,1,2,37,14,24,43,28])));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(dg,{})})})}const hg=oe.lazy(()=>le(()=>import("./OrganismPanel-5eKj-u5O.js"),__vite__mapDeps([101,1,2,37,14,24,38])));function fg(){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(hg,{})})})}const pg=oe.lazy(()=>le(()=>import("./FleetPanel-01gxZlxR.js"),__vite__mapDeps([102,1,2,37,14,24,60])));function mg(){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 gg=oe.lazy(()=>le(()=>import("./BrowserPanel-CpcHkt_q.js"),__vite__mapDeps([103,1,2,37,14])));function yg(){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(gg,{})})})}const bg=oe.lazy(()=>le(()=>import("./EvalPanel-DDDTr1W8.js"),__vite__mapDeps([104,1,2,37,14,24,42])));function xg(){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 wg(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 vg(t){const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>=0?t.slice(e+1):t}function _g(){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),[I,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"})]})]}),I&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,background:I.kind==="ok"?"rgba(34,197,94,0.12)":"rgba(239,68,68,0.12)",border:`1px solid ${I.kind==="ok"?"rgba(34,197,94,0.3)":"rgba(239,68,68,0.3)"}`,color:I.kind==="ok"?"#86efac":"#fca5a5",fontSize:11},children:I.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:wg(C.timestamp)})]}),n.jsx("div",{style:{fontSize:12,color:"#e2e8f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:C.filePath,children:vg(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(`
969
+ `).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 Ki=5e3,Ji={planning:"#a5b4fc",delegating:"#60a5fa",observing:"#22d3ee",iterating:"#f59e0b",verifying:"#a78bfa",reporting:"#34d399",blocked:"#facc15",escalated:"#fb7185",done:"#34d399",failed:"#ef4444",cancelled:"#737373"};function kg(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 Sg(t){return t===0?"$0":t<.01?"$<0.01":`$${t.toFixed(2)}`}function jg(){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),I=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(()=>{I();const _=setInterval(I,Ki);return()=>clearInterval(_)},[I]);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),I()}catch(S){v("err",S.message||"launch failed")}finally{x(!1)}},[l,g,I,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."),I()}catch(T){v("err",T.message||"cancel failed")}},[I,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 ",Ki/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:I,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=Ji[_.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:Sg(_.budget.costUsd)}),n.jsx("span",{children:"·"}),n.jsx("span",{children:kg(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:Ji[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 Eg=6e4,Ng=[{label:"6h",hours:6},{label:"24h",hours:24},{label:"7d",hours:168}];function Cg(t){return t===0?"$0":t<.01?"$<0.01":`$${t.toFixed(2)}`}function Tg(t){return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(1)}k`:`${(t/1e6).toFixed(2)}M`}function Rg(){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,Eg);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:Ng.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(Ws,{label:"Done",value:s.stats.completed,color:"#34d399"}),n.jsx(Ws,{label:"Failed",value:s.stats.failed,color:s.stats.failed>0?"#fca5a5":"rgba(255,255,255,0.5)"}),n.jsx(Ws,{label:"Active",value:s.stats.active,color:"#60a5fa"}),n.jsx(Ws,{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:Cg(s.stats.totalCostUsd)})]}),n.jsxs("span",{children:["Tokens: ",n.jsx("strong",{style:{color:"#e2e8f5"},children:Tg(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 Ws({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 Bs={pending:"#737373",running:"#60a5fa",done:"#34d399",failed:"#ef4444",skipped:"#a78bfa"},Xi=6e3,_t=180,nr=64,Qi=96,Us=24;function Ag(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 Lg(){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,Xi);return()=>clearInterval(v)},[g]),w.useEffect(()=>{if(!s){o(null);return}u(s);const v=setInterval(()=>u(s),Xi);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=Ag(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,_*(_t+Us)+Us),S=k.length*Qi+nr+40,C=new Map,D=[];for(const R of k){const P=m.get(R),B=P.length*_t+(P.length-1)*Us,z=(T-B)/2,q=R*Qi+20;for(let H=0;H<P.length;H++){const J=z+H*(_t+Us);C.set(P[H].id,{x:J,y:q}),D.push({...P[H],x:J,y:q})}}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+_t/2,y1:z.y+nr,x2:P.x+_t/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]),I=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=Bs[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:_t,height:nr,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:_t-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."})}),I&&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:I.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:`${Bs[I.status]}22`,border:`1px solid ${Bs[I.status]}55`,color:Bs[I.status]},children:I.status}),I.retries>0&&n.jsxs("span",{style:{marginLeft:6,color:"rgba(255,255,255,0.5)"},children:[I.retries," retries"]})]}),n.jsx("div",{style:{color:"rgba(255,255,255,0.85)",lineHeight:1.5,marginBottom:10},children:I.description}),I.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:"})," ",I.dependsOn.map(v=>{var A;return((A=E.get(v))==null?void 0:A.title)||v}).join(", ")]}),I.completedAt&&n.jsxs("div",{style:{color:"rgba(255,255,255,0.45)",fontSize:10},children:["Completed: ",new Date(I.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 Ig(){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(so,{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(fn,{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(mo,{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 Dg(){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(so,{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(Al,{className:"w-3.5 h-3.5 text-emerald-400"}):n.jsx(zl,{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(Vt,{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 Fs({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 Mg(){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(Fs,{label:"CPU",value:t.cpu,icon:n.jsx(Nr,{className:"w-3 h-3 text-[#6366f1]"}),color:"#6366f1",unknown:s}),n.jsx(Fs,{label:"Memory",value:t.memory,icon:n.jsx(Ll,{className:"w-3 h-3 text-[#a78bfa]"}),color:"#a78bfa",unknown:s}),n.jsx(Fs,{label:"Disk",value:t.disk,icon:n.jsx(Il,{className:"w-3 h-3 text-[#10b981]"}),color:"#10b981",unknown:s||!t.diskAvailable}),n.jsx(Fs,{label:"Load",value:t.load,icon:n.jsx(Vt,{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 Og=[{label:"Nav",source:"system:nav",w:3,h:4,icon:n.jsx(Vl,{className:"w-3.5 h-3.5"})},{label:"Agents",source:"system:agents",w:3,h:4,icon:n.jsx(mo,{className:"w-3.5 h-3.5"})},{label:"Health",source:"system:health",w:3,h:3,icon:n.jsx(Vt,{className:"w-3.5 h-3.5"})},{label:"Stats",source:"system:stats",w:3,h:4,icon:n.jsx(Kl,{className:"w-3.5 h-3.5"})},{label:"Chat",source:"system:chat",w:4,h:5,icon:n.jsx(lo,{className:"w-3.5 h-3.5"})},{label:"Files",source:"system:files",w:4,h:6,icon:n.jsx(pn,{className:"w-3.5 h-3.5"})},{label:"Skills",source:"system:tools",w:5,h:4,icon:n.jsx(Er,{className:"w-3.5 h-3.5"})},{label:"Soma",source:"system:soma",w:6,h:6,icon:n.jsx(Dl,{className:"w-3.5 h-3.5"})},{label:"Intel",source:"system:intelligence",w:6,h:5,icon:n.jsx(yt,{className:"w-3.5 h-3.5"})},{label:"Infra",source:"system:infra",w:6,h:4,icon:n.jsx(Rr,{className:"w-3.5 h-3.5"})},{label:"Tools",source:"system:tools",w:5,h:4,icon:n.jsx(jr,{className:"w-3.5 h-3.5"})},{label:"Settings",source:"system:settings",w:4,h:6,icon:n.jsx(Sr,{className:"w-3.5 h-3.5"})},{label:"Wiki",source:"system:memory-wiki",w:5,h:5,icon:n.jsx(fs,{className:"w-3.5 h-3.5"})},{label:"Research",source:"system:autoresearch",w:5,h:5,icon:n.jsx(uo,{className:"w-3.5 h-3.5"})},{label:"Proposals",source:"system:self-proposals",w:5,h:5,icon:n.jsx(go,{className:"w-3.5 h-3.5"})},{label:"Overview",source:"system:overview",w:5,h:4,icon:n.jsx(eo,{className:"w-3.5 h-3.5"})},{label:"Sessions",source:"system:sessions",w:5,h:4,icon:n.jsx(ps,{className:"w-3.5 h-3.5"})},{label:"Watch",source:"system:watch",w:6,h:5,icon:n.jsx(Vt,{className:"w-3.5 h-3.5"})},{label:"Backup",source:"system:backup",w:5,h:5,icon:n.jsx(ho,{className:"w-3.5 h-3.5"})},{label:"Training",source:"system:training",w:5,h:5,icon:n.jsx(yt,{className:"w-3.5 h-3.5"})},{label:"Recipes",source:"system:recipes",w:5,h:5,icon:n.jsx(fs,{className:"w-3.5 h-3.5"})},{label:"VRAM",source:"system:vram",w:5,h:5,icon:n.jsx(Nr,{className:"w-3.5 h-3.5"})},{label:"Teams",source:"system:teams",w:5,h:5,icon:n.jsx(Cr,{className:"w-3.5 h-3.5"})},{label:"Cron",source:"system:cron",w:5,h:5,icon:n.jsx(ps,{className:"w-3.5 h-3.5"})},{label:"Checkpoints",source:"system:checkpoints",w:5,h:5,icon:n.jsx(mn,{className:"w-3.5 h-3.5"})},{label:"Organism",source:"system:organism",w:5,h:5,icon:n.jsx(Tr,{className:"w-3.5 h-3.5"})},{label:"Fleet",source:"system:fleet",w:5,h:5,icon:n.jsx(fo,{className:"w-3.5 h-3.5"})},{label:"Browser",source:"system:browser",w:5,h:5,icon:n.jsx(to,{className:"w-3.5 h-3.5"})},{label:"Eval",source:"system:eval",w:5,h:5,icon:n.jsx(po,{className:"w-3.5 h-3.5"})}];function Pg(){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:Og.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 Wg extends oe.Component{componentDidCatch(e){this.props.onError(e.message)}render(){return this.props.children}}function Bg({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(Wg,{onError:r,children:e})}const Ug=oe.lazy(()=>le(()=>import("./legacy-DWFG28eD.js"),__vite__mapDeps([105,1,2,4])).then(t=>({default:t.Responsive}))),Fg={"system:nav":ll,"system:chat":hl,"system:cmd":bl,"system:soma":xl,"system:command-post":Pp,"system:intelligence":Bp,"system:memory-graph":Fp,"system:voice":$p,"system:infra":Hp,"system:tools":Gp,"system:settings":Yp,"system:files":Kp,"system:settings-general":Xp,"system:settings-security":Zp,"system:settings-audit":tm,"system:settings-specialists":nm,"system:settings-privacy":im,"system:intelligence-autopilot":am,"system:intelligence-workflows":cm,"system:intelligence-learning":um,"system:intelligence-self-improve":fm,"system:intelligence-personas":mm,"system:intelligence-persona-profiles":ym,"system:intelligence-dream":xm,"system:infra-homelab":vm,"system:infra-gpu":km,"system:infra-files":jm,"system:infra-logs":Nm,"system:infra-telemetry":Tm,"system:tools-skills":Am,"system:tools-mcp":Im,"system:tools-integrations":Mm,"system:tools-channels":Pm,"system:tools-mesh":Bm,"system:agents":Ig,"system:health":Dg,"system:stats":Mg,"system:quick-links":Pg,"system:memory-wiki":Fm,"system:autoresearch":zm,"system:self-proposals":Vm,"system:overview":qm,"system:sessions":Km,"system:watch":Xm,"system:backup":Zm,"system:training":tg,"system:recipes":ng,"system:vram":ig,"system:teams":ag,"system:cron":cg,"system:checkpoints":ug,"system:organism":fg,"system:fleet":mg,"system:browser":yg,"system:eval":xg,"system:time-travel":_g,"system:mission-driver":jg,"system:daily-digest":Rg,"system:mission-graph":Lg},$g={lg:12,md:10,sm:6,xs:4,xxs:2},zg=60,Hg={lg:1200,md:996,sm:768,xs:480,xxs:0},Vg=[12,12],Gg=["se","sw","ne","nw","e","w","n","s"],wl=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(Kg,{widget:t,space:e,onRemove:u}),p]})});wl.displayName="MemoWidgetItem";const qg=oe.memo(wl);function Yg({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 al(r.current,{onLog:u=>console.log(`[Widget ${t.id}]`,u)}),i.current.setMessageHandler(u=>{var x,y,E,I;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}:Gs(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"&&((I=u.payload)==null?void 0:I.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=Fg[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(Bg,{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 Kg=oe.memo(Yg);function Jg(){const{spaceId:t}=Ml(),e=Zi(),[s,r]=w.useState(null),[i]=w.useState(!0),[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,I]=w.useState(1200),v=w.useRef(null),A=w.useRef(null),{info:m,triggerUpdate:k,waitForReload:_}=wf(),[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 Y=new ResizeObserver(te=>{for(const Q of te)I(Q.contentRect.width)});return Y.observe(se),I(se.getBoundingClientRect().width||1200),Y};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",$)},[]),vf([{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(Y=>Y.id===$);Dn("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(Y=>Y.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]}),Dn($.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 Y of s.widgets)for(let te=0;te<Y.w;te++)for(let Q=0;Q<Y.h;Q++)se.add(`${Y.x+te},${Y.y+Q}`);for(let Y=0;Y<200;Y++)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},${Y+Ce}`)){Q=!1;break}if(!Q)break}if(Q)return{x:te,y:Y}}return{x:0,y:0}},[s]),q=w.useCallback(($,F,V=4,se=4)=>{const Y=z(V,se);B({name:F,format:"system",source:$,x:Y.x,y:Y.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,Y=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,Y);B({name:te,format:Q,source:String(V.source),x:be.x,y:be.y,w:se,h:Y})}};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]),J=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(xp,{}),n.jsxs("div",{ref:v,className:"flex-1 relative overflow-auto",children:[n.jsx("style",{children:`
970
970
  .titan-canvas-grid .react-grid-item > .react-resizable-handle {
971
971
  background: none;
972
972
  padding: 0;