dorkos 0.128.0 → 0.129.0

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 (359) hide show
  1. package/dist/bin/cli.js +84 -16
  2. package/dist/browser/native/package-manifest.json +1 -1
  3. package/dist/browser/source-manifest.json +1 -1
  4. package/dist/client/assets/{AboutPage-CmQERFxo.js → AboutPage-CML_SdU1.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-Dw231W2w.js → ActivityErrorState-TuQRJopr.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-DVfeyA9u.js → ActivityPage-CmSxeVSK.js} +1 -1
  7. package/dist/client/assets/ActivityRow-DJhDehIR.js +1 -0
  8. package/dist/client/assets/{AdapterIcon-NqCDzgCI.js → AdapterIcon-CeRDpZGz.js} +1 -1
  9. package/dist/client/assets/AdapterSetupWizard-B6KkTuJo.js +2 -0
  10. package/dist/client/assets/{AgentOptionRow-BRJfZo2y.js → AgentOptionRow-388OJkPc.js} +1 -1
  11. package/dist/client/assets/{AgentPicker-B7upjYRk.js → AgentPicker-C51wqToQ.js} +1 -1
  12. package/dist/client/assets/{AgentRequestCard-DXJnLk6q.js → AgentRequestCard-Bz31ewIs.js} +4 -4
  13. package/dist/client/assets/AppearancePage-DSVeowGb.js +1 -0
  14. package/dist/client/assets/{ApplyToOverridesDialog-C_QQhNIf.js → ApplyToOverridesDialog-DRtcLrVY.js} +1 -1
  15. package/dist/client/assets/AttentionSignalRow-CqKZyoxB.js +1 -0
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-G7vrCqeA.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-DA1jhqFy.js} +3 -3
  17. package/dist/client/assets/BindingDialog-D25PAed0.js +1 -0
  18. package/dist/client/assets/{BlintzCanvas-DruVZcDU.js → BlintzCanvas-BgIQdpTx.js} +3 -3
  19. package/dist/client/assets/{CanvasCsvContent-CtLpZnTs.js → CanvasCsvContent-ZWHWmb88.js} +4 -4
  20. package/dist/client/assets/CanvasFileContent-DR5pUgca.js +2 -0
  21. package/dist/client/assets/CanvasModel3dContent-OP1ZOMui.js +2 -0
  22. package/dist/client/assets/ChannelComposer-BJ0nNzQb.js +45 -0
  23. package/dist/client/assets/{ChatAppsOff-CCZUzDIH.js → ChatAppsOff-ByitL4Xt.js} +2 -2
  24. package/dist/client/assets/{CodeMirrorDiff-BCpYdhgZ.js → CodeMirrorDiff-JsV_vWBa.js} +1 -1
  25. package/dist/client/assets/{CodeMirrorEditor-BeCubxHV.js → CodeMirrorEditor-BfCJG9hQ.js} +1 -1
  26. package/dist/client/assets/{CommitmentList-BZtfTnwg.js → CommitmentList-yFV3_m00.js} +1 -1
  27. package/dist/client/assets/{CommitmentsPage-DmurDgxV.js → CommitmentsPage-DeERVg-2.js} +1 -1
  28. package/dist/client/assets/{ComputerResourceView-Bik6GLKp.js → ComputerResourceView-CYMMSE8Y.js} +1 -1
  29. package/dist/client/assets/{ComputerViewer-CksBDqdu.js → ComputerViewer-H7kJSIj7.js} +1 -1
  30. package/dist/client/assets/ConnectionAccessLists-SRkf7-Y6.js +1 -0
  31. package/dist/client/assets/{ConnectionsPage-Cgg36gDY.js → ConnectionsPage-D6e3hd4L.js} +2 -2
  32. package/dist/client/assets/{ConventionPage-CNhpF6Z1.js → ConventionPage-CpvRMcSG.js} +2 -2
  33. package/dist/client/assets/{ExtensionPageRoute-C2zue_Pw.js → ExtensionPageRoute-CiFv6we8.js} +2 -2
  34. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-3v1TfY1P.js → FloatingTanStackRouterDevtools-CqogiFob-D-8CeYC7.js} +1 -1
  35. package/dist/client/assets/{ForwardConsentHost-Mbo0D-zk.js → ForwardConsentHost-ml3b_fsX.js} +1 -1
  36. package/dist/client/assets/HandlePage-Bq5qdCfY.js +1 -0
  37. package/dist/client/assets/HeartbeatPage-C0zSvWH4.js +1 -0
  38. package/dist/client/assets/{KeyEntry-C43vkwpA.js → KeyEntry-Dq6eKAbX.js} +1 -1
  39. package/dist/client/assets/{LexicalField-iAHcvRmI.js → LexicalField-CYOqOLpV.js} +1 -1
  40. package/dist/client/assets/{ManagesPage-BUIJvLmv.js → ManagesPage-DZTMD3Al.js} +1 -1
  41. package/dist/client/assets/Marketplace-buSfuVrY.js +36 -0
  42. package/dist/client/assets/{MarketplaceSourcesView-BZODwhxu.js → MarketplaceSourcesView-BxwvBWgh.js} +1 -1
  43. package/dist/client/assets/{McpAppFrame-D15nxVaI.js → McpAppFrame-CWiRFp8o.js} +2 -2
  44. package/dist/client/assets/{McpSigninBody-DmBxqgxN.js → McpSigninBody-BpYSAV1h.js} +1 -1
  45. package/dist/client/assets/{Model3dViewer-RGXeJd6a.js → Model3dViewer-B2KTvx6d.js} +1 -1
  46. package/dist/client/assets/NamePage-_yT2RQvT.js +1 -0
  47. package/dist/client/assets/{NewDirectMessageMenu-DBAdvv5p.js → NewDirectMessageMenu-CMp4ppiH.js} +1 -1
  48. package/dist/client/assets/{NotificationsPage-NRfyiinS.js → NotificationsPage-CWXIghVM.js} +1 -1
  49. package/dist/client/assets/{OpenMeshSwitch-CgQ6uefo.js → OpenMeshSwitch-C9hiAEHP.js} +2 -2
  50. package/dist/client/assets/OperatorIdentityForm-CjmMoP6n.js +1 -0
  51. package/dist/client/assets/{PermissionHistory-DPEPq8D9.js → PermissionHistory-D_Imuq02.js} +1 -1
  52. package/dist/client/assets/{PermissionsPage--k-xutbJ.js → PermissionsPage-QMLV8PfB.js} +1 -1
  53. package/dist/client/assets/{PersonalityPopover-DMMptmPS.js → PersonalityPopover-BL9DLK0Q.js} +1 -1
  54. package/dist/client/assets/PhotoPage-Djh4IZBF.js +1 -0
  55. package/dist/client/assets/PreviewRefusedNotice-Dt2hV0aJ.js +1 -0
  56. package/dist/client/assets/{ProfileFields-DbPJ7fvN.js → ProfileFields-DD6X85w2.js} +1 -1
  57. package/dist/client/assets/{ProfilePanelContainer-CzwhrIlw.js → ProfilePanelContainer-DuFEpNJ3.js} +1 -1
  58. package/dist/client/assets/{ProfileRolePicker-CZEXvlJm.js → ProfileRolePicker-CT9eJ1J0.js} +1 -1
  59. package/dist/client/assets/PromptSuggestionChips-C8V611-5.js +1 -0
  60. package/dist/client/assets/{ReportsToPopover-YOwGLJy5.js → ReportsToPopover-Bs55bP7b.js} +1 -1
  61. package/dist/client/assets/RoomSurface-DXZ36tmU.js +1 -0
  62. package/dist/client/assets/{RoomsPage-CoXjZMWL.js → RoomsPage-CDiSwt-I.js} +1 -1
  63. package/dist/client/assets/RunsOnPopover-CFBDa9DO.js +1 -0
  64. package/dist/client/assets/RuntimeConnectFlow-DsawxJN7.js +1 -0
  65. package/dist/client/assets/RuntimeSetupDialog-bdf844gx.js +1 -0
  66. package/dist/client/assets/{SeenDevices-Bh2yh-PW.js → SeenDevices-Cix5nnGQ.js} +2 -2
  67. package/dist/client/assets/{SessionsPage-CFvkbT9X.js → SessionsPage-CCu8rM-J.js} +1 -1
  68. package/dist/client/assets/SettingsDialog-D7sVluoe.js +12 -0
  69. package/dist/client/assets/SkillsPage-SSq7ofgp.js +1 -0
  70. package/dist/client/assets/TaskDialogWrapper-CBIuIbmj.js +1 -0
  71. package/dist/client/assets/TasksEmptyState-C0K_NOA3.js +3 -0
  72. package/dist/client/assets/{TasksPage-D0Zi6Mve.js → TasksPage-BpSn7GmR.js} +1 -1
  73. package/dist/client/assets/{TeamComputerEntry-CY9eLVad.js → TeamComputerEntry-BAi9omUC.js} +1 -1
  74. package/dist/client/assets/{ToolsPage-0_vx5P-F.js → ToolsPage-nkGWy6MR.js} +2 -2
  75. package/dist/client/assets/{TopologyGraph-DUZLZZrB.js → TopologyGraph-D6SSv0kC.js} +14 -14
  76. package/dist/client/assets/TourHost-CrZciWIf.js +1 -0
  77. package/dist/client/assets/{UnlinkDialog-ptZy3IN4.js → UnlinkDialog-B9zw8r6F.js} +1 -1
  78. package/dist/client/assets/{UnreadDivider-Ckey1IWn.js → UnreadDivider-BnJ06LmP.js} +1 -1
  79. package/dist/client/assets/WidgetErrorCard-CQKYI7oK.js +108 -0
  80. package/dist/client/assets/{WithheldExtensionsNotice-7Vu1Jctn.js → WithheldExtensionsNotice-VMM5NjL5.js} +1 -1
  81. package/dist/client/assets/WorkView-D5d8DDxS.js +51 -0
  82. package/dist/client/assets/_shell-CTKp94uQ.js +80 -0
  83. package/dist/client/assets/{_shell._home-BRIXhYLg.js → _shell._home-CcfELPIk.js} +1 -1
  84. package/dist/client/assets/_shell._home.activity-CGKsuLq8.js +1 -0
  85. package/dist/client/assets/_shell._home.index-DrJRgJCb.js +3 -0
  86. package/dist/client/assets/_shell._home.tasks-B_lv_-fX.js +1 -0
  87. package/dist/client/assets/_shell._home.workspaces-CjBJymCW.js +1 -0
  88. package/dist/client/assets/{_shell.channels-Bx6q9xVH.js → _shell.channels-CzQFR6pU.js} +4 -4
  89. package/dist/client/assets/_shell.connections-B5hafeep.js +1 -0
  90. package/dist/client/assets/{_shell.feedback-requests-DFznTGbN.js → _shell.feedback-requests-DtD2bH-4.js} +2 -2
  91. package/dist/client/assets/_shell.marketplace-DUpaCb0r.js +1 -0
  92. package/dist/client/assets/_shell.marketplace_.sources-C3pA7zZW.js +1 -0
  93. package/dist/client/assets/_shell.session-DH_9f3AK.js +1 -0
  94. package/dist/client/assets/{_shell.team-DmA09abY.js → _shell.team-BrGo-IxK.js} +6 -6
  95. package/dist/client/assets/_shell.threads-Ceq_tmNk.js +1 -0
  96. package/dist/client/assets/_shell.x._extensionId-DaXLhYNr.js +1 -0
  97. package/dist/client/assets/_shell.x._extensionId_._-DaXLhYNr.js +1 -0
  98. package/dist/client/assets/{abnfDiagram-WEYOIA3C-DxgtVd9I.js → abnfDiagram-WEYOIA3C-BN5bqwbu.js} +1 -1
  99. package/dist/client/assets/{access-copy-Dqct36mi.js → access-copy-BAhTOOsG.js} +1 -1
  100. package/dist/client/assets/{arc-C-67Ef0p.js → arc-BfTE_VoF.js} +1 -1
  101. package/dist/client/assets/{architectureDiagram-ZHVYKT53-B7TjdT-_.js → architectureDiagram-ZHVYKT53-Dc6keeDz.js} +1 -1
  102. package/dist/client/assets/{banner-C9qTs6-C.js → banner-DOgGDCJ5.js} +2 -2
  103. package/dist/client/assets/{blockDiagram-RJAE7QA3-DNqxJ3Ww.js → blockDiagram-RJAE7QA3-B4c6U-ob.js} +1 -1
  104. package/dist/client/assets/{c4Diagram-XDPPPE54-D3jNLV0j.js → c4Diagram-XDPPPE54-CCtD8QC8.js} +1 -1
  105. package/dist/client/assets/channel-CF9_Q7CV.js +1 -0
  106. package/dist/client/assets/{chunk-2E7WHVMD-C6OKx0ty.js → chunk-2E7WHVMD-DcDNqIJG.js} +1 -1
  107. package/dist/client/assets/{chunk-2Q5K7J3B-Dr_6hHrZ.js → chunk-2Q5K7J3B-DOVVK0B8.js} +1 -1
  108. package/dist/client/assets/{chunk-4EMNKR2T-CSrZVDEt.js → chunk-4EMNKR2T-Cg-Do982.js} +1 -1
  109. package/dist/client/assets/{chunk-55XCU76K-CIazeRXO.js → chunk-55XCU76K-CDmULSeY.js} +1 -1
  110. package/dist/client/assets/{chunk-5VM5RSS4-C8IJ3zTR.js → chunk-5VM5RSS4-Bi0yIWW1.js} +1 -1
  111. package/dist/client/assets/{chunk-JWPE2WC7-D9DGXb79.js → chunk-JWPE2WC7-ZHaJh6CV.js} +1 -1
  112. package/dist/client/assets/{chunk-VQ5W62QI-B0LNYdif.js → chunk-VQ5W62QI-DZi6GyW_.js} +1 -1
  113. package/dist/client/assets/{chunk-XXDRQBXY-C7IAIbvZ.js → chunk-XXDRQBXY-D18oZOrd.js} +1 -1
  114. package/dist/client/assets/{chunk-ZCHMQSOR-C79hvjlu.js → chunk-ZCHMQSOR-BkZ0l0fE.js} +2 -2
  115. package/dist/client/assets/{classDiagram-v2-4MYWR3UA-0Di1C2ZB.js → classDiagram-v2-4MYWR3UA-BfmK1buF.js} +1 -1
  116. package/dist/client/assets/{command-BVQb6I3_.js → command-CZqA020F.js} +1 -1
  117. package/dist/client/assets/copy-button-ByA00JGh.js +1 -0
  118. package/dist/client/assets/{cose-bilkent-JH36ORCC-rZumaV4b.js → cose-bilkent-JH36ORCC-B1NTVSbk.js} +1 -1
  119. package/dist/client/assets/{cpu-DeRuDMl4.js → cpu-DNvpMmNN.js} +1 -1
  120. package/dist/client/assets/{cynefin-EF2NZ3EQ-CI9l9xhM.js → cynefin-EF2NZ3EQ-CB_HMIZ8.js} +1 -1
  121. package/dist/client/assets/{cynefinDiagram-WF24UDRP-C8CdorJJ.js → cynefinDiagram-WF24UDRP-MmIWYdc2.js} +1 -1
  122. package/dist/client/assets/{dagre-NK4GIZVX-AHpsTq1O.js → dagre-NK4GIZVX-BQay0k4e.js} +1 -1
  123. package/dist/client/assets/detail-row-290qyusq.js +1 -0
  124. package/dist/client/assets/{diagram-CBK3MWTC-BpPLL30n.js → diagram-CBK3MWTC-C1lRH4cb.js} +1 -1
  125. package/dist/client/assets/{diagram-I5XIIV2D-D6loMn3G.js → diagram-I5XIIV2D-CnANa27A.js} +1 -1
  126. package/dist/client/assets/{diagram-ODIL2UCW-BaGNd5eN.js → diagram-ODIL2UCW-Cwt7hxes.js} +1 -1
  127. package/dist/client/assets/{diagram-PFBEJUXE-BnDdKu_g.js → diagram-PFBEJUXE-DZtAER77.js} +1 -1
  128. package/dist/client/assets/{diagram-RJA3I4VV-UXagB0_c.js → diagram-RJA3I4VV-CbVXbiGs.js} +1 -1
  129. package/dist/client/assets/{diagram-TYUNFSNR-C-whBP-S.js → diagram-TYUNFSNR-D-AcGdsL.js} +1 -1
  130. package/dist/client/assets/{ebnfDiagram-V4P3TTPT-BbG481iS.js → ebnfDiagram-V4P3TTPT-DLkrFSAy.js} +1 -1
  131. package/dist/client/assets/{elk-QONTBCTQ-FtssIxOc.js → elk-QONTBCTQ-DQM6Glxa.js} +1 -1
  132. package/dist/client/assets/{empty-state-CACt-76q.js → empty-state-BnuM8oop.js} +1 -1
  133. package/dist/client/assets/{erDiagram-KYQIGQAA-PpFgUf4C.js → erDiagram-KYQIGQAA-C1qgB1Mn.js} +1 -1
  134. package/dist/client/assets/{execution-config-CGL73sRn.js → execution-config-BjLHHc9x.js} +1 -1
  135. package/dist/client/assets/{file-D80JE_L0.js → file-D7_QdH_S.js} +1 -1
  136. package/dist/client/assets/{file-exclamation-point-CcJ_e4_m.js → file-exclamation-point-Cdt8YqyQ.js} +1 -1
  137. package/dist/client/assets/{file-text-Ds9edaTZ.js → file-text-CB9l6Ur-.js} +1 -1
  138. package/dist/client/assets/{find-latest-widget-fence-BtqFMP_f.js → find-latest-widget-fence-SQB9WgjN.js} +5 -5
  139. package/dist/client/assets/{flowDiagram-IUGLLWBU-BIva66g9.js → flowDiagram-IUGLLWBU-DH-ePeFu.js} +1 -1
  140. package/dist/client/assets/form--HjBAzX8.js +1 -0
  141. package/dist/client/assets/{format-cron-BpGrgPLu.js → format-cron-svkfKW5b.js} +1 -1
  142. package/dist/client/assets/format-tokens-DymkROvy.js +1 -0
  143. package/dist/client/assets/{ganttDiagram-R7GPNTJY-CZqips_4.js → ganttDiagram-R7GPNTJY-fjb_iAW1.js} +1 -1
  144. package/dist/client/assets/{git-branch-B8JNwQ6q.js → git-branch-CPOwiT8a.js} +1 -1
  145. package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-DoIc3lda.js → gitGraphDiagram-PDYL7XHY-CcCqH5T3.js} +1 -1
  146. package/dist/client/assets/{graph-yizM0vwL.js → graph-DS3J2jnN.js} +1 -1
  147. package/dist/client/assets/{heart-BavUIV45.js → heart-C6uRnXx3.js} +1 -1
  148. package/dist/client/assets/{highlighted-body-KPVGNVTW-CGr3AgaU.js → highlighted-body-KPVGNVTW-CNygKq0i.js} +1 -1
  149. package/dist/client/assets/image-lightbox-BQV3i0WJ.js +1 -0
  150. package/dist/client/assets/{image-off-C1uTDs9-.js → image-off-B88WBkcV.js} +1 -1
  151. package/dist/client/assets/{index-SOKlO1zZ.js → index-3CJSEcZE.js} +1 -1
  152. package/dist/client/assets/index-3JL8A9YZ.css +1 -0
  153. package/dist/client/assets/{index-BJEt9R_G.js → index-57qzL_5b.js} +1 -1
  154. package/dist/client/assets/index-5RD9flqf.js +1 -0
  155. package/dist/client/assets/{index-FhWMRBQP.js → index-B6pmysqs.js} +1 -1
  156. package/dist/client/assets/{index-DEiSJbvu.js → index-BIZNH5u1.js} +1 -1
  157. package/dist/client/assets/{index-BOhSPP-6.js → index-BKdXHSbr.js} +1 -1
  158. package/dist/client/assets/{index-B36osK_S.js → index-BN3zOTbR.js} +3 -3
  159. package/dist/client/assets/{index-DYEmUa5t.js → index-BNq_mnok.js} +1 -1
  160. package/dist/client/assets/index-BPp-rj-W.js +1 -0
  161. package/dist/client/assets/{index-DW4KUPHp.js → index-BTqJGL1_.js} +1 -1
  162. package/dist/client/assets/{index-CJXMgnYp.js → index-B_YZ5cyn.js} +1 -1
  163. package/dist/client/assets/{index-Dcd4NqFB.js → index-B_rc9Pb1.js} +1 -1
  164. package/dist/client/assets/{index-56EOd-zy.js → index-B_v2l2ND.js} +1 -1
  165. package/dist/client/assets/{index-QSXJR98z.js → index-Bktc0aFV.js} +1 -1
  166. package/dist/client/assets/index-BtTqA4_d.js +1 -0
  167. package/dist/client/assets/{index-CiGYtR9O.js → index-BxsALYNM.js} +1 -1
  168. package/dist/client/assets/index-C4Uak2ha.js +1 -0
  169. package/dist/client/assets/{index-FI_y_dND.js → index-C7I0BjyX.js} +1 -1
  170. package/dist/client/assets/{index-CoNMlH37.js → index-CEicS7Zi.js} +1 -1
  171. package/dist/client/assets/{index-1QfQImuJ.js → index-CLTrC-a-.js} +3 -3
  172. package/dist/client/assets/{index-CXBYgGja.js → index-CLVvKY2v.js} +1 -1
  173. package/dist/client/assets/{index-BKWJiERs.js → index-COXdXByr.js} +1 -1
  174. package/dist/client/assets/{index-CoKNU2F9.js → index-CTJA-mZu.js} +1 -1
  175. package/dist/client/assets/{index-BOEPL6hN.js → index-CZmU-67J.js} +1 -1
  176. package/dist/client/assets/{index-LwL5BpE4.js → index-Cbbw2ByB.js} +1 -1
  177. package/dist/client/assets/{index-C4t0UTU-.js → index-Cbk19RQp.js} +1 -1
  178. package/dist/client/assets/{index-DqkFtcGQ.js → index-D0QV18E0.js} +1 -1
  179. package/dist/client/assets/{index-7XeZCCDI.js → index-D5fV4hrl.js} +1 -1
  180. package/dist/client/assets/{index-CeDn1Ak1.js → index-DBAPfYwE.js} +1 -1
  181. package/dist/client/assets/{index-Cdod8zEY.js → index-DK8zHloW.js} +1 -1
  182. package/dist/client/assets/index-DO8NbOqk.js +1 -0
  183. package/dist/client/assets/{index-C8ZpJXTQ.js → index-DXZ-w0Z9.js} +1 -1
  184. package/dist/client/assets/{index-n_pnc-CO.js → index-DYQjub9g.js} +1 -1
  185. package/dist/client/assets/index-Daoy3TZ8.js +1 -0
  186. package/dist/client/assets/{index-tgbcsB6H.js → index-DdBvjuc4.js} +1 -1
  187. package/dist/client/assets/{index-X282DRZf.js → index-DhqeMM58.js} +2 -2
  188. package/dist/client/assets/{index-YSHcMqHa.js → index-Ds9wPt9M.js} +1 -1
  189. package/dist/client/assets/{index-Br6xDNvu.js → index-RQhQx8gq.js} +1 -1
  190. package/dist/client/assets/{index-CrTmY12y.js → index-UJpgX--l.js} +2 -2
  191. package/dist/client/assets/index-YUtEyz7O.js +1053 -0
  192. package/dist/client/assets/{index-BkJlIXqM.js → index-oc-yQ5Q4.js} +1 -1
  193. package/dist/client/assets/index-tRdq7FGO.js +1 -0
  194. package/dist/client/assets/{index-ZR5f82z2.js → index-um-0KSur.js} +1 -1
  195. package/dist/client/assets/{index.esm-CAeUe7uQ.js → index.esm-B10OaB6F.js} +1 -1
  196. package/dist/client/assets/{infoDiagram-MVDRKAX5-DweUdYSy.js → infoDiagram-MVDRKAX5-CGtvYWtj.js} +1 -1
  197. package/dist/client/assets/{inline-code-SYHTKcle.js → inline-code-BL-6EKVP.js} +1 -1
  198. package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-DKNQIv7P.js → ishikawaDiagram-HPEHV2GE-ICsVVT2t.js} +1 -1
  199. package/dist/client/assets/{journeyDiagram-BOSHW7O7-DPD7F4VO.js → journeyDiagram-BOSHW7O7-DEmSX2Hn.js} +1 -1
  200. package/dist/client/assets/{kanban-definition-FNSA4HC5-B_uPSwxC.js → kanban-definition-FNSA4HC5-SAV5PQOr.js} +1 -1
  201. package/dist/client/assets/{layers-F4mvrI2l.js → layers-Bfdpn7ZM.js} +1 -1
  202. package/dist/client/assets/{lightbulb-a6nNsrzy.js → lightbulb-CSPTiZoi.js} +1 -1
  203. package/dist/client/assets/{link-2-yI2Tlm7Q.js → link-2-ZzmN9B9k.js} +1 -1
  204. package/dist/client/assets/{list-runtime-types-CsGil5te.js → list-runtime-types-7qV7HQ7K.js} +1 -1
  205. package/dist/client/assets/{markdown-content-Cjhsscbn.js → markdown-content-CiDXslQf.js} +1 -1
  206. package/dist/client/assets/mention-pill-CuSUdpn7.js +1 -0
  207. package/dist/client/assets/{mermaid.core-9PwG-9fN.js → mermaid.core-C-qvGQ5g.js} +4 -4
  208. package/dist/client/assets/{message-square-off-aV4NMCjd.js → message-square-off-BehEHG9c.js} +1 -1
  209. package/dist/client/assets/{mindmap-definition-6OY57UG3-BRbWmQkj.js → mindmap-definition-6OY57UG3-DzU2APoo.js} +1 -1
  210. package/dist/client/assets/{more-details-CRLU2HN4.js → more-details-DF2dJXMV.js} +1 -1
  211. package/dist/client/assets/{owner-notice-CTJbhUak.js → owner-notice-DoH-_Veh.js} +1 -1
  212. package/dist/client/assets/{package-sPggO7Dr.js → package-Fm_v1gMn.js} +1 -1
  213. package/dist/client/assets/{page-container-CnfDuiDC.js → page-container-Bcz5wJVR.js} +1 -1
  214. package/dist/client/assets/{pane-resize-handle-63OC5vfI.js → pane-resize-handle-_EuIpxzc.js} +1 -1
  215. package/dist/client/assets/{paperclip-WhPo3_WD.js → paperclip-AGN67YEM.js} +1 -1
  216. package/dist/client/assets/path-input-jrT0Ap4j.js +1 -0
  217. package/dist/client/assets/{pegDiagram-ECIUJNBX-Ct9Li_PA.js → pegDiagram-ECIUJNBX-CAyGJ7fm.js} +1 -1
  218. package/dist/client/assets/{pieDiagram-GNMPY74T-BAB5RA5v.js → pieDiagram-GNMPY74T-tmLJe1p-.js} +1 -1
  219. package/dist/client/assets/{plug-_q5iqunq.js → plug-C-4o4Kb8.js} +1 -1
  220. package/dist/client/assets/primer-trigger-CmE4Ib-X.js +3 -0
  221. package/dist/client/assets/{profile-errors-COcBx7w5.js → profile-errors-vJU1kT3U.js} +1 -1
  222. package/dist/client/assets/{progress-77FCPL2y.js → progress-BTu_QWg8.js} +1 -1
  223. package/dist/client/assets/{quadrantDiagram-D57K4MC3-BqPJVmMS.js → quadrantDiagram-D57K4MC3-CUr2zJoz.js} +1 -1
  224. package/dist/client/assets/{query-error-state-5236P3z0.js → query-error-state-BCX32dab.js} +1 -1
  225. package/dist/client/assets/{radio-C8xmfoqO.js → radio-DBitPjM1.js} +1 -1
  226. package/dist/client/assets/{railroadDiagram-Y72NRBL7-B8U11nT6.js → railroadDiagram-Y72NRBL7-Bk9OMEWz.js} +1 -1
  227. package/dist/client/assets/registry-DVPRVi8T.js +34 -0
  228. package/dist/client/assets/registry-DiFfRDdW.js +1 -0
  229. package/dist/client/assets/{relay-trace-schemas-B80E4EUn.js → relay-trace-schemas-C-1Js81V.js} +2 -2
  230. package/dist/client/assets/{repeat-CHmB_vD7.js → repeat-B1wCYWXI.js} +1 -1
  231. package/dist/client/assets/{requirementDiagram-EQYSW5RA-CzJ1gzTh.js → requirementDiagram-EQYSW5RA-B2pkljrw.js} +1 -1
  232. package/dist/client/assets/{room-files-source-B0gc97Ri.js → room-files-source-BDkq0-fd.js} +2 -2
  233. package/dist/client/assets/{rotate-ccw-clock-CCU6SVnv.js → rotate-ccw-clock-Ds8cHkxD.js} +1 -1
  234. package/dist/client/assets/{rotate-cw-B8WQa8O-.js → rotate-cw-hUzouNTK.js} +1 -1
  235. package/dist/client/assets/{sankeyDiagram-SY24JHO5-D4vQwyve.js → sankeyDiagram-SY24JHO5-DEW9eIPS.js} +1 -1
  236. package/dist/client/assets/scroll-area-RSd8NjrE.js +1 -0
  237. package/dist/client/assets/{sequenceDiagram-BLEHNHQU-BVnIsPQe.js → sequenceDiagram-BLEHNHQU-CoiCdD1D.js} +1 -1
  238. package/dist/client/assets/{shield-x-ijIbRppV.js → shield-x-KL4ZbHfz.js} +1 -1
  239. package/dist/client/assets/signed-in-Dzxe2378.js +1 -0
  240. package/dist/client/assets/{sizeCapture-INFHLROL-DGb1rAJL.js → sizeCapture-INFHLROL-BWGf0Ghs.js} +1 -1
  241. package/dist/client/assets/{soul-file-CXgYs25S.js → soul-file-BQXbWArv.js} +1 -1
  242. package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-DeX3IKTm.js → stateDiagram-v2-A6IESKWZ-aeqwGZMB.js} +1 -1
  243. package/dist/client/assets/{swimlanes-B3ENRKFQ-DN5ljYhG.js → swimlanes-B3ENRKFQ-BkWhAAlV.js} +1 -1
  244. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-CS2DMvLi.js +8 -0
  245. package/dist/client/assets/{table-D9ww_3Ij.js → table-CfLst6CF.js} +1 -1
  246. package/dist/client/assets/{timeline-definition-JXYKGLGB-DpRthC3r.js → timeline-definition-JXYKGLGB-C1BUxIfq.js} +1 -1
  247. package/dist/client/assets/{trust-posture-Dn2ciEE0.js → trust-posture-CfEIPM4Z.js} +1 -1
  248. package/dist/client/assets/{unplug-BZ8zSvfB.js → unplug-B3eDst8L.js} +1 -1
  249. package/dist/client/assets/{unverified-catalog-notice-CGy05tAO.js → unverified-catalog-notice-BqIWxQuN.js} +1 -1
  250. package/dist/client/assets/{use-bindings-BLAWQRpe.js → use-bindings-DhOKnybh.js} +1 -1
  251. package/dist/client/assets/{use-composer-prefs-ICOpilWK.js → use-composer-prefs-_rlNL0D8.js} +1 -1
  252. package/dist/client/assets/{use-connector-management-DEMGZy9N.js → use-connector-management-CHLdhBhC.js} +1 -1
  253. package/dist/client/assets/{use-deep-link-scroll-DxGYrks3.js → use-deep-link-scroll-BVkszEn2.js} +1 -1
  254. package/dist/client/assets/{use-delete-binding-Bnv3J5Fu.js → use-delete-binding-BET7vH2R.js} +1 -1
  255. package/dist/client/assets/{use-dev-links-BOcktLiE.js → use-dev-links-BjLPuSUC.js} +1 -1
  256. package/dist/client/assets/{use-direct-message-panel-D38tSozW.js → use-direct-message-panel-ClXVf94w.js} +1 -1
  257. package/dist/client/assets/{use-external-adapter-catalog-9qiNBqpc.js → use-external-adapter-catalog-D1INoacX.js} +1 -1
  258. package/dist/client/assets/use-filter-state-BRlb3qG3.js +6 -0
  259. package/dist/client/assets/use-full-activity-feed-GWBg-_1B.js +1 -0
  260. package/dist/client/assets/use-is-below-desktop-BjWA-tqP.js +1 -0
  261. package/dist/client/assets/{use-local-browser-B1huJhdg.js → use-local-browser-C-V2n_wd.js} +1 -1
  262. package/dist/client/assets/{use-mesh-topology-BTYAy6zc.js → use-mesh-topology-BzSFyR_s.js} +1 -1
  263. package/dist/client/assets/{use-mounted-ref-CaPc6Prv.js → use-mounted-ref-1T3JbkY1.js} +1 -1
  264. package/dist/client/assets/{use-notification-prefs-u76DPoP0.js → use-notification-prefs-qcYeVmLQ.js} +1 -1
  265. package/dist/client/assets/use-pending-read-C1oA2H00.js +1 -0
  266. package/dist/client/assets/use-personality-commit-CJb-rqmM.js +1 -0
  267. package/dist/client/assets/{use-promo-activation-5HG08FlB.js → use-promo-activation-CAJItujg.js} +3 -3
  268. package/dist/client/assets/{use-promo-dismissals-CO7-qhEl.js → use-promo-dismissals-C6bPU5Rm.js} +1 -1
  269. package/dist/client/assets/{use-pulse-freshness-D07Mv-Sa.js → use-pulse-freshness-Y11Ibit1.js} +1 -1
  270. package/dist/client/assets/{use-room-follow-claim-DRQBuAIe.js → use-room-follow-claim-Di-yvoJD.js} +1 -1
  271. package/dist/client/assets/{use-room-sessions-Bzk7rM40.js → use-room-sessions-CPDRbQAW.js} +1 -1
  272. package/dist/client/assets/{use-roving-tab-list-CcznVldj.js → use-roving-tab-list-DK0OzOUz.js} +1 -1
  273. package/dist/client/assets/{use-session-canvas-CpgE7tFb.js → use-session-canvas-DA2i9Mdm.js} +6 -6
  274. package/dist/client/assets/use-status-budget-jMg_w0rF.js +21 -0
  275. package/dist/client/assets/{use-transform-ByJGn3hq.js → use-transform-BX3r518L.js} +1 -1
  276. package/dist/client/assets/{use-unclaimed-chats-C-z5fstJ.js → use-unclaimed-chats-B0nk8b84.js} +1 -1
  277. package/dist/client/assets/use-update-config-Ce7sHmp2.js +1 -0
  278. package/dist/client/assets/{useMutationState-BF1EFtIZ.js → useMutationState-Rlga1GBT.js} +1 -1
  279. package/dist/client/assets/{usecaseDiagram-WPOLBNNX-efVKbRIX.js → usecaseDiagram-WPOLBNNX-mjIwRNL1.js} +1 -1
  280. package/dist/client/assets/{vennDiagram-Q3Y3IDCW-Bravmwce.js → vennDiagram-Q3Y3IDCW-BcDIpVa6.js} +1 -1
  281. package/dist/client/assets/{wardleyDiagram-IVAIDKWA-fR77zByv.js → wardleyDiagram-IVAIDKWA-NFX31kox.js} +1 -1
  282. package/dist/client/assets/{xychartDiagram-4URNHDU4-BphORSLh.js → xychartDiagram-4URNHDU4-DZZY7dL1.js} +1 -1
  283. package/dist/client/index.html +2 -2
  284. package/dist/drizzle/20261031012841_dor3309_file_turn_on_offer.sql +2 -0
  285. package/dist/drizzle/20261101122330_schedule_declined_content_key.sql +1 -0
  286. package/dist/drizzle/meta/20261031012841_snapshot.json +14116 -0
  287. package/dist/drizzle/meta/20261101122330_snapshot.json +14123 -0
  288. package/dist/drizzle/meta/_journal.json +14 -0
  289. package/dist/server/index.js +6424 -4548
  290. package/dist/server/index.js.map +2 -2
  291. package/package.json +5 -5
  292. package/dist/client/assets/ActivityRow-DIBH4v9c.js +0 -1
  293. package/dist/client/assets/AdapterSetupWizard-Dle_b9qc.js +0 -2
  294. package/dist/client/assets/AppearancePage-DXbhUt2e.js +0 -1
  295. package/dist/client/assets/AttentionSignalRow-5E7TkG98.js +0 -1
  296. package/dist/client/assets/BindingDialog-q--8SDJF.js +0 -1
  297. package/dist/client/assets/CanvasFileContent-BThy5fjD.js +0 -2
  298. package/dist/client/assets/CanvasModel3dContent-BbgR73jh.js +0 -2
  299. package/dist/client/assets/ChannelComposer-qhk0KtW7.js +0 -44
  300. package/dist/client/assets/ConnectionAccessLists-DRwO1v0V.js +0 -1
  301. package/dist/client/assets/HandlePage-B4qbFi40.js +0 -1
  302. package/dist/client/assets/HeartbeatPage-BnNbQLCW.js +0 -1
  303. package/dist/client/assets/Marketplace-DbdLWz0-.js +0 -36
  304. package/dist/client/assets/NamePage-fhxyWDDY.js +0 -1
  305. package/dist/client/assets/OperatorIdentityForm-Bls5Vo_u.js +0 -1
  306. package/dist/client/assets/PhotoPage-CNHcXbz4.js +0 -1
  307. package/dist/client/assets/PreviewRefusedNotice-Ds4IO32o.js +0 -1
  308. package/dist/client/assets/PromptSuggestionChips-BXxC799Q.js +0 -1
  309. package/dist/client/assets/RoomSurface-DgH3a_Fv.js +0 -1
  310. package/dist/client/assets/RunsOnPopover-CEkkjrGg.js +0 -1
  311. package/dist/client/assets/RuntimeConnectFlow-DXWGgvCW.js +0 -1
  312. package/dist/client/assets/RuntimeSetupDialog-D6L1QhMF.js +0 -1
  313. package/dist/client/assets/SettingsDialog-BOOqWKcj.js +0 -12
  314. package/dist/client/assets/SkillsPage-ntCEhUIM.js +0 -1
  315. package/dist/client/assets/TaskDialogWrapper-vBWAWwTY.js +0 -1
  316. package/dist/client/assets/TasksEmptyState-C_3UkAbA.js +0 -3
  317. package/dist/client/assets/TourHost-B69XAKpE.js +0 -1
  318. package/dist/client/assets/WidgetErrorCard-BlqaIsPK.js +0 -108
  319. package/dist/client/assets/WorkView-BekLkR4O.js +0 -51
  320. package/dist/client/assets/_shell-Du0F-5fK.js +0 -80
  321. package/dist/client/assets/_shell._home.activity-5rihXoYF.js +0 -1
  322. package/dist/client/assets/_shell._home.index-BsLNqt4f.js +0 -3
  323. package/dist/client/assets/_shell._home.tasks-Cxs5tLWA.js +0 -1
  324. package/dist/client/assets/_shell._home.workspaces-CEHDdfbP.js +0 -1
  325. package/dist/client/assets/_shell.connections-Bm0WmgXH.js +0 -1
  326. package/dist/client/assets/_shell.marketplace-CsQ60Mlc.js +0 -1
  327. package/dist/client/assets/_shell.marketplace_.sources-DNyShS1x.js +0 -1
  328. package/dist/client/assets/_shell.session-BN42bV3w.js +0 -1
  329. package/dist/client/assets/_shell.threads-HH4EvufJ.js +0 -1
  330. package/dist/client/assets/_shell.x._extensionId-3ZlJV1iu.js +0 -1
  331. package/dist/client/assets/_shell.x._extensionId_._-3ZlJV1iu.js +0 -1
  332. package/dist/client/assets/card-DUmTNXJJ.js +0 -1
  333. package/dist/client/assets/channel-B7zgJbnU.js +0 -1
  334. package/dist/client/assets/form-D93N5lrK.js +0 -1
  335. package/dist/client/assets/image-lightbox-vgPEvSCc.js +0 -1
  336. package/dist/client/assets/index-B446r3dL.js +0 -1
  337. package/dist/client/assets/index-BGo1YiUE.js +0 -1
  338. package/dist/client/assets/index-BO3yPJt-.js +0 -1
  339. package/dist/client/assets/index-DE6uOpn4.js +0 -1
  340. package/dist/client/assets/index-Dag1qeZI.js +0 -1
  341. package/dist/client/assets/index-Dm0Tav7v.js +0 -1
  342. package/dist/client/assets/index-Dry_agqN.css +0 -1
  343. package/dist/client/assets/index-OQuvRZTD.js +0 -1058
  344. package/dist/client/assets/index-eVrGefuq.js +0 -1
  345. package/dist/client/assets/mention-pill-BsOeTJ2f.js +0 -1
  346. package/dist/client/assets/path-input-C2KIXdON.js +0 -1
  347. package/dist/client/assets/primer-trigger-B2tjuHBx.js +0 -3
  348. package/dist/client/assets/registry-BzXBOE9h.js +0 -34
  349. package/dist/client/assets/registry-sfhDu9q2.js +0 -1
  350. package/dist/client/assets/scroll-area-FwZwM74Q.js +0 -1
  351. package/dist/client/assets/search-x-Q18Wm-C5.js +0 -6
  352. package/dist/client/assets/signed-in-DEOMBWVX.js +0 -1
  353. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-D8kHFWtL.js +0 -8
  354. package/dist/client/assets/use-full-activity-feed-CtQquOBW.js +0 -1
  355. package/dist/client/assets/use-is-below-desktop-CAGEAsCC.js +0 -1
  356. package/dist/client/assets/use-pending-read-D0y6i7G9.js +0 -1
  357. package/dist/client/assets/use-personality-commit-C3h8upDo.js +0 -1
  358. package/dist/client/assets/use-status-budget-Xn2sIeM1.js +0 -16
  359. package/dist/client/assets/use-update-config-L5NCTj3t.js +0 -1
@@ -0,0 +1,12 @@
1
+ import{O as Nn,r as m,p4 as $t,p5 as Sa,hl as kn,j as e,p6 as Aa,p7 as Ta,cY as tt,cZ as nt,p8 as Oa,c_ as Ea,p9 as Ra,d0 as at,d1 as it,pa as Da,pb as Ia,pc as Pa,pd as La,pe as _a,pf as $a,G as P,pg as Fa,aO as Se,Z as _e,_ as Te,a5 as F,a6 as Y,a7 as B,B as y,fg as rt,fh as ot,fj as xs,fk as hs,aJ as Q,ph as Ma,pi as za,e as se,bh as R,bi as D,hI as fe,b9 as we,x as bs,eP as lt,bj as _,bI as me,h1 as Me,pj as Ua,ll as Ka,X as ct,bJ as xe,bK as re,bL as oe,bM as le,bN as ce,bO as de,bQ as pe,a4 as Re,fA as qa,gQ as wn,pk as dt,lr as Ns,el as G,I as J,ee as te,ef as ne,eg as ae,eh as ie,ei as L,Y as ut,J as qe,$ as Cn,ff as ps,a8 as ge,pl as Ba,a2 as Z,pm as Sn,kv as mt,pn as Wa,po as Ha,a3 as Ve,fi as qs,pp as Ya,pq as Va,bR as Qa,ar as os,bD as Oe,C as Be,Q as Qe,T as Ge,f as Ga,V as Xe,l6 as Xa,mH as Ja,a9 as An,mV as Za,i7 as ei,eU as $,ec as je,e8 as ks,jZ as ws,e7 as Je,ea as Cs,l4 as si,pr as Tn,l5 as xt,me as ti,ps as ze,pt as ni,pu as ai,pv as ii,pw as ri,dB as $e,px as oi,ep as Ss,py as gs,c$ as On,eA as En,dL as Rn,pz as li,pA as ci,pB as di,pC as ui,pD as mi,pE as xi,pF as hi,pG as pi,pH as gi,j_ as fi,pI as ji,gr as Rs,aZ as Ee,dE as ht,gX as Ze,U as We,ed as yi,hp as As,hq as Fe,m8 as Dn,gR as vi,gY as bi,gV as In,bW as ue,hV as Ni,gU as ki,pJ as wi,aT as Ci,mB as Bs,pK as Ws,id as Si,ao as He,jQ as Le,pL as Ai,lm as Pn,ln as Hs,by as Ti,bz as Oi,pM as Ei,bA as Ri,bC as Di,pN as Ii,h2 as Pi,pO as Li,pP as pt,pQ as Ln,pR as ke,pS as _i,pT as $i,eb as _n,nQ as Fi,aa as $n,pU as Fn,eN as gt,ab as ft,ak as Mi,al as zi,c0 as Ui,gM as Ki,e6 as qi,pV as Bi,cV as Wi,g8 as Hi,g9 as Yi,ga as Vi,am as Qi,kF as Mn,kG as Gi,jE as Xi,pW as Ji,dS as Zi,gb as jt,h8 as er,dh as sr,di as tr,dj as nr,pX as ar,em as yt,iv as ir,jt as vt,pY as rr,pZ as or,p_ as Ie,p$ as ls,q0 as Ft,q1 as Mt,q2 as lr,q3 as cr,gc as dr,ct as zn,l as Un,y as ur,q4 as mr,q5 as xr,eO as hr,q6 as pr,io as gr,e1 as Kn,eM as fr,aK as jr,fy as yr,bg as vr,q7 as br,q8 as Nr,q9 as kr,qa as wr,qb as Cr,cw as Sr,l3 as Ar,ci as Tr,cj as Or,qc as Er,jk as Rr,qd as Dr,qe as Ir,g4 as Pr,n as Lr,bb as _r,ih as $r,en as Fr,mO as Mr,ig as zr,kh as Ur}from"./index-YUtEyz7O.js";import{a as Kr}from"./ProfilePanelContainer-DuFEpNJ3.js";import{u as ye}from"./use-update-config-Ce7sHmp2.js";import{u as qr,a as Br}from"./use-composer-prefs-_rlNL0D8.js";import{I as Ye}from"./trust-posture-CfEIPM4Z.js";import{u as qn,a as Wr,i as Hr}from"./use-notification-prefs-qcYeVmLQ.js";import{u as Bn}from"./use-bindings-DhOKnybh.js";import{T as Yr,a as Vr,A as Wn,B as fs,u as Qr,i as js,f as us,r as Gr,b as zt,w as Ds,c as bt,d as Ys,C as Hn,e as Xr,K as Jr,U as Zr,S as eo,g as so,h as to,j as no,W as Ut,k as ao,l as io,m as ro,P as oo,O as lo,n as co}from"./SeenDevices-Cix5nnGQ.js";import{M as Ts}from"./more-details-DF2dJXMV.js";import{u as Yn}from"./use-deep-link-scroll-BVkszEn2.js";import{Q as es}from"./query-error-state-BCX32dab.js";import{b as uo,C as mo,u as xo,a as ho,K as po}from"./KeyEntry-Dq6eKAbX.js";import{s as go,e as Nt}from"./access-copy-BAhTOOsG.js";import{c as Vn,W as Kt,a as Qn}from"./connection-copy--MA7AN04.js";import{C as fo,g as Gn,r as Xn,R as jo,u as yo}from"./ChatAppsOff-ByitL4Xt.js";import{a as vo,B as bo}from"./BindingDialog-D25PAed0.js";import{D as No,a as ko}from"./dead-letter-reasons-DtBHju9v.js";import{C as wo}from"./relay-trace-schemas-C-1Js81V.js";import{u as Jn,B as Co,R as qt}from"./ApplyToOverridesDialog-DRtcLrVY.js";import{P as So,a as Ao,D as To}from"./PermissionHistory-D_Imuq02.js";import{s as Zn}from"./settings-for-runtime-BoOa-ZFG.js";import{l as Oo}from"./list-runtime-types-7qV7HQ7K.js";import{I as Eo}from"./inline-code-BL-6EKVP.js";import{a as Ro,r as Vs,d as ea,b as Do,D as kt,u as Io,C as Po}from"./RuntimeConnectFlow-DsawxJN7.js";import{k as Lo,e as ms}from"./execution-config-BjLHHc9x.js";import{U as _o}from"./unverified-catalog-notice-BqIWxQuN.js";import{P as sa}from"./path-input-jrT0Ap4j.js";import{a as $o}from"./format-tokens-DymkROvy.js";import{C as Fo}from"./runtime-connect-Dn0T5YWv.js";import{C as Ce}from"./copy-button-ByA00JGh.js";import{U as Mo}from"./unplug-B3eDst8L.js";import{L as zo}from"./link-2-ZzmN9B9k.js";import{P as Uo,S as Ko}from"./progress-BTu_QWg8.js";import{C as qo,a as Bo}from"./cpu-DNvpMmNN.js";import"./ProfileFields-DD6X85w2.js";import"./profile-errors-vJU1kT3U.js";import"./use-mounted-ref-1T3JbkY1.js";import"./ProfileRolePicker-CT9eJ1J0.js";import"./use-promo-dismissals-C6bPU5Rm.js";import"./empty-state-BnuM8oop.js";import"./form--HjBAzX8.js";import"./useMutationState-Rlga1GBT.js";/**
2
+ * @license lucide-react v1.48.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const ta={name:"palette",size:24,node:[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]};ta.node;const Wo=Nn(ta);/**
7
+ * @license lucide-react v1.48.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const na={name:"settings-2",size:24,node:[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]};na.node;const Ho=Nn(na);function Yo({open:s,initialTab:t,defaultTab:n}){const[a,i]=m.useState(t??n),[r,o]=m.useState(s);return s!==r&&(o(s),s&&t&&i(t)),[a,i]}function Vo({storageKey:s,dialogOpen:t,activeInGroup:n,activeTab:a}){const[i,r]=m.useState(()=>$t(s,!1)),[o,l]=m.useState(t),c=t&&n?a:null,[d,u]=m.useState(null);let x=i;return t!==o&&(l(t),t&&(x=$t(s,!1))),c!==d&&(u(c),c!==null&&(x=!0)),x!==i&&r(x),[x,p=>{Sa(s,p),r(p)}]}function Qo({open:s,onOpenChange:t,title:n,description:a,headerSlot:i,defaultTab:r,initialTab:o,tabs:l,extensionSlot:c,maxWidth:d="max-w-2xl",minHeight:u="min-h-[280px]",maximized:x=!1,foldedGroup:h,testId:p}){const f=kn(c??"settings.tabs"),g=c?[...l,...f.map(Xo)]:l,v=[];for(const T of g)v.includes(T.group)||v.push(T.group);const N=h==null?void 0:h.group;N!==void 0&&v.includes(N)&&(v.splice(v.indexOf(N),1),v.push(N));const j=g.some(T=>T.group),S=o&&g.some(T=>T.id===o)?o:null;m.useEffect(()=>{},[o,S,r]);const[E,A]=Yo({open:s,initialTab:S,defaultTab:r}),O=N!==void 0&&g.some(T=>T.id===E&&T.group===N),[w,b]=Vo({storageKey:(h==null?void 0:h.storageKey)??"",dialogOpen:s,activeInGroup:O,activeTab:E}),k=m.useId(),ee=T=>T.map(K=>e.jsx(Fa,{value:K.id,icon:K.icon,children:K.label},K.id)),V=N===void 0?[]:g.filter(T=>T.group===N&&(w||T.id===E)),M=N!==void 0&&g.some(T=>T.group===N),z=m.useRef(!1);m.useEffect(()=>{var T,K,I;!w||!z.current||(z.current=!1,(I=(K=(T=document.getElementById(k))==null?void 0:T.querySelector("[data-value]"))==null?void 0:K.scrollIntoView)==null||I.call(K,{block:"nearest"}))},[w,k]);const W=M?e.jsxs(e.Fragment,{children:[e.jsx(Aa,{expanded:w,onExpandedChange:T=>{z.current=T,b(T)},controls:V.length>0?k:void 0,children:N}),V.length>0&&e.jsx(Ta,{id:k,label:N,children:ee(V)})]}):void 0;return e.jsx(tt,{open:s,onOpenChange:t,children:e.jsx(nt,{"data-testid":p,className:P("max-h-[85vh] gap-0 p-0",d,x&&"md:h-[92svh] md:max-h-[92svh] md:w-[95vw] md:max-w-[90rem]"),children:e.jsxs(Oa,{value:E,onValueChange:T=>A(T),children:[e.jsx(Ea,{}),e.jsxs(Ra,{children:[e.jsx(at,{className:"text-sm font-medium",children:n}),e.jsx(it,{className:a?"text-muted-foreground text-xs":"sr-only",children:a??"Dialog"}),i]}),e.jsxs(Da,{children:[e.jsx(Ia,{footer:W,children:j?v.filter(T=>T===void 0||T!==N).map(T=>e.jsxs(m.Fragment,{children:[T&&e.jsx(Pa,{children:T}),ee(g.filter(K=>K.group===T))]},T??"__ungrouped")):ee(g)}),e.jsx(La,{className:P(u,"p-4"),children:g.map(T=>{const K=T.component;return e.jsx(_a,{value:T.id,children:e.jsxs("div",{className:"max-w-3xl space-y-4",children:[e.jsx($a,{actions:T.actions,description:T.description,children:T.label}),e.jsx(m.Suspense,{fallback:e.jsx(Go,{}),children:e.jsx(K,{})})]})},T.id)})})]})]})})})}function Go(){return e.jsx("div",{className:"text-muted-foreground py-8 text-center text-sm",children:"Loading…"})}function Xo(s){return{id:s.id,label:s.label,icon:s.icon,component:s.component,group:s.group??"Add-ons"}}function Jo(){const s=typeof window<"u"?window.electronAPI:void 0,t=s==null?void 0:s.chooseCertificateFile;return typeof t!="function"?null:async()=>{const n=await t();if(!n.ok)throw new Error(n.message);return n.path}}function Zo(){const{data:s}=Se(),t=ye(),n=s==null?void 0:s.welcomeBack,a=m.useCallback(r=>{t.mutate({welcomeBack:{enabled:r}})},[t]),i=m.useCallback(r=>{t.mutate({welcomeBack:{offersEnabled:r}})},[t]);return{enabled:(n==null?void 0:n.enabled)??!1,absenceThresholdMinutes:(n==null?void 0:n.absenceThresholdMinutes)??0,maxPosts:(n==null?void 0:n.maxPosts)??0,offersEnabled:(n==null?void 0:n.offersEnabled)??!1,setEnabled:a,setOffersEnabled:i,isAvailable:n!==void 0,isPending:t.isPending}}function el({className:s}){const[t,n]=m.useState(!1);return e.jsxs("div",{className:P("w-full",s),children:[e.jsx(Yr,{open:t,onToggle:()=>n(a=>!a)}),e.jsx(_e,{initial:!1,children:t&&e.jsx(Te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:[0,0,.2,1]},className:"overflow-hidden",children:e.jsx("div",{className:"pt-2",children:e.jsx(Vr,{})})},"payload")})]})}const aa=["claude-signin-policy"];function ia(){const s=F();return Y({queryKey:aa,queryFn:()=>s.getClaudeSigninPolicy(),retry:!1})}function Ke({label:s,title:t,description:n,change:a,children:i,disabled:r=!1}){const[o,l]=m.useState(!1),[c,d]=m.useState(!1),[u,x]=m.useState(null),h=F(),p=B();async function f(){d(!0),x(null);try{await h.changeClaudeSigninPolicy(a),await Promise.all([p.invalidateQueries({queryKey:aa}),p.invalidateQueries({queryKey:Q.current()}),p.invalidateQueries({queryKey:["accounts"]})]),l(!1)}catch{x("Couldn’t change this sign-in. Try again.")}finally{d(!1)}}return e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"outline",size:"sm",className:"pointer-coarse:min-h-11",disabled:r,onClick:()=>l(!0),children:s}),e.jsx(rt,{open:o,onOpenChange:g=>{l(g),g||x(null)},children:e.jsxs(ot,{children:[e.jsx(xs,{children:t}),e.jsx(hs,{children:n}),i,u&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:u}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:()=>l(!1),disabled:c,children:"Cancel"}),e.jsx(y,{onClick:()=>void f(),disabled:c,children:c?"Saving…":s})]})]})})]})}function sl(s){const{identity:t,signInState:n}=s;switch(t==null?void 0:t.state){case"never-use":case"blocked":return{kind:"blocked"};case"changed":return{kind:"changed",email:t.email,previousEmail:t.previousEmail};case"unconfirmed":return{kind:"unconfirmed",email:t.email};default:return n==="signed-out"?{kind:"signed-out"}:{kind:"healthy"}}}const tl="pointer-coarse:min-h-11";function nl({accountId:s,accountRoot:t,name:n,signInState:a}){var l;const{data:i}=ia(),r=s?(l=i==null?void 0:i.accounts.find(c=>c.accountId===s))==null?void 0:l.identity:void 0,o=sl({identity:r,signInState:a});return e.jsx(al,{state:o,accountId:s,accountRoot:t,name:n})}function al({state:s,accountId:t,accountRoot:n,name:a}){switch(s.kind){case"healthy":return null;case"blocked":return e.jsx("p",{className:"text-status-warning-fg mt-1 text-xs",role:"status",children:"Not used · on your Never use list"});case"signed-out":return e.jsx(Wn,{accountRoot:n,name:a,state:"signed-out"});case"changed":return e.jsxs("div",{className:"mt-1 space-y-2 text-xs",children:[e.jsxs("p",{className:"text-status-warning-fg",role:"status",children:["Now signed in as ",s.email,", not ",s.previousEmail,"."]}),e.jsx("p",{className:"text-muted-foreground",children:"DorkOS won’t pick it on its own until you keep it."}),t&&e.jsx(Bt,{accountId:t,name:a,email:s.email,label:"Keep this sign-in"})]});case"unconfirmed":return e.jsxs("div",{className:"mt-1 space-y-2 text-xs",children:[e.jsxs("p",{className:"text-status-warning-fg",role:"status",children:["New sign-in",s.email?` ${s.email}`:"",". Not confirmed yet."]}),e.jsx("p",{className:"text-muted-foreground",children:"DorkOS won’t pick it on its own until you do."}),t?e.jsx(Bt,{accountId:t,name:a,email:s.email,label:"Use this account"}):e.jsx(il,{accountRoot:n,name:a})]})}}function Bt({accountId:s,name:t,email:n,label:a}){return e.jsx(Ke,{label:a,title:n?`Use ${n} for ${t}?`:`Use this sign-in for ${t}?`,description:"DorkOS can then pick this account on its own.",change:{action:"accept",accountId:s}})}function il({accountId:s,accountRoot:t,name:n}){const a=Ro("claude-code",s?{accountId:s}:{accountRoot:t});return e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",className:tl,disabled:a.isPending,onClick:a.login,"aria-label":`Sign in to ${n}`,children:a.isPending?"Signing in…":"Sign in again"}),a.isError&&e.jsxs("p",{role:"alert",className:"text-destructive text-xs",children:["Couldn’t sign in to ",n,". Try again."]})]})}function ra(s){return{connectionId:s.connectionId,name:`${go(s.toolkit)} (${s.label})`,agentCount:s.agentCount,everyAgent:s.everyAgent!==null,usable:s.readiness.state==="ready"}}function wt(s){return s.filter(t=>t.readiness.state!=="gone"&&t.mode==="managed").map(ra)}function oa(s){return{stopping:s.filter(t=>t.usable),idle:s.filter(t=>!t.usable)}}function ys(s){return`${s} ${s===1?"app":"apps"}`}function Wt({app:s}){return e.jsxs("li",{children:[s.name,s.everyAgent?e.jsx("span",{className:"text-muted-foreground",children:" · used by every agent"}):s.agentCount>0&&e.jsxs("span",{className:"text-muted-foreground",children:[" ","· used by ",s.agentCount," ",s.agentCount===1?"agent":"agents"]})]})}function Qs({stopping:s,idle:t,stopLine:n}){if(s.length===0&&t.length===0)return null;const a="text-foreground max-h-40 list-disc space-y-1 overflow-y-auto pl-5 text-sm";return e.jsxs("div",{className:"space-y-3 text-sm","data-testid":"connection-impact-list",children:[s.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-muted-foreground",children:n}),e.jsx("ul",{className:a,children:s.map(i=>e.jsx(Wt,{app:i},i.connectionId))})]}),t.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-muted-foreground",children:[t.length===1?"This app":`These ${t.length} apps`," can’t be used now either way:"]}),e.jsx("ul",{className:a,children:t.map(i=>e.jsx(Wt,{app:i},i.connectionId))})]})]})}function rl({signedOut:s,children:t}){var x;const{view:n,start:a,unlink:i,cancel:r,starting:o,unlinking:l,startError:c,unlinkError:d}=Ma();ol(n,a);const u=((x=za().data)==null?void 0:x.linked)===!0;return n.kind==="loading"?e.jsx(se,{className:"h-24 w-full"}):n.kind==="linked"?e.jsxs("div",{className:"space-y-4",children:[e.jsx(dl,{view:n,start:a,starting:o,startError:c,dismiss:r}),t,e.jsx(ul,{unlink:i,unlinking:l,unlinkError:d})]}):e.jsxs("div",{className:"space-y-4",children:[!u&&s,e.jsx(R,{children:e.jsx(D,{children:e.jsx(ll,{view:n,start:a,cancel:r,starting:o,startError:c,relinking:u})})})]})}function ol(s,t){const{section:n,setSection:a}=fe(),i=m.useRef(!1),r=n===Ka;m.useEffect(()=>{if(!r){i.current=!1;return}i.current||s.kind==="loading"||(i.current=!0,a(null),s.kind!=="pending"&&t())},[r,s.kind,t,a])}function ll({view:s,start:t,cancel:n,starting:a,startError:i,relinking:r}){switch(s.kind){case"idle":return e.jsx(cl,{start:t,starting:a,startError:i});case"pending":return e.jsx(Ua,{view:s,cancel:n,relinking:r},s.userCode);case"expired":return e.jsx(Is,{title:"Your code expired",description:"It ran out before you approved it.",actionLabel:"Get a new code",onAction:t,pending:a});case"denied":return e.jsx(Is,{title:"Link request denied",description:"It was turned down on dorkos.ai.",actionLabel:"Link this computer",onAction:t,pending:a});case"revoked":return e.jsx(Is,{title:"This computer was unlinked",description:"DorkOS removed its access to your account.",actionLabel:"Link again",onAction:t,pending:a})}}function cl({start:s,starting:t,startError:n}){var N;const a=m.useId(),{data:i}=Se(),r=ye(),o=((N=i==null?void 0:i.telemetry)==null?void 0:N.linkAnalyticsToAccount)??!1,l=qa({value:o,generation:0});l.read().value!==o&&l.write({value:o,generation:l.read().generation+1});const c=l.read().generation,[d,u]=m.useState(null),x=d!==null&&d.generation===c?d.value:o,h=j=>u({generation:c,value:j}),[p,f]=m.useState(null),g=m.useCallback(async()=>{f(null);try{await r.mutateAsync({telemetry:{linkAnalyticsToAccount:x}})}catch{f("Couldn’t save your choice. Try again.");return}await s()},[r,x,s]),v=t||r.isPending;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(wn,{id:a,checked:x,onCheckedChange:j=>h(j===!0),disabled:v,className:"mt-0.5"}),e.jsxs("label",{htmlFor:a,className:"space-y-1 text-sm leading-snug",children:[e.jsx("span",{className:"font-medium",children:"Link usage counts to your account"}),e.jsx("span",{className:"text-muted-foreground block text-xs",children:"See this install’s anonymous usage counts when signed in."}),e.jsx("span",{className:"text-muted-foreground block text-xs",children:"Applies when you link. To change it later, link again."})]})]}),e.jsxs(y,{onClick:()=>void g(),disabled:v,children:[v?e.jsx(bs,{className:"mr-1.5"}):e.jsx(zo,{className:"mr-1.5 size-(--size-icon-sm)"}),v?"Starting…":"Link this computer"]}),(p??n)&&e.jsx("p",{className:"text-destructive text-sm",role:"alert",children:p??n})]})}function dl({view:s,start:t,starting:n,startError:a,dismiss:i}){return e.jsxs("div",{className:"space-y-4",children:[s.relinkOutcome&&e.jsx(xl,{outcome:s.relinkOutcome,dismiss:i}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Signed in"}),s.accountLabel?e.jsx("p",{className:"text-foreground truncate text-sm",children:s.accountLabel}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Syncing account…"}),s.lastHeartbeatAt&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Last synced ",we(s.lastHeartbeatAt).toLowerCase()]})]}),e.jsxs(y,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void t(),disabled:n,children:[n?e.jsx(bs,{className:"mr-1.5"}):e.jsx(lt,{className:"mr-1.5 size-3.5"}),"Link again"]})]}),a&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:a})]})}function ul({unlink:s,unlinking:t,unlinkError:n}){return e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Unlink this computer",description:"Stops using your DorkOS account. You can link again anytime.",children:e.jsxs(me,{children:[e.jsx(Me,{asChild:!0,children:e.jsxs(y,{variant:"outline",size:"sm",disabled:t,"aria-label":"Unlink this computer",children:[e.jsx(Mo,{className:P("mr-1.5 size-3.5",t&&"animate-pulse")}),t?"Unlinking…":"Unlink"]})}),e.jsx(hl,{unlink:s})]})}),n&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:n})]})})}const ml={denied:"The new link was turned down on dorkos.ai.",expired:"The new link’s code expired.",failed:"The new link couldn’t finish."};function xl({outcome:s,dismiss:t}){return e.jsxs("div",{role:"status",className:"bg-muted/40 flex items-start gap-2 rounded-lg p-3 text-sm",children:[e.jsxs("p",{className:"min-w-0 flex-1",children:[ml[s]," This computer is still linked."]}),e.jsx(y,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss",className:"-my-1 shrink-0",onClick:()=>void t(),children:e.jsx(ct,{className:"size-3.5"})})]})}function hl({unlink:s}){const t=Nt(),n=t.data?wt(t.data.connections):[],{stopping:a,idle:i}=oa(n);return e.jsxs(xe,{children:[e.jsxs(re,{children:[e.jsx(oe,{children:"Unlink this computer?"}),e.jsx(le,{children:"It stops using your DorkOS account. You can link again anytime."})]}),t.isPending?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Checking which apps use this account…"}):t.isError?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t check which apps use this account. Any that do will stop working."}):e.jsx(Qs,{stopping:a,idle:i,stopLine:`${a.length===1?"This app":`These ${a.length} apps`} will stop working for every agent:`}),e.jsxs(ce,{children:[e.jsx(de,{children:"Cancel"}),e.jsx(pe,{onClick:()=>void s(),children:a.length>0?`Unlink and stop ${ys(a.length)}`:"Unlink"})]})]})}function Is({title:s,description:t,actionLabel:n,onAction:a,pending:i}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Re,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:s}),e.jsx("p",{className:"text-muted-foreground text-sm",children:t})]})]}),e.jsxs(y,{onClick:()=>void a(),disabled:i,children:[i?e.jsx(bs,{className:"mr-1.5"}):e.jsx(lt,{className:"mr-1.5 size-(--size-icon-sm)"}),n]})]})}const Ct=["auth","api-keys"];function pl(){const s=dt();return Y({queryKey:Ct,queryFn:async()=>{const{data:t,error:n}=await s.apiKey.list();if(n||!t)throw new Error("Couldn’t load API keys. Try again.");return t.apiKeys},staleTime:3e4})}function gl(){const s=dt(),t=B(),[n,a]=m.useState(!1),[i,r]=m.useState(null);return{run:m.useCallback(async(l,c)=>{a(!0),r(null);const{data:d,error:u}=await s.apiKey.create({name:l.trim()||void 0,expiresIn:c??null});return a(!1),u||!d?(r(u??{message:"Couldn’t create the key. Try again.",status:0}),null):(await t.invalidateQueries({queryKey:Ct}),d)},[s,t]),isPending:n,error:i,reset:()=>r(null)}}function fl(){const s=dt(),t=B(),[n,a]=m.useState(null),[i,r]=m.useState(null);return{run:m.useCallback(async l=>{a(l),r(null);const{error:c}=await s.apiKey.delete({keyId:l});return a(null),c?(r(c),!1):(await t.invalidateQueries({queryKey:Ct}),!0)},[s,t]),pendingId:n,error:i,reset:()=>r(null)}}const Ht=[{label:"Never",value:"never",seconds:null},{label:"7 days",value:"7d",seconds:3600*24*7},{label:"30 days",value:"30d",seconds:3600*24*30},{label:"90 days",value:"90d",seconds:3600*24*90}];function jl({loginRequired:s=!0}={}){const t=m.useId(),{data:n,isError:a,isFetching:i,isLoading:r,refetch:o}=pl(),l=gl(),c=fl(),[d,u]=m.useState(""),[x,h]=m.useState("never"),[p,f]=m.useState(null);async function g(){var j;const v=((j=Ht.find(S=>S.value===x))==null?void 0:j.seconds)??null,N=await l.run(d,v);N&&(f(N),u(""),h("never"))}return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"text-muted-foreground size-4"}),e.jsx("p",{className:"text-sm font-medium",children:"API keys"})]}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Keys for MCP clients, scripts and agents. Send one as a"," ",e.jsx("code",{className:"font-mono",children:"Bearer"})," token."]}),!s&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Keys still work with login off. Revoke any you don’t need."})]}),p?e.jsx(yl,{created:p,onDone:()=>f(null)}):e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[e.jsxs("div",{className:"min-w-40 flex-1 space-y-1.5",children:[e.jsx(G,{htmlFor:t,children:"Name"}),e.jsx(J,{id:t,placeholder:"e.g. laptop-cli",value:d,onChange:v=>u(v.target.value)})]}),e.jsxs("div",{className:"w-32 space-y-1.5",children:[e.jsx(G,{children:"Expires"}),e.jsxs(te,{value:x,onValueChange:h,children:[e.jsx(ne,{children:e.jsx(ae,{})}),e.jsx(ie,{children:Ht.map(v=>e.jsx(L,{value:v.value,children:v.label},v.value))})]})]}),e.jsx(y,{onClick:g,disabled:l.isPending,children:l.isPending?"Creating…":"Create key"})]}),l.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:l.error.message}),e.jsx("div",{className:"space-y-1.5",children:r?e.jsx(se,{className:"h-9 w-full"}):a?e.jsx(es,{title:"Couldn’t load API keys",description:"No keys were changed. Try again.",onRetry:()=>void o(),isRetrying:i,className:"py-6"}):n&&n.length>0?n.map(v=>e.jsx(vl,{apiKey:v,revoking:c.pendingId===v.id,onRevoke:()=>c.run(v.id)},v.id)):e.jsx("p",{className:"text-muted-foreground text-xs",children:"No API keys yet."})}),c.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:c.error.message})]})}function yl({created:s,onDone:t}){const{copied:n,failed:a,copy:i}=ut();return e.jsxs("div",{className:"border-primary/40 bg-primary/5 space-y-3 rounded-lg border p-3",children:[e.jsx("p",{className:"text-sm font-medium",children:"Copy your key now. It won’t be shown again."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:s.key}),e.jsx("button",{className:"text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-1.5 transition-colors",onClick:()=>void i(s.key),"aria-label":a?"Couldn’t copy API key. Try again":"Copy API key",children:n?e.jsx(qe,{className:"text-status-success size-4"}):a?e.jsx(ct,{className:"text-destructive size-4"}):e.jsx(Cn,{className:"size-4"})})]}),e.jsx(y,{variant:"outline",size:"sm",onClick:t,children:"Done"})]})}function vl({apiKey:s,revoking:t,onRevoke:n}){const a=s.name||"Unnamed key",i=s.start?`${s.start}…`:s.prefix||"";return e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:a}),e.jsxs("p",{className:"text-muted-foreground font-mono text-xs",children:[i,s.expiresAt?` · expires ${new Date(s.expiresAt).toLocaleDateString()}`:" · no expiry"]})]}),e.jsxs(me,{children:[e.jsx(Me,{asChild:!0,children:e.jsx(y,{variant:"ghost",size:"sm",disabled:t,"aria-label":`Revoke ${a}`,children:e.jsx(ps,{className:"size-3.5"})})}),e.jsxs(xe,{children:[e.jsxs(re,{children:[e.jsxs(oe,{children:["Revoke “",a,"”?"]}),e.jsx(le,{children:"Anything using it loses access right away. This can’t be undone."})]}),e.jsxs(ce,{children:[e.jsx(de,{children:"Cancel"}),e.jsx(pe,{onClick:n,children:"Revoke key"})]})]})]})]})}const Yt=["auth","signed-in-devices"];function bl(s){if((s==null?void 0:s.status)===404)return"That list was out of date. It’s up to date now.";const t=s instanceof Error?s.message:"";return t&&!/^HTTP \d+$/.test(t)?t:"Couldn’t sign that out. Try again."}function Nl(s=!0){const t=F(),n=B(),[a,i]=m.useState(null),[r,o]=m.useState(null),l=Y({queryKey:Yt,queryFn:()=>t.listSignedInDevices(),enabled:s,retry:!1,staleTime:1e4}),c=ge({mutationFn:d=>d(),onMutate:()=>o(null),onError:d=>o(bl(d)),onSettled:()=>{i(null),n.invalidateQueries({queryKey:Yt})}});return{data:l.data,isLoading:l.isLoading,isError:l.isError,isFetching:l.isFetching,refetch:()=>void l.refetch(),pendingId:a,signingOutOthers:c.isPending&&a===null,error:r,signOutDevice:d=>{i(d),c.mutate(()=>t.signOutDevice(d))},signOutEverywhereElse:()=>c.mutate(()=>t.signOutEverywhereElse())}}const kl={local:null,wifi:"Wi-Fi",tunnel:"Remote access",managed:"Remote access",network:"Another network",hub:"DorkOS in the cloud"};function wl(){var i,r;const s=Nl(),t=((i=s.data)==null?void 0:i.sessions)??[],n=((r=s.data)==null?void 0:r.canSignOutOthers)??!1,a=t.some(o=>!o.current);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ba,{className:"text-muted-foreground size-4"}),e.jsx("p",{className:"text-sm font-medium",children:"Signed-in devices"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Signing a device out closes everything it had open."})]}),e.jsx("div",{className:"space-y-1.5",children:s.isLoading?e.jsx(se,{className:"h-12 w-full"}):s.isError?e.jsx(es,{title:"Couldn’t load signed-in devices",description:"Nothing was signed out. Try again.",onRetry:s.refetch,isRetrying:s.isFetching,className:"py-6"}):t.length>0?t.map(o=>e.jsx(Cl,{device:o,canSignOut:!o.current&&n,signingOut:s.pendingId===o.id,onSignOut:()=>s.signOutDevice(o.id)},o.id)):e.jsx("p",{className:"text-muted-foreground text-xs",children:"No devices are signed in."})}),a&&!n&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Sign out other devices on the computer DorkOS runs on."}),a&&n&&e.jsxs(me,{children:[e.jsx(Me,{asChild:!0,children:e.jsx(y,{variant:"outline",size:"sm",disabled:s.signingOutOthers,children:s.signingOutOthers?"Signing out…":"Sign out everywhere else"})}),e.jsxs(xe,{children:[e.jsxs(re,{children:[e.jsx(oe,{children:"Sign out everywhere else?"}),e.jsx(le,{children:"Every other device must sign in again. This one stays signed in."})]}),e.jsxs(ce,{children:[e.jsx(de,{children:"Cancel"}),e.jsx(pe,{onClick:s.signOutEverywhereElse,children:"Sign out everywhere else"})]})]})]}),s.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:s.error})]})}function Cl({device:s,canSignOut:t,signingOut:n,onSignOut:a}){const i=kl[s.route],r=`Last active ${Sl(we(s.lastSeenAt))}`;return e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:s.name}),s.current&&e.jsx(Z,{variant:"secondary",children:"This device"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:i?`${i} · ${r}`:r})]}),t&&e.jsxs(y,{variant:"ghost",size:"sm",onClick:a,disabled:n,"aria-label":`Sign out ${s.name}`,children:[e.jsx(Sn,{className:"mr-1.5 size-3.5"}),n?"Signing out…":"Sign out"]})]})}function Sl(s){return s.replace(/^(Just now|Yesterday)/,t=>t.toLowerCase())}function Al(){var p,f;const s=mt(),{data:t,refetch:n}=Se(),a=ye(),i=Wa(),r=Ha(),o=((p=t==null?void 0:t.auth)==null?void 0:p.enabled)??!1,l=((f=t==null?void 0:t.auth)==null?void 0:f.ownerEmail)??null,[c,d]=m.useState(null);function u(g){g?d(l?{kind:"sign-in",email:l}:{kind:"create"}):a.mutate({auth:{enabled:!1}})}async function x(){await a.mutateAsync({auth:{enabled:!0}}),d(null)}async function h(g){var j;const{data:v}=await n(),N=((j=v==null?void 0:v.auth)==null?void 0:j.ownerEmail)??g;N&&d({kind:"sign-in",email:N})}return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"space-y-1",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:s?"You sign in here with your DorkOS account.":"Other devices always need your password. This computer can ask for it too."})}),e.jsx(R,{children:e.jsxs(D,{children:[!s&&e.jsx(_,{label:"Ask for a password on this computer too",description:o?"This computer asks for your password before DorkOS opens.":"This computer opens DorkOS without a password.",children:e.jsx(Ve,{checked:o,onCheckedChange:u,"aria-label":"Ask for a password on this computer too"})}),i&&e.jsx(_,{label:"Signed in",description:(i==null?void 0:i.email)??"Owner account",children:e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>r.run(),disabled:r.isPending,children:[e.jsx(Sn,{className:"mr-1.5 size-3.5"}),r.isPending?"Signing out…":"Sign out"]})})]})}),(i||l)&&e.jsx(R,{children:e.jsx(D,{children:e.jsx(wl,{})})}),(o||i)&&e.jsx(R,{children:e.jsx(D,{children:e.jsx(jl,{loginRequired:o})})}),e.jsx(rt,{open:c!==null,onOpenChange:g=>!g&&d(null),children:e.jsx(ot,{children:(c==null?void 0:c.kind)==="sign-in"?e.jsxs(e.Fragment,{children:[e.jsxs(qs,{children:[e.jsx(xs,{children:"Ask for a password here too"}),e.jsx(hs,{children:"This turns on once your password checks out."})]}),e.jsx(Ya,{ownerEmail:c.email,onVerified:x,onCancel:()=>d(null)})]}):e.jsxs(e.Fragment,{children:[e.jsxs(qs,{children:[e.jsx(xs,{children:"Create an owner account"}),e.jsx(hs,{children:"This becomes your sign-in on every device."})]}),e.jsx(Va,{submitLabel:"Create account & ask here too",onCreated:x,onOwnerExists:h,onCancel:()=>d(null)})]})})})]})}function Tl(s){const t=F();return Y({queryKey:["relay","trace",s],queryFn:()=>t.getRelayTrace(s),enabled:!!s,staleTime:3e4})}function St(){const s=F();return Y({queryKey:["relay","metrics"],queryFn:()=>s.getRelayDeliveryMetrics(),staleTime:3e4,refetchInterval:3e4})}const Vt=["relay","conversations"],Ol=500,El=15e3;function Rl(s=!0){const t=F(),n=Qa({coalesceMs:Ol}),a=()=>{s&&n([{queryKey:[...Vt]}])};return os("relay_message",a),os("relay_signal",a),os("relay_flow",a),os("relay_dead_letter",a),Y({queryKey:[...Vt],queryFn:()=>t.listRelayConversations(),enabled:s,refetchInterval:El})}function Dl(s,t){var i,r;const n=new Set(t.map(o=>o.providerInstanceId)),a={dorkosAccount:wt(s),byKeyInstance:{}};for(const o of s)o.readiness.state==="gone"||o.mode==="managed"||n.has(o.providerInstanceId)&&((i=a.byKeyInstance)[r=o.providerInstanceId]??(i[r]=[])).push(ra(o));return a}function la({testId:s,name:t,detail:n,status:a,usedForNewApps:i=!1,actions:r,children:o}){return e.jsxs("li",{"data-testid":s,className:"space-y-3 px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[e.jsxs("div",{className:"min-w-0 flex-1 basis-48",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 text-sm font-medium",children:[t,i&&e.jsx(Z,{size:"xs",variant:"secondary","data-testid":"used-for-new-apps",children:"Used for new apps"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:n})]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:P("size-2 rounded-full",Oe[a.tone]),"aria-hidden":!0}),a.label]}),r&&e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r})]}),o]})}function Il(s){return s==="user"?"using your account key":s==="project"?"using your project key":null}function Pl(s,t){return s.registered&&!t?{tone:"warning",label:"Can’t run actions"}:s.registered?{tone:"success",label:"Working"}:s.configured?{tone:"error",label:"Not working"}:{tone:"warning",label:"Key removed"}}function Ll(s){return s==="composio"?"Composio project":s==="nango"?"Nango environment":`${Vn(s)} account`}function _l({status:s,apps:t,usedForNewApps:n=!1,way:a}){const i=(a==null?void 0:a.canRunActions)!==!1,[r,o]=m.useState(!1),[l,c]=m.useState(null),d=uo(),u=Vn(s.type),x=s.configured?Il(s.keyKind):null,h=[`${ys(t.length)} connected`,x].filter(Boolean).join(" · "),{stopping:p,idle:f}=oa(t),g=()=>{t.length===0||!s.configured?o(!0):c("change")};return e.jsxs(la,{testId:`connection-way-${s.type}`,name:Qn(s.type),detail:h,status:Pl(s,i),usedForNewApps:n,actions:e.jsxs(e.Fragment,{children:[e.jsx(y,{size:"sm",variant:"outline",onClick:g,disabled:r,children:s.configured?"Change key":"Add key again"}),s.configured&&e.jsx(y,{size:"sm",variant:"ghost",className:"text-destructive",disabled:d.isPending,onClick:()=>c("remove"),children:d.isPending?"Removing…":"Remove…"})]}),children:[s.error&&e.jsx("p",{role:"alert",className:"text-destructive border-destructive/30 bg-destructive/5 rounded-md border px-3 py-2 text-xs leading-relaxed",children:s.error}),s.registered&&!i&&e.jsx("p",{className:"text-muted-foreground text-xs",children:a!=null&&a.keyCanFix?Kt.accountKeyCannotRunActions:Kt.cannotRunActions}),!s.configured&&t.length>0&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"These apps stopped when the key was removed. Add it again to restore them."}),r&&e.jsx(mo,{type:s.type,submitLabel:"Save key",onSaved:()=>o(!1),onCancel:()=>o(!1)}),e.jsx(me,{open:l!==null,onOpenChange:v=>{v||c(null)},children:e.jsx(xe,{children:l==="change"?e.jsxs(e.Fragment,{children:[e.jsxs(re,{children:[e.jsxs(oe,{children:["Change your ",u," key?"]}),e.jsx(le,{children:"A new key pauses these apps until you review their access."})]}),e.jsx(Qs,{stopping:p,idle:f,stopLine:p.length===1?"This app pauses until you review it on the Connections page:":`These ${p.length} apps pause until you review them on the Connections page:`}),e.jsxs("div",{className:"text-muted-foreground space-y-1 text-sm",children:[e.jsx("p",{children:"Nothing changes until you save the new key."}),e.jsx("p",{children:"A key that doesn’t work stops every app until you fix it."}),e.jsxs("p",{children:["A key from a different ",Ll(s.type)," can’t reach them at all."]})]}),e.jsxs(ce,{children:[e.jsx(de,{children:"Keep this key"}),e.jsx(pe,{onClick:()=>{c(null),o(!0)},children:"Continue to a new key"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(re,{children:[e.jsxs(oe,{children:["Remove your ",u," key?"]}),e.jsx(le,{children:t.length===0?"No apps use this key right now.":"Your sign-ins are kept. Add the same key again to restore these apps."})]}),e.jsx(Qs,{stopping:p,idle:f,stopLine:`${p.length===1?"This app":`These ${p.length} apps`} will stop working for every agent:`}),e.jsxs(ce,{children:[e.jsx(de,{children:"Keep key"}),e.jsx(pe,{onClick:()=>d.mutate({provider:s.type}),variant:"destructive",children:p.length>0?`Remove key and stop ${ys(p.length)}`:"Remove key"})]})]})})})]})}function $l({onManageAccount:s,onOpenConnectionsPage:t}){var E,A,O,w;const n=F(),a=Y({queryKey:Xa,queryFn:()=>n.getCloudStatus(),staleTime:3e4}),i=xo(),r=ho(),o=Nt();if(i.isPending||o.isPending)return e.jsxs("div",{className:"space-y-2","aria-label":"Loading how DorkOS reaches your apps",children:[e.jsx(se,{className:"h-16 rounded-lg"}),e.jsx(se,{className:"h-16 rounded-lg"})]});if(i.isError||o.isError)return e.jsx(es,{title:"Couldn’t check how DorkOS reaches your apps",description:"Try again. Nothing was changed.",onRetry:()=>{i.isError&&i.refetch(),o.isError&&o.refetch()},isRetrying:i.isFetching||o.isFetching});const l=i.data,c=Dl(o.data.connections,l),d=((E=a.data)==null?void 0:E.linked)===!0,u=d||a.isError||c.dorkosAccount.length>0,x=l.filter(b=>{var k;return b.configured||(((k=c.byKeyInstance[b.providerInstanceId])==null?void 0:k.length)??0)>0}),h=l.filter(b=>!x.includes(b)),p=a.isSuccess&&!u,f=!u&&x.length===0;if(f&&a.isPending)return e.jsx(se,{className:"h-16 rounded-lg","aria-label":"Checking your DorkOS account"});const g=((A=r.data)==null?void 0:A.newApps.status)==="ready"?r.data.newApps.way:null,v=((O=r.data)==null?void 0:O.ways)??[],N=((w=v.find(b=>b.kind==="dorkos_account"))==null?void 0:w.status)!=="unavailable",j=(u?1:0)+x.length>1,S=e.jsx(zl,{keys:h,offerAccount:p,onManageAccount:s});return f?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-muted/40 space-y-3 rounded-lg p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Set up with your first app"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Connect an app and DorkOS asks how to reach it. You answer once."})]}),e.jsx(y,{size:"sm",variant:"outline",onClick:t,children:"Open the Connections page"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Or set one up here now:"}),S]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("ul",{className:"divide-border divide-y rounded-lg border",children:[u&&e.jsx(Fl,{linked:d,reachesApps:N,checkFailed:a.isError,retrying:a.isFetching,onRetry:()=>void a.refetch(),apps:c.dorkosAccount,usedForNewApps:j&&(g==null?void 0:g.kind)==="dorkos_account",onManageAccount:s}),x.map(b=>e.jsx(_l,{status:b,apps:c.byKeyInstance[b.providerInstanceId]??[],usedForNewApps:j&&(g==null?void 0:g.kind)==="own_key"&&g.type===b.type,way:v.find(k=>k.kind==="own_key"&&k.type===b.type)},b.providerInstanceId))]}),(h.length>0||p)&&e.jsx(Ml,{label:"Add another way",children:S})]})}function Fl({linked:s,reachesApps:t,checkFailed:n,retrying:a,onRetry:i,apps:r,usedForNewApps:o,onManageAccount:l}){const c=s?t?{tone:"success",label:"Working"}:{tone:"warning",label:"Can’t reach apps"}:n?{tone:"neutral",label:"Couldn’t check"}:{tone:"warning",label:"Not linked"};return e.jsxs(la,{testId:"connection-way-dorkos-account",name:"Your DorkOS account",detail:n&&r.length===0?"Couldn’t check your DorkOS account":`${ys(r.length)} connected`,status:c,usedForNewApps:o,actions:e.jsxs(e.Fragment,{children:[n&&e.jsx(y,{size:"sm",variant:"outline",onClick:i,disabled:a,children:a?"Checking…":"Try again"}),e.jsxs(y,{size:"sm",variant:"outline",onClick:l,children:["Manage account",e.jsx(Be,{className:"size-3.5","aria-hidden":!0})]})]}),children:[s&&!t&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Linked, but can’t reach apps now. Its apps won’t work until then."}),!s&&!n&&r.length>0&&e.jsxs("div",{className:"text-muted-foreground space-y-0.5 text-xs",children:[e.jsx("p",{children:"These apps stopped when the account was unlinked."}),e.jsx("p",{children:"Linking the same DorkOS account again can restore them. Otherwise, reconnect them."})]})]})}function Ml({label:s,children:t}){return e.jsxs(Qe,{children:[e.jsxs(Ge,{className:"text-muted-foreground hover:text-foreground focus-ring flex items-center gap-1.5 rounded-md text-sm font-medium",children:[e.jsx(Ga,{className:"size-4","aria-hidden":!0}),s]}),e.jsx(Xe,{className:"pt-3",children:t})]})}function zl({keys:s,offerAccount:t,onManageAccount:n}){return s.length===0&&!t?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Every way is set up."}):e.jsxs("ul",{className:"divide-border divide-y rounded-lg border",children:[t&&e.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 basis-48",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your DorkOS account"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Link this computer, then connect apps."})]}),e.jsxs(y,{size:"sm",variant:"outline",onClick:n,children:["Link account",e.jsx(Be,{className:"size-3.5","aria-hidden":!0})]})]}),s.map(a=>e.jsxs("li",{"data-testid":`add-connection-way-${a.type}`,className:"space-y-2 px-4 py-3",children:[e.jsx("p",{className:"text-sm font-medium",children:Qn(a.type)}),e.jsx(po,{status:a})]},a.providerInstanceId))]})}const Ul=3,Kl=3e5,Qt={min:1,max:20},Gt={min:10,max:3600},Xt=1e3;function ql(){const s=Ja();return s.isLoading?e.jsx(se,{className:"h-40 rounded-lg","aria-label":"Loading chat app settings"}):s.isError?e.jsx(es,{title:"Couldn’t check chat apps",description:"Check that DorkOS is running, then try again.",onRetry:s.retry,isRetrying:s.isRetrying}):s.enabled?e.jsx(Bl,{}):e.jsx(fo,{relay:s,variant:"block"})}function Bl(){var o,l,c;const s=An(!0),{mutate:t}=Za(),{mutate:n}=ei();if(s.isPending)return e.jsx(se,{className:"h-40 rounded-lg","aria-label":"Loading chat app settings"});if(s.isError)return e.jsx(es,{title:"Couldn’t load chat app settings",description:"Try again. Nothing was changed.",onRetry:()=>void s.refetch(),isRetrying:s.isFetching});const a=(o=s.data.find(d=>d.manifest.category==="internal"&&d.manifest.type==="claude-code"))==null?void 0:o.instances[0];if(!a)return e.jsx("p",{className:"text-muted-foreground text-sm",children:"Nothing to set. Chat messages can’t start agents here."});const i=Number(((l=a.config)==null?void 0:l.maxConcurrent)??Ul),r=Number(((c=a.config)==null?void 0:c.defaultTimeoutMs)??Kl);return e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Start working right away",description:"New messages start the agent at once.",checked:a.enabled,onCheckedChange:d=>t({id:a.id,enabled:d})}),e.jsx(_,{label:"Most chats at once",description:"More wait their turn.",children:e.jsx(fs,{"aria-label":"Most chats at once",value:i,min:Qt.min,max:Qt.max,onCommit:d=>n({id:a.id,config:{maxConcurrent:d}})})}),e.jsx(_,{label:"Give up after",description:"Seconds a message waits before it’s turned away.",children:e.jsx(fs,{"aria-label":"Give up after, in seconds",value:Math.round(r/Xt),min:Gt.min,max:Gt.max,onCommit:d=>n({id:a.id,config:{defaultTimeoutMs:d*Xt}})})})]})})}function Wl(s,t=()=>null,n={}){return s?[...new Set([...Object.keys(s.runtimes),...Object.keys(s.defaults??{})])].flatMap(i=>{var c,d,u,x,h,p;const r=(c=s.defaults)==null?void 0:c[i],o=(r==null?void 0:r.runsOn)==="credits",l=s.enabled&&s.runtimes[i]==="wired";return!l&&!o?[]:[{runtime:i,name:je(i).label,on:o,chosenBy:o?(r==null?void 0:r.chosenBy)??null:null,canTurnOn:l,canTurnOff:!0,unreachable:!l,previousSignIn:t(i),scope:(u=(d=n[i])==null?void 0:d.credits)==null?void 0:u.scope,caveat:(h=(x=n[i])==null?void 0:x.credits)==null?void 0:h.caveat,hasAccountPicks:((p=n[i])==null?void 0:p.supportsAccounts)===!0}]}):[]}function Hl(s){return!s||s.killed?[]:Object.entries(s.runtimes).filter(([,t])=>t==="wired").map(([t])=>je(t).label)}function ca(){const{data:s}=ks(),t=ws(),{data:n}=Je(),{accounts:a,ownResolvedAccount:i,nameFor:r}=Cs(),o=Wl(s,d=>d==="claude-code"&&i?Yl(i,a,r):null,n==null?void 0:n.capabilities),l=(d,u)=>{const x=o.find(h=>h.runtime===d);x===void 0||x.on===u||(u?!x.canTurnOn:!x.canTurnOff)||t.mutate({runtime:d,useCredits:u})},c=t.isError?`Couldn’t change that. ${da(t.error)}`:null;return{rows:o,pending:t.isPending,failure:c,setOn:l}}function Yl(s,t,n){const a=t.find(r=>r.path===s);if(a)return a.label;const i=n(s);return i===si(s,[])?null:i}const Vl="Try again in a moment.";function da(s){return Tn(s)??Vl}function Ql(){var c;const{rows:s}=ca(),t=Nt(),n=Qr(!0),a=xt(),i=s.filter(d=>d.on).map(d=>d.name),r=t.data?wt(t.data.connections):[],o=a&&((c=n.data)!=null&&c.available)?n.data.communities:[],l=i.length===0&&r.length===0&&o.length===0;return e.jsx(R,{children:e.jsxs(D,{className:"space-y-3",children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"What’s on your account"}),l?e.jsx("p",{className:"text-muted-foreground text-sm",children:a?"Nothing uses this account yet. Agents on credits, connected apps and spaces show here.":"Nothing uses this account yet. Agents on credits and connected apps show here."}):e.jsxs("dl",{className:"space-y-3 text-sm",children:[i.length>0&&e.jsx(Ps,{label:"Running on credits",items:i}),r.length>0&&e.jsx(Ps,{label:"Connected apps",items:r.map(d=>d.name)}),o.length>0&&e.jsx(Ps,{label:"Spaces",items:o.map(d=>d.name)})]})]})})}function Ps({label:s,items:t}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:s}),e.jsx("dd",{className:"font-medium",children:t.join(", ")})]})}function Gl(){const s=ti(n=>n.sessions),{data:t}=Je();return m.useMemo(()=>{var r;let n=0,a=0;for(const o of Object.values(s)){const l=(r=o.sessionStatus)==null?void 0:r.costUsd;typeof l=="number"&&l>0&&(n+=l,a+=1)}const i=Object.entries((t==null?void 0:t.capabilities)??{}).filter(([,o])=>o.supportsCostTracking===!1).map(([o])=>o).sort();return{totalUsd:n,sessionCount:a,runtimesWithoutCost:i,hasAnything:a>0||i.length>0}},[s,t])}function Xl(s,t,n){return s===0&&BigInt(n)>0n?`<0.001 ${t}`:`${s.toLocaleString("en-US",{maximumFractionDigits:3})} ${t}`}const Jt=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",timeZone:"UTC"}),Zt=1440*60*1e3;function Jl(s,t){const n=new Date(t),a=n.getTime()%Zt===0?new Date(n.getTime()-Zt):n;return`${Jt.format(new Date(s))} – ${Jt.format(a)}`}function vs(){return e.jsx("p",{className:"text-muted-foreground text-xs",children:"Couldn’t read the credit figures from your DorkOS account."})}function Zl({otherCharges:s,denomination:t}){const n=(s==null?void 0:s.rows)??[];if(n.length===0)return null;const a=js(t);return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Other charges"}),!a&&e.jsx(vs,{}),e.jsx("ul",{className:"space-y-2 text-sm",children:n.map((i,r)=>e.jsxs("li",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",children:i.displayName}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:[Xl(i.units,i.unit,i.dorkosPriceMicro)," ·"," ",e.jsx("span",{className:"whitespace-nowrap",children:Jl(i.periodStart,i.periodEnd)})]})]}),a&&e.jsx("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:us(i.dorkosPriceMicro,t)})]},`${r}-${i.periodStart}-${i.unit}`))})]})}function ec(){const{data:s}=ze(),{data:t}=ni("seat"),n=Gl();if(!(s!=null&&s.available))return null;const a=s.balance,i=a===null?null:Gr(a.allowance.remainingMicro,a.allowance.grantedMicro),r=a==null?void 0:a.denomination,o=zt(a==null?void 0:a.allowance.remainingMicro,r),l=Ds(zt(a==null?void 0:a.allowance.grantedMicro,r)),c=bt(a==null?void 0:a.purchased.remainingMicro,r,"position"),d=us(a==null?void 0:a.owedMicro,r),u=d===null||d==="0"?null:Ds(d),x=a?sc(a.allowance.resetsAt):null,h=t!=null&&t.available?t.usage.rows:[],p=t!=null&&t.available?t.usage.denomination:void 0,f=js(p),g=t!=null&&t.available?Ds(us(t.usage.totals.dorkosPriceMicro,p)):null,v=t!=null&&t.available?t.usage.otherCharges:void 0;return e.jsx(R,{children:e.jsxs(D,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Credits"}),a!==null&&(js(r)?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-3 text-sm",children:[o!==null&&l!==null&&e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:"Included"}),e.jsxs("dd",{className:"font-medium",children:[o," of ",l," left"]})]}),c!==null&&e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:"Added"}),e.jsx("dd",{className:"font-medium",children:c})]}),u!==null&&e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:"Owed"}),e.jsx("dd",{className:"font-medium",children:u})]})]}),i!==null&&e.jsx(Uo,{value:i*100,"aria-label":"Included left"}),x!==null&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Included credits renew ",x,"."]})]}):e.jsx(vs,{})),h.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Where the credits went"}),!f&&e.jsx(vs,{}),e.jsx("ul",{className:"space-y-1 text-sm",children:h.map(N=>e.jsxs("li",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("span",{className:"truncate",children:N.displayName}),f&&e.jsx("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:us(N.dorkosPriceMicro,p)})]},N.key))}),g!==null&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Total for the last 30 days: ",g]})]}),e.jsx(Zl,{otherCharges:v,denomination:p}),n.hasAnything&&e.jsxs("div",{className:"space-y-1 border-t pt-3",children:[e.jsx("p",{className:"text-sm font-medium",children:"On this machine"}),n.sessionCount>0&&e.jsxs("p",{className:"text-sm",children:[n.totalUsd.toFixed(2)," across ",n.sessionCount," ",n.sessionCount===1?"open chat":"open chats",", by their own estimate."]}),n.runtimesWithoutCost.length>0&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:[n.runtimesWithoutCost.join(", ")," report no cost, so they’re left out."]})]})]})})}function sc(s){const t=new Date(s);return Number.isNaN(t.getTime())?null:`on ${t.toLocaleDateString(void 0,{day:"numeric",month:"short"})}`}const tc=6e4,nc=2**31-1;function ac(){const s=F(),[t,n]=m.useState(null),[a,i]=m.useState({kind:"idle"}),[r,o]=m.useState(null),l=m.useRef(!1),c=m.useCallback(async()=>{if(l.current)return!1;l.current=!0,i({kind:"requesting"});try{const x=await s.requestCloudAccountDeletion();return x.ok?(n(x.deletion),i({kind:"idle"}),!0):(i({kind:"failed",notice:"problem"in x?{problem:x.problem}:{message:x.message}}),!1)}catch{return i({kind:"failed",notice:ai}),!1}finally{l.current=!1}},[s]),d=m.useCallback(()=>{l.current||i({kind:"idle"})},[]);m.useEffect(()=>{if(t===null||t.confirmBy===null)return;const x=Date.parse(t.confirmBy)-Date.now();if(Number.isNaN(x)||x>nc)return;const h=setTimeout(()=>o(t),Math.max(0,x));return()=>clearTimeout(h)},[t]);const u=t!==null&&r===t;return ic(t!==null&&!u),{sent:t,expired:u,attempt:a,request:c,reset:d}}function ic(s){const t=B(),n=ii();m.useEffect(()=>{if(!s)return;let a=!1,i=!1;const r=async()=>{if(a||i)return;i=!0;let d=null;try{d=await n({expected:!0})}catch{}finally{i=!1}a||d===null||d.linked||(a=!0,c(),t.invalidateQueries({queryKey:ri.all}),$e.success("This computer is unlinked",{description:"The deletion is confirmed. Everything on this computer stays."}))},o=()=>void r();window.addEventListener("focus",o);const l=setInterval(()=>void r(),tc);function c(){window.removeEventListener("focus",o),clearInterval(l)}return()=>{a=!0,c()}},[s,n,t])}function ua({heading:s="Your data"}){const{data:t}=ze(),{state:n,request:a,download:i}=oi();return t!=null&&t.available?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:s}),n.kind==="requested"?n.export.downloadUrl!==null?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm",children:"Your export is ready."}),e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:i,children:["Download your data",e.jsx(Ss,{className:"size-3.5","aria-hidden":!0})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{role:"status",className:"text-sm",children:n.export.emailRequested?"Your export is being prepared. You’ll get an email when it’s ready.":"Your export is being prepared. Check back in a few minutes."}),e.jsx(y,{type:"button",size:"sm",variant:"outline",onClick:a,children:"Check again"})]}):e.jsx(y,{type:"button",size:"sm",variant:"outline",disabled:n.kind==="requesting","aria-busy":n.kind==="requesting",onClick:a,children:n.kind==="requesting"?"Asking…":"Export your account data"}),n.kind==="failed"&&e.jsx(gs,{notice:n.notice})]}):null}const Ls="delete";function rc(s){const t=new Date(s);return Number.isNaN(t.getTime())?null:new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function oc(){const{data:s}=ze(),{sent:t,expired:n,attempt:a,request:i,reset:r}=ac(),[o,l]=m.useState(!1),[c,d]=m.useState(""),u=m.useRef(null),x=m.useRef(null),h=m.useRef(null);if(!(s!=null&&s.available))return null;const p=c.trim().toLowerCase()===Ls,f=a.kind==="requesting",g=a.kind==="failed"?a.notice:null,v=j=>{f||(l(j),j||(d(""),r()))},N=()=>{!p||f||i().then(j=>{j&&(l(!1),d(""))})};return e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Delete your DorkOS account"}),t!==null?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{ref:x,role:"status",tabIndex:-1,className:"text-sm outline-none",children:n?"The link has expired, so nothing was deleted. Send a new one to carry on.":e.jsx(lc,{sentTo:t.confirmationSentTo,confirmBy:t.confirmBy})}),e.jsx(y,{type:"button",size:"sm",variant:"outline",disabled:f,"aria-busy":f,onClick:()=>void i(),children:f?"Sending…":"Send a new link"}),g!==null&&e.jsx(gs,{notice:g})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Ends your plan and erases the account for good. Everything on this computer stays."}),e.jsx(y,{ref:h,type:"button",size:"sm",variant:"destructive",onClick:()=>l(!0),children:"Delete your DorkOS account…"})]}),e.jsx(tt,{open:o,onOpenChange:v,children:e.jsxs(nt,{className:"min-h-0 sm:max-w-md",onOpenAutoFocus:j=>{var S;j.preventDefault(),(S=u.current)==null||S.focus()},onCloseAutoFocus:j=>{const S=x.current??h.current;S!==null&&(j.preventDefault(),S.focus())},children:[e.jsxs(On,{children:[e.jsx(at,{children:"Delete your DorkOS account?"}),e.jsx(it,{children:"This can’t be undone. Nothing is deleted until you follow the emailed link."})]}),e.jsx(En,{children:e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"What goes"}),e.jsxs("ul",{className:"text-muted-foreground list-inside list-disc space-y-1",children:[e.jsx("li",{children:"Your plan, which ends right away"}),e.jsx("li",{children:"Credits you haven’t used"}),e.jsx("li",{children:"The seats on your account"}),e.jsx("li",{children:"Everything else your DorkOS account holds"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"What stays"}),e.jsx("p",{className:"text-muted-foreground",children:"Everything on this computer: your agents, chats, projects and files."}),e.jsx("p",{className:"text-muted-foreground",children:"This computer unlinks and keeps working on its own."})]}),e.jsx(ua,{heading:"Want a copy first?"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:"delete-account-confirm",className:"font-medium",children:["Type ",e.jsx("strong",{children:Ls})," to confirm"]}),e.jsx(J,{ref:u,id:"delete-account-confirm","data-testid":"delete-account-confirm-input",value:c,onChange:j=>d(j.target.value),onKeyDown:j=>{j.key==="Enter"&&N()},placeholder:Ls,autoComplete:"off",disabled:f})]}),g!==null&&e.jsx(gs,{notice:g})]})}),e.jsxs(Rn,{children:[e.jsx(li,{asChild:!0,children:e.jsx(y,{variant:"outline",disabled:f,children:"Cancel"})}),e.jsx(y,{variant:"destructive",disabled:!p||f,"aria-busy":f,onClick:N,children:f?"Sending…":"Email me the link"})]})]})})]})}function lc({sentTo:s,confirmBy:t}){const n=t===null?null:rc(t);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"block",children:["Check your email. A link went to ",e.jsx("span",{className:"font-medium",children:s}),"."]})," ",e.jsxs("span",{className:"block",children:["Your account is deleted only when you follow it",n===null?".":`, and the link works until ${n}.`]})," ",e.jsx("span",{className:"block",children:"This computer then unlinks on its own."})]})}const cc={month:"a month",year:"a year"};function dc(){const{data:s}=ze(),t=ci();return s!=null&&s.available?e.jsx(R,{children:e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Manage on the web"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Payments happen on the DorkOS website. Each of these opens in your browser."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Gs,{billing:t,page:"portal",children:"Billing and invoices"}),e.jsx(Gs,{billing:t,page:"topup",children:"Add credits"})]}),e.jsx(uc,{billing:t,currentPlanId:s.entitlements.planId}),e.jsx(gs,{notice:t.notice}),e.jsx(ua,{}),e.jsx(oc,{})]})}):null}function Gs({billing:s,page:t,children:n}){var i;const a=((i=s.pending)==null?void 0:i.page)===t;return e.jsxs(y,{type:"button",size:"sm",variant:"outline",disabled:s.pending!==null,"aria-busy":a,onClick:()=>s.open({page:t}),children:[a?"Opening…":n,e.jsx(Ss,{className:"size-3.5","aria-hidden":!0})]})}function uc({billing:s,currentPlanId:t}){const{data:n}=di();if(!(n!=null&&n.available)||n.offers.offers.length===0)return null;const{offers:a,denomination:i}=n.offers;return a.some(r=>r.planId===t)?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Change plan"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Switch to another plan, or end yours, on the billing page."}),e.jsx(Gs,{billing:s,page:"portal",children:"Change plan"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Choose a plan"}),e.jsx("ul",{className:"divide-y rounded-md border",children:a.map(r=>{var d;const o=i?Ys(r.amountMicro,i):null,l=cc[r.interval],c=((d=s.pending)==null?void 0:d.skuId)===r.skuId;return e.jsxs("li",{className:"flex items-center justify-between gap-3 px-3 py-2 text-sm",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-medium",children:r.displayName}),o!==null&&e.jsx("p",{className:"text-muted-foreground text-xs",children:l?`${o} ${l}`:o})]}),e.jsxs(y,{type:"button",size:"sm",variant:"outline",disabled:s.pending!==null,"aria-busy":c,"aria-label":`Choose ${r.displayName}${l?`, billed ${l}`:""}`,onClick:()=>s.open({page:"checkout",skuId:r.skuId}),children:[c?"Opening…":"Choose",e.jsx(Ss,{className:"size-3.5","aria-hidden":!0})]})]},r.skuId)})})]})}const mc={byo:"Bring your own tunnel",on_demand:"Reachable when you open it",always_available:"Always reachable"},xc={none:"Not available",addon:"Available separately",included:"Included"},hc={community:"Community",priority:"Priority"};function pc(){const{data:s}=ze(),t=xt();if(!(s!=null&&s.available))return null;const{entitlements:n}=s,{limits:a,seats:i}=n,r=n.denomination,o=bt(a.includedCreditsMicro,r,"position"),l=!js(r);return e.jsx(R,{children:e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Your plan"}),e.jsx("p",{className:"text-base font-semibold",children:n.planDisplayName})]}),e.jsxs("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-3 text-sm sm:grid-cols-3",children:[e.jsx(Ne,{label:"People",value:`${n.used.personSeats} of ${a.personSeatsIncluded}`}),e.jsx(Ne,{label:"Agents with an address",value:`${n.used.agentSeats} of ${a.agentSeatsIncluded}`}),e.jsx(Ne,{label:"Seats assigned",value:`${i.assigned} of ${i.total}`}),o!==null&&e.jsx(Ne,{label:"Included credits",value:o}),e.jsx(Ne,{label:"Cloud hours",value:`${a.cloudHours}`}),e.jsx(Ne,{label:"Storage",value:`${a.storageGb} GB`}),e.jsx(Ne,{label:"Remote access",value:mc[a.remoteAccess]}),e.jsx(Ne,{label:"Custom address",value:xc[a.customAddress]}),e.jsx(Ne,{label:"Support",value:hc[a.support]})]}),l&&e.jsx(vs,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"Only agents with an address take a seat. Local-only agents take none."}),e.jsx(Hn,{withSpaces:t})]})]})})}function Ne({label:s,value:t}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:s}),e.jsx("dd",{className:"font-medium",children:t})]})}function gc(){const{data:s}=ui(),[t,n]=m.useState(null),a=s!=null&&s.available?s.orgs:[];m.useEffect(()=>{t===null&&a.length>0&&n(a[0].id)},[t,a]);const{data:i,isLoading:r,isError:o}=mi(t),{data:l}=xi(t),{assign:c,release:d}=hi(t),[u,x]=m.useState(null),[h,p]=m.useState(null);if(!(s!=null&&s.available))return null;if(r&&!i)return e.jsx(se,{className:"h-24 w-full"});if(o)return e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t load your seats. Try again later."});if(!(i!=null&&i.available)||i.seats.length===0&&a.length<=1)return null;const f=l!=null&&l.available?l.members:[],g=j=>{x(null),p(null),!j.ok&&("problem"in j?x(j.problem):p(j.message))},v=async j=>{try{g(await d.mutateAsync(j))}catch{x(null),p("Couldn’t reach your account just now. Nothing changed.")}},N=async(j,S)=>{try{g(await c.mutateAsync({seatId:j,subject:{kind:"user",id:S}}))}catch{x(null),p("Couldn’t reach your account just now. Nothing changed.")}};return e.jsx(R,{children:e.jsxs(D,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Seats"}),a.length>1&&e.jsx("select",{className:"border-input bg-background rounded-md border px-2 py-1 text-sm","aria-label":"Organization",value:t??"",onChange:j=>n(j.target.value),children:a.map(j=>e.jsx("option",{value:j.id,children:j.name},j.id))})]}),i.seats.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"No seats in this organization."}):e.jsx("ul",{className:"divide-y",children:i.seats.map(j=>e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:jc(j)}),e.jsx("p",{className:"text-muted-foreground text-xs",children:j.assignedAt?`Assigned ${we(j.assignedAt)}`:"Not assigned"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(Z,{variant:"secondary",children:j.status}),j.status==="assigned"?e.jsx(y,{variant:"outline",size:"sm",disabled:d.isPending,onClick:()=>void v(j.id),children:"Release"}):f.length>0&&e.jsxs("select",{className:"border-input bg-background rounded-md border px-2 py-1 text-sm","aria-label":"Assign this seat to",defaultValue:"",disabled:c.isPending,onChange:S=>{const E=S.target.value;E!==""&&N(j.id,E)},children:[e.jsx("option",{value:"",children:"Assign to…"}),f.map(S=>e.jsx("option",{value:S.userId,children:fc(S,f)},S.id))]})]})]},j.id))}),u!==null&&e.jsxs("div",{className:"border-destructive/40 bg-destructive/5 space-y-1 rounded-md border px-3 py-2",children:[e.jsx("p",{className:"text-sm font-medium",children:u.title}),u.detail!==void 0&&e.jsx("p",{className:"text-sm",children:u.detail}),u.requiredPlanDisplayName!==void 0&&e.jsxs("p",{className:"text-muted-foreground text-sm",children:["This needs ",u.requiredPlanDisplayName,"."]})]}),h!==null&&e.jsx("div",{className:"border-destructive/40 bg-destructive/5 rounded-md border px-3 py-2",children:e.jsx("p",{className:"text-sm",children:h})})]})})}function fc(s,t){return t.filter(a=>a.role===s.role).length===1?s.role:`${s.role} · ${s.userId}`}function jc(s){return s.address!==null?s.address.canonical:s.kind==="person"?"Person":"Agent"}function yc(){const{data:s}=pi(),[t,n]=m.useState(!1);if(t||!(s!=null&&s.available))return null;const{nudge:a}=s,i=a.denomination,r=bt(a.trailing30Micro,i,"charge"),o=Ys(a.suggestedPlanPriceMicro,i),l=Ys(a.savingMicro,i);return l===null||r===null||o===null?null:e.jsxs("div",{className:"bg-muted/50 flex items-start justify-between gap-3 rounded-md border px-3 py-2",children:[e.jsxs("p",{className:"text-sm",children:["Your last 30 days: ",r,". ",a.suggestedPlanDisplayName,": ",o,". Difference: ",l,"."]}),a.dismissible&&e.jsx(y,{variant:"ghost",size:"icon-sm",className:"size-6 shrink-0","aria-label":"Dismiss",onClick:()=>n(!0),children:e.jsx(ct,{className:"size-4"})})]})}function ma(s){return je(s).label}function vc(s){const t=s.map(ma);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function bc(){const{data:s}=ks(),t=(s==null?void 0:s.notices)??[];return t.length===0?null:e.jsx("div",{className:"space-y-2","data-testid":"credits-notices",children:t.map(n=>e.jsx(Nc,{notice:n},n.kind==="signed-in"?`signed-in:${n.runtime}`:n.kind))})}function Nc({notice:s}){const t=gi(),n=fi(s.kind==="filled"?s.runtimes:[]),a=ji(),i=ws(),r=fe(),o=t.isPending||a.isPending||i.isPending,l=[i,a,t].find(u=>u.isError),c=l?e.jsxs("p",{role:"alert",className:"text-destructive text-sm",children:["Couldn’t change that. ",da(l.error)]}):null;if(s.kind==="filled"){const u=vc(s.runtimes);return e.jsxs(Rs,{className:"space-y-2","data-testid":"credits-notice-filled",children:[e.jsxs("p",{className:"text-sm",children:[u," now ",s.runtimes.length===1?"runs":"run"," on your DorkOS credits."]}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:[s.runtimes.length===1?"It":"They"," had no working sign-in when you linked."]}),n.map(x=>e.jsx("p",{className:"text-muted-foreground text-sm",children:x},x)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(y,{size:"sm",variant:"outline",disabled:o,onClick:()=>{t.mutate({kind:"filled"}),r.open("runtimes")},children:"Change"}),e.jsx(y,{size:"sm",variant:"outline",disabled:o,onClick:()=>a.mutate(),children:"Undo all"}),e.jsx(y,{size:"sm",variant:"ghost",disabled:o,onClick:()=>t.mutate({kind:"filled"}),children:"OK"})]}),c]})}if(s.kind==="offer")return e.jsxs(Rs,{className:"space-y-2","data-testid":"credits-notice-offer",children:[e.jsx("p",{className:"text-sm",children:"Your DorkOS account can pay for Claude Code. Nothing changes until you turn it on."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(y,{size:"sm",disabled:o,onClick:()=>i.mutate({runtime:"claude-code",useCredits:!0}),children:"Use DorkOS credits"}),e.jsx(y,{size:"sm",variant:"ghost",disabled:o,onClick:()=>t.mutate({kind:"offer"}),children:"Not now"})]}),c]});const d=ma(s.runtime);return e.jsxs(Rs,{className:"space-y-2","data-testid":"credits-notice-signed-in",children:[e.jsxs("p",{className:"text-sm",children:["You’re signed in to ",d," now. It still uses your credits until you switch back."]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(y,{size:"sm",variant:"outline",disabled:o,onClick:()=>i.mutate({runtime:s.runtime,useCredits:!1}),children:["Use my ",d," sign-in"]}),e.jsx(y,{size:"sm",variant:"ghost",disabled:o,onClick:()=>t.mutate({kind:"signed-in",runtime:s.runtime}),children:"Keep credits"})]}),c]})}function kc(){const{rows:s,pending:t,failure:n,setOn:a}=ca();return s.length===0?null:e.jsx(R,{children:e.jsxs(D,{className:"space-y-3",children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Use credits for"}),e.jsx(bc,{}),s.map(i=>e.jsx(_,{label:i.name,description:wc(i),children:e.jsx(Ve,{checked:i.on,disabled:t||(i.on?!i.canTurnOff:!i.canTurnOn),onCheckedChange:r=>a(i.runtime,r),"aria-label":`Use credits for ${i.name}`})},i.runtime)),n!==null&&e.jsx("p",{className:"text-destructive text-sm",role:"alert",children:n})]})})}function wc(s){const t=Cc(s);return s.caveat?`${t} ${s.caveat}`:t}function Cc(s){if(s.on&&s.unreachable)return`${s.name} can’t run on credits now, so new work stops. Turn this off to continue.`;if(!s.on)return s.previousSignIn===null?`New ${s.name} work uses its own sign-in.`:`New ${s.name} work uses ${s.previousSignIn}.`;const t=s.previousSignIn===null?"Turning this off puts it back on its own sign-in.":`Turning this off puts it back on ${s.previousSignIn}.`;return s.chosenBy==="default"?`DorkOS turned this on when you linked, because ${s.name} had no sign-in. ${t}`:s.scope==="runtime"?`${s.name} runs on your DorkOS credits, chats already going included. ${t} It can't be switched while ${s.name} is in the middle of a reply.`:s.hasAccountPicks?`New ${s.name} work runs on your DorkOS credits unless an agent or a chat picks another account. ${t}`:`New ${s.name} chats run on your DorkOS credits. ${t}`}function Sc(){const{data:s,isError:t,isPending:n}=ze();return n?e.jsx(se,{className:"h-40 w-full"}):t?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t reach your DorkOS account. Local agents still work."}):e.jsxs("div",{className:"space-y-4",children:[s.available?e.jsxs(e.Fragment,{children:[e.jsx(yc,{}),e.jsx(pc,{}),e.jsx(ec,{})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"No plan details to show yet."}),e.jsx(kc,{}),e.jsx(Ql,{}),e.jsx(gc,{}),e.jsx(dc,{})]})}function Ac(s){if(s<60)return`${s} minutes`;const t=Math.round(s/60);return t<48?t===1?"an hour":`${t} hours`:`${Math.round(t/24)} days`}function Tc(){const{enabled:s,absenceThresholdMinutes:t,offersEnabled:n,setEnabled:a,setOffersEnabled:i,isAvailable:r}=Zo();return r?e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Coming back"}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Welcome-back notes",description:e.jsxs(e.Fragment,{children:[`Agents may leave a short note in your team channel after ${Ac(t)} away.`," ",e.jsxs(Ye,{label:"About welcome-back notes",children:[e.jsx("p",{children:"Off means no note, and no agent time spent checking."}),e.jsx("p",{children:"This setting follows you to every device."})]})]}),checked:s,onCheckedChange:a}),s&&e.jsx($,{label:"Next-step offers",description:"Notes can end with a decision for you. Each runs that agent for a turn.",checked:n,onCheckedChange:i})]})})]}):null}function Oc(){var s;return typeof window>"u"||(s=window.electronAPI)==null?void 0:s.tabSession}function Ec(){const s=Oc(),[t,n]=m.useState(null);if(m.useEffect(()=>{if(!s)return;let i=!0;return s.getStartupMode().then(r=>{i&&n(r)}),()=>{i=!1}},[s]),!s||t===null)return null;const a=i=>{i!=="reopen"&&i!=="fresh"||(n(i),s.setStartupMode(i).then(r=>{r&&n(r)}))};return e.jsx(_,{label:"When DorkOS opens",description:"After a quit. Updates and crashes always bring your tabs back.",children:e.jsxs(te,{value:t,onValueChange:a,children:[e.jsx(ne,{className:"w-40","aria-label":"When DorkOS opens",children:e.jsx(ae,{})}),e.jsxs(ie,{children:[e.jsx(L,{value:"reopen",children:"Reopen your tabs"}),e.jsx(L,{value:"fresh",children:"Start fresh"})]})]})})}function Rc(){const{showTimestamps:s,setShowTimestamps:t,expandToolCalls:n,setExpandToolCalls:a,autoHideToolCalls:i,setAutoHideToolCalls:r,showTaskCelebrations:o,setShowTaskCelebrations:l,promoEnabled:c,setPromoEnabled:d,enableMessagePolling:u,setEnableMessagePolling:x,setOnboardingHiddenForSession:h}=Ee(),p=qr(),{setRichText:f}=Br(),{close:g}=fe(),v=ye(),N=B(),j=()=>{v.mutate({onboarding:{completedSteps:[],skippedSteps:[],startedAt:null,dismissedAt:null,completedAt:null}},{onSuccess:()=>{N.invalidateQueries({queryKey:Q.all})}}),h(!1),g()};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Chat"}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Show timestamps",description:"Shows the time on each message.",checked:s,onCheckedChange:t}),e.jsx($,{label:"Expand tool calls",description:"Opens tool call details in messages.",checked:n,onCheckedChange:a}),e.jsx($,{label:"Auto-hide tool calls",description:"Finished tool calls fade after a moment.",checked:i,onCheckedChange:r}),e.jsx($,{label:"To-do celebrations",description:"Animates finished to-dos.",checked:o,onCheckedChange:l}),e.jsx($,{label:"Format text as you type",description:"Bold, headings and lists show as you write.",checked:p,onCheckedChange:f}),e.jsx($,{label:"Watch for work started elsewhere",description:"Work started in a terminal shows up here sooner.",checked:u,onCheckedChange:x})]})})]}),ht()&&e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Tabs"}),e.jsx(R,{children:e.jsx(D,{children:e.jsx(Ec,{})})})]}),e.jsx(Tc,{}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Discovery"}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Feature suggestions",description:"Feature tips on the dashboard and sidebar.",checked:c,onCheckedChange:d}),e.jsx(_,{label:"Replay setup",description:"Go through first-run setup again.",children:e.jsx(y,{variant:"outline",size:"sm",onClick:j,disabled:v.isPending,children:"Replay setup"})})]})})]})]})}function Dc(){const s=Xr(),t=F(),n=B(),a=m.useCallback(async r=>{await t.updateConfig({keepAwake:{whileAgentsWork:r}}),await Promise.all([n.invalidateQueries({queryKey:[...Jr]}),n.invalidateQueries({queryKey:Q.all})])},[t,n]);if(!s)return null;const i=s.supported?null:Zr[s.reason??"platform"];return e.jsxs("div",{className:"space-y-2","data-section":eo.section,children:[e.jsx("p",{className:"text-sm font-medium",children:"Sleep"}),e.jsx(R,{children:e.jsx(D,{children:e.jsx($,{label:"Keep this computer awake while agents work",description:e.jsxs("span",{className:"flex flex-col gap-1",children:[e.jsx("span",{children:"Stays awake during chats, rooms and tasks. Sleeps as usual when idle."}),e.jsx("span",{"data-testid":"sleep-settings-note",children:i??to})]}),checked:s.enabled,onCheckedChange:r=>void a(r),disabled:!so(s)})})})]})}const Ic=/^(\/|[A-Za-z]:[\\/]|\\\\)/;function xa(s){return`${s} ${s===1?"certificate":"certificates"}`}function Pc(s,t){const n=s.outcome==="added"&&s.path?{count:s.added,path:s.path}:null;if(t!==s.path)return t===null&&!n?{kind:"none"}:{kind:"restart",stillUsing:n,stopping:t===null};switch(s.outcome){case"added":return n?{kind:"loaded",...n}:{kind:"none"};case"unreadable":return{kind:"problem",text:"Couldn’t read this file. Check it, then restart DorkOS."};case"empty":return{kind:"problem",text:"No certificates found in this file. Choose a different one."};case"ignored-env":return{kind:"ignored-env"};default:return{kind:"none"}}}function Lc(s){const t=s.stopping?"Restart DorkOS to stop using it.":"Restart DorkOS to use this file.";return s.stillUsing?`Still using ${xa(s.stillUsing.count)} from ${s.stillUsing.path}. ${t}`:t}const Xs="max-sm:min-h-11 max-sm:w-full";function _c({config:s,desktop:t}){var A,O;const n=F(),a=B(),i=((A=s.network)==null?void 0:A.extraCaCertsPath)??null,[r,o]=m.useState(()=>{var b,k;const w=(k=(b=s.network)==null?void 0:b.companyCertificates)==null?void 0:k.outcome;return i!==null||w==="added"||w==="ignored-env"}),[l,c]=m.useState(i??""),[d,u]=m.useState(null),[x,h]=m.useState(!1),p=t?t.picker:Jo(),f=t?t.canRestart:Gn()!==null;m.useEffect(()=>c(i??""),[i]);const g=m.useCallback(async w=>{if(w!==i){if(w&&!Ic.test(w)){u("Use the full path to the file.");return}try{await n.updateConfig({network:{extraCaCertsPath:w}}),u(null),await a.invalidateQueries({queryKey:Q.all})}catch{u("Couldn’t save. Change this on the computer DorkOS runs on.")}}},[i,n,a]),v=m.useCallback(async()=>{if(p)try{const w=await p();w&&await g(w)}catch(w){u(w instanceof Error?w.message:"Couldn’t open the file dialog. Try again.")}},[p,g]),N=m.useCallback(async()=>{h(!0);try{await Xn(n)}catch(w){u(w instanceof Error?w.message:"Couldn’t restart DorkOS. Try again."),h(!1)}},[n]),j=(O=s.network)==null?void 0:O.companyCertificates;if(!j)return null;const S=Pc(j,i),E=j.outcome==="added"?j.added:null;return e.jsx(Ze,{open:r,onOpenChange:o,trigger:"Network",badge:E!==null?e.jsx(Z,{variant:"secondary",size:"xs","data-testid":"company-certificates-badge",children:xa(E)}):void 0,children:e.jsxs(_,{label:"Company certificates",description:"For company networks that check web traffic. Applies after a restart.",orientation:"vertical",children:[!p&&e.jsx(sa,{value:l,onChange:c,onBlur:()=>void g(l.trim()||null),onKeyDown:w=>{w.key==="Enter"&&g(l.trim()||null)},placeholder:"/path/to/company-ca.pem","aria-label":"Company certificates file","aria-invalid":d?!0:void 0}),d?e.jsx("p",{role:"alert",className:"text-destructive text-xs",children:d}):e.jsx($c,{row:S,saved:i,restart:f?{onClick:()=>void N(),pending:x}:null}),e.jsxs("div",{className:"flex gap-2 max-sm:flex-col",children:[p&&e.jsx(y,{type:"button",variant:"secondary",size:"sm",className:Xs,onClick:()=>void v(),children:"Choose…"}),i!==null&&e.jsx(y,{type:"button",variant:"ghost",size:"sm",className:P("hover:text-destructive",Xs),onClick:()=>void g(null),children:"Stop using this file"})]})]})})}function $c({row:s,saved:t,restart:n}){switch(s.kind){case"loaded":return e.jsxs("div",{className:"space-y-0.5","data-testid":"company-certificates-status",children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Trusting ",s.count," extra ",s.count===1?"certificate":"certificates"," from this file."]}),e.jsx(sn,{path:s.path})]});case"restart":{const a=s.stillUsing&&s.stillUsing.path===t?{...s,stillUsing:null}:s;return e.jsxs("div",{className:"flex flex-wrap items-center gap-2 max-sm:flex-col max-sm:items-stretch","data-testid":"company-certificates-status",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-0.5",children:[e.jsx(en,{className:"text-status-warning-fg",children:Lc(a)}),t!==null&&e.jsx(sn,{path:t})]}),n&&e.jsx(y,{type:"button",variant:"secondary",size:"sm",className:Xs,disabled:n.pending,onClick:n.onClick,children:n.pending?"Restarting…":"Restart"})]})}case"problem":return e.jsx("div",{"data-testid":"company-certificates-status",children:e.jsx(en,{className:"text-destructive",children:s.text})});case"ignored-env":return e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"company-certificates-status",children:[e.jsx("span",{className:"font-mono",children:"NODE_EXTRA_CA_CERTS"})," is ignored. Choose the file here instead."]});case"none":return null}}function en({className:s,children:t}){return e.jsxs("p",{className:P("flex min-w-0 items-start gap-1.5 text-xs",s),children:[e.jsx(Re,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 break-words",children:t})]})}function sn({path:s}){const t=Math.max(s.lastIndexOf("/"),s.lastIndexOf("\\"),0);return e.jsxs("p",{className:"text-muted-foreground flex min-w-0 overflow-hidden font-mono text-xs",title:s,children:[e.jsx("span",{className:"min-w-0 truncate",children:s.slice(0,t)}),e.jsx("span",{className:"shrink-0",children:s.slice(t)})]})}const Js={login:{id:"reconnect",label:"Fix sign-in"},"provider-picker":{id:"change",label:"Change"}};function Fc({type:s,subtitle:t,ready:n,isDefault:a,onMakeDefault:i,reconnect:r,toggleable:o,expanded:l,onToggleExpanded:c,bodyId:d,children:u}){const x=je(s),h=x.icon,p=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--runtime-accent)]/10 text-[var(--runtime-accent)]",children:e.jsx(h,{size:24})}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium whitespace-nowrap",children:x.label}),a&&e.jsx(Z,{variant:"outline",className:"shrink-0 border-[var(--runtime-accent)]/40 bg-[var(--runtime-accent)]/10 text-[var(--runtime-accent)]","data-testid":`runtime-default-pill-${s}`,children:"Default"})]}),t&&e.jsx("span",{className:"text-muted-foreground truncate text-xs",children:t})]})]}),f=r?Js[r.kind]:null;return e.jsxs("div",{className:"flex flex-col gap-1.5 p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[o?e.jsx("button",{type:"button",onClick:c,"aria-expanded":l,"aria-controls":l?d:void 0,className:"focus-ring -m-1 flex min-w-0 flex-1 items-start gap-3 rounded-md p-1 text-left","data-testid":`runtime-card-toggle-${s}`,children:p}):e.jsx("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:p}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 pt-0.5",children:[n&&e.jsxs("span",{className:"text-status-success-fg inline-flex items-center gap-1 text-xs whitespace-nowrap","data-testid":`runtime-ready-${s}`,children:[e.jsx(qe,{className:"size-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Ready"})]}),n&&f&&e.jsx("button",{type:"button",onClick:r==null?void 0:r.onOpen,className:"focus-ring text-muted-foreground hover:text-foreground hidden rounded-sm text-xs whitespace-nowrap underline-offset-2 transition-colors hover:underline sm:inline-flex","data-testid":`runtime-${f.id}-${s}`,children:f.label}),n&&!a&&i&&e.jsx("button",{type:"button",onClick:i,className:"focus-ring text-muted-foreground hover:text-foreground hidden rounded-sm text-xs whitespace-nowrap underline-offset-2 transition-colors hover:underline sm:inline-flex","data-testid":`runtime-make-default-${s}`,children:"Make default"}),o&&e.jsx("button",{type:"button",onClick:c,"aria-expanded":l,"aria-controls":l?d:void 0,"aria-label":`${l?"Hide":"Show"} ${x.label} ${n?"settings":"setup"}`,className:"focus-ring text-muted-foreground hover:text-foreground -m-1 inline-flex rounded-sm p-1 transition-colors","data-testid":`runtime-card-chevron-${s}`,children:e.jsx(We,{className:P("size-4 transition-transform",l&&"rotate-180")})})]})]}),u&&(o?e.jsx("button",{type:"button",tabIndex:-1,onClick:c,className:"focus-ring w-full rounded-md pl-12 text-left","data-testid":`runtime-card-summary-toggle-${s}`,children:u}):e.jsx("div",{className:"w-full pl-12",children:u}))]})}const _s="__inherit__";function Mc({runtimeType:s,runtimeLabel:t,models:n,value:a,onChange:i,disabled:r,inheritLabel:o="Automatic",description:l}){const c=Lo(n),d=a!==null&&c!==void 0&&!c.includes(a),u=(n??[]).some(h=>h.unverified),x=m.useId();return e.jsx(_,{label:"Model",description:l??`Which ${t} model new chats start on. Automatic lets ${t} pick.`,orientation:"vertical",children:e.jsxs("div",{className:"w-52 space-y-1.5",children:[e.jsxs(te,{value:a??_s,disabled:r,onValueChange:h=>i(h===_s?null:h),children:[e.jsx(ne,{className:"w-full","aria-label":`Default ${t} model`,...u?{"aria-describedby":x}:{},"data-testid":`runtime-model-select-${s}`,children:e.jsx(ae,{})}),e.jsxs(ie,{children:[e.jsx(L,{value:_s,children:o}),(n??[]).map(h=>e.jsx(L,{value:h.value,children:h.displayName},h.value)),a!==null&&!(n??[]).some(h=>h.value===a)&&e.jsx(L,{value:a,children:d?`${a} (no longer offered)`:a})]})]}),u&&e.jsx(_o,{id:x})]})})}const Pe="__inherit__",zc=5;function Uc({runtimeType:s,runtimeLabel:t,supportsEffort:n,selectedModel:a,configuredModelId:i,value:r,onChange:o,disabled:l}){const c=a?a.supportsEffort??!1:!0,d=yi.filter(u=>!(a!=null&&a.supportedEffortLevels)||a.supportedEffortLevels.includes(u));return e.jsx(_,{label:"Effort",description:"How much effort new chats put into answers.",orientation:"vertical",children:n?c?d.length+1>zc?e.jsxs(te,{value:r??Pe,disabled:l,onValueChange:u=>o(u===Pe?null:u),children:[e.jsx(ne,{className:"w-52","aria-label":`Default ${t} effort`,"data-testid":`runtime-effort-${s}`,children:e.jsx(ae,{})}),e.jsxs(ie,{children:[e.jsx(L,{value:Pe,children:"Automatic"}),d.map(u=>e.jsx(L,{value:u,children:ms(u)},u))]})]}):e.jsxs(As,{"aria-label":`Default ${t} effort`,"data-testid":`runtime-effort-${s}`,disabled:l,value:r??Pe,onValueChange:u=>o(u===Pe?null:u),children:[e.jsx(Fe,{value:Pe,children:e.jsx("span",{className:"truncate",children:"Automatic"})}),d.map(u=>e.jsx(Fe,{value:u,children:e.jsx("span",{className:"truncate",children:ms(u)})},u))]}):e.jsxs("div",{className:"flex flex-col gap-1","data-testid":`runtime-effort-model-unsupported-${s}`,children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:[(a==null?void 0:a.displayName)??i," doesn’t take an effort setting"]}),r&&e.jsxs("button",{type:"button",onClick:()=>o(null),disabled:l,className:"focus-ring text-status-warning-fg self-start rounded-sm text-xs underline-offset-2 hover:underline disabled:pointer-events-none disabled:opacity-50","data-testid":`runtime-effort-clear-${s}`,children:[ms(r)," is saved but unused. Clear it"]})]}):e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":`runtime-effort-unsupported-${s}`,children:["Not supported by ",t]})})}const Zs={ask:"Asks before acting",act:"Pauses at big steps",autonomy:"Full autonomy"};function Kc({runtimeType:s,runtimeLabel:t,descriptors:n,stop:a,globalStop:i,onChange:r,disabled:o}){var p;const l=a!==null,c=a??i,d=(p=Dn(n).find(f=>f.stop===c))==null?void 0:p.mode,u=(d==null?void 0:d.id)??"",x=c==="autonomy"&&(a===null||a===i),h=d!==void 0&&vi(d)&&!x;return e.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":`runtime-trust-${s}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Where it stops for you"}),l?e.jsx(y,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",disabled:o,onClick:()=>r(null),children:"Use the shared setting"}):e.jsx("span",{className:"text-muted-foreground text-3xs tracking-wide uppercase","data-testid":`runtime-trust-global-${s}`,children:"Global setting"})]}),n.length===0?e.jsxs("p",{"data-testid":`runtime-trust-unavailable-${s}`,className:"text-muted-foreground px-1 text-xs leading-relaxed",children:[t," hasn’t listed its options yet. New chats use its own setting."]}):e.jsx(bi,{mode:u,descriptors:n,stopLabels:Zs,disabled:o===!0,strandsWorkingMode:!0,strandedNote:`${t} has no setting here. New chats use its own.`,onChangeMode:f=>{const g=n.find(v=>v.id===f);g&&r(g.stop)}}),h&&e.jsx(In,{mode:u,descriptor:d,className:"px-1"})]})}const qc="One sign-in away from its settings.",Bc="Your default isn’t connected, so new chats can’t start.",Wc=(s,t)=>`Your ${s} sign-in runs out in ${t}. Sign in again to keep agents working.`,Hc=s=>`Your ${s} sign-in stops working soon. Sign in again now.`,Yc=s=>`${s} keeps no settings here. It uses its own model and the setting below.`,Vc="Starts with";function Qc({type:s,subtitle:t,ready:n,isDefault:a,onMakeDefault:i,expanded:r,onToggleExpanded:o,summary:l,connectSlot:c,reconnect:d,reconnectPanel:u,model:x,effort:h,trust:p,storesDefaults:f=!0,sections:g,renderSection:v,setupDetails:N,setupBadge:j,expiringSignIn:S,className:E}){const A=je(s),O=m.useId(),[w,b]=m.useState(!1),k=n||!!N,ee=a&&!n,V=(g??[]).flatMap(M=>{const z=v==null?void 0:v(M.kind);return z?[e.jsx("div",{"data-testid":`runtime-card-section-${M.kind}-${s}`,children:z},M.kind)]:[]});return e.jsxs("article",{style:{"--runtime-accent":A.accent},className:P("bg-card border-border shadow-soft rounded-lg border",a&&"border-[var(--runtime-accent)]/40 ring-1 ring-[var(--runtime-accent)]/30",E),"data-testid":`runtime-card-${s}`,children:[e.jsx(Fc,{type:s,subtitle:t,ready:n,isDefault:a,onMakeDefault:i,reconnect:d,toggleable:k,expanded:r,onToggleExpanded:o,bodyId:O,children:n?!r&&l.length>0&&e.jsxs("span",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 text-xs","data-testid":`runtime-card-summary-${s}`,children:[e.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:Vc}),l.map((M,z)=>e.jsxs("span",{className:"inline-flex max-w-full items-center gap-x-1.5 whitespace-nowrap",children:[z>0&&e.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/60 shrink-0",children:"·"}),e.jsx("span",{className:P("min-w-0 truncate",M.inherited?"text-muted-foreground":"text-foreground font-medium"),"data-inherited":M.inherited===!0,"data-testid":`runtime-card-summary-segment-${M.kind}-${z}`,children:M.label})]},`${M.kind}-${M.label}`))]}):e.jsx("span",{className:"text-muted-foreground text-xs","data-testid":`runtime-card-locked-${s}`,children:qc})}),ee&&e.jsxs("p",{className:"text-status-warning-fg flex items-start gap-1.5 px-4 pb-3 text-xs","data-testid":`runtime-default-broken-${s}`,children:[e.jsx(ue,{className:"mt-px size-3.5 shrink-0","aria-hidden":!0}),Bc]}),S&&e.jsxs("p",{className:"text-status-warning-fg flex items-start gap-1.5 px-4 pb-3 text-xs","data-testid":`runtime-sign-in-expiring-${s}`,children:[e.jsx(ue,{className:"mt-px size-3.5 shrink-0","aria-hidden":!0}),S.timeLeft===null?Hc(A.label):Wc(A.label,S.timeLeft)]}),!n&&c&&e.jsx("div",{className:"px-4 pb-4",children:c}),n&&u&&e.jsx("div",{className:"px-4 pb-4",children:u}),r&&k&&e.jsxs("div",{id:O,className:"border-border/60 space-y-5 border-t px-4 py-4","data-testid":`runtime-card-body-${s}`,children:[n&&(d||!a&&i)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 sm:hidden",children:[d&&e.jsx("button",{type:"button",onClick:d.onOpen,className:"focus-ring text-muted-foreground hover:text-foreground rounded-sm text-xs underline-offset-2 transition-colors hover:underline","data-testid":`runtime-${Js[d.kind].id}-compact-${s}`,children:Js[d.kind].label}),!a&&i&&e.jsx("button",{type:"button",onClick:i,className:"focus-ring text-muted-foreground hover:text-foreground rounded-sm text-xs underline-offset-2 transition-colors hover:underline","data-testid":`runtime-make-default-compact-${s}`,children:"Make default"})]}),n&&(f?e.jsxs(e.Fragment,{children:[e.jsx(Mc,{runtimeType:s,runtimeLabel:A.label,...x}),e.jsx(Uc,{runtimeType:s,runtimeLabel:A.label,...h}),e.jsx(Kc,{runtimeType:s,runtimeLabel:A.label,...p}),V]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":`runtime-card-no-settings-${s}`,children:Yc(A.label)}),V]})),N&&e.jsx(Ze,{open:w,onOpenChange:b,trigger:"Setup details",badge:j,className:"bg-transparent",children:N})]})]})}const Gc="Automatic",Xc={ask:"Asks first",act:"Pauses at big steps",autonomy:"Full autonomy"},Jc={"claude-accounts":s=>`runs on ${s}`,"opencode-power-source":s=>s};function Zc(s){var a,i,r,o,l,c;if(!s.ready)return[];const t=[],n=(a=s.model)==null?void 0:a.trim();if(n){const d=(i=s.models)==null?void 0:i.find(u=>u.value===n);t.push({kind:"model",label:(d==null?void 0:d.displayName)??n,inherited:!1})}else t.push({kind:"model",label:s.inheritModelLabel??Gc,inherited:!0});(r=s.settings)!=null&&r.supportsEffort&&s.effort&&s.modelTakesEffort!==!1&&t.push({kind:"effort",label:`${ms(s.effort)} effort`}),s.trustStop&&t.push({kind:"trust",label:Xc[s.trustStop],inherited:s.trustInherited??!1});for(const d of((o=s.settings)==null?void 0:o.sections)??[]){const u=(c=(l=s.sectionValues)==null?void 0:l[d.kind])==null?void 0:c.trim(),x=Jc[d.kind];u&&x&&t.push({kind:"section",label:x(u)})}return t}function ed(s){const t=s.map(n=>n.label);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function sd({stop:s,effectiveStop:t,runtimes:n,onChange:a,onChangeRuntime:i}){var x;const r=s??t,o=Dn(Ni),l=n.filter(h=>h.stop==="autonomy"),c=r==="autonomy",d=c||l.length>0,u=(x=o.find(h=>h.stop===(d?"autonomy":r)))==null?void 0:x.mode;return e.jsxs("section",{className:"@container/trust-row flex flex-col gap-2","data-testid":"global-trust-row",children:[e.jsxs("div",{className:"flex flex-col gap-3 @2xl/trust-row:flex-row @2xl/trust-row:items-center @2xl/trust-row:justify-between @2xl/trust-row:gap-6",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:"Where chats stop for you"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Cards above use this unless set otherwise."}),e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"global-trust-row-timing",children:[e.jsx("span",{children:"Applies to all chats from their next turn."})," ",e.jsx("span",{children:"Chats you set by hand only follow it down."})]})]}),e.jsx(As,{"aria-label":"Where chats stop for you",className:"w-full @2xl/trust-row:w-auto @2xl/trust-row:shrink-0",value:r,onValueChange:h=>a(h),children:o.map(({stop:h,mode:p})=>e.jsxs(Fe,{value:h,"aria-label":Zs[h],children:[e.jsx(ki,{descriptor:p,className:"size-(--size-icon-xs) shrink-0"}),e.jsx("span",{className:"truncate",children:Zs[h]})]},h))})]}),(c||l.length>0)&&e.jsxs("p",{className:`flex items-start gap-1.5 px-1 text-xs ${wi.power}`,"data-testid":"default-trust-stop-standing-note",children:[e.jsx(Ci,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsxs("span",{children:[c?"New chats run at full power":`New chats on ${ed(l)} run at full power`,"."," ",e.jsx("button",{type:"button",className:"focus-ring rounded-sm underline underline-offset-2",onClick:()=>{c&&a("ask");for(const h of l)i(h.runtime,null)},children:"Change"})]})]}),e.jsx(In,{descriptor:u,className:"px-1"})]})}const td=[{key:"five_hour",label:"5-hour window"},{key:"seven_day",label:"Weekly"}];function ha(s,t=new Date){return!!s&&(s.windows.length>0||pa(s.spend,t))}function pa(s,t=new Date){if(!s)return!1;const n=new Date(s.periodStart);return Number.isNaN(n.getTime())?!1:n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()}function nd({spend:s}){return e.jsxs("p",{className:"text-muted-foreground text-xs tabular-nums","data-slot":"spend-line",children:[$o(s.costUsd)," spent this month"]})}function ga({usage:s,name:t,now:n=new Date}){if(!ha(s,n))return null;const a=s.windows.length>0;return e.jsxs("div",{className:"space-y-2","data-slot":"account-usage-bars",children:[t&&e.jsx("p",{className:"text-sm font-medium",children:t}),a?td.map(({key:i,label:r})=>e.jsx(Bs,{window:Ws(s,i),label:r},i)):pa(s.spend,n)&&e.jsx(nd,{spend:s.spend})]})}function tn(s){return new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime()}function ad(s,t){if(s===null)return null;const n=new Date(s);if(Number.isNaN(n.getTime()))return null;const a=Math.round((tn(t)-tn(n))/864e5);return a<=0?"used today":a===1?"used yesterday":`used ${a} days ago`}function id({folders:s,onAdd:t,onDismiss:n,error:a=null,disabled:i=!1}){const r=m.useId();if(s.length===0)return null;const o=new Date;return e.jsxs("div",{role:"group","aria-labelledby":r,className:"bg-muted/50 rounded-md border border-dashed px-3 py-1.5","data-testid":"found-accounts-group",children:[e.jsx("p",{id:r,className:"text-muted-foreground py-1 text-xs",children:"Found on this computer"}),e.jsx("ul",{className:"divide-y",children:s.map(l=>{const c=ad(l.lastUsedAt,o),d=(a==null?void 0:a.path)===l.path?a.message:null;return e.jsxs("li",{className:"py-2","data-testid":"found-account-row",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"min-w-40 flex-1",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-sm",children:[e.jsx("span",{className:"font-semibold break-all",children:l.name}),c&&e.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:["· ",c]}),l.orgManaged&&e.jsx("span",{className:P("text-2xs rounded-full px-2 leading-5 whitespace-nowrap",Si.warning),children:"managed by an organization"})]}),e.jsx("p",{className:"text-muted-foreground truncate font-mono text-xs",title:l.path,children:He(l.path)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx(y,{size:"sm",variant:l.orgManaged?"outline":"default",onClick:()=>t(l),disabled:i,"aria-label":`Add ${l.name}`,children:"Add"}),e.jsx(y,{size:"sm",variant:"outline",onClick:()=>n(l),disabled:i,"aria-label":`Dismiss ${l.name}`,children:"Dismiss"})]})]}),d&&e.jsxs("p",{role:"alert",className:"text-destructive mt-1 flex items-start gap-1.5 text-xs","data-testid":"found-account-error",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:d})]})]},l.path)})})]})}function fa(s){return s.length<=1?s[0]??"":`${s.slice(0,-1).join(", ")} and ${s[s.length-1]}`}function At(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function Tt(){const s=B();return()=>{s.invalidateQueries({queryKey:Q.all}),s.invalidateQueries({queryKey:Le.all})}}function rd({onlyProjects:s}){return s===null?null:e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"claude-account-only-for",children:s.length===0?Ai:`Only for ${fa(s.map(t=>t.name))}`})}function od({open:s,onOpenChange:t,accountId:n,accountName:a,current:i}){const r=F(),o=Tt(),l=m.useId(),c=Y({queryKey:Le.projects(),queryFn:()=>r.listProjects(),enabled:s}),[d,u]=m.useState(i===null?"any":"only"),[x,h]=m.useState(()=>new Set((i??[]).map(A=>A.root))),[p,f]=m.useState(!1),g=ge({mutationFn:()=>r.setAccountOnlyProjects(n,d==="any"?null:[...x]),onSuccess:()=>{o(),t(!1)}}),v=c.data??[],N=(i??[]).filter(A=>!v.some(O=>O.root===A.root)),j=[...v,...N];function S(){if(d==="only"&&x.size===0){f(!0);return}f(!1),g.mutate()}function E(A,O){f(!1),h(w=>{const b=new Set(w);return O?b.add(A):b.delete(A),b})}return e.jsx(tt,{open:s,onOpenChange:t,children:e.jsxs(nt,{className:"max-h-[85vh] md:max-w-md",children:[e.jsxs(On,{children:[e.jsxs(at,{className:"text-sm font-medium",children:["Where can ",a," work?"]}),e.jsx(it,{className:"text-muted-foreground text-xs",children:"Nobody can use it anywhere else, even in folders outside a project."})]}),e.jsxs(En,{className:"space-y-3",children:[e.jsxs(Pn,{value:d,onValueChange:A=>u(A),"aria-labelledby":l,children:[e.jsxs("span",{id:l,className:"sr-only",children:["Where ",a," can work"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hs,{value:"any",id:`${l}-any`}),e.jsx(G,{htmlFor:`${l}-any`,className:"text-sm font-normal",children:"Any project"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hs,{value:"only",id:`${l}-only`}),e.jsx(G,{htmlFor:`${l}-only`,className:"text-sm font-normal",children:"Only these projects"})]})]}),d==="only"&&e.jsxs("div",{className:"space-y-1.5 pl-6","data-testid":"limit-projects-list",children:[c.isPending&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Looking for projects…"}),!c.isPending&&j.length===0&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"No projects yet. Start a chat in one first."}),j.map(A=>{const O=`${l}-${A.root}`;return e.jsxs("div",{className:"flex min-h-11 items-center gap-2 md:min-h-8",children:[e.jsx(wn,{id:O,checked:x.has(A.root),onCheckedChange:w=>E(A.root,w===!0)}),e.jsx(G,{htmlFor:O,className:"min-w-0 text-sm font-normal",children:e.jsx("span",{className:"truncate",children:A.name})})]},A.root)})]}),p&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 text-xs",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Pick a project, or choose Any project."})]}),g.isError&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 text-xs",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:At(g.error)})]})]}),e.jsxs(Rn,{children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(y,{size:"sm",onClick:S,disabled:g.isPending,children:"Save"})]})]})})}function ld({limits:s,nameForId:t}){const n=F(),a=Tt(),i=m.useId(),r=ge({mutationFn:o=>n.setProjectAccounts(o,null),onSuccess:a});return s.length===0?null:e.jsxs("div",{role:"group","aria-labelledby":i,className:"rounded-md border px-3 py-1.5","data-testid":"project-limits",children:[e.jsxs("div",{className:"flex items-center gap-1.5 pt-1",children:[e.jsx("p",{id:i,className:"text-muted-foreground text-xs",children:"Project limits"}),e.jsxs(Ye,{label:"About project limits",children:[e.jsx("p",{children:"The Flow extension or a script sets each project’s list."}),e.jsx("p",{children:"Remove a limit to let that project use every account."})]})]}),e.jsx("p",{className:"text-muted-foreground pb-1 text-xs","data-testid":"project-limits-note",children:"These projects use only the accounts listed."}),e.jsx("ul",{className:"divide-y",children:s.map(({project:o,allow:l})=>e.jsxs("li",{className:"flex flex-wrap items-center gap-2 py-2","data-testid":"project-limit-row",children:[e.jsxs("div",{className:"min-w-40 flex-1",children:[e.jsx("p",{className:"text-sm font-medium break-all",children:o.name}),e.jsx("p",{className:"text-muted-foreground text-xs",children:l.length===0?"Uses no account":`Uses only ${fa(l.map(t))}`})]}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>r.mutate(o.root),disabled:r.isPending,"aria-label":`Let ${o.name} use every account`,children:"Remove"})]},o.root))}),r.isError&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 pb-1.5 text-xs",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:At(r.error)})]})]})}const cd=["blue","green","amber","purple","pink","teal","indigo","stone"],cs=[...Ii.map((s,t)=>({name:cd[t]??s,hex:s})),{name:"Default",hex:null}];function dd({name:s,color:t,colorIsDefault:n,onChoose:a,disabled:i,defaultOpen:r=!1}){const[o,l]=m.useState(r),c=m.useRef([]),d=cs.findIndex(p=>p.hex===null?n:!n&&p.hex===t.toLowerCase()),u=d===-1?0:d;function x(p){l(!1),a(p)}function h(p){var j;const f=p.key==="ArrowRight"||p.key==="ArrowDown"?1:p.key==="ArrowLeft"||p.key==="ArrowUp"?-1:0;if(f===0)return;p.preventDefault();const g=c.current.findIndex(S=>S===document.activeElement),N=((g===-1?u:g)+f+cs.length)%cs.length;(j=c.current[N])==null||j.focus()}return e.jsxs(Ti,{open:o,onOpenChange:l,children:[e.jsx(Oi,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`Color for ${s}`,"aria-haspopup":"dialog",disabled:i,className:"focus-visible:ring-ring -m-1 inline-flex shrink-0 rounded-full p-1 focus-visible:ring-2 focus-visible:outline-none",children:e.jsx(Ei,{color:t,name:s,size:"md"})})}),e.jsxs(Ri,{className:"w-auto p-3",align:"start",children:[e.jsxs(Di,{className:"sr-only",children:["Color for ",s]}),e.jsx("div",{role:"radiogroup","aria-label":`Color for ${s}`,className:"flex flex-wrap items-center gap-1.5",onKeyDown:h,children:cs.map((p,f)=>{const g=f===d;return e.jsx("button",{ref:v=>{c.current[f]=v},type:"button",role:"radio","aria-checked":g,"aria-label":p.name,title:p.name,tabIndex:f===u?0:-1,onClick:()=>x(p.hex),className:P("focus-visible:ring-ring inline-flex items-center justify-center rounded-full focus-visible:ring-2 focus-visible:outline-none",p.hex===null?"text-foreground hover:bg-muted h-6 gap-1 border px-2 text-xs":"size-6 bg-(--swatch) text-white",g&&p.hex!==null&&"ring-foreground ring-2 ring-offset-2"),style:p.hex?{"--swatch":p.hex}:void 0,children:p.hex===null?e.jsxs(e.Fragment,{children:[g&&e.jsx(qe,{className:"size-3","aria-hidden":!0}),"Default"]}):g&&e.jsx(qe,{className:"size-3.5","aria-hidden":!0})},p.name)})})]})]})}function ud(s){const t=F(),n=Tt();return ge({mutationFn:a=>t.setAccountNoAutoMove(s,a),onSuccess:n})}function md({accountId:s,noAutoMove:t,disabled:n}){const a=m.useId(),i=ud(s),r=i.isPending?i.variables===!1:!t;return e.jsxs("div",{className:"mt-1 space-y-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ve,{id:a,size:"sm",className:"mt-0.5",checked:r,onCheckedChange:o=>i.mutate(!o),disabled:n||i.isPending,"data-testid":"claude-account-auto-move"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(G,{htmlFor:a,className:"text-xs font-normal",children:"Move agents here automatically"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"When an agent runs out in a room, it can continue here."})]})]}),i.error&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 text-xs",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:At(i.error)})]})]})}function xd({name:s,rule:t,disabled:n}){const[a,i]=m.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(rd,{onlyProjects:t.onlyProjects}),e.jsx(y,{variant:"link",size:"sm",className:"text-muted-foreground h-auto px-0 py-0.5 text-xs",onClick:()=>i(!0),disabled:n,children:"Limit to projects…"}),a&&e.jsx(od,{open:!0,onOpenChange:i,accountId:t.accountId,accountName:s,current:t.onlyProjects}),t.noAutoMove!==void 0&&e.jsx(md,{accountId:t.accountId,noAutoMove:t.noAutoMove,disabled:n})]})}function nn({name:s,account:t,isActive:n,onRemove:a,onChooseColor:i,rule:r,disabled:o,identity:l,signInState:c}){return e.jsxs("div",{className:"flex items-start gap-3","data-testid":"claude-account-row",children:[l&&e.jsx("span",{className:"mt-1 flex",children:e.jsx(dd,{name:s,color:t.color,colorIsDefault:t.colorIsDefault,onChoose:i,disabled:o})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium",children:[s,n&&e.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:"in use"})]}),e.jsx("p",{className:"text-muted-foreground truncate font-mono text-xs",title:t.path,children:He(t.path)}),e.jsx(nl,{accountId:r==null?void 0:r.accountId,accountRoot:t.path,name:s,signInState:c}),r&&e.jsx(xd,{name:s,rule:r,disabled:o}),!t.isAccountRoot&&e.jsxs("p",{className:"text-muted-foreground mt-1 flex items-start gap-1.5 text-xs","data-testid":"claude-account-not-ready",children:[e.jsx(ue,{className:"text-destructive mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Not a Claude Code account yet. No chats show from it."})]})]}),l&&e.jsxs("div",{className:"w-36 shrink-0 space-y-1 pt-0.5",children:[e.jsx(Bs,{window:Ws(l.usage,"five_hour"),label:"5h",compact:!0}),e.jsx(Bs,{window:Ws(l.usage,"seven_day"),label:"wk",compact:!0})]}),a?e.jsx(y,{variant:"ghost",size:"sm",onClick:a,disabled:o,"aria-label":`Remove ${s}`,children:e.jsx(ps,{className:"size-3.5"})}):e.jsx("span",{"aria-hidden":"true","data-testid":"claude-account-remove-spacer",className:P(Pi({variant:"ghost",size:"sm"}),"invisible"),children:e.jsx(ps,{className:"size-3.5"})})]})}const $s="__default__",Fs="__credits__";function ds(s){return s.flatMap(t=>t.id?[t.id]:[])}function et(s){const t=new Set([$n,...s.flatMap(n=>n.id?[n.id]:[])]);return s.map(n=>{const a=n.id??Fn({label:n.label,path:n.path,taken:t});return t.add(a),{id:a,path:n.path,label:n.label,color:n.colorIsDefault?null:n.color}})}function an(s,t,n){const a=et(s),i=Fn({label:n,path:t,taken:[$n,...a.map(r=>r.id)]});return[...a,{id:i,path:t,label:n,color:null}]}function Ms(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function hd(){var as,be;const{data:s}=Se(),{nameFor:t,credits:n}=Cs(),a=ye(),i=ws(),r=B(),[o,l]=m.useState(""),[c,d]=m.useState(""),[u,x]=m.useState(!1),[h,p]=m.useState(!1),[f,g]=m.useState(null),[v,N]=m.useState(null),j=F(),S=Y({queryKey:Le.found(),queryFn:()=>j.getFoundClaudeFolders()}),E=ge({mutationFn:C=>j.dismissFoundClaudeFolder(C.path),onMutate:()=>N(null),onSuccess:()=>r.invalidateQueries({queryKey:Le.found()}),onError:(C,q)=>N({path:q.path,message:Ms(C)})}),A=Li("claude-code"),O=pt("claude-code",{fetch:!0}),w=kn("settings.tabs").some(C=>C.id===Ln),b=s==null?void 0:s.claudeCode,k=(b==null?void 0:b.accounts)??[],ee=b==null?void 0:b.resolvedAccount,V=(b==null?void 0:b.inherited)??!0,M=b==null?void 0:b.resolvedAccountId,z=M&&M!==ke?k.find(C=>C.id===M):void 0,W=(z==null?void 0:z.path)??ee,T=n!==null&&(n.available||n.isDefault),K=n!=null&&n.isDefault?Fs:V||!W?$s:W,I=A?O.byId.get(ke):void 0,ve=o.trim(),De=k.some(C=>C.path===ve),ss=ve.length>0&&!_i(ve),ts=ve.length>0&&!De&&!ss;function he(C,q,X=g){g(null),N(null),a.mutate({runtimes:{claudeCode:C}},{onSuccess:()=>{r.invalidateQueries({queryKey:Q.all}),r.invalidateQueries({queryKey:Le.usage("claude-code")}),q==null||q()},onError:H=>X(Ms(H))})}function ns(C){g(null);const q=H=>g(Ms(H));if(C===Fs){i.mutate({runtime:"claude-code",useCredits:!0},{onError:q});return}const X=C===$s?null:C;if(n!=null&&n.isDefault){i.mutate({runtime:"claude-code",useCredits:!1},{onError:q,onSuccess:()=>{const H=V?null:(b==null?void 0:b.resolvedAccount)??null;X!==H&&he({defaultAccount:X})}});return}he({defaultAccount:X})}function Os(){ts&&he({accounts:an(k,ve,c.trim()||null),accountsSeen:ds(k)},()=>{l(""),d(""),x(!1)})}function Rt(C){he({accounts:an(k,C.path,null),accountsSeen:ds(k)},()=>void r.invalidateQueries({queryKey:Le.found()}),q=>N({path:C.path,message:q}))}function Es(C,q){he({accounts:et(k).map((X,H)=>k[H].path===C?{...X,color:q}:X),accountsSeen:ds(k)})}function Ue(C){const q=et(k.filter(H=>H.path!==C)),X=!V&&z!==void 0&&z.path===C;he({accounts:q,accountsSeen:ds(k),...X&&{defaultAccount:null}})}return e.jsxs("section",{className:"bg-muted/30 space-y-3 rounded-lg border p-3","data-testid":"claude-accounts-section",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Runs on"}),e.jsx(y,{variant:"ghost",size:"sm",className:"text-muted-foreground h-auto px-1 py-0 text-xs",onClick:()=>x(C=>!C),"aria-expanded":u,children:"Add account"})]}),!A&&e.jsx(pd,{accounts:k,usage:O}),b&&k.length===0&&!A&&e.jsx(Wn,{accountRoot:b.resolvedAccount,name:t(b.resolvedAccount),state:(as=O.byId.get(ke))==null?void 0:as.signInState}),e.jsx(_,{label:"Default account",description:"New chats run on this unless the agent or the chat picks another.",children:e.jsxs(te,{value:K,onValueChange:ns,disabled:i.isPending,children:[e.jsx(ne,{className:"w-52","aria-label":"Default account","data-testid":"claude-account-select",children:e.jsx(ae,{})}),e.jsxs(ie,{children:[e.jsx(L,{value:$s,children:V&&ee?`Default (${He(ee)})`:"Default"}),$i(k,V?null:W).map(C=>e.jsx(L,{value:C.path,children:t(C.path)},C.path)),T&&e.jsx(L,{value:Fs,children:_n})]})]})}),(n==null?void 0:n.isDefault)&&n.chosenBy==="default"&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"claude-credits-chosen-for-you",children:"DorkOS chose this when you linked your account. Claude Code had no working sign-in."}),(n==null?void 0:n.isDefault)&&!n.available&&e.jsxs("div",{className:"text-muted-foreground text-xs","data-testid":"claude-credits-unavailable",children:[e.jsx("p",{children:"DorkOS credits aren’t available, so new chats here won’t start."}),e.jsx("p",{children:"Sign in to your DorkOS account again, or pick another account."})]}),(b==null?void 0:b.launchOverride)&&!M&&e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"claude-account-launch-override",children:["New chats use ",He(b.launchOverride.path),", from the server’s $CLAUDE_CONFIG_DIR."]}),k.map(C=>{var q;return e.jsx(nn,{name:t(C.path),account:C,signInState:(q=O.byPath.get(C.path))==null?void 0:q.signInState,isActive:C.id!==null&&C.id===M,onRemove:()=>Ue(C.path),onChooseColor:X=>Es(C.path,X),rule:C.id?{accountId:C.id,onlyProjects:C.onlyProjects??null,noAutoMove:C.noAutoMove===!0}:null,disabled:a.isPending,identity:A?{usage:(C.id?O.byId.get(C.id):void 0)??O.byPath.get(C.path)}:null},C.path)}),I&&e.jsx(nn,{signInState:I.signInState,name:I.label??t(I.path),account:{path:I.path,color:(b==null?void 0:b.defaultAccountResolvedColor)??I.color,colorIsDefault:((b==null?void 0:b.defaultAccountColor)??null)===null,isAccountRoot:!0},isActive:M===ke,onChooseColor:C=>he({defaultAccountColor:C}),rule:{accountId:ke,onlyProjects:(b==null?void 0:b.defaultAccountOnlyProjects)??null},disabled:a.isPending,identity:{usage:I}}),e.jsx(ld,{limits:(b==null?void 0:b.projectAccounts)??[],nameForId:C=>{if(C===ke)return(I==null?void 0:I.label)??"Main";const q=k.find(X=>X.id===C);return q?t(q.path):C}}),e.jsx(id,{folders:((be=S.data)==null?void 0:be.folders)??[],onAdd:Rt,onDismiss:C=>E.mutate(C),error:v,disabled:a.isPending||E.isPending}),A&&w&&e.jsx(gd,{}),u&&e.jsx(_,{orientation:"vertical",label:"Add an account",description:e.jsxs(e.Fragment,{children:["Pick the account’s Claude Code folder, then name it."," ",e.jsxs(Ye,{label:"About adding an account",children:[e.jsx("p",{children:"Name it after the client it bills."}),e.jsx("p",{children:"DorkOS only reads the folder. It never signs you in or moves anything."})]})]}),children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(sa,{"aria-label":"Account folder",placeholder:"/Users/you/.claude2",value:o,onChange:l,onBrowse:()=>p(!0),browseTestId:"browse-claude-account","data-testid":"claude-account-path"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{htmlFor:"claude-account-label",className:"text-muted-foreground text-xs",children:"Name"}),e.jsx(J,{id:"claude-account-label",placeholder:"Acme Corp",value:c,onChange:C=>d(C.target.value),className:"h-11 flex-1 md:h-8"}),e.jsx(y,{size:"sm",onClick:Os,disabled:!ts||a.isPending,children:"Add"})]}),De&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"claude-account-duplicate",children:"That folder is already added."}),ss&&e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"claude-account-not-absolute",children:["Use the full path, like ",e.jsx("code",{children:"/Users/you/.claude2"}),". A path starting with"," ",e.jsx("code",{children:"~"})," won’t work."]})]})}),f&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 text-xs","data-testid":"claude-account-error",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:f})]}),e.jsx(Fi,{open:h,onOpenChange:p,onSelect:l,initialPath:ve||null})]})}function pd({accounts:s,usage:t}){const{nameFor:n}=Cs();if(s.length>1)return null;const a=s[0],i=a?(a.id?t.byId.get(a.id):void 0)??t.byPath.get(a.path):t.byId.get(ke);if(!i)return null;const r=a?n(a.path):i.label??n(i.path);return e.jsx(ga,{usage:i,name:r})}function gd(){const{setTab:s}=fe();return e.jsxs("p",{className:"bg-muted text-muted-foreground rounded-md px-3 py-2 text-xs",children:["Flow uses these accounts. Choose how in"," ",e.jsx("button",{type:"button",onClick:()=>s(Ln),className:"text-foreground font-semibold underline-offset-2 hover:underline",children:"Settings → Flow"}),"."]})}function fd({type:s,provider:t,renderConnect:n}){const[a,i]=m.useState(!1);return e.jsxs("section",{className:"bg-muted/30 space-y-3 rounded-lg border p-3","data-testid":"power-source-section",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Power source"}),t&&!a&&e.jsx(y,{variant:"ghost",size:"sm",className:"text-muted-foreground h-auto px-1 py-0 text-xs",onClick:()=>i(!0),"data-testid":"power-source-change",children:"Change"})]}),t?e.jsx("p",{className:"text-sm font-medium","data-testid":"power-source-current",children:ea(t)}):e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"power-source-empty",children:[ft(s)," was signed in outside DorkOS, so its model source is unknown."]}),t&&a&&e.jsxs("div",{className:"space-y-2","data-testid":"power-source-panel",children:[n({type:s,connect:{kind:"provider-picker",label:"Change power source"},currentProvider:t,onConnected:()=>i(!1)}),e.jsx("button",{type:"button",onClick:()=>i(!1),className:"focus-ring text-muted-foreground hover:text-foreground rounded-sm text-xs transition-colors","data-testid":"power-source-cancel",children:"Keep current source"})]})]})}function jd({type:s}){var a;const{data:t}=gt(),n=(a=t==null?void 0:t.runtimes[s])==null?void 0:a.provider;return e.jsx(fd,{type:s,...n?{provider:n}:{},renderConnect:Vs})}function yd(s,t){return s==="effort"?`effort ${t}`:s==="account"||s==="runtime"?`runs on ${t}`:`${s} ${t}`}function vd({exceptions:s}={}){const t=no({checkModels:s===void 0}),n=s??t.exceptions,a=fe();function i(r){a.close(),Ui.getState().openProfileDocked(r)}return n.length===0?null:e.jsxs("div",{className:"space-y-1","data-testid":"execution-exceptions-strip",children:[e.jsx("p",{className:"text-muted-foreground px-1 text-xs",children:"These agents run on something else:"}),e.jsx("ul",{className:"divide-border bg-card divide-y overflow-hidden rounded-lg border",children:n.map(({path:r,agent:o,report:l})=>{const c=l.isBroken?l.breakages.map(u=>u.message).join(" "):l.deviations.map(u=>yd(u.field,u.label)).join(", "),d=Mi(o);return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>i(r),className:"hover:bg-accent flex w-full items-center gap-2 px-3 py-2 text-left transition-colors","data-testid":l.isBroken?"execution-exception-broken":"execution-exception",children:[e.jsx(zi,{color:d.color,emoji:d.emoji,size:"xs"}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5 sm:flex-row sm:items-start sm:gap-3",children:[e.jsx("span",{className:"truncate text-sm font-medium sm:pt-px",children:o.name}),e.jsxs("span",{className:P("flex min-w-0 items-start gap-1.5 text-xs sm:ml-auto sm:max-w-[65%]",l.isBroken?"text-status-warning-fg":"text-muted-foreground"),children:[l.isBroken&&e.jsx(Re,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"line-clamp-2",title:c,children:c})]})]})]})},r)})})]})}function bd(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function ja(){const{data:s}=Je(),t=ye(),n=B(),[a,i]=m.useState(null),r=m.useCallback(c=>{i(null),t.mutate(c,{onSuccess:()=>{n.invalidateQueries({queryKey:Q.all}),n.invalidateQueries({queryKey:Ki.all})},onError:d=>i(bd(d))})},[t,n]),o=m.useCallback((c,d)=>{var x;if(c===null){r({runtimes:{defaultTrustStop:d}});return}const u=(x=Zn(s,c))==null?void 0:x.configSection;u&&r({runtimes:{[u]:{defaultTrustStop:d}}})},[s,r]),l=m.useCallback(()=>i(null),[]);return{changeTrustStop:o,writeError:a,clearWriteError:l,isPending:t.isPending}}function Nd(){const s=ia(),[t,n]=m.useState(""),[a,i]=m.useState(""),[r,o]=m.useState("");if(s.isPending)return null;if(!s.data)return e.jsx("p",{className:"text-muted-foreground text-xs",children:"Only you can manage sign-ins, in the app."});const{deniedOrganizations:l,folders:c,accounts:d}=s.data;return e.jsxs("section",{className:"mt-6 space-y-3","aria-label":"Never use",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Never use"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"DorkOS won’t run agents on these."}),l.length===0&&c.length===0&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Nothing here yet."}),c.map(u=>e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsxs("span",{className:"min-w-0 truncate",title:u.path,children:[He(u.path)," · DorkOS never opens this folder."]}),e.jsx(Ke,{label:"Remove folder",title:"Remove this folder from Never use?",description:"DorkOS can open and use it again.",change:{action:"allow-folder",accountId:u.accountId}})]},u.accountId)),l.map(u=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[e.jsxs("span",{children:[u.label," · org ",u.id.slice(0,4),"…"]}),e.jsx(Ke,{label:"Remove sign-in",title:"Remove this organization from Never use?",description:"Its sign-ins can run agents again.",change:{action:"remove-org",orgId:u.id}})]},u.id)),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(G,{htmlFor:"excluded-folder",children:"Folder"}),e.jsxs(te,{value:r,onValueChange:o,children:[e.jsx(ne,{id:"excluded-folder",children:e.jsx(ae,{placeholder:"Choose a folder"})}),e.jsx(ie,{children:d.filter(u=>u.identity.state!=="never-use"&&!c.some(x=>x.accountId===u.accountId)).map(u=>e.jsx(L,{value:u.accountId,children:u.name},u.accountId))})]}),e.jsx(Ke,{label:"Add a folder",title:"Never use this folder?",description:"DorkOS won’t open it or run agents on it, even at Full.",change:{action:"exclude-folder",accountId:r},disabled:!r})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(G,{htmlFor:"excluded-org-label",children:"Label"}),e.jsx(J,{id:"excluded-org-label",value:a,onChange:u=>i(u.target.value)}),e.jsx(G,{htmlFor:"excluded-org-id",children:"Organization ID"}),e.jsx(J,{id:"excluded-org-id",className:"font-mono","aria-describedby":"excluded-org-id-hint",value:t,onChange:u=>n(u.target.value)}),e.jsx("p",{id:"excluded-org-id-hint",className:"text-muted-foreground text-xs",children:"From Anthropic’s account settings. DorkOS won’t look it up."}),e.jsx(Ke,{label:"Add a sign-in",title:"Never use this organization?",description:"Sign-ins in it won’t run agents, even at Full.",change:{action:"add-org",orgId:t,label:a},disabled:!a.trim()||!t.trim()})]})]})]})}const kd={healthy:"success",delivered:"success",connected:"success",pending:"info",starting:"info",new:"info",reconnecting:"warning",degraded:"warning",warning:"warning",rate_limited:"warning",failed:"error",error:"error",disconnected:"error",inactive:"neutral",stopped:"neutral"};function Ot(s){return kd[s]??"neutral"}function wd(s){return Oe[Ot(s)]}function Cd(s){return qi[Ot(s)]}function Sd(s){return Bi[Ot(s)]}const Ad={delivered:"success",failed:"error",no_subscriber:"neutral",sent:"info",timeout:"neutral"};function Td(s){return Oe[Ad[s]]??Oe.neutral}function Od(s){return new Date(s).toLocaleTimeString()}function rn(s,t){if(s==null||t==null)return null;const n=new Date(t).getTime()-new Date(s).getTime();return n<1e3?`${n}ms`:`${(n/1e3).toFixed(1)}s`}function Ed({messageId:s,onClose:t}){const{data:n,isLoading:a,error:i}=Tl(s);if(a)return e.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading trace…"});if(i||!n)return e.jsx("div",{className:"text-destructive p-4 text-sm",children:"Couldn’t load where this message went."});const{traceId:r,spans:o}=n;return e.jsxs("div",{className:"flex flex-col gap-2 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-muted-foreground font-mono text-xs",children:["Trace: ",r.slice(0,8),"…"]}),t&&e.jsx("button",{onClick:t,className:"text-muted-foreground hover:text-foreground text-xs",children:"Close"})]}),e.jsx("div",{className:"border-border relative ml-3 border-l pl-6",children:o.map(l=>{const c=rn(l.sentAt,l.deliveredAt),d=rn(l.deliveredAt,l.processedAt);return e.jsxs("div",{className:"relative pb-4 last:pb-0",children:[e.jsx("div",{className:`absolute top-1 -left-[calc(1.5rem+0.3125rem)] h-2.5 w-2.5 rounded-full ${Td(l.status)}`}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:l.subject}),e.jsx("span",{className:"bg-muted rounded px-1.5 py-0.5 text-xs",children:l.status})]}),e.jsxs("div",{className:"text-muted-foreground flex gap-3 text-xs",children:[e.jsxs("span",{children:["Sent: ",Od(l.sentAt)]}),c&&e.jsxs("span",{children:["Delivery: ",c]}),d&&e.jsxs("span",{children:["Processing: ",d]})]}),l.errorMessage&&e.jsx("div",{className:"bg-destructive/10 text-destructive mt-1 rounded px-2 py-1 text-xs",children:l.errorMessage})]})]},l.id)})})]})}function zs(s){if(s.payload&&typeof s.payload=="object"){const n=s.payload;if(typeof n.adapterId=="string")return n.adapterId}const t=s.from.raw.match(/^relay\.human\.([^.]+)/);return t?t[1]:""}function on(s){if(s.payload&&typeof s.payload=="object"){const t=s.payload;if(typeof t.chatId=="string")return t.chatId}}function ln(s){if(s.payload&&typeof s.payload=="object"){const n=s.payload.channelType;if(n==="dm"||n==="group"||n==="channel"||n==="thread")return n}}const Rd={delivered:"Delivered",failed:"Error",pending:"Pending"};function cn(s){return new Date(s).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",second:"2-digit"})}function Dd(s){return s<1e3?`${s}ms`:`${(s/1e3).toFixed(1)}s`}function Id(s){return s.status==="delivered"?s.responseCount>0?`delivered · ${s.responseCount} chunks`:"delivered":s.failureReason??Rd[s.status].toLowerCase()}function Pd({conversation:s}){const[t,n]=m.useState(!1),[a,i]=m.useState(!1),[r,o]=m.useState(!1),[l,c]=m.useState(""),[d,u]=m.useState(!1),[x,h]=m.useState(!1),{data:p}=Wi(),f=m.useMemo(()=>(p==null?void 0:p.agents)??[],[p]),{mutate:g}=vo(),{data:v=[]}=Bn(),N=zs(s),j=m.useMemo(()=>v.filter(k=>k.adapterId===N),[v,N]),S=wd(s.status),E=Cd(s.status),A=Sd(s.status),O=m.useCallback(()=>{f.find(ee=>ee.id===l)&&(g({adapterId:zs(s),agentId:l,sessionStrategy:"per-chat",label:"",chatId:on(s),channelType:ln(s)}),c(""),u(!1))},[f,l,s,g]),w=m.useCallback(()=>{u(!1),h(!0)},[]),b=m.useCallback(k=>{g({adapterId:k.adapterId,agentId:k.agentId,sessionStrategy:k.sessionStrategy,label:k.label,chatId:k.chatId,channelType:k.channelType,canInitiate:k.canInitiate,canReply:k.canReply,canReceive:k.canReceive}),h(!1)},[g]);return e.jsxs("div",{className:P("hover:bg-muted/50 w-full rounded-lg border border-l-2 text-left transition-colors hover:shadow-sm",A,t&&"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-start gap-2 p-3",children:[e.jsxs("button",{type:"button",onClick:()=>n(!t),className:"flex min-w-0 flex-1 items-start gap-2",children:[e.jsx("span",{className:P("mt-1 size-2 shrink-0 rounded-full",S)}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"text-muted-foreground text-xs",children:[e.jsx("span",{className:"inline-block w-8 font-medium",children:"From"}),e.jsx("span",{className:"text-foreground",children:s.from.label})]}),e.jsxs("div",{className:"text-muted-foreground text-xs",children:[e.jsx("span",{className:"inline-block w-8 font-medium",children:"To"}),e.jsx("span",{className:"text-foreground",children:s.to.label})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[s.preview&&e.jsxs("span",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",children:["“",s.preview,"”"]}),e.jsx("span",{className:P("shrink-0 text-xs",E),children:Id(s)})]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:we(s.sentAt)}),e.jsxs(Hi,{open:d,onOpenChange:u,children:[e.jsx(Yi,{asChild:!0,children:e.jsxs(y,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:k=>k.stopPropagation(),"aria-label":"Route to agent",children:[e.jsx(jo,{className:"mr-1 size-3"}),"Route"]})}),e.jsxs(Vi,{className:"w-64 space-y-3 p-3",align:"end",children:[e.jsx("p",{className:"text-xs font-medium",children:"Route to agent"}),j.length>0&&e.jsx("div",{className:"rounded border border-blue-200 bg-blue-50 px-2 py-1.5 text-xs dark:border-blue-900 dark:bg-blue-950",children:e.jsxs("p",{className:"font-medium text-blue-800 dark:text-blue-200",children:["Already goes to ",j.length," ",j.length===1?"agent":"agents"]})}),e.jsxs(te,{value:l,onValueChange:c,children:[e.jsx(ne,{responsive:!1,className:"h-8 text-xs",children:e.jsx(ae,{placeholder:"Select agent"})}),e.jsx(ie,{children:f.map(k=>e.jsx(L,{value:k.id,children:Qi(k)},k.id))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"link",size:"sm",className:"h-6 px-0 text-xs",onClick:w,children:"More options…"}),e.jsx(y,{size:"sm",className:"h-7 text-xs",disabled:!l,onClick:O,children:"Add connection"})]})]})]})]})]}),x&&e.jsx(bo,{open:!0,onOpenChange:k=>{k||h(!1)},mode:"create",initialValues:{adapterId:zs(s),agentId:l||void 0,chatId:on(s),channelType:ln(s)},onConfirm:b}),e.jsx(_e,{initial:!1,children:t&&e.jsx(Te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:e.jsxs("div",{className:"space-y-3 border-t px-3 pt-3 pb-3",children:[s.payload!=null&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs font-medium",children:"Content"}),e.jsx("pre",{className:"bg-muted mt-1 max-h-40 overflow-auto rounded p-2 font-mono text-xs",children:JSON.stringify(s.payload,null,2)})]}),e.jsxs("div",{className:"text-muted-foreground text-xs",children:[e.jsxs("span",{children:["Sent ",cn(s.sentAt)]}),s.completedAt&&e.jsxs("span",{children:[" · Completed ",cn(s.completedAt)]}),s.durationMs!=null&&e.jsxs("span",{children:[" · Duration: ",Dd(s.durationMs)]}),s.responseCount>0&&e.jsxs("span",{children:[" · ",s.responseCount," reply parts"]})]}),s.failureReason&&e.jsx("div",{className:"bg-destructive/10 text-destructive rounded px-2 py-1 text-xs",children:s.failureReason}),e.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),i(!a)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[a?e.jsx(We,{className:"size-3.5"}):e.jsx(Be,{className:"size-3.5"}),"Technical details"]}),e.jsx(_e,{initial:!1,children:a&&e.jsx(Te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Subject"}),e.jsx("dd",{className:"truncate font-mono",children:s.subject}),s.sessionId&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Chat"}),e.jsx("dd",{className:"font-mono",children:s.sessionId.slice(0,8)})]}),s.traceId&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Trace ID"}),e.jsxs("dd",{className:"font-mono",children:[s.traceId.slice(0,12),"…"]})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Source"}),e.jsx("dd",{className:"truncate font-mono",children:s.from.raw}),e.jsx("dt",{className:"text-muted-foreground",children:"Destination"}),e.jsx("dd",{className:"truncate font-mono",children:s.to.raw})]})})}),s.traceId&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),o(!r)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[r?e.jsx(We,{className:"size-3.5"}):e.jsx(Be,{className:"size-3.5"}),"Trace timeline"]}),e.jsx(_e,{initial:!1,children:r&&e.jsx(Te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:e.jsx(Ed,{messageId:s.traceId,onClose:()=>o(!1)})})})]})]})})})]})}const Ld={hop_limit:"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400",ttl_expired:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",cycle_detected:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",budget_exhausted:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"},_d="bg-muted text-muted-foreground";function $d(s,t){const n=we(s),a=we(t);return n===a?a:`${n} to ${a}`}function Fd({group:s}){const[t,n]=m.useState(!1),a=Gi(),i=No[s.reason]??ko,r=Ld[s.reason]??_d;return e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50/50 p-3 dark:border-red-900/40 dark:bg-red-950/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Re,{className:"mt-0.5 size-4 shrink-0 text-red-500"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:s.source}),e.jsx(Z,{className:P("shrink-0 border-0 font-normal",r),children:i}),e.jsx(Z,{variant:"destructive",className:"shrink-0 tabular-nums",children:s.count.toLocaleString()})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:$d(s.firstSeen,s.lastSeen)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.sample!=null&&e.jsxs(e.Fragment,{children:[e.jsxs(y,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>n(!0),children:[e.jsx(Xi,{className:"mr-1 size-3"}),"See one"]}),e.jsx(rt,{open:t,onOpenChange:n,children:e.jsxs(ot,{className:"max-w-lg",children:[e.jsxs(qs,{children:[e.jsx(xs,{children:"What was sent"}),e.jsxs(hs,{children:["Never arrived: ",i,"."]})]}),e.jsx("pre",{className:"bg-muted max-h-80 overflow-auto rounded-md p-3 font-mono text-xs",children:JSON.stringify(s.sample,null,2)})]})})]}),e.jsxs(me,{children:[e.jsx(Me,{asChild:!0,children:e.jsxs(y,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-7 px-2 text-xs",disabled:a.isPending,children:[e.jsx(ps,{className:"mr-1 size-3"}),"Clear these"]})}),e.jsxs(xe,{children:[e.jsxs(re,{children:[e.jsx(oe,{children:"Clear these messages?"}),e.jsxs(le,{children:["Clears ",s.count," message",s.count!==1?"s":""," from"," ",e.jsx("span",{className:"font-medium",children:s.source})," (",i,"). They won’t be sent, and this can’t be undone."]})]}),e.jsxs(ce,{children:[e.jsx(de,{children:"Cancel"}),e.jsx(pe,{onClick:()=>a.mutate({source:s.source,reason:s.reason}),children:"Clear these"})]})]})]})]})]})})}function Md({enabled:s=!0}){const{data:t=[],isLoading:n}=Mn(s),{data:a}=St(),i=a==null?void 0:a.budgetRejections,r=i&&Object.values(i).some(o=>o>0);return n||t.length===0?null:e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-900 dark:bg-amber-950",children:e.jsxs("p",{className:"text-xs font-medium text-amber-800 dark:text-amber-200",children:["Not delivered: ",i.hopLimit," too many hand-offs,"," ",i.cycleDetected," loops, ",i.budgetExhausted," over limit,"," ",i.ttlExpired," expired"]})}),t.map(o=>e.jsx(Fd,{group:o},`${o.source}:${o.reason}`))]})}function zd({enabled:s}){const{data:t}=St();if(!s||!t)return null;const n=[{label:"Total",value:t.totalMessages,variant:"default"},{label:"Delivered",value:t.deliveredCount,variant:"success"},{label:"Errors",value:t.failedCount,variant:t.failedCount>0?"danger":"default"},{label:"No listener",value:t.noSubscriberCount,variant:"default"},{label:"Never arrived",value:t.deadLetteredCount,variant:t.deadLetteredCount>0?"warning":"default"}];return e.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[n.map(({label:a,value:i,variant:r})=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:a}),e.jsx("span",{className:P("font-medium tabular-nums",r==="success"&&i>0&&"text-status-success-fg",r==="danger"&&"text-destructive",r==="warning"&&"text-status-warning-fg"),children:i.toLocaleString()})]},a)),t.avgDeliveryLatencyMs!=null&&e.jsxs("div",{className:"ml-auto flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Avg"}),e.jsx("span",{className:"font-medium tabular-nums",children:t.avgDeliveryLatencyMs<1e3?`${Math.round(t.avgDeliveryLatencyMs)}ms`:`${(t.avgDeliveryLatencyMs/1e3).toFixed(1)}s`})]})]})}function Ud(s){return s.startsWith("relay.agent.")?"chat":s.startsWith("relay.system.tasks.")?"tasks":"system"}const Kd={initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}},qd={initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}};function Bd(s,t,n,a){return s.filter(i=>{if(t!=="all"&&Ud(i.subject)!==t||n!=="all"&&i.status!==n)return!1;if(a){const r=a.toLowerCase();if(!(i.from.label.toLowerCase().includes(r)||i.to.label.toLowerCase().includes(r)||i.preview.toLowerCase().includes(r)||i.subject.toLowerCase().includes(r)))return!1}return!0})}function Wd({enabled:s,deadLetterRef:t,onSwitchToIntegrations:n,autoShowFailures:a}){const[i,r]=m.useState("all"),[o,l]=m.useState("all"),[c,d]=m.useState(""),[u,x]=m.useState(null),{data:h,isLoading:p}=Rl(s),{data:f=[]}=Mn(s),g=m.useMemo(()=>(h==null?void 0:h.conversations)??[],[h==null?void 0:h.conversations]);f.length>0;const v=m.useRef(null);m.useEffect(()=>{g.length>0&&v.current===null&&(v.current=new Set(g.map(w=>w.id)))},[g]);const N=u!==null&&(u.afterAutoShow||!a)?u:null,j=N!==null,S=N!==null?N.open:!!a||f.length>0,E=i!=="all"||o!=="all"||c!=="",A=Bd(g,i,o,c);function O(){r("all"),l("all"),d("")}return p?e.jsx("div",{className:"space-y-2 p-4",children:[1,2,3].map(w=>e.jsx("div",{className:"rounded-lg border p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"bg-muted animate-breath size-4 rounded"}),e.jsx("div",{className:"bg-muted animate-breath h-4 w-40 rounded"}),e.jsx("div",{className:"bg-muted animate-breath ml-auto h-3 w-16 rounded"})]})},w))}):e.jsxs(e.Fragment,{children:[e.jsx(zd,{enabled:s}),e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(te,{value:i,onValueChange:w=>r(w),children:[e.jsx(ne,{className:"w-32",children:e.jsx(ae,{})}),e.jsxs(ie,{children:[e.jsx(L,{value:"all",children:"All sources"}),e.jsx(L,{value:"chat",children:"Chat messages"}),e.jsx(L,{value:"tasks",children:"Scheduled runs"}),e.jsx(L,{value:"system",children:"System"})]})]}),e.jsxs(te,{value:o,onValueChange:w=>l(w),children:[e.jsx(ne,{className:"w-32",children:e.jsx(ae,{})}),e.jsxs(ie,{children:[e.jsx(L,{value:"all",children:"All statuses"}),e.jsx(L,{value:"delivered",children:"Delivered"}),e.jsx(L,{value:"failed",children:"Error"}),e.jsx(L,{value:"pending",children:"Pending"})]})]}),e.jsxs(y,{variant:S?"secondary":"ghost",size:"sm",className:"relative",onClick:()=>{x({open:!S,afterAutoShow:a??!1})},"aria-pressed":S,"aria-label":"Show messages that never arrived",children:[e.jsx(Re,{className:"mr-1 size-3.5"}),"Never arrived",f.length>0&&!S&&j&&e.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full bg-red-500"})]}),e.jsx(J,{className:"h-9 w-44",placeholder:"Filter by agent or message…",value:c,onChange:w=>d(w.target.value),"aria-label":"Search chats"}),E&&e.jsx(y,{variant:"ghost",size:"sm",onClick:O,children:"Clear filters"}),e.jsx("div",{className:"ml-auto",children:e.jsx(wo,{})})]}),S&&e.jsx("div",{ref:t,children:e.jsx(Md,{enabled:s})}),A.length===0&&!E?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[e.jsx("div",{className:"pointer-events-none mb-2 w-full max-w-sm opacity-20 select-none",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"rounded-lg border p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"bg-muted size-4 rounded"}),e.jsx("div",{className:"bg-muted h-3 w-32 rounded"}),e.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"bg-muted size-4 rounded"}),e.jsx("div",{className:"bg-muted h-3 w-44 rounded"}),e.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"bg-muted size-4 rounded"}),e.jsx("div",{className:"bg-muted h-3 w-24 rounded"}),e.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})})]})}),e.jsx(Ji,{className:"text-muted-foreground/50 size-10"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"No activity yet"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Messages between your agents show up here."})]})]}):A.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[e.jsx(Zi,{className:"text-muted-foreground/50 size-10"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"No messages match your filters"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Try different filters."})]}),e.jsx(y,{variant:"ghost",size:"sm",onClick:O,children:"Clear filters"})]}):e.jsx("div",{className:"space-y-2",children:e.jsx(_e,{mode:"popLayout",children:A.map(w=>{const k=v.current!==null&&!v.current.has(w.id)?Kd:qd;return e.jsx(Te.div,{...k,children:e.jsx(Pd,{conversation:w})},w.id)})})})]})]})}const dn={healthy:Oe.success,degraded:Oe.warning,critical:Oe.error};function Hd(s){return s==null?"—":s<1?"<1ms":`${Math.round(s)}ms`}function Yd(s,t,n){const a=s.totalMessages>0?s.failedCount/s.totalMessages:0;if(n===0)return{state:"healthy",message:"No connections yet"};if(a>.5||t===0){const i=Math.round(a*100);return{state:"critical",message:`${s.failedCount} messages had errors today (${i}%)`}}if(t<n||a>=.05){const i=n-t;return i>0?{state:"degraded",message:`${i} connection${i>1?"s":""} disconnected`}:{state:"degraded",message:`${s.failedCount} error${s.failedCount!==1?"s":""} in the last day`}}return{state:"healthy",message:`${t} connection${t>1?"s":""} active`}}function Vd(s){const{data:t=[],isLoading:n}=An(s),a=t.flatMap(o=>o.instances),i=a.length,r=a.filter(o=>o.status.state==="connected").length;return{total:i,connected:r,isLoading:n}}function Qd({enabled:s=!0,onFailedClick:t}){const n=jt(),{data:a,isLoading:i}=St(),{total:r,connected:o,isLoading:l}=Vd(s&&n);if(!n||!s||i||l||!a)return null;const{state:c,message:d}=Yd(a,o,r),u=(c==="degraded"||c==="critical")&&t!=null,x=Hd(a.avgDeliveryLatencyMs),h=`${a.totalMessages} messages today · ${a.failedCount} errors · ${x} average delivery`;return e.jsx(er,{children:e.jsx("div",{className:"text-muted-foreground flex items-center gap-2 border-b px-3 py-1.5 text-xs",children:c==="healthy"?e.jsxs(sr,{children:[e.jsx(tr,{asChild:!0,children:e.jsxs("span",{className:"flex min-w-0 flex-1 cursor-default items-center gap-1.5",children:[e.jsx("span",{className:`size-2 shrink-0 rounded-full ${dn[c]}`,"aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:d}),a.avgDeliveryLatencyMs!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:x})]})]})}),e.jsx(nr,{side:"bottom",children:h})]}):e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:`size-2 shrink-0 rounded-full ${dn[c]}`,"aria-hidden":"true"}),u?e.jsx("button",{type:"button",onClick:t,className:"truncate text-left hover:underline","aria-label":`${d}. Show messages with problems`,children:d}):e.jsx("span",{className:"truncate",children:d})]})})})}function Gd(){const{data:s}=Jn();return s!=null&&s.newAgentRecordUnreadable?e.jsxs("div",{"data-testid":"permissions-record-unreadable",className:"text-muted-foreground rounded-md border px-3 py-2 text-sm",children:[e.jsx("p",{role:"status",children:"Some agents may do less than their own settings allow."}),e.jsxs(Ts,{className:"mt-1",children:[e.jsx("p",{children:"DorkOS couldn’t read its list of checked agents."}),e.jsx("p",{children:"Each agent gets the stricter of its own and everyone’s settings."}),e.jsx("p",{children:"It tries again when you add or remove an agent."})]})]}):null}function un(s){const t=s instanceof Error?s.message:"";return t&&!/^HTTP \d+$/.test(t)?t:"Couldn’t change that. Try again."}function Xd(s){var p,f;const t=F(),n=B(),[a,i]=m.useState(null),[r,o]=m.useState(null),l=Y({queryKey:Ut,queryFn:()=>t.listSessionRelayPasskeys(),enabled:s,retry:!1,refetchOnWindowFocus:!0}),c=((p=l.data)==null?void 0:p.keys)??[],d=ge({mutationFn:async g=>{try{const v=await g.send();if(!g.pending.go(v.approveUrl))throw new Error("Couldn’t open your browser. Try again.")}catch(v){throw g.pending.close(),v}},onMutate:()=>i(null),onSuccess:()=>o(c.length),gcTime:0,onError:g=>i(un(g))}),u=ge({mutationFn:g=>g(),onMutate:()=>i(null),onSuccess:g=>n.setQueryData(Ut,g),gcTime:0,onError:g=>i(un(g))}),x={onSettled:()=>d.reset()},h={onSettled:()=>u.reset()};return{keys:c,damaged:((f=l.data)==null?void 0:f.damaged)===!0,busy:d.isPending||u.isPending,waiting:r!==null&&c.length<=r,error:a,add:(g,v)=>{const N=ar();if(!N){i("Allow pop-ups for this page, then try again.");return}d.mutate({send:()=>t.startSessionRelayPasskey({label:g,password:v}),pending:N},x)},remove:(g,v)=>u.mutate(()=>t.removeSessionRelayPasskey(g,v),h),removeDamaged:g=>u.mutate(()=>t.removeDamagedSessionRelayPasskeys(g),h)}}function ya({prompt:s,onClose:t}){const n=m.useId(),[a,i]=m.useState(""),r=()=>{i(""),t()};return e.jsx(me,{open:s!==null,onOpenChange:o=>!o&&r(),children:e.jsx(xe,{children:e.jsxs("form",{className:"space-y-4",onSubmit:o=>{o.preventDefault(),s==null||s.run(a),r()},children:[e.jsxs(re,{children:[e.jsx(oe,{children:s==null?void 0:s.title}),e.jsx(le,{children:"Enter your password for this computer."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(G,{htmlFor:n,children:"Password"}),e.jsx(yt,{id:n,value:a,onChange:o=>i(o.target.value),autoComplete:"current-password"})]}),e.jsxs(ce,{children:[e.jsx(de,{type:"button",children:"Cancel"}),e.jsx(y,{type:"submit",disabled:!a,children:s==null?void 0:s.confirm})]})]})})})}function Jd({open:s,onClose:t,passkeys:n}){const a=m.useId(),i=m.useId(),[r,o]=m.useState(""),[l,c]=m.useState(""),d=()=>{o(""),c(""),t()};return e.jsx(me,{open:s,onOpenChange:u=>!u&&d(),children:e.jsx(xe,{children:e.jsxs("form",{className:"space-y-4",onSubmit:u=>{u.preventDefault(),n.add(r.trim(),l),d()},children:[e.jsxs(re,{children:[e.jsx(oe,{children:"Add a passkey"}),e.jsx(le,{children:"Your browser opens to create it. Then come back here."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(G,{htmlFor:a,children:"Name"}),e.jsx(J,{id:a,value:r,onChange:u=>o(u.target.value),placeholder:"MacBook passkey",maxLength:64,autoComplete:"off"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(G,{htmlFor:i,children:"Your password for this computer"}),e.jsx(yt,{id:i,value:l,onChange:u=>c(u.target.value),autoComplete:"current-password"})]}),e.jsxs(ce,{children:[e.jsx(de,{type:"button",children:"Cancel"}),e.jsx(y,{type:"submit",disabled:!r.trim()||!l,children:"Continue"})]})]})})})}function Zd(){const s=Xd(!0),[t,n]=m.useState(!1),[a,i]=m.useState(null);return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ya,{prompt:a,onClose:()=>i(null)}),e.jsx(Jd,{open:t,onClose:()=>n(!1),passkeys:s}),s.damaged?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-destructive text-xs",children:"Passkey file is damaged. Remove it to start again."}),e.jsx(y,{variant:"outline",size:"sm",disabled:s.busy,onClick:()=>i({title:"Remove the damaged passkey file?",confirm:"Remove",run:s.removeDamaged}),children:"Remove"})]}):s.keys.length===0?e.jsx("p",{className:"text-muted-foreground text-xs",children:"No passkeys yet."}):e.jsx("ul",{className:"space-y-1","data-testid":"approval-passkeys",children:s.keys.map(r=>e.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsxs("span",{className:"min-w-0 truncate",children:[r.label,e.jsxs("span",{className:"text-muted-foreground ml-2 font-mono text-xs",children:["…",r.credentialId.slice(-6)]})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[e.jsxs("span",{className:"text-muted-foreground text-xs",children:["Added ",we(r.addedAt)]}),e.jsx(y,{variant:"ghost",size:"sm",disabled:s.busy,"aria-label":`Remove ${r.label}`,onClick:()=>i({title:"Remove this passkey?",confirm:"Remove",run:o=>s.remove(r.credentialId,o)}),children:"Remove"})]})]},r.credentialId))}),e.jsx(y,{variant:"outline",size:"sm",disabled:s.busy||s.damaged,onClick:()=>n(!0),children:"Add a passkey"}),s.waiting&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Finish in your browser. This list updates when you return."}),s.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:s.error})]})}function eu({atThisComputer:s}){const t=ir();return e.jsxs("div",{className:"space-y-1.5","data-testid":"approval-passkeys-section",children:[e.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:"Approvals from the web"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Approve tool calls from your hub with a passkey made for this computer."}),t||!s?e.jsx("p",{className:"text-muted-foreground text-xs",children:"Manage passkeys at this computer."}):e.jsx(Zd,{})]})}function su(s){if(!s)return"";try{return new URL(s).host}catch{return s}}function tu({access:s,status:t}){const n=m.useId(),a=m.useId(),i=m.useId(),[r,o]=m.useState(""),[l,c]=m.useState(t.suggestedName),[d,u]=m.useState(""),x=!s.canChange||s.busy;return e.jsxs("form",{className:"space-y-3",onSubmit:h=>{h.preventDefault(),s.link({linkCode:r.trim(),computerName:l.trim(),password:d}),u("")},children:[e.jsx("p",{className:"text-sm",children:"Your DorkOS account, or DorkOS itself, can run commands here through your agents."}),e.jsxs(Qe,{children:[e.jsxs(Ge,{className:"text-muted-foreground hover:text-foreground group flex items-center gap-1 text-xs",children:[e.jsx(Be,{className:"size-3 transition-transform group-data-[state=open]:rotate-90"}),"Learn more"]}),e.jsx(Xe,{children:e.jsx("p",{className:"text-muted-foreground pt-1 text-xs",children:"Chats pass through the hub that made this code. Turn this off here anytime."})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(G,{htmlFor:n,children:"Link code"}),e.jsx(J,{id:n,value:r,onChange:h=>o(h.target.value),placeholder:"XXXX-XXXX-XXXX-XXXX@your-hub",autoComplete:"off",spellCheck:!1,disabled:x})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(G,{htmlFor:a,children:"Name for this computer"}),e.jsx(J,{id:a,value:l,onChange:h=>c(h.target.value),maxLength:64,disabled:x})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(G,{htmlFor:i,children:"Your password for this computer"}),e.jsx(yt,{id:i,value:d,onChange:h=>u(h.target.value),autoComplete:"current-password",disabled:x})]}),e.jsx(y,{type:"submit",size:"sm",disabled:x||!r.trim()||!l.trim()||!d,children:"Link"})]})}function mn({value:s,title:t,description:n,disabled:a,comingSoon:i}){const r=m.useId();return e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Hs,{value:s,id:r,disabled:a,className:"mt-0.5"}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(G,{htmlFor:r,className:P("text-sm",a&&"opacity-60"),children:[t,i&&e.jsx(Z,{variant:"secondary",className:"ml-2",children:"Coming soon"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:n})]})]})}function nu(s){return s.paused?"Paused":s.connected?"Connected":"Not connected"}function au({access:s,status:t}){const n=!s.canChange||s.busy,[a,i]=m.useState(null);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ya,{prompt:a,onClose:()=>i(null)}),e.jsxs("div",{children:[e.jsx("p",{className:"truncate text-sm",children:su(t.hubOrigin)}),e.jsx("p",{className:"text-muted-foreground text-xs",children:nu(t)})]}),e.jsxs(Pn,{value:t.level,onValueChange:r=>r==="full"?i({title:"Allow Full control from the web?",confirm:"Allow",run:o=>s.setLevel("full",o)}):s.setLevel(r),"aria-label":"What the web can do here",disabled:n,children:[e.jsx(mn,{value:"chat",title:"Chat",description:"Read and send messages. Questions and approvals wait for you here.",disabled:n}),e.jsx(mn,{value:"full",title:"Full control",description:"Also open the terminal, files and settings from the web.",disabled:!0,comingSoon:!0})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",disabled:n,onClick:()=>t.paused?i({title:"Resume chat from the web?",confirm:"Resume",run:s.resume}):s.pause(),children:t.paused?"Resume":"Pause"}),e.jsxs(me,{children:[e.jsx(Me,{asChild:!0,children:e.jsx(y,{variant:"outline",size:"sm",disabled:n,children:"Unlink"})}),e.jsxs(xe,{children:[e.jsxs(re,{children:[e.jsx(oe,{children:"Unlink from your hub?"}),e.jsx(le,{children:"Chatting from the web stops now. You can link again anytime."})]}),e.jsxs(ce,{children:[e.jsx(de,{children:"Cancel"}),e.jsx(pe,{onClick:s.unlink,children:"Unlink"})]})]})]})]})]})}function iu({className:s}){const t=ao(),n=t.status,a=io((n==null?void 0:n.linked)===!0);return!t.available||!n?null:e.jsxs("section",{"aria-labelledby":"web-access-title",className:P("border-border bg-muted/30 space-y-3 rounded-lg border p-4",s),children:[e.jsx("p",{id:"web-access-title",className:"text-sm font-medium",children:"Chat from the web"}),!t.canChange&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Change this on the computer DorkOS runs on."}),n.linked?e.jsxs(e.Fragment,{children:[e.jsx(au,{access:t,status:n}),e.jsx(ro,{devices:a}),e.jsx(eu,{atThisComputer:t.atThisComputer})]}):e.jsx(tu,{access:t,status:n}),t.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:t.error})]})}const va="/sw.js",Us=["push","subscriptions"],ru=["push","vapid-public-key"],Et="dorkos.push.device-id";function ou(){var j,S;const s=F(),t=B(),[n,a]=m.useState(null),[i,r]=m.useState(xn),o=lu(),l=Y({queryKey:[...ru],queryFn:()=>s.getPushVapidPublicKey(),enabled:o==="available",staleTime:1/0}),c=Y({queryKey:[...Us],queryFn:()=>s.listPushSubscriptions()}),d=ge({mutationFn:async E=>{const A=await cu(E);return s.registerPushSubscription(A)},onSuccess:E=>{xu(E.subscription.id),r(E.subscription.id),t.invalidateQueries({queryKey:[...Us]})},meta:{suppressErrorToast:!0}}),u=ge({mutationFn:E=>s.deletePushSubscription(E),onSuccess:(E,A)=>{xn()===A&&(hn(),r(null),du()),t.invalidateQueries({queryKey:[...Us]})},meta:{suppressErrorToast:!0}}),x=(j=c.data)==null?void 0:j.subscriptions,h=x!==void 0&&i!==null&&!x.some(E=>E.id===i),p=h?null:i;m.useEffect(()=>{h&&hn()},[h]);const f=((S=l.data)==null?void 0:S.key)??null,g=m.useCallback(async()=>{if(a(null),f===null){a("Couldn’t set up notifications on this computer. Try again later.");return}try{await d.mutateAsync(f)}catch(E){a(uu(E))}},[d,f]),v=m.useCallback(async E=>{a(null);try{await u.mutateAsync(E)}catch{a("Couldn’t remove that device. Try again.")}},[u]);return{availability:o!=="available"?o:l.isSuccess&&f===null?"server-unavailable":"available",devices:x??[],devicesLoaded:c.isSuccess,localDeviceId:p,subscribe:g,remove:v,isPending:d.isPending||u.isPending,error:n}}function lu(){return ht()?"desktop-shell":typeof window>"u"||typeof navigator>"u"||!("serviceWorker"in navigator)||!("PushManager"in window)?"unsupported":window.isSecureContext===!1?"insecure-context":"available"}async function cu(s){var c,d;const t=await navigator.serviceWorker.register(va,{scope:"/"});await navigator.serviceWorker.ready;const n=await Notification.requestPermission();if(n!=="granted")throw new ba(n);const r=(await t.pushManager.getSubscription()??await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:mu(s)})).toJSON(),o=(c=r.keys)==null?void 0:c.p256dh,l=(d=r.keys)==null?void 0:d.auth;if(typeof r.endpoint!="string"||!o||!l)throw new Error("This browser produced a subscription DorkOS cannot use.");return{endpoint:r.endpoint,keys:{p256dh:o,auth:l}}}async function du(){try{const s=await navigator.serviceWorker.getRegistration(va),t=await(s==null?void 0:s.pushManager.getSubscription());await(t==null?void 0:t.unsubscribe())}catch{}}class ba extends Error{constructor(t){super(`Notification permission was ${t}`),this.permission=t,this.name="PushPermissionError"}}function uu(s){return s instanceof ba?s.permission==="denied"?"Your browser blocks notifications from DorkOS. Allow them in this site’s settings.":"Allow notifications so DorkOS can reach this device.":"Couldn’t set up this device for notifications. Try again."}function mu(s){const t=s.padEnd(s.length+(4-s.length%4)%4,"="),n=atob(t.replace(/-/g,"+").replace(/_/g,"/")),a=new Uint8Array(new ArrayBuffer(n.length));for(let i=0;i<n.length;i+=1)a[i]=n.charCodeAt(i);return a}function xn(){try{return window.localStorage.getItem(Et)}catch{return null}}function xu(s){try{window.localStorage.setItem(Et,s)}catch{}}function hn(){try{window.localStorage.removeItem(Et)}catch{}}const hu=[{value:1,label:"1 min"},{value:2,label:"2 min"},{value:5,label:"5 min"},{value:15,label:"15 min"},{value:"never",label:"Never"}];function pu(s){return s==="never"?"never":Number(s)}function gu(){const{prefs:s,setPrefs:t,isPending:n}=qn(),a=ou(),i=Bn(),r=(i.data??[]).some(c=>c.enabled&&c.canInitiate),o=s.escalation.phoneAfterMinutes==="never",l=a.devicesLoaded&&i.isSuccess;return e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{orientation:"vertical",label:"Reach you elsewhere after",description:"DorkOS pings your devices and chat apps. Answering one quiets the rest.",children:e.jsx(As,{value:String(s.escalation.phoneAfterMinutes),onValueChange:c=>t({escalation:{phoneAfterMinutes:pu(c)}}),disabled:n,"aria-label":"Wait before reaching you elsewhere",children:hu.map(c=>e.jsx(Fe,{value:String(c.value),children:c.label},String(c.value)))})}),l&&!o&&a.devices.length===0&&!r&&e.jsx("p",{className:"text-muted-foreground text-xs",role:"status",children:"Nothing can reach you yet. Add this device, or a chat app in Connections."}),e.jsx(_,{orientation:"vertical",label:"Devices DorkOS can reach",description:fu(a.availability),children:e.jsxs("div",{className:"w-full space-y-3",children:[a.devices.length>0&&e.jsx("ul",{className:"divide-border divide-y","aria-label":"Subscribed devices",children:a.devices.map(c=>e.jsxs("li",{className:"flex items-center justify-between gap-4 py-2 first:pt-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm",children:ju(c,a.localDeviceId)}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Added ",we(c.createdAt)]})]}),e.jsx(y,{variant:"ghost",size:"sm",disabled:a.isPending,onClick:()=>void a.remove(c.id),children:"Remove"})]},c.id))}),a.availability==="available"&&a.localDeviceId===null&&e.jsx(y,{variant:"outline",size:"sm",disabled:a.isPending,onClick:()=>void a.subscribe(),children:"Add this device"}),a.error!==null&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:a.error})]})})]})})}function fu(s){switch(s){case"available":return"Added browsers get notified even when DorkOS is closed. Add your phone’s browser.";case"desktop-shell":return"The desktop app shows its own notifications. Add your phone’s browser instead.";case"unsupported":return"This browser can’t get notifications while DorkOS is closed. Other devices still work.";case"insecure-context":return"This needs a secure connection. Open DorkOS at localhost or over HTTPS.";case"server-unavailable":return"DorkOS couldn’t set up notifications on this computer. No device can be added now."}}function ju(s,t){return s.id===t?"This device":s.service==="unknown"?"Another device":`Another device (${s.service})`}function yu(){return e.jsx(Kr,{})}function vu({onClick:s}){return e.jsx("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"})}function bu(){const{setTheme:s}=vt(),t=Ee(n=>n.resetAppearance);return e.jsx(vu,{onClick:()=>{t(),s("system")}})}function Nu(){const{theme:s,setTheme:t}=vt(),{fontFamily:n,setFontFamily:a,fontSize:i,setFontSize:r}=Ee();return e.jsx("div",{className:"space-y-4",children:e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Theme",children:e.jsxs(te,{value:s,onValueChange:t,children:[e.jsx(ne,{className:"w-32",children:e.jsx(ae,{})}),e.jsxs(ie,{children:[e.jsx(L,{value:"light",children:"Light"}),e.jsx(L,{value:"dark",children:"Dark"}),e.jsx(L,{value:"system",children:"System"})]})]})}),e.jsx(_,{label:"Font family",children:e.jsxs(te,{value:n,onValueChange:o=>a(o),children:[e.jsx(ne,{className:"w-40",children:e.jsx(ae,{})}),e.jsx(ie,{children:rr.map(o=>e.jsx(L,{value:o.key,children:e.jsxs("div",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"truncate",children:o.displayName}),e.jsx("span",{className:"text-muted-foreground truncate text-xs",children:o.description})]})},o.key))})]})}),e.jsx(_,{label:"Font size",children:e.jsxs(te,{value:i,onValueChange:o=>r(o),children:[e.jsx(ne,{className:"w-32",children:e.jsx(ae,{})}),e.jsxs(ie,{children:[e.jsx(L,{value:"small",children:"Small"}),e.jsx(L,{value:"medium",children:"Medium"}),e.jsx(L,{value:"large",children:"Large"})]})]})})]})})})}function ku(){const{prefs:s,setPrefs:t,isPending:n}=qn(),{permission:a,request:i}=Wr(),r=ht(),[o,l]=m.useState(!1);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Knock when an agent needs you",description:"Plays when something waits on you.",checked:s.sounds.knock,onCheckedChange:c=>t({sounds:{knock:c}}),disabled:n}),e.jsx($,{label:"Chime when everything is answered",description:"Plays when nothing is waiting.",checked:s.sounds.allClear,onCheckedChange:c=>t({sounds:{allClear:c}}),disabled:n}),e.jsx($,{label:"Chime every time a turn finishes",description:"Every reply. Noisy with many agents.",checked:s.sounds.turnEnd,onCheckedChange:c=>t({sounds:{turnEnd:c}}),disabled:n})]})}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Notifications from your browser",description:wu(a,r),children:!r&&a==="default"&&e.jsx(y,{variant:"outline",size:"sm",onClick:()=>void i(),children:"Turn on"})}),e.jsx($,{label:"Notify when work finishes while you’re away",description:"Anything waiting on you always gets through.",checked:s.notifyOnTurnCompleteWhileAway,onCheckedChange:c=>t({notifyOnTurnCompleteWhileAway:c}),disabled:n})]})}),e.jsx(gu,{}),e.jsx(Ze,{open:o,onOpenChange:l,trigger:"Get these on your phone",children:e.jsxs("ol",{className:"text-muted-foreground list-decimal space-y-1.5 pl-4 text-xs",children:[e.jsx("li",{children:"Open DorkOS on your phone, at your Remote access address."}),e.jsx("li",{children:"Choose “Add to Home Screen”. iPhone needs this for notifications."}),e.jsx("li",{children:"Open Settings there and add it as a device above."})]})})]})}function wu(s,t){return t?"The desktop app shows its own notifications.":s==="granted"?"Allowed, even while this tab is hidden.":s==="denied"?"Blocked. Change it in your browser’s settings for this site.":s==="unsupported"?"This browser cannot show notifications.":"Not turned on yet."}const Cu=[{key:"maxAgentDepth",label:"Replies in a row",description:`Agents pause after this many replies in a row. Default: ${ls.maxAgentDepth}.`,details:["Your next message starts the count over.","Set it to 0 to stop automatic replies."],min:Ie.maxAgentDepth.min,max:Ie.maxAgentDepth.max},{key:"maxTurnsPerAgentPerCascade",label:"Replies from one agent",description:`Most turns one agent takes in one back-and-forth. Default: ${ls.maxTurnsPerAgentPerCascade}.`,details:["Progress notes an agent posts while it works don’t count extra."],min:Ie.maxTurnsPerAgentPerCascade.min,max:Ie.maxTurnsPerAgentPerCascade.max},{key:"maxAutomaticTurnsPerRoomPerHour",label:"Replies in one room each hour",description:`Most automatic replies one room runs in an hour. Default: ${ls.maxAutomaticTurnsPerRoomPerHour}.`,details:["It keeps one busy room from using up the whole allowance below."],min:Ie.maxAutoTurnsPerHour.min,max:Ie.maxAutoTurnsPerHour.max},{key:"maxAutomaticTurnsTotalPerHour",label:"Replies everywhere each hour",description:`Most automatic replies across all rooms in an hour. Default: ${ls.maxAutomaticTurnsTotalPerHour}.`,details:["This caps what automatic replies can cost you.","No room can set its own."],min:Ft.min,max:Ft.max}],pn="Chats at once";function Su(){const{limits:s,unsupported:t,loadError:n,maxConcurrentTurnsPerAgent:a,setLimits:i}=or();return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"How far agents reply to each other, and how many chats each runs."}),e.jsxs(Ts,{className:"text-xs",children:[e.jsx("p",{children:"Every message you send starts the reply counts over."}),e.jsx("p",{children:"A room can have limits of its own, in the panel beside it."})]})]}),s===null?e.jsx(R,{children:e.jsx(D,{children:n!==null?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t load these settings. Close Settings and open it again."}):t?e.jsx("p",{className:"text-muted-foreground text-sm",children:"This version of DorkOS doesn’t have these settings. Update to change them."}):[0,1,2,3,4].map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsx(se,{className:"h-4 w-40"}),e.jsx(se,{className:"h-3 w-full max-w-xs"})]}),e.jsx(se,{className:"h-9 w-24"})]},r))})}):e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Limit automatic replies",description:s.turnLimitsEnabled?"Agents pause when they reach a limit below.":"Agents reply to each other without limit until you press Stop.",checked:s.turnLimitsEnabled,onCheckedChange:r=>i({turnLimitsEnabled:r})}),Cu.map(r=>e.jsx(_,{orientation:"vertical",label:r.label,description:e.jsxs(e.Fragment,{children:[r.description," ",e.jsx(Ye,{label:`About ${r.label.toLowerCase()}`,children:r.details.map(o=>e.jsx("p",{children:o},o))})]}),children:e.jsx(fs,{"aria-label":r.label,value:s[r.key],min:r.min,max:r.max,disabled:!s.turnLimitsEnabled,onCommit:o=>i({[r.key]:o})})},r.key))]})}),s!==null&&a!==null&&e.jsx(R,{children:e.jsx(D,{children:e.jsx(_,{orientation:"vertical",label:pn,description:e.jsxs(e.Fragment,{children:[`How many chats one agent works in at once. Default: ${lr}.`," ",e.jsx(Ye,{label:"About chats at once",children:e.jsx("p",{children:"Higher is faster, but turns that change the same files can collide."})})]}),children:e.jsx(fs,{"aria-label":pn,value:a,min:Mt.min,max:Mt.max,onCommit:r=>i({maxConcurrentTurnsPerAgent:r})})})})})]})}function Au(){const s=fe(),t=cr(),n=dr(),a=jt();Yn(s.section);const i=()=>{s.close(),n()};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Access and chat app settings. Your apps are on the"," ",e.jsx(y,{variant:"link",className:"h-auto p-0 text-xs",onClick:i,children:"Connections page"}),"."]}),e.jsxs("section",{"data-section":"ways","aria-labelledby":"settings-connection-ways",className:"space-y-3",children:[e.jsx("h3",{id:"settings-connection-ways",className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"How DorkOS reaches your apps"}),e.jsx($l,{onManageAccount:()=>{t.onValueChange("account")},onOpenConnectionsPage:i})]}),e.jsxs("section",{"data-section":"chat-apps","aria-labelledby":"settings-chat-apps",className:"space-y-3",children:[e.jsx("h3",{id:"settings-chat-apps",className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Chat apps"}),e.jsx(ql,{}),a&&e.jsxs(Qe,{children:[e.jsx(Ge,{className:"text-muted-foreground hover:text-foreground focus-ring rounded-md text-sm font-medium",children:"Message history"}),e.jsxs(Xe,{className:"space-y-3 pt-3",children:[e.jsx(Qd,{enabled:!0}),e.jsx(Wd,{enabled:!0})]})]})]})]})}function Tu(){const{data:s}=Jn(),t=ja();return s?e.jsxs(e.Fragment,{children:[e.jsx(To,{files:s.filesAndCommands,preset:s.preset,onChange:n=>t.changeTrustStop(null,n),disabled:t.isPending,runtimeLabel:n=>je(n).label}),t.writeError?e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:t.writeError}):null]}):null}function Ou(){const s=zn(),{close:t}=fe();return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Gd,{}),e.jsx(R,{children:e.jsx(D,{className:"@container space-y-2",children:e.jsx(oo,{surface:"settings"})})}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"What agents may do"}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Allowed runs without asking. Ask waits for your yes. Blocked is refused."," ",Co," ",qt[0]," ",qt[1]]}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(Tu,{}),e.jsx(So,{scope:{kind:"default"}})]})})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"History"}),e.jsx(R,{children:e.jsx(D,{children:e.jsx(Ao,{})})})]}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Connected accounts have their own permissions, in"," ",e.jsx(y,{variant:"link",size:"sm",className:"h-auto p-0 text-sm",onClick:()=>{t(),s({...Un.connections()})},children:"Connections"}),"."]})]})}function Na(s,t){return(s==null?void 0:s.enabled)===!0&&s.runtimes[t]==="wired"}function Eu(s,t){var n,a;return((a=(n=s==null?void 0:s.defaults)==null?void 0:n[t])==null?void 0:a.runsOn)==="credits"||Na(s,t)}function Ru(s,t,n){const a=t==="runtime"?`A change moves every ${s} chat, so it can't be made while ${s} is in the middle of a reply.`:`A change applies to new ${s} chats. One already going stays on what it started on.`;return n?`DorkOS chose credits when you linked, because ${s} had no sign-in. ${a}`:a}function Du({type:s,runsOn:t,chosenByDorkos:n,scope:a,caveat:i,canChooseCredits:r,pending:o,failure:l,onChange:c}){const d=ft(s);return e.jsxs("section",{className:"bg-muted/30 space-y-3 rounded-lg border p-3","data-testid":"credits-runs-on-section",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Runs on"}),e.jsxs(As,{"aria-label":`What ${d} runs on`,className:"w-full",value:t,disabled:o,onValueChange:u=>c(u),children:[e.jsx(Fe,{value:"own-sign-in",children:e.jsxs("span",{className:"truncate",children:["Your ",d," sign-in"]})}),e.jsx(Fe,{value:"credits",disabled:!r&&t!=="credits",children:e.jsx("span",{className:"truncate",children:_n})})]}),e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"credits-runs-on-note",children:t==="credits"&&!r?`${d} can’t run on credits now, so new work stops. Switch to your own sign-in.`:Ru(d,a,n)}),i?e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"credits-runs-on-caveat",children:i}):null,l!==null&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:l})]})}function Iu({type:s}){var l,c;const{data:t}=ks(),n=ws(),a=(l=ur(s))==null?void 0:l.credits,i=a==null?void 0:a.scope;if(!Eu(t,s))return null;const r=(c=t==null?void 0:t.defaults)==null?void 0:c[s],o=(r==null?void 0:r.runsOn)==="credits"?"credits":"own-sign-in";return e.jsx(Du,{type:s,runsOn:o,chosenByDorkos:o==="credits"&&(r==null?void 0:r.chosenBy)==="default",scope:i,...a!=null&&a.caveat?{caveat:a.caveat}:{},canChooseCredits:Na(t,s),pending:n.isPending,failure:n.isError?`Couldn’t change that. ${Tn(n.error)??"Try again in a moment."}`:null,onChange:d=>{d!==o&&n.mutate({runtime:s,useCredits:d==="credits"})}})}function Pu({type:s}){const{byId:t,byPath:n}=pt(s),a=t.get(ke)??n.values().next().value;return ha(a)?e.jsxs("section",{className:"bg-muted/30 space-y-3 rounded-lg border p-3","aria-label":`${je(s).label} usage`,children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Usage"}),e.jsx(ga,{usage:a})]}):null}const Ks={"claude-accounts":()=>e.jsx(hd,{}),"credits-runs-on":({type:s})=>e.jsx(Iu,{type:s}),"opencode-power-source":({type:s})=>e.jsx(jd,{type:s}),"runtime-usage":({type:s})=>e.jsx(Pu,{type:s})};function Lu(s,t){var n;return((n=Ks[s])==null?void 0:n.call(Ks,t))??null}function _u(s){const t=F(),{data:n}=Y({queryKey:["doe-inference"],queryFn:()=>t.getDoeInference(),enabled:s}),a=(n==null?void 0:n.autoProtocol)??null,i=!s||n===void 0?null:n.inference!==null?"own":a!==null?"credits":"none",{data:r}=Y({queryKey:["doe-credits-models",a],queryFn:()=>t.getDoeCreditsModels(a??"anthropic-messages"),enabled:i==="credits"});return{state:i,models:r==null?void 0:r.models.map(o=>({value:o.id,displayName:o.displayName,description:"",contextWindow:o.contextWindow,maxOutputTokens:o.maxOutputTokens,paidFromCredits:!0}))}}const $u="a model chosen by DorkOS";function Fu(s){switch(s){case"credits":return{inheritLabel:Fo,description:"Which model new chats start on."};case"own":return{description:"Change it in the DorkOS setup."};case"none":return{inheritLabel:"None yet",description:"Connect AI to choose a model."};case null:return{}}}const Mu={login:{id:"reconnect",cancelLabel:"Keep current sign-in"},"provider-picker":{id:"change",cancelLabel:"Keep current source"}};function zu(s,t){return fr(s)==="provider-picker"?t?{kind:"provider-picker",connect:{kind:"provider-picker",label:"Change power source"},currentProvider:t}:null:jr.includes(s)?{kind:"login",connect:{kind:"login",label:`Reconnect ${ft(s)}`}}:null}function Uu(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function Ku({type:s,isDefault:t,trustStop:n,globalStop:a,onChangeTrustStop:i,onMakeDefault:r}){var Dt,It,Pt,Lt,_t;const{data:o}=Se(),{nameFor:l,resolvedAccount:c,inherited:d}=Cs();pt(mr.includes(s)?s:null,{fetch:!0});const{data:u}=Je(),{data:x}=gt(),{registered:h}=xr(s),p=ye(),f=B(),g=F(),[v,N]=m.useState(!1),[j,S]=m.useState(!1),[E,A]=m.useState(null),[O,w]=m.useState(!1),b=hr(x,s,h),k=b.state==="ready",ee=Do(),V=_u(s==="doe"&&ee),M=V.state==="credits"&&k,z=je(s),W=Zn(u,s),T=(Dt=o==null?void 0:o.executionDefaults)==null?void 0:Dt.perRuntime.find(U=>U.runtime===s),K=(T==null?void 0:T.model)??null,I=x==null?void 0:x.runtimes[s],ve=pr(x,s),{data:De}=Y({...gr(g,{runtime:s}),enabled:k&&(v||K!==null)});function ss(U){A(null),p.mutate({runtimes:U},{onSuccess:()=>{f.invalidateQueries({queryKey:Q.all}),w(!0)},onError:rs=>A(Uu(rs))})}const ts=W?W.configSection!==null:!0,he=W===void 0;function ns(U){const rs=W==null?void 0:W.configSection;rs&&ss({[rs]:U})}const Os=n??a,Es={"claude-accounts":!(o==null?void 0:o.claudeCode)||d||!c?null:l(c),"opencode-power-source":I!=null&&I.provider?ea(I.provider):null},Ue=K?(De??[]).find(U=>U.value===K):void 0,as=Zc({ready:k,settings:W,model:K,models:M?V.models:De,...M?{inheritModelLabel:$u}:{},effort:T==null?void 0:T.effort,modelTakesEffort:Ue?Ue.supportsEffort??!1:void 0,trustStop:Os,trustInherited:n===null,sectionValues:Es}),be=I==null?void 0:I.dependencies.find(U=>U.status!=="satisfied"&&U.installHint),C=(be==null?void 0:be.installHint)??((It=z.setup)==null?void 0:It.installCommand),q=(be==null?void 0:be.infoUrl)??((Pt=z.setup)==null?void 0:Pt.infoUrl),X=!k&&b.connect?e.jsx("div",{"data-testid":`runtime-card-connect-${s}`,children:b.connect.kind==="install"?e.jsx(qu,{type:s,label:b.connect.label,installCommand:C,installInfoUrl:q}):Vs({type:s,connect:b.connect})}):null,H=k?zu(s,I==null?void 0:I.provider):null;!H&&j&&S(!1);const is=H?Mu[H.kind]:null,ka=H&&is&&j?e.jsxs("div",{className:"space-y-2","data-testid":`runtime-${is.id}-panel-${s}`,children:[Vs({type:s,connect:H.connect,...H.currentProvider?{currentProvider:H.currentProvider}:{},onConnected:()=>S(!1)}),e.jsx("button",{type:"button",onClick:()=>S(!1),className:"focus-ring text-muted-foreground hover:text-foreground rounded-sm text-xs transition-colors","data-testid":`runtime-${is.id}-cancel-${s}`,children:is.cancelLabel})]}):null,wa=I?I.dependencies.map(U=>e.jsx(Bu,{dep:U},U.name)):z.setup?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Not set up here. Install it, then turn on ",e.jsxs(Eo,{children:["runtimes.",s]})," in your DorkOS config."]}),e.jsx(kt,{command:z.setup.installCommand,infoUrl:z.setup.infoUrl,copyLabel:`Copy install command for ${z.label}`})]}):void 0,Ae=I==null?void 0:I.dependencies.filter(U=>U.status!=="satisfied"),Ca=I?e.jsx(Z,{variant:"secondary",className:P("text-xs",Ae!=null&&Ae.length?"text-status-warning-fg":""),children:Ae!=null&&Ae.length?`${Ae.length} missing`:`${I.dependencies.length} ${I.dependencies.length===1?"check":"checks"}`}):void 0;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(Qc,{type:s,...z.subtitle?{subtitle:z.subtitle}:{},ready:k,isDefault:t,onMakeDefault:r,expanded:v,onToggleExpanded:()=>N(U=>!U),summary:as,...ve?{expiringSignIn:ve}:{},connectSlot:X,...H&&!j?{reconnect:{kind:H.kind,onOpen:()=>S(!0)}}:{},reconnectPanel:ka,model:{models:M?V.models:De,value:K,onChange:U=>ns({defaultModel:U}),disabled:he||s==="doe"&&!M,...Fu(V.state==="credits"&&!k?"none":V.state)},effort:{supportsEffort:(W==null?void 0:W.supportsEffort)??!0,selectedModel:Ue,configuredModelId:K,value:(T==null?void 0:T.effort)??null,onChange:U=>ns({defaultEffort:U}),disabled:he},trust:{descriptors:((_t=(Lt=u==null?void 0:u.capabilities[s])==null?void 0:Lt.permissionModes)==null?void 0:_t.values)??[],stop:n,globalStop:a,onChange:i,disabled:he},storesDefaults:ts,sections:W==null?void 0:W.sections,renderSection:U=>Lu(U,{type:s}),setupDetails:wa,setupBadge:Ca}),O&&e.jsx("p",{className:"text-muted-foreground px-4 text-xs","data-testid":`runtime-card-timing-${s}`,children:"Applies to new chats only."}),E&&e.jsxs("p",{className:"text-destructive flex items-start gap-1.5 px-4 text-xs","data-testid":`runtime-card-error-${s}`,children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:E})]})]})}function qu({type:s,label:t,installCommand:n,installInfoUrl:a}){const i=je(s),r=Kn(),{provision:o,isPending:l,isError:c,errorMessage:d,progress:u,result:x}=Io(s);if(l||x!=null&&x.ok){const h=(u==null?void 0:u.message)??`Installing ${i.label}…`;return e.jsxs(Te.div,{className:"bg-muted flex items-center gap-2 rounded-lg px-3 py-2.5",initial:r?!1:{opacity:0},animate:{opacity:1},"data-testid":"provision-progress",children:[e.jsx(bs,{size:"xs",className:P("text-muted-foreground shrink-0",r&&"animate-none")}),e.jsx(_e,{mode:"wait",children:e.jsx(Te.span,{className:"truncate text-xs",initial:r?!1:{opacity:0},animate:{opacity:1},exit:r?void 0:{opacity:0},transition:{duration:.2},children:h},h)})]})}return c?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:d}),n&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"You can install it yourself instead:"}),e.jsx(kt,{command:n,infoUrl:a,copyLabel:`Copy install command for ${i.label}`})]}),e.jsx(y,{size:"sm",onClick:o,children:"Try again"})]}):e.jsxs("div",{children:[e.jsx(y,{size:"sm",onClick:o,children:t}),n&&e.jsx(Po,{command:n,runtimeLabel:i.label})]})}function Bu({dep:s}){const t=s.status==="satisfied";return e.jsxs("div",{className:"space-y-2","data-testid":"runtime-setup-dependency",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-x-2",children:[t?e.jsx(qe,{className:"text-status-success size-3.5 shrink-0"}):e.jsx(ue,{className:"text-status-warning-dot size-3.5 shrink-0"}),e.jsx("span",{className:"text-sm",children:s.name}),e.jsx("p",{className:"text-muted-foreground col-start-2 mt-1 text-xs",children:t&&s.version?`v${s.version}`:s.description})]}),!t&&(s.installHint||s.infoUrl)&&e.jsx(kt,{command:s.installHint,infoUrl:s.infoUrl,copyLabel:`Copy install command for ${s.name}`})]})}function Wu(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function Hu(){var S,E,A;const s=gt(),{data:t}=Je(),{data:n}=Se(),a=ye(),i=B(),r=ja(),o=Kn(),[l,c]=m.useState(null),d=Oo(t?Object.keys(t.capabilities):[]),u=n==null?void 0:n.executionDefaults,x=(u==null?void 0:u.runtime)??"claude-code",h=(u==null?void 0:u.perRuntime)??[],p=(S=t==null?void 0:t.capabilities[x])==null?void 0:S.permissionModes,f=((A=(E=p==null?void 0:p.values)==null?void 0:E.find(O=>O.id===p.default))==null?void 0:A.stop)??"ask",g=(u==null?void 0:u.trustStop)??f;function v(O){c(null),a.mutate({runtimes:{default:O}},{onSuccess:()=>void i.invalidateQueries({queryKey:Q.all}),onError:w=>c(Wu(w))})}const N=h.map(O=>({runtime:O.runtime,label:je(O.runtime).label,stop:O.trustStop})),j=l??r.writeError;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Runtimes are the AI tools that do the work."}),e.jsx("button",{type:"button",onClick:()=>void s.refetch(),disabled:s.isFetching,"aria-label":"Check runtimes again",title:"Check again",className:"focus-ring text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-1 transition-colors disabled:opacity-50","data-testid":"runtimes-recheck",children:e.jsx(lt,{className:P("size-3.5",s.isFetching&&!o&&"animate-spin")})})]}),e.jsx("div",{className:"space-y-3",children:d.map(O=>{var w;return e.jsx(Ku,{type:O,isDefault:O===x,trustStop:((w=h.find(b=>b.runtime===O))==null?void 0:w.trustStop)??null,globalStop:g,onChangeTrustStop:b=>r.changeTrustStop(O,b),onMakeDefault:()=>v(O)},O)})}),j&&e.jsxs("p",{className:"text-destructive flex items-start gap-1.5 text-xs","data-testid":"runtimes-tab-error",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:j})]}),e.jsx(sd,{stop:(u==null?void 0:u.trustStop)??null,effectiveStop:f,runtimes:N,onChange:O=>r.changeTrustStop(null,O),onChangeRuntime:(O,w)=>r.changeTrustStop(O,w)}),e.jsx(Nd,{}),e.jsx(vd,{})]})}const Yu=["fatal","error","warn","info","debug","trace"];function Vu(){const s=F(),{data:t,isLoading:n,isError:a,error:i,refetch:r,isRefetching:o}=Y({queryKey:Q.current(),queryFn:()=>s.getConfig(),staleTime:3e4});return e.jsx("div",{className:"space-y-3",children:a&&!t?e.jsx(Ju,{detail:i instanceof Error?i.message:null,onRetry:()=>void r(),isRetrying:o}):n?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((l,c)=>e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsx("div",{className:"bg-muted animate-breath h-4 w-24 rounded"}),e.jsx("div",{className:"bg-muted animate-breath h-4 w-16 rounded"})]},c))}):t?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[t.isDevMode?e.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[e.jsx("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Development build"}),e.jsx("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:"Running from source. Update checks are off."})]}):e.jsxs(e.Fragment,{children:[e.jsx(st,{label:"Version",value:t.version}),t.latestVersion&&Hr(t.latestVersion,t.version)&&e.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:["Update available: v",t.latestVersion]})}),e.jsxs("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:["Run"," ",e.jsx("code",{className:"text-3xs rounded bg-amber-100 px-1 py-0.5 font-mono dark:bg-amber-900/50",children:"npm update -g dorkos"})," ","to update"]})]})]}),e.jsx(Zu,{port:t.port}),e.jsx(st,{label:"Uptime",value:em(t.uptime)})]}),e.jsx(Qu,{config:t}),e.jsx(Gu,{config:t}),e.jsx(_c,{config:t})]}):null})}function Qu({config:s}){const[t,n]=m.useState(!1),a=[{label:"Working folder",value:s.workingDirectory},{label:"Data folder",value:s.dorkHome},{label:"Boundary",value:s.boundary},{label:"Node.js",value:s.nodeVersion}];return e.jsx(Ze,{open:t,onOpenChange:n,trigger:"Diagnostics",action:e.jsx(Ce,{value:a.map(i=>`${i.label}: ${i.value}`).join(`
12
+ `),label:"Copy all diagnostics"}),children:e.jsx("div",{className:"space-y-1",children:a.map(i=>e.jsx(st,{label:i.label,value:i.value,mono:!0,truncate:!0},i.label))})})}function Gu({config:s}){const[t,n]=m.useState(!1),a=F(),i=B(),r=s.logging,o=m.useCallback(async l=>{const c=r??{level:"info",maxLogSizeKb:500,maxLogFiles:14};await a.updateConfig({logging:{...c,...l}}),await i.invalidateQueries({queryKey:Q.all})},[a,i,r]);return r?e.jsxs(Ze,{open:t,onOpenChange:n,trigger:"Logging",badge:e.jsx("span",{className:"text-muted-foreground text-xs",children:r.level}),children:[e.jsx(_,{label:"Log level",description:"How much detail DorkOS writes down.",children:e.jsxs(te,{value:r.level,onValueChange:l=>o({level:l}),children:[e.jsx(ne,{className:"w-28",children:e.jsx(ae,{})}),e.jsx(ie,{children:Yu.map(l=>e.jsx(L,{value:l,children:l},l))})]})}),e.jsx(_,{label:"Biggest log file",description:"When DorkOS starts a new file.",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(J,{type:"number",min:100,max:10240,value:r.maxLogSizeKb,onChange:l=>{const c=parseInt(l.target.value,10);c>=100&&c<=10240&&o({maxLogSizeKb:c})},className:"w-24"}),e.jsx("span",{className:"text-muted-foreground text-xs",children:"KB"})]})}),e.jsx(_,{label:"Days of logs kept",description:"From 1 to 30, up to 200 MB in all.",children:e.jsx(J,{type:"number",min:1,max:30,value:r.maxLogFiles,onChange:l=>{const c=parseInt(l.target.value,10);c>=1&&c<=30&&o({maxLogFiles:c})},className:"w-20"})}),s.dorkHome&&e.jsx(Xu,{dorkHome:s.dorkHome})]}):null}function Xu({dorkHome:s}){const{copied:t,failed:n,copy:a}=ut(),i=`${s}/logs`;function r(){return t?e.jsx("span",{className:"text-xs",children:"Copied"}):n?e.jsx("span",{className:"text-destructive text-xs",children:"Couldn’t copy"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"max-w-40 truncate font-mono text-xs",dir:"rtl",title:i,children:e.jsx("bdi",{dir:"ltr",children:i})}),e.jsx(Cn,{className:"size-3 shrink-0"})]})}return e.jsx(_,{label:"Log location",description:"Where DorkOS keeps these files.",children:e.jsx("button",{type:"button",onClick:()=>void a(i),className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 transition-colors",children:r()})})}function Ju({detail:s,onRetry:t,isRetrying:n}){return e.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[e.jsx("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Can’t reach the DorkOS server"}),e.jsx("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:"It may be restarting. Try again shortly."}),s?e.jsx("p",{className:"text-3xs mt-1 font-mono break-words text-amber-700/80 dark:text-amber-300/80",children:s}):null,e.jsx(y,{variant:"outline",size:"sm",className:"mt-2",onClick:t,disabled:n,"aria-label":"Try reaching the server again",children:n?"Trying…":"Try again"})]})}function Zu({port:s}){const t=`http://localhost:${s}`;return e.jsxs("div",{className:"border-border/60 -mx-1 mt-3 mb-3 space-y-2 border-b px-1 pb-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Address"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Where DorkOS runs on this computer. Bookmark it or share it."})]}),e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-1.5 gap-y-2",children:[e.jsx(gn,{url:t,label:"DorkOS address",children:e.jsx("button",{type:"button",onClick:()=>yr(t),className:"text-muted-foreground hover:text-foreground focus-ring rounded-sm p-1 transition-colors","aria-label":"Open DorkOS in your browser",title:"Open in your browser",children:e.jsx(Ss,{className:"size-3.5"})})}),e.jsx("p",{className:"text-muted-foreground col-span-2 text-xs",children:"For MCP clients like Claude Code or Cursor. Paste it, don’t visit it."}),e.jsx(gn,{url:`${t}/mcp`,label:"MCP endpoint"})]})]})}function gn({url:s,label:t,children:n}){return e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"bg-muted min-w-0 truncate rounded-md px-3 py-2 font-mono text-xs",children:s}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ce,{value:s,label:`Copy the ${t}`}),n]})]})}function st({label:s,value:t,mono:n,truncate:a,muted:i}){const{copied:r,failed:o,copy:l}=ut();function c(){return r?e.jsx("span",{className:"text-muted-foreground text-xs",children:"Copied"}):o?e.jsx("span",{className:"text-destructive text-xs",children:"Couldn’t copy"}):e.jsx("span",{className:P("text-right text-sm",n&&"font-mono",a&&"max-w-48 min-w-0 truncate",i&&"text-muted-foreground"),dir:a?"rtl":void 0,title:t,children:e.jsx("bdi",{dir:"ltr",children:t})})}return e.jsxs("button",{type:"button",onClick:()=>void l(t),className:"hover:bg-muted/50 active:bg-muted/70 -mx-1 flex w-full items-center justify-between gap-4 rounded px-1 py-1 transition-colors duration-100",children:[e.jsx("span",{className:"text-muted-foreground shrink-0 text-sm",children:s}),c()]})}function em(s){const t=Math.floor(s/3600),n=Math.floor(s%3600/60),a=Math.floor(s%60),i=[];return t>0&&i.push(`${t}h`),n>0&&i.push(`${n}m`),i.push(`${a}s`),i.join(" ")}function sm({scheduler:s,onUpdate:t}){return e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Scheduled runs at once",description:"How many tasks can run at once.",children:e.jsx(J,{type:"number",min:1,max:10,value:s.maxConcurrentRuns,onChange:n=>{const a=parseInt(n.target.value,10);a>=1&&a<=10&&t({maxConcurrentRuns:a})},className:"w-20"})}),e.jsx(_,{label:"Run history",description:"How many finished runs to keep.",children:e.jsx(J,{type:"number",min:1,max:1e4,value:s.retentionCount,onChange:n=>{const a=parseInt(n.target.value,10);a>=1&&t({retentionCount:a})},className:"w-24"})})]})}function fn(s){return s.lockedByEnv?s.running:s.enabledInConfig??s.running}function jn(s,t,n){const a=tm(s,t);return a?`${n} ${a}`:n}function tm(s,t){if(s.lockedByEnv)return`${t} on this computer controls this switch.`;const n=s.enabledInConfig??s.running;return n&&!s.running&&s.initError?"It’s on, but didn’t start last time. Nothing is running.":n!==s.running?"Saved. Applies the next time DorkOS starts.":null}function nm({tasks:s,relay:t,onTasksChange:n,onRelayChange:a}){return e.jsxs("div",{className:"space-y-4","data-testid":"background-systems",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"These run in the background. Turning one off also stops its tools."}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Scheduled runs",description:jn(s,"DORKOS_TASKS_ENABLED","Runs scheduled tasks when they’re due. Off means nothing runs on a schedule."),checked:fn(s),onCheckedChange:n,disabled:s.lockedByEnv===!0}),e.jsx($,{label:"Agent messaging",description:jn(t,"DORKOS_RELAY_ENABLED","Carries messages between agents and chat apps. Off stops Telegram and Slack too."),checked:fn(t),onCheckedChange:a,disabled:t.lockedByEnv===!0})]})})]})}function am(){return e.jsxs("div",{className:"flex gap-3 rounded-md border border-amber-500/20 bg-amber-500/10 p-3",children:[e.jsx(Re,{className:"mt-0.5 size-4 shrink-0 text-amber-500"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Not for agents that run inside DorkOS"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Those agents already have these tools. Adding them twice stops every tool call."}),e.jsxs(Ts,{className:"text-xs",children:[e.jsx("p",{children:"Claude rejects the repeated tool names with “Tool names must be unique”."}),e.jsx("p",{children:"This is for apps running on their own: Claude Code, Cursor, Windsurf."})]})]})]})}function im({endpoint:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Endpoint"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"The address to give other apps"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:s}),e.jsx(Ce,{value:s})]})]})}function rm({rateLimit:s,onUpdate:t}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx($,{label:"Cap incoming requests",description:"Limits how often other apps can call DorkOS.",checked:s.enabled,onCheckedChange:n=>t({enabled:n}),ariaLabel:"Toggle rate limiting"}),s.enabled&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{htmlFor:"mcp-max-requests",className:"text-muted-foreground text-xs",children:"Max requests"}),e.jsx(J,{id:"mcp-max-requests",type:"number",min:1,max:1e3,value:s.maxPerWindow,onChange:n=>{const a=parseInt(n.target.value,10);a>=1&&a<=1e3&&t({maxPerWindow:a})},className:"w-20"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{htmlFor:"mcp-window-secs",className:"text-muted-foreground text-xs",children:"Window (sec)"}),e.jsx(J,{id:"mcp-window-secs",type:"number",min:1,max:3600,value:s.windowSecs,onChange:n=>{const a=parseInt(n.target.value,10);a>=1&&a<=3600&&t({windowSecs:a})},className:"w-20"})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Changes apply after DorkOS restarts."})]})]})}function om(s,t){const n=t?`Bearer ${t}`:"Bearer dork_mcp_YOUR_API_KEY";return{claudeCode:JSON.stringify({mcpServers:{"dorkos-external":{type:"http",url:s,headers:{Authorization:n}}}},null,2),claudeCodeCli:`claude mcp add-json dorkos-external '${JSON.stringify({type:"http",url:s,headers:{Authorization:n}})}'`,cursor:JSON.stringify({mcpServers:{"dorkos-external":{url:s,headers:{Authorization:n}}}},null,2),windsurf:JSON.stringify({mcpServers:{"dorkos-external":{serverUrl:s,headers:{Authorization:n}}}},null,2)}}function lm({endpoint:s,apiKey:t}){const[n,a]=m.useState(!1),[i,r]=m.useState("claude-code"),o=om(s,t),l=i==="claude-code"?o.claudeCode:i==="cursor"?o.cursor:o.windsurf;return e.jsxs(Qe,{open:n,onOpenChange:a,children:[e.jsxs(Ge,{className:"flex w-full items-center justify-between text-sm font-medium",children:[e.jsx("span",{children:"Setup instructions"}),e.jsx(We,{className:P("text-muted-foreground size-3.5 transition-transform duration-150",!n&&"-rotate-90")})]}),e.jsx(Xe,{children:e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("div",{className:"bg-muted flex gap-0.5 rounded-md p-0.5",children:["claude-code","cursor","windsurf"].map(c=>e.jsx("button",{onClick:()=>r(c),className:P("flex-1 rounded-sm px-3 py-1.5 text-xs font-medium transition-colors",i===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:c==="claude-code"?"Claude Code":c==="cursor"?"Cursor":"Windsurf"},c))}),e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:l}),e.jsx("div",{className:"absolute top-2 right-2",children:e.jsx(Ce,{value:l})})]}),i==="claude-code"&&e.jsxs("div",{className:"relative",children:[e.jsx("p",{className:"text-muted-foreground mb-1 text-xs",children:"Or add it from the terminal:"}),e.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:o.claudeCodeCli}),e.jsx("div",{className:"absolute right-2 bottom-2",children:e.jsx(Ce,{value:o.claudeCodeCli})})]})]})})]})}function cm({mcp:s,authEnabled:t}){const n=F(),a=B(),[i,r]=m.useState(!1),o=m.useCallback(()=>a.invalidateQueries({queryKey:Q.all}),[a]),l=m.useCallback(async f=>{await n.updateConfig({mcp:{enabled:f,rateLimit:s.rateLimit}}),await o()},[n,s.rateLimit,o]),c=m.useCallback(async f=>{await n.updateConfig({mcp:{enabled:s.enabled,rateLimit:{...s.rateLimit,...f}}}),await o()},[n,s.enabled,s.rateLimit,o]),[d,u]=m.useState(null),x=m.useCallback(async()=>{const{localToken:f}=await n.revealMcpLocalToken();u(f)},[n]),h=m.useCallback(async()=>{const{localToken:f}=await n.rotateMcpLocalToken();u(f),await o()},[n,o]),p=s.enabled?s.authConfigured?e.jsx(Z,{variant:"outline",tone:"success",children:"Enabled"}):e.jsx(Z,{variant:"outline",tone:"warning",children:"Not protected"}):e.jsx(Z,{variant:"secondary",children:"Disabled"});return e.jsx(R,{children:e.jsxs(Qe,{open:i,onOpenChange:r,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Connect other apps to DorkOS"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Lets Claude Code, Cursor and others use DorkOS tools"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[p,e.jsx(Ve,{checked:s.enabled,onCheckedChange:l,"aria-label":"Toggle access for other apps"}),e.jsx(Ge,{asChild:!0,children:e.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-sm p-0.5 transition-colors duration-150","aria-label":`${i?"Collapse":"Expand"} MCP server settings`,children:e.jsx(We,{className:P("size-3.5 transition-transform duration-150",!i&&"-rotate-90")})})})]})]}),e.jsx(Xe,{children:e.jsxs(D,{children:[e.jsx(am,{}),e.jsx(dm,{}),e.jsx(im,{endpoint:s.endpoint}),e.jsx(um,{authSource:s.authSource,authEnabled:t,revealedToken:d,onReveal:x,onRotate:h}),e.jsx(rm,{rateLimit:s.rateLimit,onUpdate:c}),e.jsx(lm,{endpoint:s.endpoint,apiKey:d})]})})]})})}function dm(){const s=zn(),{close:t}=fe();return e.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:["To give an agent another server’s tools, open its profile."," ",e.jsx(y,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>{t(),s({...Un.team()})},children:"Open the Team page"})]})}function um({authSource:s,authEnabled:t,revealedToken:n,onReveal:a,onRotate:i}){return s==="env"?e.jsx(_,{label:"Authentication",description:"Protected by the MCP_API_KEY environment variable.",children:e.jsx(Z,{variant:"outline",children:"Environment variable"})}):s==="local-token"?e.jsx(mm,{revealedToken:n,onReveal:a,onRotate:i}):s==="none"&&!t?e.jsx(_,{label:"Authentication",description:"Couldn’t make a token for other apps. Use a personal API key instead.",children:e.jsx(Z,{variant:"outline",tone:"warning",children:"No key yet"})}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"text-muted-foreground size-3.5"}),e.jsx("p",{className:"text-sm font-medium",children:"Authentication"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Other apps sign in with a personal API key."}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Make one in Settings → Login & security. Send it as a"," ",e.jsx("code",{className:"font-mono",children:"Bearer"})," token."]})]})}function mm({revealedToken:s,onReveal:t,onRotate:n}){const[a,i]=m.useState(!1),[r,o]=m.useState(!1),[l,c]=m.useState(!1);async function d(){c(!0);try{await t()}catch(x){$e.error("Couldn’t show the token.",{description:x instanceof Error?x.message:"Try again in a moment."})}finally{c(!1)}}async function u(){o(!0);try{await n(),i(!1)}catch(x){$e.error("Couldn’t make a new token.",{description:x instanceof Error?x.message:"The old one still works."})}finally{o(!1)}}return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"text-muted-foreground size-3.5"}),e.jsx("p",{className:"text-sm font-medium",children:"Local MCP token"})]}),e.jsxs(me,{open:a,onOpenChange:i,children:[e.jsx(Me,{asChild:!0,children:e.jsx(y,{variant:"outline",size:"sm",children:"Rotate"})}),e.jsxs(xe,{children:[e.jsxs(re,{children:[e.jsx(oe,{children:"Rotate the local MCP token?"}),e.jsx(le,{children:"The old token stops working. Apps need the new one. This can’t be undone."})]}),e.jsxs(ce,{children:[e.jsx(de,{children:"Cancel"}),e.jsx(pe,{disabled:r,onClick:x=>{x.preventDefault(),u()},children:r?"Rotating…":"Rotate token"})]})]})]})]}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Paste it into your MCP client as a ",e.jsx("code",{className:"font-mono",children:"Bearer"})," token."]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"It guards tools that change things. Read-only checks work without it."}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Only apps on this computer can use it. Other devices need a personal API key."}),s?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:s}),e.jsx(Ce,{value:s})]}):e.jsx(y,{variant:"outline",size:"sm",onClick:d,disabled:l,children:l?"Revealing…":"Reveal token"})]})}function xm(){var x,h,p,f,g,v,N;const s=mt(),t=jt(),n=vr(),a=F(),i=B(),{section:r}=fe();Yn(r);const{data:o}=Y({queryKey:Q.current(),queryFn:()=>a.getConfig(),staleTime:3e4}),l=o==null?void 0:o.scheduler,c=m.useCallback(async j=>{const S=l??{maxConcurrentRuns:1,retentionCount:100};await a.updateConfig({scheduler:{...S,...j}}),await i.invalidateQueries({queryKey:Q.all})},[a,i,l]),d=m.useCallback(async j=>{await a.updateConfig({scheduler:{enabled:j}}),await i.invalidateQueries({queryKey:Q.all})},[a,i]),u=m.useCallback(async j=>{await a.updateConfig({relay:{enabled:j}}),await i.invalidateQueries({queryKey:Q.all})},[a,i]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(nm,{tasks:{running:n,enabledInConfig:(x=o==null?void 0:o.tasks)==null?void 0:x.enabledInConfig,lockedByEnv:(h=o==null?void 0:o.tasks)==null?void 0:h.lockedByEnv,initError:(p=o==null?void 0:o.tasks)==null?void 0:p.initError},relay:{running:t,enabledInConfig:(f=o==null?void 0:o.relay)==null?void 0:f.enabledInConfig,lockedByEnv:(g=o==null?void 0:o.relay)==null?void 0:g.lockedByEnv,initError:(v=o==null?void 0:o.relay)==null?void 0:v.initError},onTasksChange:j=>void d(j),onRelayChange:j=>void u(j)}),l&&n&&e.jsx(R,{children:e.jsx(D,{children:e.jsx(sm,{scheduler:l,onUpdate:c})})}),!s&&e.jsx(Dc,{}),(o==null?void 0:o.mcp)&&e.jsx("div",{"data-section":"external-mcp",children:e.jsx(cm,{mcp:o.mcp,authEnabled:((N=o.auth)==null?void 0:N.enabled)===!0})})]})}const yn=["hub","computers"];function hm(){var d;const s=F(),t=B(),[n,a]=m.useState(null),[i,r]=m.useState(null),o=Y({queryKey:yn,queryFn:()=>s.listHubComputers(),retry:!1,staleTime:15e3}),l=ge({mutationFn:()=>s.createHubLinkCode(),onMutate:()=>r(null),onSuccess:u=>a(u),onError:()=>r("Couldn’t make a code. Try again.")}),c=ge({mutationFn:u=>s.removeHubComputer(u),onMutate:()=>r(null),onSuccess:()=>t.invalidateQueries({queryKey:yn}),onError:()=>r("Couldn’t remove that computer. Try again.")});return{isHub:o.isSuccess,computers:((d=o.data)==null?void 0:d.computers)??[],linkCode:n,error:i,minting:l.isPending,removing:c.isPending?c.variables??null:null,mint:()=>l.mutate(),dismissCode:()=>a(null),remove:u=>c.mutate(u)}}function pm(s){const t=new Date(s);return Number.isNaN(t.getTime())?"":t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function gm({code:s,onDone:t}){const n=pm(s.expiresAt);return e.jsxs("div",{className:"bg-muted space-y-2 rounded-md p-3",children:[e.jsx("p",{className:"text-sm",children:"Paste this code into DorkOS on the computer to link."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 truncate font-mono text-sm","data-testid":"hub-link-code",children:s.linkCode}),e.jsx(Ce,{value:s.linkCode,label:"Copy code"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:n?`Works once, until ${n}.`:"Works once, for 10 minutes."}),e.jsx(y,{variant:"ghost",size:"sm",onClick:t,children:"Done"})]})]})}function fm({computer:s,removing:t,onRemove:n}){const a=s.computerName??s.computerId;return e.jsxs("li",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm",children:a}),e.jsx("p",{className:"text-muted-foreground text-xs",children:s.connected?"Connected":"Not connected"})]}),e.jsx(y,{variant:"outline",size:"sm",onClick:n,disabled:t,"aria-label":`Remove ${a}`,children:"Remove"})]})}function jm({className:s}){const t=hm();return t.isHub?e.jsxs("section",{"aria-labelledby":"linked-computers-title",className:P("border-border bg-muted/30 space-y-3 rounded-lg border p-4",s),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{id:"linked-computers-title",className:"text-sm font-medium",children:"Linked computers"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Chat with the agents on your own computers from here."})]}),e.jsx(y,{size:"sm",onClick:t.mint,disabled:t.minting,children:"Link a computer"})]}),t.linkCode&&e.jsx(gm,{code:t.linkCode,onDone:t.dismissCode}),t.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:t.error}),t.computers.length===0?e.jsx("p",{className:"text-muted-foreground text-xs",children:"No computers linked yet."}):e.jsx("ul",{className:"space-y-2",children:t.computers.map(n=>e.jsx(fm,{computer:n,removing:t.removing===n.computerId,onRemove:()=>t.remove(n.computerId)},n.computerId))})]}):null}function ym(){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(jm,{}),e.jsx(iu,{}),e.jsxs(rl,{signedOut:e.jsx(vm,{}),children:[e.jsx(lo,{}),e.jsx(Sc,{})]})]})}function vm(){const{data:s}=ks(),t=Hl(s),n=xt();return e.jsxs("div",{className:"space-y-2",children:[t.length>0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:"Link a DorkOS account to:"}),e.jsxs("ul",{className:"text-muted-foreground list-disc space-y-1 pl-5 text-sm",children:[e.jsxs("li",{children:["Use one account for ",t.join(" and "),": run"," ",t.length===1?"it":"them"," on your DorkOS credits."]}),e.jsx("li",{children:"See your plan, credits and seats here."})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Link a DorkOS account to see your plan, credits and seats here."}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Everything else works without one."})]}),e.jsx(Hn,{withSpaces:n})]})}const vn=["lan-access"],bm=15e3;function Nm(){const s=F(),t=B(),[n,a]=m.useState(!1),[i,r]=m.useState(null),{data:o}=Y({queryKey:vn,queryFn:()=>s.getLanAccess(),refetchInterval:bm}),l=m.useCallback(async c=>{const d=async u=>{a(!0),r(null);try{const x=await s.setLanAccess(u);t.setQueryData(vn,x),t.invalidateQueries({queryKey:Q.current()})}catch(x){(x==null?void 0:x.code)==="AUTH_REQUIRED_FOR_EXPOSURE"?br({reason:"exposure",message:"Wi-Fi access needs a login.",onComplete:()=>void d(!0)}):r(x instanceof Error&&x.message?x.message:"Could not change that.")}finally{a(!1)}};await d(c)},[s,t]);return{status:o,busy:n,error:i,setEnabled:l}}function km(s){const t=s.localName??s.addresses[0];return t?`http://${t}:${s.port}`:null}function bn({url:s,label:t}){return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("code",{className:"truncate text-sm",children:s}),e.jsx(Ce,{value:s,label:t})]})}function wm({status:s}){const t=km(s);if(!t)return e.jsx("p",{className:"text-muted-foreground text-xs",children:"Join a Wi-Fi network to get an address."});const n=s.localName?s.addresses.map(a=>`http://${a}:${s.port}`):s.addresses.slice(1).map(a=>`http://${a}:${s.port}`);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(Nr,{url:t,size:160}),e.jsx("p",{className:"text-muted-foreground text-center text-xs",children:"Scan with a phone or tablet on the same Wi-Fi."}),e.jsx(bn,{url:t,label:"Copy address"}),n.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"If that name doesn’t open, use:"}),n.map(a=>e.jsx(bn,{url:a,label:"Copy address"},a))]})]})}function Cm({className:s}){const{status:t,busy:n,error:a,setEnabled:i}=Nm();if(!t)return null;const r=t.setByEnvironment!==null,o=r||!t.supported,l=a??t.error;return e.jsxs("section",{"aria-labelledby":"lan-access-title",className:P("border-border bg-muted/30 space-y-3 rounded-lg border p-4",s),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{id:"lan-access-title",className:"text-sm font-medium",children:"Let devices on my Wi-Fi in"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"For home or office Wi-Fi. It isn’t encrypted yet."})]}),e.jsx(Ve,{"aria-labelledby":"lan-access-title",checked:o?!1:t.enabled,onCheckedChange:c=>void i(c),disabled:n||o})]}),r&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:[t.setByEnvironment," is set, so it decides where DorkOS listens."]}),l&&e.jsx("p",{className:"text-destructive text-xs",children:l}),t.listening&&e.jsx(wm,{status:t})]})}function Sm(){const s=kr({open:!0}),t=wr({machine:s});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Cr,{machine:s,actions:t}),e.jsx(Sr,{}),e.jsx(Cm,{})]})}function Am(){const{data:s}=Se(),t=ye(),n=s==null?void 0:s.telemetry,a=(i,r)=>{t.mutate({telemetry:{[i]:r,userHasDecided:!0}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Nothing is shared unless a switch below is on."," ",e.jsx("a",{href:Ar("/telemetry"),target:"_blank",rel:"noopener noreferrer",className:"text-foreground underline underline-offset-2",children:"Read the full contract"}),"."]}),e.jsxs(Ts,{className:"text-xs",children:[e.jsx("p",{children:"The three count switches are anonymous. They never send prompts, code or file paths."}),e.jsx("p",{children:"The counts never send before the first-run notice."}),e.jsx("p",{children:"Crash reports and AI run data are separate. Both start off."})]})]}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Share anonymous install counts",description:"Counts marketplace installs, to rank packages and spot broken ones.",checked:(n==null?void 0:n.install)??!1,onCheckedChange:i=>a("install",i),disabled:t.isPending}),e.jsx($,{label:"Share an anonymous daily heartbeat",description:"One anonymous ping a day, to count active installs. Exact payload below.",checked:(n==null?void 0:n.heartbeat)??!1,onCheckedChange:i=>a("heartbeat",i),disabled:t.isPending}),e.jsx($,{label:"Share anonymous feature-usage events",description:"Counts events like app start and finished setup, plus any install tag.",checked:(n==null?void 0:n.usage)??!1,onCheckedChange:i=>a("usage",i),disabled:t.isPending}),e.jsx($,{label:"Share AI run metadata",description:"Model, tokens, time and cost per turn. Never your prompts, code or chats.",checked:(n==null?void 0:n.aiMetadata)??!1,onCheckedChange:i=>a("aiMetadata",i),disabled:t.isPending}),e.jsx($,{label:"Share crash reports",description:"A scrubbed report to dorkos.ai when something breaks. No error messages, paths or code.",checked:(n==null?void 0:n.errorReporting)??!1,onCheckedChange:i=>a("errorReporting",i),disabled:t.isPending})]})}),e.jsx(el,{})]})}async function Tm(s){const t=new Map;for(let n=0;n<localStorage.length;n++){const a=localStorage.key(n);if(a===null)continue;const i=localStorage.getItem(a);i!==null&&t.set(a,i)}localStorage.clear();try{return await s()}catch(n){for(const[a,i]of t)localStorage.setItem(a,i);throw n}}function Om({open:s,onOpenChange:t,onResetComplete:n}){const[a,i]=m.useState(""),[r,o]=m.useState(!1),l=F(),c=a==="reset";async function d(){o(!0);try{const x=Gn();if(x)await Tm(async()=>{yo(await x.resetAllData())});else{const{token:h}=await l.prepareReset();await l.resetAllData("reset",h),localStorage.clear()}t(!1),n()}catch(x){$e.error("Couldn’t reset your data.",{description:x instanceof Error?x.message:"Some of it may already be gone. Try again."})}finally{o(!1)}}function u(x){x||(i(""),o(!1)),t(x)}return e.jsx(me,{open:s,onOpenChange:u,children:e.jsxs(xe,{children:[e.jsxs(re,{children:[e.jsx(oe,{children:"Reset all data?"}),e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"This deletes all DorkOS data for good, including:"}),e.jsxs("ul",{className:"list-inside list-disc space-y-1 text-sm",children:[e.jsx("li",{children:"Scheduled tasks and their run history"}),e.jsx("li",{children:"Agent messaging setup and messages"}),e.jsx("li",{children:"DorkOS’s list of your agents"}),e.jsx("li",{children:"Your config file and preferences"}),e.jsx("li",{children:"Server logs"})]}),e.jsx("p",{children:"DorkOS restarts on its own. This device’s preferences are cleared too."}),e.jsx("p",{className:"font-semibold",children:"This can’t be undone."})]})})]}),e.jsx("div",{className:"py-2",children:e.jsx(J,{placeholder:"Type “reset” to continue",value:a,onChange:x=>i(x.target.value),"data-testid":"reset-confirm-input"})}),e.jsxs(ce,{children:[e.jsx(de,{children:"Cancel"}),e.jsx(pe,{disabled:!c||r,onClick:d,variant:"destructive",children:r?"Resetting…":"Reset all data"})]})]})})}function Em({open:s,onOpenChange:t}){const n=Ee(r=>r.resetAllSettings),{setTheme:a}=vt();function i(){n(),a("system"),t(!1),$e.success("Settings are back to defaults")}return e.jsx(me,{open:s,onOpenChange:t,children:e.jsxs(xe,{children:[e.jsxs(re,{children:[e.jsx(oe,{children:"Reset all settings?"}),e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:"Theme, text, toggles and layouts on this device go back to default."}),e.jsx("p",{children:"Nothing you made is deleted. Your projects, agents and chats stay."})]})})]}),e.jsxs(ce,{children:[e.jsx(de,{children:"Cancel"}),e.jsx(pe,{onClick:i,variant:"destructive",children:"Reset settings"})]})]})})}function Rm({open:s,onOpenChange:t,onRestartComplete:n}){const[a,i]=m.useState(!1),r=F();async function o(){i(!0);try{await Xn(r),t(!1),n()}catch(l){$e.error("Couldn’t restart DorkOS.",{description:l instanceof Error?l.message:"It may not have restarted. Try again."})}finally{i(!1)}}return e.jsx(me,{open:s,onOpenChange:t,children:e.jsxs(xe,{children:[e.jsxs(re,{children:[e.jsx(oe,{children:"Restart DorkOS?"}),e.jsx(le,{children:"Anything running right now stops. DorkOS is back in seconds."})]}),e.jsxs(ce,{children:[e.jsx(de,{children:"Cancel"}),e.jsx(pe,{disabled:a,onClick:o,children:a?"Restarting…":"Restart DorkOS"})]})]})})}function Dm(){const[s,t]=m.useState(!1),[n,a]=m.useState(!1),[i,r]=m.useState(!1),o=Ee(l=>l.setRestartOverlayOpen);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(R,{children:e.jsxs(D,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Reset all settings"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Theme, text, toggles and layouts on this device go back to default."}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Your projects, agents and chats stay."})]}),e.jsx(y,{variant:"destructive",size:"sm",onClick:()=>a(!0),children:"Reset settings"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Reset all data"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Deletes everything DorkOS saved, then restarts it. Can’t be undone."})]}),e.jsx(y,{variant:"destructive",size:"sm",onClick:()=>t(!0),children:"Reset data"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Restart DorkOS"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Anything running right now stops."})]}),e.jsx(y,{variant:"destructive",size:"sm",onClick:()=>r(!0),children:"Restart"})]})]})}),e.jsx(Em,{open:n,onOpenChange:a}),e.jsx(Om,{open:s,onOpenChange:t,onResetComplete:()=>o(!0)}),e.jsx(Rm,{open:i,onOpenChange:r,onRestartComplete:()=>o(!0)})]})}function Im(){const s=Tr(),t=Or(),{setShowSessions:n}=Er();return s?e.jsx($,{label:"Show sessions",description:"See the working session behind each chat: model, account and context.",checked:t,onCheckedChange:n}):null}function Pm(s,t){return s.split(".").reduceRight((a,i)=>({[i]:a}),t)}function Lm(s,t,n){const a=[s];return t!==void 0&&a.push(t),n!==void 0&&a.push(`${n} on this computer controls this switch.`),a.join(" ")}function _m(){const{data:s,isLoading:t}=Se(),n=ye(),a=Ee(o=>o.devtoolsOpen),i=Ee(o=>o.toggleDevtools),r=(s==null?void 0:s.experiments)??[];return e.jsxs("div",{className:"space-y-6","data-testid":"experiments-tab",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"Unfinished features you can try early."}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Show dev tools",description:"Opens a panel showing what the app has loaded.",checked:a,onCheckedChange:()=>i()}),e.jsx(Im,{})]})}),t?null:r.length===0?e.jsx("p",{className:"text-muted-foreground text-sm","data-testid":"experiments-empty",children:"No experiments right now. New ones show up here."}):e.jsx(R,{children:e.jsx(D,{children:r.map(o=>e.jsx($,{label:o.title,description:Lm(o.description,o.costNote,o.envOverride),checked:o.enabled,onCheckedChange:l=>n.mutate(Pm(o.key,l)),disabled:o.lockedByEnv},o.key))})}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"These start off. Each one graduates or goes away."})]})}const $m={group:Dr,storageKey:Rr.SETTINGS_ADVANCED_OPEN},Fm={profile:{icon:Ur,component:yu},account:{icon:Bo,component:ym},appearance:{icon:Wo,component:Nu,actions:e.jsx(bu,{})},preferences:{icon:Ho,component:Rc},notifications:{icon:zr,component:ku},runtimes:{icon:qo,component:Hu},permissions:{icon:Ns,component:Ou},connections:{icon:Mr,component:Au},security:{icon:Fr,component:Al},"remote-access":{icon:$r,component:Sm},privacy:{icon:_r,component:Am},server:{icon:Ko,component:Vu},tools:{icon:co,component:xm},rooms:{icon:Lr,component:Su},experiments:{icon:Pr,component:_m},danger:{icon:Re,component:Dm}};function Mm(s){return Ir(s).map(t=>({id:t.id,label:t.label,group:t.group,...Fm[t.id]}))}function Tx({open:s,onOpenChange:t}){const{activeTab:n}=fe(),a=mt(),i=m.useMemo(()=>Mm(a),[a]);return e.jsx(Qo,{open:s,onOpenChange:t,title:"Settings",description:"Application settings",defaultTab:"appearance",initialTab:n,tabs:i,extensionSlot:"settings.tabs",maximized:!0,foldedGroup:$m,testId:"settings-dialog"})}export{Tx as SettingsDialog};